refactor: organize file dir

This commit is contained in:
chenxin 2024-09-05 16:02:24 +08:00
parent 5e88b8d01f
commit c14ebc2343
22 changed files with 74 additions and 77 deletions

6
.env
View File

@ -8,13 +8,13 @@ VITE_APP_NAME = Nova - Admin
VITE_ROUTE_MODE = web
# 路由加载模式 static dynamic
VITE_ROUTE_LOAD_MODE = dynamic
VITE_ROUTE_LOAD_MODE = static
# 设置登陆后跳转地址
VITE_HOME_PATH = /dashboard/workbench
# 本地存储前缀
VITE_STORAGE_PREFIX=
VITE_STORAGE_PREFIX =
# 版权信息
VITE_COPYRIGHT_INFO = Copyright © 2024 chansee97
@ -22,5 +22,5 @@ VITE_COPYRIGHT_INFO = Copyright © 2024 chansee97
# 自动刷新token
VITE_AUTO_REFRESH_TOKEN = Y
# 默认多语言
# 默认多语言 enUS | zhCN
VITE_DEFAULT_LANG = enUS

View File

@ -95,11 +95,11 @@
"fetch": "Request example",
"list": "List",
"monitor": "Monitoring",
"test": "Multi-level menu",
"test2": "Multi-level menu subpage",
"test2Detail": "Details page of multi-level menu",
"test3": "multi-level menu",
"test4": "Multi-level menu 3-1",
"multi": "Multi-level menu",
"multi2": "Multi-level menu subpage",
"multi2Detail": "Details page of multi-level menu",
"multi3": "multi-level menu",
"multi4": "Multi-level menu 3-1",
"workbench": "Workbench",
"QRCode": "QR code",
"about": "About",

View File

@ -118,11 +118,11 @@
"dashboard": "仪表盘",
"workbench": "工作台",
"monitor": "监控页",
"test": "多级菜单演示",
"test2": "多级菜单子页",
"test2Detail": "多级菜单的详情页",
"test3": "多级菜单",
"test4": "多级菜单3-1",
"multi": "多级菜单演示",
"multi2": "多级菜单子页",
"multi2Detail": "多级菜单的详情页",
"multi3": "多级菜单",
"multi4": "多级菜单3-1",
"list": "列表页",
"commonList": "常用列表",
"cardList": "卡片列表",

View File

@ -50,41 +50,41 @@
"sizecheck": "npx vite-bundle-visualizer"
},
"dependencies": {
"@vueuse/core": "^10.11.1",
"alova": "^3.0.8",
"@vueuse/core": "^11.0.3",
"alova": "^3.0.16",
"colord": "^2.9.3",
"echarts": "^5.5.1",
"md-editor-v3": "^4.15.2",
"pinia": "^2.2.1",
"pinia-plugin-persistedstate": "^3.2.1",
"pinia": "^2.2.2",
"pinia-plugin-persistedstate": "^4.0.0",
"quill": "^2.0.2",
"radash": "^12.1.0",
"vue": "^3.4.37",
"vue-i18n": "^9.13.1",
"vue": "^3.5.1",
"vue-i18n": "^9.14.0",
"vue-router": "^4.4.3"
},
"devDependencies": {
"@antfu/eslint-config": "^2.25.1",
"@iconify-json/icon-park-outline": "^1.1.16",
"@antfu/eslint-config": "^3.2.0",
"@iconify-json/icon-park-outline": "^1.2.0",
"@iconify/vue": "^4.1.2",
"@types/node": "^22.3.0",
"@vitejs/plugin-vue": "^5.1.2",
"@vitejs/plugin-vue-jsx": "^4.0.0",
"eslint": "^9.9.0",
"@types/node": "^22.5.4",
"@vitejs/plugin-vue": "^5.1.3",
"@vitejs/plugin-vue-jsx": "^4.0.1",
"eslint": "^9.9.1",
"lint-staged": "^15.2.9",
"naive-ui": "^2.39.0",
"sass": "^1.77.8",
"sass": "^1.78.0",
"simple-git-hooks": "^2.11.1",
"typescript": "^5.5.4",
"unocss": "^0.62.1",
"unocss": "^0.62.3",
"unplugin-auto-import": "^0.18.2",
"unplugin-icons": "^0.19.2",
"unplugin-icons": "^0.19.3",
"unplugin-vue-components": "^0.27.4",
"vite": "^5.4.0",
"vite": "^5.4.3",
"vite-bundle-visualizer": "^1.2.1",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-vue-devtools": "7.3.8",
"vue-tsc": "^2.0.29"
"vite-plugin-vue-devtools": "7.3.9",
"vue-tsc": "^2.1.6"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"

View File

@ -39,6 +39,16 @@ async function fetchIconAllList(nameList: string[]) {
return i
})
}
// svg
function getSvgName(path: string) {
const regex = /\/([^/]+)\.svg$/
const match = path.match(regex)
if (match) {
const fileName = match[1]
return fileName
}
return path
}
//
function generateLocalIconList() {
@ -48,15 +58,6 @@ function generateLocalIconList() {
eager: true,
})
function getSvgName(path: string) {
const regex = /\/([^/]+)\.svg$/
const match = path.match(regex)
if (match) {
const fileName = match[1]
return fileName
}
return path
}
return mapEntries(localSvgList, (key, value) => {
return [getSvgName(key), value]
})
@ -103,9 +104,8 @@ const icons = computed(() => {
//
const visibleIcons = computed(() => {
return icons.value
?.filter(i => i.includes(searchValue.value))
?.slice((currentPage.value - 1) * 200, (currentPage.value) * 200)
return icons.value?.filter(i => i
.includes(searchValue.value))?.slice((currentPage.value - 1) * 200, (currentPage.value) * 200)
})
const showModal = ref(false)

View File

@ -34,8 +34,8 @@ export const staticRoutes: AppRoute.RowRoute[] = [
pid: 1,
},
{
name: 'test',
path: '/test',
name: 'multi',
path: '/multi',
title: '多级菜单演示',
requiresAuth: true,
icon: 'icon-park-outline:list',
@ -45,32 +45,32 @@ export const staticRoutes: AppRoute.RowRoute[] = [
pid: null,
},
{
name: 'test2',
path: '/test/test2',
name: 'multi2',
path: '/multi/multi2',
title: '多级菜单子页',
requiresAuth: true,
icon: 'icon-park-outline:list',
menuType: 'page',
componentPath: '/test/test2/index.vue',
componentPath: '/demo/multi/multi2/index.vue',
id: 6,
pid: 4,
},
{
name: 'test2Detail',
path: '/test/test2/detail',
name: 'multi2Detail',
path: '/multi/multi2/detail',
title: '多级菜单的详情页',
requiresAuth: true,
icon: 'icon-park-outline:list',
hide: true,
activeMenu: '/test/test2',
activeMenu: '/multi/multi2',
menuType: 'page',
componentPath: '/test/test2/detail/index.vue',
componentPath: '/demo/multi/multi2/detail/index.vue',
id: 7,
pid: 4,
},
{
name: 'test3',
path: '/test/test3',
name: 'multi3',
path: '/multi/multi3',
title: '多级菜单',
requiresAuth: true,
icon: 'icon-park-outline:list',
@ -80,12 +80,12 @@ export const staticRoutes: AppRoute.RowRoute[] = [
pid: 4,
},
{
name: 'test4',
path: '/test/test3/test4',
name: 'multi4',
path: '/multi/multi3/multi4',
title: '多级菜单3-1',
requiresAuth: true,
icon: 'icon-park-outline:list',
componentPath: '/test/test3/test4/index.vue',
componentPath: '/demo/multi/multi3/multi4/index.vue',
id: 9,
pid: 8,
},
@ -106,7 +106,7 @@ export const staticRoutes: AppRoute.RowRoute[] = [
title: '常用列表',
requiresAuth: true,
icon: 'icon-park-outline:list-view',
componentPath: '/list/commonList/index.vue',
componentPath: '/demo/list/commonList/index.vue',
id: 11,
pid: 10,
},
@ -116,7 +116,7 @@ export const staticRoutes: AppRoute.RowRoute[] = [
title: '卡片列表',
requiresAuth: true,
icon: 'icon-park-outline:view-grid-list',
componentPath: '/list/cardList/index.vue',
componentPath: '/demo/list/cardList/index.vue',
id: 12,
pid: 10,
},
@ -240,7 +240,7 @@ export const staticRoutes: AppRoute.RowRoute[] = [
title: 'Vue',
requiresAuth: true,
icon: 'logos:vue',
componentPath: '/documents/vue/index.vue',
componentPath: '/demo/documents/vue/index.vue',
id: 25,
pid: 24,
},
@ -250,7 +250,7 @@ export const staticRoutes: AppRoute.RowRoute[] = [
title: 'Vite',
requiresAuth: true,
icon: 'logos:vitejs',
componentPath: '/documents/vite/index.vue',
componentPath: '/demo/documents/vite/index.vue',
id: 26,
pid: 24,
},
@ -282,7 +282,7 @@ export const staticRoutes: AppRoute.RowRoute[] = [
title: '权限示例',
requiresAuth: true,
icon: 'icon-park-outline:right-user',
componentPath: '/permission/permission/index.vue',
componentPath: '/demo/permission/permission/index.vue',
id: 29,
pid: 28,
},
@ -295,7 +295,7 @@ export const staticRoutes: AppRoute.RowRoute[] = [
'super',
],
icon: 'icon-park-outline:wrong-user',
componentPath: '/permission/justSuper/index.vue',
componentPath: '/demo/permission/justSuper/index.vue',
id: 30,
pid: 28,
},
@ -390,7 +390,7 @@ export const staticRoutes: AppRoute.RowRoute[] = [
title: '个人中心',
requiresAuth: true,
icon: 'carbon:user-avatar-filled-alt',
componentPath: '/userCenter/index.vue',
componentPath: '/demo/userCenter/index.vue',
id: 39,
pid: null,
},
@ -400,7 +400,7 @@ export const staticRoutes: AppRoute.RowRoute[] = [
title: '关于',
requiresAuth: true,
icon: 'icon-park-outline:info',
componentPath: '/about/index.vue',
componentPath: '/demo/about/index.vue',
id: 40,
pid: null,
},

View File

@ -104,8 +104,9 @@ export function createMenus(userRoutes: AppRoute.RowRoute[]) {
// render the returned routing table as a sidebar
function transformAuthRoutesToMenus(userRoutes: AppRoute.Route[]) {
const { hasPermission } = usePermission()
return userRoutes
// Filter out side menus without permission
return userRoutes.filter(i => hasPermission(i.meta.roles))
.filter(i => hasPermission(i.meta.roles))
// Sort the menu according to the order size
.sort((a, b) => {
if (a.meta && a.meta.order && b.meta && b.meta.order)
@ -116,7 +117,6 @@ function transformAuthRoutesToMenus(userRoutes: AppRoute.Route[]) {
return 1
else return 0
})
// Convert to side menu data structure
.map((item) => {
const target: MenuOption = {

View File

@ -39,9 +39,8 @@ function createLocalStorage<T extends Storage.Local>() {
window.localStorage.removeItem(`${STORAGE_PREFIX}${String(key)}`)
}
function clear() {
window.localStorage.clear()
}
const clear = window.localStorage.clear
return {
set,
get,
@ -73,9 +72,7 @@ function createSessionStorage<T extends Storage.Session>() {
function remove(key: keyof T) {
window.sessionStorage.removeItem(`${STORAGE_PREFIX}${String(key)}`)
}
function clear() {
window.sessionStorage.clear()
}
const clear = window.sessionStorage.clear
return {
set,

View File

@ -5,7 +5,7 @@ const router = useRouter()
<template>
<n-card class="h-130vh">
这个页面包含了一个不在侧边菜单的详情页面
<n-button @click="router.push('/test/test2/detail')">
<n-button @click="router.push('/multi/multi2/detail')">
跳转详情子页
</n-button>
</n-card>

View File

@ -108,7 +108,7 @@ const rules = {
},
}
const options = ref<Entity.Role[]>([])
const options = ref()
async function getRoleList() {
const { data } = await fetchRoleList()
options.value = data

View File

@ -161,7 +161,7 @@ const rules = {
},
}
const options = ref<Entity.Role[]>([])
const options = ref()
async function getRoleList() {
const { data } = await fetchRoleList()
options.value = data