feat: new feat

This commit is contained in:
JaguarJack 2023-01-11 17:21:16 +08:00
parent 2a1afa3e1a
commit dcd6b7a9d7
7 changed files with 22 additions and 23 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div :style="bgColor" class="flex flex-col w-full"> <div :style="bgColor" class="flex flex-col w-full">
<img src="/admin/assets/404.png" class="w-full sm:w-3/5 m-auto" /> <img :src="notFound" class="w-full sm:w-3/5 m-auto" />
<div class="mr-auto w-full bottom-0 m-auto"> <div class="mr-auto w-full bottom-0 m-auto">
<div class="w-full text-center text-base text-gray-400">抱歉您访问的页面不存在</div> <div class="w-full text-center text-base text-gray-400">抱歉您访问的页面不存在</div>
<div @click="push('/')" class="text-center w-full mt-2"> <div @click="push('/')" class="text-center w-full mt-2">
@ -14,6 +14,7 @@
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useAppStore } from '/admin/stores/modules/app' import { useAppStore } from '/admin/stores/modules/app'
import { computed } from 'vue' import { computed } from 'vue'
import notFound from '/admin/assets/404.png'
const { push } = useRouter() const { push } = useRouter()

View File

@ -18,6 +18,8 @@ export function useCreate(path: string, id: string | number | null = null, _form
// 更新前 hook // 更新前 hook
const beforeUpdate = ref() const beforeUpdate = ref()
const afterCreate = ref()
// store // store
function store(path: string, id: string | number | null = null) { function store(path: string, id: string | number | null = null) {
loading.value = true loading.value = true
@ -41,6 +43,13 @@ export function useCreate(path: string, id: string | number | null = null, _form
if (r.data.code === Code.SUCCESS) { if (r.data.code === Code.SUCCESS) {
isClose.value = true isClose.value = true
Message.success(r.data.message) Message.success(r.data.message)
// 创建后的操作
if (!id) {
if (isFunction(afterCreate.value)) {
afterCreate.value()
}
}
} else { } else {
Message.error(r.data.message) Message.error(r.data.message)
} }
@ -72,5 +81,5 @@ export function useCreate(path: string, id: string | number | null = null, _form
}) })
} }
return { formData, loading, form, submitForm, close, beforeCreate, beforeUpdate } return { formData, loading, form, submitForm, close, beforeCreate, beforeUpdate, afterCreate }
} }

View File

@ -1,11 +1,14 @@
import { RouteRecordRaw } from 'vue-router' import { RouteRecordRaw } from 'vue-router'
import { isUndefined } from '/admin/support/helper'
// @ts-ignore // @ts-ignore
export function getModuleRoutes() { export function getModuleRoutes() {
const modules = import.meta.glob('@/module/**/views/router.ts', { eager: true }) const modules = import.meta.glob('@/module/**/views/router.ts', { eager: true })
let moduleRoutes: RouteRecordRaw[] = [] let moduleRoutes: RouteRecordRaw[] = []
Object.keys(modules).forEach(routePath => { Object.keys(modules).forEach(routePath => {
if (!isUndefined(modules[routePath].default)) {
moduleRoutes = moduleRoutes.concat(modules[routePath].default) moduleRoutes = moduleRoutes.concat(modules[routePath].default)
}
}) })
return moduleRoutes return moduleRoutes

View File

@ -140,7 +140,7 @@ export const useUserStore = defineStore('UserStore', {
this.setStatus(status) this.setStatus(status)
this.setAvatar(avatar) this.setAvatar(avatar)
this.setPermissions(permissions) this.setPermissions(permissions)
console.log(this.getAvatar)
resolve(response.data.data) resolve(response.data.data)
}) })
.catch(e => { .catch(e => {

View File

@ -129,7 +129,7 @@ export const usePermissionsStore = defineStore('PermissionsStore', {
// menu // menu
let importComponent let importComponent
if (permission.type === MenuType.TOP_TYPE) { if (permission.type === MenuType.TOP_TYPE) {
importComponent = () => import('/admin/layout/index') importComponent = () => import('/admin/layout/index.vue')
} else { } else {
importComponent = viewComponents['/modules' + permission.component] importComponent = viewComponents['/modules' + permission.component]
} }

View File

@ -1,27 +1,15 @@
export interface Permission { export interface Permission {
id: number id: number
parent_id: number parent_id: number
permission_name: string permission_name: string
type: number type: number
icon: string icon: string
component: string component: string
module: string module: string
permission_mark: string permission_mark: string
route: string route: string
redirect: string redirect: string
keepAlive: boolean keepAlive: boolean
hidden: boolean hidden: boolean
is_inner: boolean is_inner: boolean
} }

View File

@ -1,7 +1,5 @@
export default interface ResponseData { export default interface ResponseData {
code: number; code: number
message: string
message: string;
data: any data: any
} }