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

View File

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

View File

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

View File

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

View File

@ -39,6 +39,16 @@ async function fetchIconAllList(nameList: string[]) {
return i 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() { function generateLocalIconList() {
@ -48,15 +58,6 @@ function generateLocalIconList() {
eager: true, 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 mapEntries(localSvgList, (key, value) => {
return [getSvgName(key), value] return [getSvgName(key), value]
}) })
@ -103,9 +104,8 @@ const icons = computed(() => {
// //
const visibleIcons = computed(() => { const visibleIcons = computed(() => {
return icons.value return icons.value?.filter(i => i
?.filter(i => i.includes(searchValue.value)) .includes(searchValue.value))?.slice((currentPage.value - 1) * 200, (currentPage.value) * 200)
?.slice((currentPage.value - 1) * 200, (currentPage.value) * 200)
}) })
const showModal = ref(false) const showModal = ref(false)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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