mirror of
https://github.com/fantastic-admin/basic.git
synced 2026-10-07 11:34:10 +08:00
修复 eslint 警告
This commit is contained in:
+7
-6
@@ -5,12 +5,13 @@ import router from '@/router/index'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
|
||||
const toLogin = () => {
|
||||
useUserStore().logout()
|
||||
router.push({
|
||||
path: '/login',
|
||||
query: {
|
||||
redirect: router.currentRoute.value.path !== '/login' ? router.currentRoute.value.fullPath : undefined,
|
||||
},
|
||||
void useUserStore().logout().then(() => {
|
||||
void router.push({
|
||||
path: '/login',
|
||||
query: {
|
||||
redirect: router.currentRoute.value.path !== '/login' ? router.currentRoute.value.fullPath : undefined,
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import '@/assets/styles/globals.scss'
|
||||
// 加载 iconify 图标(element plus)
|
||||
import { downloadAndInstall } from '@/iconify-ep'
|
||||
if (useSettingsStore().app.iconifyOfflineUse) {
|
||||
downloadAndInstall()
|
||||
await downloadAndInstall()
|
||||
}
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
+23
-30
@@ -138,45 +138,38 @@ const useMenuStore = defineStore(
|
||||
},
|
||||
actions: {
|
||||
// 生成导航(前端生成)
|
||||
generateMenusAtFront() {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise<void>(async (resolve) => {
|
||||
async generateMenusAtFront() {
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
let accessedMenus
|
||||
// 如果权限功能开启,则需要对导航数据进行筛选过滤
|
||||
if (settingsStore.app.enablePermission) {
|
||||
const permissions = await userStore.getPermissions()
|
||||
accessedMenus = filterAsyncMenus(menu, permissions)
|
||||
}
|
||||
else {
|
||||
accessedMenus = cloneDeep(menu)
|
||||
}
|
||||
this.menus = accessedMenus.filter(item => item.children.length !== 0)
|
||||
},
|
||||
// 生成导航(后端生成)
|
||||
async generateMenusAtBack() {
|
||||
await api.get('menu/list', {
|
||||
baseURL: '/mock/',
|
||||
}).then(async (res) => {
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
let accessedMenus
|
||||
let accessedMenus: Menu.recordMainRaw[]
|
||||
// 如果权限功能开启,则需要对导航数据进行筛选过滤
|
||||
if (settingsStore.app.enablePermission) {
|
||||
const permissions = await userStore.getPermissions()
|
||||
accessedMenus = filterAsyncMenus(menu, permissions)
|
||||
accessedMenus = filterAsyncMenus(res.data, permissions)
|
||||
}
|
||||
else {
|
||||
accessedMenus = cloneDeep(menu)
|
||||
accessedMenus = cloneDeep(res.data)
|
||||
}
|
||||
this.menus = accessedMenus.filter(item => item.children.length !== 0)
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
// 生成导航(后端生成)
|
||||
generateMenusAtBack() {
|
||||
return new Promise<void>((resolve) => {
|
||||
api.get('menu/list', {
|
||||
baseURL: '/mock/',
|
||||
}).then(async (res) => {
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
let accessedMenus: Menu.recordMainRaw[]
|
||||
// 如果权限功能开启,则需要对导航数据进行筛选过滤
|
||||
if (settingsStore.app.enablePermission) {
|
||||
const permissions = await userStore.getPermissions()
|
||||
accessedMenus = filterAsyncMenus(res.data, permissions)
|
||||
}
|
||||
else {
|
||||
accessedMenus = cloneDeep(res.data)
|
||||
}
|
||||
this.menus = accessedMenus.filter(item => item.children.length !== 0)
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 切换主导航
|
||||
setActived(data: number | string) {
|
||||
|
||||
+39
-50
@@ -162,57 +162,30 @@ const useRouteStore = defineStore(
|
||||
},
|
||||
actions: {
|
||||
// 根据权限动态生成路由(前端生成)
|
||||
generateRoutesAtFront(asyncRoutes: Route.recordMainRaw[]) {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise<void>(async (resolve) => {
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
let accessedRoutes
|
||||
// 如果权限功能开启,则需要对路由数据进行筛选过滤
|
||||
if (settingsStore.app.enablePermission) {
|
||||
const permissions = await userStore.getPermissions()
|
||||
accessedRoutes = filterAsyncRoutes(asyncRoutes, permissions)
|
||||
}
|
||||
else {
|
||||
accessedRoutes = cloneDeep(asyncRoutes)
|
||||
}
|
||||
// 设置 routes 数据
|
||||
this.isGenerate = true
|
||||
this.routes = accessedRoutes.filter(item => item.children?.length !== 0) as any
|
||||
resolve()
|
||||
})
|
||||
async generateRoutesAtFront(asyncRoutes: Route.recordMainRaw[]) {
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
let accessedRoutes
|
||||
// 如果权限功能开启,则需要对路由数据进行筛选过滤
|
||||
if (settingsStore.app.enablePermission) {
|
||||
const permissions = await userStore.getPermissions()
|
||||
accessedRoutes = filterAsyncRoutes(asyncRoutes, permissions)
|
||||
}
|
||||
else {
|
||||
accessedRoutes = cloneDeep(asyncRoutes)
|
||||
}
|
||||
// 设置 routes 数据
|
||||
this.isGenerate = true
|
||||
this.routes = accessedRoutes.filter(item => item.children?.length !== 0) as any
|
||||
},
|
||||
// 根据权限动态生成路由(后端获取)
|
||||
generateRoutesAtBack() {
|
||||
return new Promise<void>((resolve) => {
|
||||
api.get('route/list', {
|
||||
baseURL: '/mock/',
|
||||
}).then(async (res) => {
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
const asyncRoutes = formatBackRoutes(res.data)
|
||||
let accessedRoutes
|
||||
// 如果权限功能开启,则需要对路由数据进行筛选过滤
|
||||
if (settingsStore.app.enablePermission) {
|
||||
const permissions = await userStore.getPermissions()
|
||||
accessedRoutes = filterAsyncRoutes(asyncRoutes, permissions)
|
||||
}
|
||||
else {
|
||||
accessedRoutes = cloneDeep(asyncRoutes)
|
||||
}
|
||||
// 设置 routes 数据
|
||||
this.isGenerate = true
|
||||
this.routes = accessedRoutes.filter(item => item.children.length !== 0) as any
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
},
|
||||
// 根据权限动态生成路由(文件系统生成)
|
||||
generateRoutesAtFilesystem(asyncRoutes: RouteRecordRaw[]) {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise<void>(async (resolve) => {
|
||||
async generateRoutesAtBack() {
|
||||
await api.get('route/list', {
|
||||
baseURL: '/mock/',
|
||||
}).then(async (res) => {
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
const asyncRoutes = formatBackRoutes(res.data)
|
||||
let accessedRoutes
|
||||
// 如果权限功能开启,则需要对路由数据进行筛选过滤
|
||||
if (settingsStore.app.enablePermission) {
|
||||
@@ -224,9 +197,25 @@ const useRouteStore = defineStore(
|
||||
}
|
||||
// 设置 routes 数据
|
||||
this.isGenerate = true
|
||||
this.fileSystemRoutes = accessedRoutes.filter(item => item.children?.length !== 0) as any
|
||||
resolve()
|
||||
})
|
||||
this.routes = accessedRoutes.filter(item => item.children.length !== 0) as any
|
||||
}).catch(() => {})
|
||||
},
|
||||
// 根据权限动态生成路由(文件系统生成)
|
||||
async generateRoutesAtFilesystem(asyncRoutes: RouteRecordRaw[]) {
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
let accessedRoutes
|
||||
// 如果权限功能开启,则需要对路由数据进行筛选过滤
|
||||
if (settingsStore.app.enablePermission) {
|
||||
const permissions = await userStore.getPermissions()
|
||||
accessedRoutes = filterAsyncRoutes(asyncRoutes, permissions)
|
||||
}
|
||||
else {
|
||||
accessedRoutes = cloneDeep(asyncRoutes)
|
||||
}
|
||||
// 设置 routes 数据
|
||||
this.isGenerate = true
|
||||
this.fileSystemRoutes = accessedRoutes.filter(item => item.children?.length !== 0) as any
|
||||
},
|
||||
// 记录 accessRoutes 路由,用于登出时删除路由
|
||||
setCurrentRemoveRoutes(routes: Function[]) {
|
||||
|
||||
+16
-23
@@ -61,34 +61,27 @@ const useUserStore = defineStore(
|
||||
})
|
||||
},
|
||||
// 获取我的权限
|
||||
getPermissions() {
|
||||
return new Promise<string[]>((resolve) => {
|
||||
// 通过 mock 获取权限
|
||||
api.get('member/permission', {
|
||||
baseURL: '/mock/',
|
||||
params: {
|
||||
account: this.account,
|
||||
},
|
||||
}).then((res) => {
|
||||
this.permissions = res.data.permissions
|
||||
resolve(res.data.permissions)
|
||||
})
|
||||
async getPermissions() {
|
||||
// 通过 mock 获取权限
|
||||
const res = await api.get('member/permission', {
|
||||
baseURL: '/mock/',
|
||||
params: {
|
||||
account: this.account,
|
||||
},
|
||||
})
|
||||
this.permissions = res.data.permissions
|
||||
return this.permissions
|
||||
},
|
||||
editPassword(data: {
|
||||
async editPassword(data: {
|
||||
password: string
|
||||
newpassword: string
|
||||
}) {
|
||||
return new Promise<void>((resolve) => {
|
||||
api.post('member/edit/password', {
|
||||
account: this.account,
|
||||
password: data.password,
|
||||
newpassword: data.newpassword,
|
||||
}, {
|
||||
baseURL: '/mock/',
|
||||
}).then(() => {
|
||||
resolve()
|
||||
})
|
||||
await api.post('member/edit/password', {
|
||||
account: this.account,
|
||||
password: data.password,
|
||||
newpassword: data.newpassword,
|
||||
}, {
|
||||
baseURL: '/mock/',
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@ import router from '@/router'
|
||||
|
||||
export default function useMainPage() {
|
||||
function reload() {
|
||||
router.push({
|
||||
void router.push({
|
||||
name: 'reload',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export default function useMenu() {
|
||||
window.open(menuStore.sidebarMenusFirstDeepestPath, '_blank')
|
||||
}
|
||||
else {
|
||||
router.push(menuStore.sidebarMenusFirstDeepestPath)
|
||||
void router.push(menuStore.sidebarMenusFirstDeepestPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,12 @@ const num = ref(1)
|
||||
function go(type: number) {
|
||||
let routerName
|
||||
switch (type) {
|
||||
case 1: routerName = 'keepAliveExampleDetail'; break
|
||||
case 2: routerName = 'keepAliveExampleNestedDetail'; break
|
||||
case 1:
|
||||
routerName = 'keepAliveExampleDetail'
|
||||
break
|
||||
case 2:
|
||||
routerName = 'keepAliveExampleNestedDetail'
|
||||
break
|
||||
}
|
||||
router.push({
|
||||
name: routerName,
|
||||
|
||||
Reference in New Issue
Block a user