mirror of
https://github.com/fantastic-admin/basic.git
synced 2026-10-06 17:43:27 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7668bd5063 | ||
|
|
5e3fa9a567 | ||
|
|
571190cd78 | ||
|
|
bd5c921bca | ||
|
|
b236df4e30 | ||
|
|
657bec97f6 | ||
|
|
5d0141011b | ||
|
|
b8e53fb259 | ||
|
|
66c0e4f8c7 | ||
|
|
7457fcc23e | ||
|
|
9a7331f32f | ||
|
|
87819b4b5d | ||
|
|
d00fc26616 | ||
|
|
647edd7207 | ||
|
|
23d36432da | ||
|
|
2fdc4f18ca | ||
|
|
961df08e2b | ||
|
|
1d62ac7558 | ||
|
|
456ef83081 | ||
|
|
90b588028a | ||
|
|
9e444c83f8 | ||
|
|
57fcd2785c | ||
|
|
3c8b4881b4 | ||
|
|
e32d0561c7 | ||
|
|
d303776825 | ||
|
|
3ef0f69bcc | ||
|
|
b00477d5fa | ||
|
|
fe00fa1e6f | ||
|
|
f0679a1d59 | ||
|
|
4c4f811f39 | ||
|
|
03e5e99896 | ||
|
|
fda48176ee | ||
|
|
b639b487db | ||
|
|
dbd93ffb7f | ||
|
|
daf9b1b2e2 | ||
|
|
e023671bac | ||
|
|
e6265a7c64 | ||
|
|
8c629050ba | ||
|
|
c7d2a857f7 | ||
|
|
b19344a1c1 | ||
|
|
b632b4d3a8 | ||
|
|
98d21845ce | ||
|
|
bbeeac41ce | ||
|
|
449495f03d | ||
|
|
14583bbaa5 | ||
|
|
045ab02bb2 | ||
|
|
b883133dc6 | ||
|
|
5269dba56b | ||
|
|
4911affd28 | ||
|
|
cb53f4c84e | ||
|
|
3164e33f1d | ||
|
|
06eee21032 | ||
|
|
79184f4eeb | ||
|
|
8416b61f6b | ||
|
|
a90a19c62e | ||
|
|
ee819445d2 | ||
|
|
679ad4c9ee | ||
|
|
805c13ba7a | ||
|
|
c61675b311 | ||
|
|
a105df66b1 | ||
|
|
107e820776 | ||
|
|
04fa39c295 | ||
|
|
1685f8b7be | ||
|
|
73074101e1 | ||
|
|
e802354cab | ||
|
|
26274fdb8e | ||
|
|
f26b4cc50e |
@@ -6,6 +6,8 @@ VITE_APP_TITLE = Fantastic-admin 基础版
|
||||
VITE_APP_API_BASEURL = /
|
||||
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
|
||||
VITE_APP_DEBUG_TOOL =
|
||||
# 是否禁用开发者工具,可防止被调试
|
||||
VITE_APP_DISABLE_DEVTOOL = false
|
||||
|
||||
# 是否开启代理
|
||||
VITE_OPEN_PROXY = false
|
||||
|
||||
@@ -6,6 +6,8 @@ VITE_APP_TITLE = 页面标题
|
||||
VITE_APP_API_BASEURL = /
|
||||
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
|
||||
VITE_APP_DEBUG_TOOL =
|
||||
# 是否禁用开发者工具,可防止被调试
|
||||
VITE_APP_DISABLE_DEVTOOL = false
|
||||
|
||||
# 是否在打包时启用 Mock
|
||||
VITE_BUILD_MOCK = false
|
||||
|
||||
@@ -6,6 +6,8 @@ VITE_APP_TITLE = 页面标题(test)
|
||||
VITE_APP_API_BASEURL = /
|
||||
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
|
||||
VITE_APP_DEBUG_TOOL =
|
||||
# 是否禁用开发者工具,可防止被调试
|
||||
VITE_APP_DISABLE_DEVTOOL = false
|
||||
|
||||
# 是否在打包时启用 Mock
|
||||
VITE_BUILD_MOCK = true
|
||||
|
||||
@@ -9,7 +9,7 @@ jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
needs: release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -57,7 +57,7 @@ jobs:
|
||||
needs: release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: example
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
name: repo-sync
|
||||
|
||||
on:
|
||||
# 每天自动同步
|
||||
# 每天 00:05 自动同步
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
- cron: '5 0 * * *'
|
||||
# 手动触发部署
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
20
|
||||
Vendored
-1
@@ -5,7 +5,6 @@
|
||||
"dbaeumer.vscode-eslint",
|
||||
"stylelint.vscode-stylelint",
|
||||
"Vue.volar",
|
||||
"Vue.vscode-typescript-vue-plugin",
|
||||
"antfu.unocss"
|
||||
]
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"eslint.experimental.useFlatConfig": true,
|
||||
"eslint.useFlatConfig": true,
|
||||
"prettier.enable": false,
|
||||
"editor.formatOnSave": false,
|
||||
"editor.codeActionsOnSave": {
|
||||
|
||||
@@ -7,16 +7,9 @@
|
||||
<p align="center">一款<b>开箱即用</b>的 Vue3 中后台管理系统框架</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://fantastic-admin.github.io" target="_blank">官网</a>
|
||||
<sup><a href="https://fantastic-admin.gitee.io" target="_blank">备用地址</a></sup>
|
||||
<a href="https://fantastic-admin.github.io" target="_blank">官网(Github)</a>
|
||||
<span> | </span>
|
||||
<a href="https://fantastic-admin.github.io/support.html" target="_blank">技术支持</a>
|
||||
<span> | </span>
|
||||
演示
|
||||
<sup><a href="https://fantastic-admin.github.io/basic-example" target="_blank">基础版</a> <a href="https://fantastic-admin.github.io/pro-example" target="_blank">专业版</a></sup>
|
||||
<span> | </span>
|
||||
购买
|
||||
<sup><a href="https://fantastic-admin.github.io/buy.html" target="_blank">专业版</a></sup>
|
||||
<a href="https://fantastic-admin.pages.dev" target="_blank">官网(Cloudflare)</a>
|
||||
<p>
|
||||
|
||||
<p align="center">
|
||||
@@ -115,3 +108,22 @@
|
||||
<td><img src="https://one-step-admin.github.io/preview6.png" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th colspan="4" align="center">
|
||||
<a href="https://fantastic-mobile.github.io" target="_blank">Fantastic-mobile</a>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="4" align="center">
|
||||
一款自成一派的移动端 H5 框架
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://fantastic-mobile.github.io/preview1.png" /></td>
|
||||
<td><img src="https://fantastic-mobile.github.io/preview2.png" /></td>
|
||||
<td><img src="https://fantastic-mobile.github.io/preview3.png" /></td>
|
||||
<td><img src="https://fantastic-mobile.github.io/preview4.png" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
+4
-1
@@ -12,7 +12,10 @@ export default antfu(
|
||||
rules: {
|
||||
'eslint-comments/no-unlimited-disable': 'off',
|
||||
'curly': ['error', 'all'],
|
||||
'antfu/consistent-list-newline': 'off',
|
||||
'ts/no-unused-expressions': ['error', {
|
||||
allowShortCircuit: true,
|
||||
allowTernary: true,
|
||||
}],
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
<div class="browsers">
|
||||
<a href="https://www.microsoft.com/edge" target="_blank" class="browser">
|
||||
<img class="browser-icon" src="/browser_upgrade/edge.png" />
|
||||
<div class="browser-name">Mircosoft Edge</div>
|
||||
<div class="browser-name">Microsoft Edge</div>
|
||||
</a>
|
||||
<a href="https://www.google.cn/chrome/" target="_blank" class="browser">
|
||||
<img class="browser-icon" src="/browser_upgrade/chrome.png" />
|
||||
|
||||
+56
-55
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"type": "module",
|
||||
"version": "4.6.2",
|
||||
"version": "4.10.0",
|
||||
"engines": {
|
||||
"node": "^18.0.0 || ^20.0.0"
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -23,84 +23,85 @@
|
||||
"release": "bumpp"
|
||||
},
|
||||
"dependencies": {
|
||||
"@headlessui/vue": "^1.7.19",
|
||||
"@imengyu/vue3-context-menu": "^1.3.8",
|
||||
"@vueuse/core": "^10.8.0",
|
||||
"@vueuse/integrations": "^10.8.0",
|
||||
"axios": "^1.6.7",
|
||||
"dayjs": "^1.11.10",
|
||||
"@headlessui/vue": "^1.7.22",
|
||||
"@imengyu/vue3-context-menu": "^1.4.2",
|
||||
"@vueuse/core": "^10.11.0",
|
||||
"@vueuse/integrations": "^10.11.0",
|
||||
"axios": "^1.7.3",
|
||||
"dayjs": "^1.11.12",
|
||||
"defu": "^6.1.4",
|
||||
"element-plus": "^2.5.6",
|
||||
"eruda": "^3.0.1",
|
||||
"disable-devtool": "^0.3.7",
|
||||
"element-plus": "^2.7.8",
|
||||
"eruda": "^3.2.1",
|
||||
"floating-vue": "5.2.2",
|
||||
"hotkeys-js": "^3.13.7",
|
||||
"lodash-es": "^4.17.21",
|
||||
"mitt": "^3.0.1",
|
||||
"mockjs": "^1.1.0",
|
||||
"nprogress": "^0.2.0",
|
||||
"overlayscrollbars": "^2.5.0",
|
||||
"overlayscrollbars-vue": "^0.5.7",
|
||||
"overlayscrollbars": "^2.10.0",
|
||||
"overlayscrollbars-vue": "^0.5.9",
|
||||
"path-browserify": "^1.0.1",
|
||||
"path-to-regexp": "^6.2.1",
|
||||
"pinia": "^2.1.7",
|
||||
"qs": "^6.11.2",
|
||||
"path-to-regexp": "^7.1.0",
|
||||
"pinia": "^2.2.0",
|
||||
"qs": "^6.13.0",
|
||||
"scule": "^1.3.0",
|
||||
"vconsole": "^3.15.1",
|
||||
"vue": "^3.4.20",
|
||||
"vue": "^3.4.35",
|
||||
"vue-m-message": "^4.0.2",
|
||||
"vue-router": "^4.3.0"
|
||||
"vue-router": "^4.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "2.6.4",
|
||||
"@iconify/json": "^2.2.186",
|
||||
"@iconify/vue": "^4.1.1",
|
||||
"@stylistic/stylelint-config": "^1.0.1",
|
||||
"@antfu/eslint-config": "2.24.1",
|
||||
"@iconify/json": "^2.2.233",
|
||||
"@iconify/vue": "^4.1.2",
|
||||
"@stylistic/stylelint-config": "^2.0.0",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/mockjs": "^1.0.10",
|
||||
"@types/nprogress": "^0.2.3",
|
||||
"@types/path-browserify": "^1.0.2",
|
||||
"@types/qs": "^6.9.11",
|
||||
"@unocss/eslint-plugin": "^0.58.5",
|
||||
"@vitejs/plugin-legacy": "^5.3.1",
|
||||
"@vitejs/plugin-vue": "^5.0.4",
|
||||
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
||||
"archiver": "^6.0.1",
|
||||
"autoprefixer": "^10.4.17",
|
||||
"@types/qs": "^6.9.15",
|
||||
"@unocss/eslint-plugin": "^0.61.9",
|
||||
"@vitejs/plugin-legacy": "^5.4.1",
|
||||
"@vitejs/plugin-vue": "^5.1.2",
|
||||
"@vitejs/plugin-vue-jsx": "^4.0.0",
|
||||
"archiver": "^7.0.1",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"boxen": "^7.1.1",
|
||||
"bumpp": "^9.3.0",
|
||||
"cz-git": "^1.8.0",
|
||||
"eslint": "^8.57.0",
|
||||
"esno": "^4.0.0",
|
||||
"bumpp": "^9.4.2",
|
||||
"cz-git": "^1.9.4",
|
||||
"eslint": "^9.8.0",
|
||||
"esno": "^4.7.0",
|
||||
"fs-extra": "^11.2.0",
|
||||
"http-server": "^14.1.1",
|
||||
"inquirer": "^9.2.15",
|
||||
"lint-staged": "^15.2.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"picocolors": "^1.0.0",
|
||||
"inquirer": "^10.1.6",
|
||||
"lint-staged": "^15.2.8",
|
||||
"npm-run-all2": "^6.2.2",
|
||||
"picocolors": "^1.0.1",
|
||||
"plop": "^4.0.1",
|
||||
"sass": "^1.71.1",
|
||||
"simple-git-hooks": "^2.9.0",
|
||||
"stylelint": "^16.2.1",
|
||||
"stylelint-config-recess-order": "^4.6.0",
|
||||
"stylelint-config-standard-scss": "^13.0.0",
|
||||
"postcss": "^8.4.40",
|
||||
"sass": "^1.77.8",
|
||||
"simple-git-hooks": "^2.11.1",
|
||||
"stylelint": "^16.8.1",
|
||||
"stylelint-config-recess-order": "^5.0.1",
|
||||
"stylelint-config-standard-scss": "^13.1.0",
|
||||
"stylelint-config-standard-vue": "^1.0.0",
|
||||
"stylelint-scss": "^6.1.0",
|
||||
"svgo": "^3.2.0",
|
||||
"terser": "^5.28.1",
|
||||
"typescript": "^5.3.3",
|
||||
"unocss": "^0.58.5",
|
||||
"unplugin-auto-import": "^0.17.5",
|
||||
"unplugin-turbo-console": "^1.4.0",
|
||||
"unplugin-vue-components": "^0.26.0",
|
||||
"vite": "^5.1.4",
|
||||
"stylelint-scss": "^6.4.1",
|
||||
"svgo": "^3.3.2",
|
||||
"typescript": "^5.5.4",
|
||||
"unocss": "^0.61.9",
|
||||
"unplugin-auto-import": "^0.18.2",
|
||||
"unplugin-turbo-console": "^1.10.1",
|
||||
"unplugin-vue-components": "^0.27.3",
|
||||
"vite": "^5.3.5",
|
||||
"vite-plugin-banner": "^0.7.1",
|
||||
"vite-plugin-compression2": "^0.12.0",
|
||||
"vite-plugin-compression2": "^1.1.3",
|
||||
"vite-plugin-fake-server": "^2.1.1",
|
||||
"vite-plugin-pages": "^0.32.0",
|
||||
"vite-plugin-pages": "^0.32.3",
|
||||
"vite-plugin-svg-icons": "^2.0.1",
|
||||
"vite-plugin-vue-devtools": "^7.0.15",
|
||||
"vite-plugin-vue-meta-layouts": "^0.4.1",
|
||||
"vue-tsc": "^1.8.27"
|
||||
"vite-plugin-vue-devtools": "^7.3.7",
|
||||
"vite-plugin-vue-meta-layouts": "^0.4.3",
|
||||
"vue-tsc": "^2.0.29"
|
||||
},
|
||||
"simple-git-hooks": {
|
||||
"pre-commit": "pnpm lint-staged",
|
||||
|
||||
@@ -45,34 +45,40 @@ export default [
|
||||
{
|
||||
url: '/mock/{{#if relativePath}}{{ relativePath }}/{{/if}}{{ moduleName }}/create',
|
||||
method: 'post',
|
||||
response: {
|
||||
error: '',
|
||||
status: 1,
|
||||
data: {
|
||||
isSuccess: true,
|
||||
},
|
||||
response: () => {
|
||||
return {
|
||||
error: '',
|
||||
status: 1,
|
||||
data: {
|
||||
isSuccess: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
url: '/mock/{{#if relativePath}}{{ relativePath }}/{{/if}}{{ moduleName }}/edit',
|
||||
method: 'post',
|
||||
response: {
|
||||
error: '',
|
||||
status: 1,
|
||||
data: {
|
||||
isSuccess: true,
|
||||
},
|
||||
response: () => {
|
||||
return {
|
||||
error: '',
|
||||
status: 1,
|
||||
data: {
|
||||
isSuccess: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
url: '/mock/{{#if relativePath}}{{ relativePath }}/{{/if}}{{ moduleName }}/delete',
|
||||
method: 'post',
|
||||
response: {
|
||||
error: '',
|
||||
status: 1,
|
||||
data: {
|
||||
isSuccess: true,
|
||||
},
|
||||
response: () => {
|
||||
return {
|
||||
error: '',
|
||||
status: 1,
|
||||
data: {
|
||||
isSuccess: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
Generated
+9196
-7939
File diff suppressed because it is too large
Load Diff
+18
-10
@@ -1,18 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import eruda from 'eruda'
|
||||
import VConsole from 'vconsole'
|
||||
import hotkeys from 'hotkeys-js'
|
||||
import eventBus from './utils/eventBus'
|
||||
import Provider from './ui-provider/index.vue'
|
||||
import useSettingsStore from '@/store/modules/settings'
|
||||
import useMenuStore from '@/store/modules/menu'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
const menuStore = useMenuStore()
|
||||
const { auth } = useAuth()
|
||||
|
||||
const isAuth = computed(() => {
|
||||
return route.matched.every((item) => {
|
||||
return auth(item.meta.auth ?? '')
|
||||
})
|
||||
})
|
||||
|
||||
// 侧边栏主导航当前实际宽度
|
||||
const mainSidebarActualWidth = computed(() => {
|
||||
let actualWidth = Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--g-main-sidebar-width'))
|
||||
if (settingsStore.settings.menu.menuMode === 'single' || (settingsStore.settings.menu.menuMode === 'head' && settingsStore.mode !== 'mobile')) {
|
||||
if (settingsStore.settings.menu.mode === 'single' || (settingsStore.settings.menu.mode === 'head' && settingsStore.mode !== 'mobile')) {
|
||||
actualWidth = 0
|
||||
}
|
||||
return `${actualWidth}px`
|
||||
@@ -24,6 +32,9 @@ const subSidebarActualWidth = computed(() => {
|
||||
if (settingsStore.settings.menu.subMenuCollapse && settingsStore.mode !== 'mobile') {
|
||||
actualWidth = Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--g-sub-sidebar-collapse-width'))
|
||||
}
|
||||
if (menuStore.sidebarMenus.every(item => item.meta?.menu === false)) {
|
||||
actualWidth = 0
|
||||
}
|
||||
return `${actualWidth}px`
|
||||
})
|
||||
|
||||
@@ -46,28 +57,25 @@ watch([
|
||||
|
||||
onMounted(() => {
|
||||
settingsStore.setMode(document.documentElement.clientWidth)
|
||||
window.onresize = () => {
|
||||
window.addEventListener('resize', () => {
|
||||
settingsStore.setMode(document.documentElement.clientWidth)
|
||||
}
|
||||
})
|
||||
hotkeys('alt+i', () => {
|
||||
eventBus.emit('global-system-info-toggle')
|
||||
})
|
||||
})
|
||||
|
||||
import.meta.env.VITE_APP_DEBUG_TOOL === 'eruda' && eruda.init()
|
||||
import.meta.env.VITE_APP_DEBUG_TOOL === 'vconsole' && new VConsole()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Provider>
|
||||
<RouterView
|
||||
v-slot="{ Component, route }"
|
||||
v-slot="{ Component }"
|
||||
:style="{
|
||||
'--g-main-sidebar-actual-width': mainSidebarActualWidth,
|
||||
'--g-sub-sidebar-actual-width': subSidebarActualWidth,
|
||||
}"
|
||||
>
|
||||
<component :is="Component" v-if="auth(route.meta.auth ?? '')" />
|
||||
<component :is="Component" v-if="isAuth" />
|
||||
<NotAllowed v-else />
|
||||
</RouterView>
|
||||
<SystemInfo />
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
// 明暗模式 CSS 变量
|
||||
/* stylelint-disable-next-line no-duplicate-selectors */
|
||||
:root {
|
||||
--g-box-shadow-color: rgb(0 0 0 / 12%);
|
||||
|
||||
&::view-transition-old(root),
|
||||
&::view-transition-new(root) {
|
||||
mix-blend-mode: normal;
|
||||
@@ -31,9 +33,9 @@
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
--g-box-shadow-color: rgb(0 0 0 / 12%);
|
||||
|
||||
&.dark {
|
||||
--g-box-shadow-color: rgb(0 0 0 / 72%);
|
||||
|
||||
&::view-transition-old(root) {
|
||||
z-index: 9999;
|
||||
}
|
||||
@@ -41,8 +43,6 @@
|
||||
&::view-transition-new(root) {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
--g-box-shadow-color: rgb(0 0 0 / 72%);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ textarea {
|
||||
|
||||
.v-popper--theme-dropdown .v-popper__inner,
|
||||
.v-popper--theme-tooltip .v-popper__inner {
|
||||
--at-apply: bg-white dark:bg-stone-8 text-dark dark:text-white rounded shadow ring-1 ring-gray-200 dark:ring-gray-800 border border-solid border-stone/20 text-xs font-normal;
|
||||
--at-apply: bg-white dark-bg-stone-8 text-dark dark-text-white rounded shadow ring-1 ring-gray-200 dark-ring-gray-800 border border-solid border-stone/20 text-xs font-normal;
|
||||
|
||||
box-shadow: 0 6px 30px rgb(0 0 0 / 10%);
|
||||
}
|
||||
@@ -124,7 +124,7 @@ textarea {
|
||||
.v-popper--theme-dropdown .v-popper__arrow-inner {
|
||||
visibility: visible;
|
||||
|
||||
--at-apply: border-white dark:border-stone-8;
|
||||
--at-apply: border-white dark-border-stone-8;
|
||||
}
|
||||
|
||||
.v-popper--theme-tooltip .v-popper__arrow-outer,
|
||||
|
||||
@@ -17,6 +17,7 @@ const props = withDefaults(
|
||||
files?: UploadUserFile[]
|
||||
notip?: boolean
|
||||
ext?: string[]
|
||||
httpRequest?: UploadProps['httpRequest']
|
||||
}>(),
|
||||
{
|
||||
name: 'file',
|
||||
@@ -29,7 +30,7 @@ const props = withDefaults(
|
||||
)
|
||||
|
||||
const emits = defineEmits<{
|
||||
'onSuccess': [
|
||||
onSuccess: [
|
||||
res: any,
|
||||
file: UploadUserFile,
|
||||
fileList: UploadUserFile[],
|
||||
@@ -57,6 +58,29 @@ const onExceed: UploadProps['onExceed'] = () => {
|
||||
const onSuccess: UploadProps['onSuccess'] = (res, file, fileList) => {
|
||||
emits('onSuccess', res, file, fileList)
|
||||
}
|
||||
|
||||
const onPreview: UploadProps['onPreview'] = (e) => {
|
||||
const getBlob = (url: string) => new Promise((resolve) => {
|
||||
const xhr = new XMLHttpRequest()
|
||||
xhr.open('GET', url, true)
|
||||
xhr.responseType = 'blob'
|
||||
xhr.onload = () => {
|
||||
if (xhr.status === 200) {
|
||||
resolve(xhr.response)
|
||||
}
|
||||
}
|
||||
xhr.send()
|
||||
})
|
||||
getBlob(e.url!).then((blob: any) => {
|
||||
const a = document.createElement('a')
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const event = new MouseEvent('click')
|
||||
a.target = '_blank'
|
||||
a.download = e.name
|
||||
a.href = url
|
||||
a.dispatchEvent(event)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -68,6 +92,8 @@ const onSuccess: UploadProps['onSuccess'] = (res, file, fileList) => {
|
||||
:before-upload="beforeUpload"
|
||||
:on-exceed="onExceed"
|
||||
:on-success="onSuccess"
|
||||
:on-preview="onPreview"
|
||||
:http-request="httpRequest"
|
||||
:file-list="files"
|
||||
:limit="max"
|
||||
drag
|
||||
|
||||
@@ -18,6 +18,7 @@ const props = withDefaults(
|
||||
placeholder?: string
|
||||
notip?: boolean
|
||||
ext?: string[]
|
||||
httpRequest?: UploadProps['httpRequest']
|
||||
}>(),
|
||||
{
|
||||
name: 'file',
|
||||
@@ -31,7 +32,7 @@ const props = withDefaults(
|
||||
)
|
||||
|
||||
const emits = defineEmits<{
|
||||
'onSuccess': [
|
||||
onSuccess: [
|
||||
res: any,
|
||||
]
|
||||
}>()
|
||||
@@ -97,6 +98,7 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
|
||||
:before-upload="beforeUpload"
|
||||
:on-progress="onProgress"
|
||||
:on-success="onSuccess"
|
||||
:http-request="httpRequest"
|
||||
drag
|
||||
class="image-upload"
|
||||
>
|
||||
|
||||
@@ -19,6 +19,7 @@ const props = withDefaults(
|
||||
placeholder?: string
|
||||
notip?: boolean
|
||||
ext?: string[]
|
||||
httpRequest?: UploadProps['httpRequest']
|
||||
}>(),
|
||||
{
|
||||
name: 'file',
|
||||
@@ -33,7 +34,7 @@ const props = withDefaults(
|
||||
)
|
||||
|
||||
const emits = defineEmits<{
|
||||
'onSuccess': [
|
||||
onSuccess: [
|
||||
res: any,
|
||||
]
|
||||
}>()
|
||||
@@ -131,6 +132,7 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
|
||||
:before-upload="beforeUpload"
|
||||
:on-progress="onProgress"
|
||||
:on-success="onSuccess"
|
||||
:http-request="httpRequest"
|
||||
drag
|
||||
class="images-upload"
|
||||
>
|
||||
|
||||
@@ -34,8 +34,8 @@ function goBack() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="absolute left-[50%] top-[50%] flex flex-col items-center justify-between lg:flex-row -translate-x-50% -translate-y-50% lg:gap-12">
|
||||
<SvgIcon name="403" class="text-[300px] lg:text-[400px]" />
|
||||
<div class="absolute left-[50%] top-[50%] flex flex-col items-center justify-between lg-flex-row -translate-x-50% -translate-y-50% lg-gap-12">
|
||||
<SvgIcon name="403" class="text-[300px] lg-text-[400px]" />
|
||||
<div class="flex flex-col gap-4">
|
||||
<h1 class="m-0 text-6xl font-sans">
|
||||
403
|
||||
|
||||
@@ -19,7 +19,7 @@ const slots = useSlots()
|
||||
{{ title }}
|
||||
</slot>
|
||||
</div>
|
||||
<div class="mt-2 text-sm text-stone-5 empty:hidden">
|
||||
<div class="mt-2 text-sm text-stone-5 empty-hidden">
|
||||
<slot name="content">
|
||||
{{ content }}
|
||||
</slot>
|
||||
|
||||
@@ -41,7 +41,7 @@ function unCollaspe() {
|
||||
<slot />
|
||||
</div>
|
||||
<div v-if="isCollaspe" class="collaspe absolute bottom-0 w-full cursor-pointer from-transparent to-[var(--g-container-bg)] bg-gradient-to-b pb-2 pt-10 text-center" @click="unCollaspe">
|
||||
<SvgIcon name="i-ep:arrow-down" class="text-xl op-30 transition-opacity hover:op-100" />
|
||||
<SvgIcon name="i-ep:arrow-down" class="text-xl op-30 transition-opacity hover-op-100" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -15,7 +15,7 @@ withDefaults(
|
||||
)
|
||||
|
||||
const emits = defineEmits<{
|
||||
'toggle': [
|
||||
toggle: [
|
||||
value: boolean,
|
||||
]
|
||||
}>()
|
||||
|
||||
@@ -14,14 +14,6 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<HSlideover v-model="isShow" title="系统信息">
|
||||
<div class="px-4">
|
||||
<h2 class="m-0 text-lg font-bold">
|
||||
版本号
|
||||
</h2>
|
||||
<div class="my-4 text-center text-lg font-sans">
|
||||
{{ pkg.version }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-4">
|
||||
<h2 class="m-0 text-lg font-bold">
|
||||
最后编译时间
|
||||
@@ -35,7 +27,7 @@ onMounted(() => {
|
||||
生产环境依赖
|
||||
</h2>
|
||||
<ul class="list-none pl-0 text-sm">
|
||||
<li v-for="(val, key) in (pkg.dependencies as object)" :key="key" class="flex items-center justify-between rounded px-2 py-1.5 hover:bg-stone-1 dark:hover:bg-stone-9">
|
||||
<li v-for="(val, key) in (pkg.dependencies as object)" :key="key" class="flex items-center justify-between rounded px-2 py-1.5 hover-bg-stone-1 dark-hover-bg-stone-9">
|
||||
<div class="font-bold">
|
||||
{{ key }}
|
||||
</div>
|
||||
@@ -50,7 +42,7 @@ onMounted(() => {
|
||||
开发环境依赖
|
||||
</h2>
|
||||
<ul class="list-none pl-0 text-sm">
|
||||
<li v-for="(val, key) in (pkg.devDependencies as object)" :key="key" class="flex items-center justify-between rounded px-2 py-1.5 hover:bg-stone-1 dark:hover:bg-stone-9">
|
||||
<li v-for="(val, key) in (pkg.devDependencies as object)" :key="key" class="flex items-center justify-between rounded px-2 py-1.5 hover-bg-stone-1 dark-hover-bg-stone-9">
|
||||
<div class="font-bold">
|
||||
{{ key }}
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@ const menuStore = useMenuStore()
|
||||
|
||||
const isShow = ref(false)
|
||||
|
||||
watch(() => settingsStore.settings.menu.menuMode, (value) => {
|
||||
watch(() => settingsStore.settings.menu.mode, (value) => {
|
||||
if (value === 'single') {
|
||||
menuStore.setActived(0)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ function handleCopy() {
|
||||
:options="[
|
||||
{ icon: 'i-ri:sun-line', label: '明亮', value: 'light' },
|
||||
{ icon: 'i-ri:moon-line', label: '暗黑', value: 'dark' },
|
||||
{ icon: 'i-ri:computer-line', label: '系统', value: '' },
|
||||
{ icon: 'i-codicon:color-mode', label: '系统', value: '' },
|
||||
]"
|
||||
class="w-60"
|
||||
/>
|
||||
@@ -103,17 +103,17 @@ function handleCopy() {
|
||||
</div>
|
||||
<div v-if="settingsStore.mode === 'pc'" class="menu-mode">
|
||||
<HTooltip text="侧边栏模式 (含主导航)" placement="bottom" :delay="500">
|
||||
<div class="mode mode-side" :class="{ active: settingsStore.settings.menu.menuMode === 'side' }" @click="settingsStore.settings.menu.menuMode = 'side'">
|
||||
<div class="mode mode-side" :class="{ active: settingsStore.settings.menu.mode === 'side' }" @click="settingsStore.settings.menu.mode = 'side'">
|
||||
<div class="mode-container" />
|
||||
</div>
|
||||
</HTooltip>
|
||||
<HTooltip text="顶部模式" placement="bottom" :delay="500">
|
||||
<div class="mode mode-head" :class="{ active: settingsStore.settings.menu.menuMode === 'head' }" @click="settingsStore.settings.menu.menuMode = 'head'">
|
||||
<div class="mode mode-head" :class="{ active: settingsStore.settings.menu.mode === 'head' }" @click="settingsStore.settings.menu.mode = 'head'">
|
||||
<div class="mode-container" />
|
||||
</div>
|
||||
</HTooltip>
|
||||
<HTooltip text="侧边栏模式 (不含主导航)" placement="bottom" :delay="500">
|
||||
<div class="mode mode-single" :class="{ active: settingsStore.settings.menu.menuMode === 'single' }" @click="settingsStore.settings.menu.menuMode = 'single'">
|
||||
<div class="mode mode-single" :class="{ active: settingsStore.settings.menu.mode === 'single' }" @click="settingsStore.settings.menu.mode = 'single'">
|
||||
<div class="mode-container" />
|
||||
</div>
|
||||
</HTooltip>
|
||||
@@ -128,7 +128,7 @@ function handleCopy() {
|
||||
<SvgIcon name="i-ri:question-line" />
|
||||
</HTooltip>
|
||||
</div>
|
||||
<HToggle v-model="settingsStore.settings.menu.switchMainMenuAndPageJump" :disabled="['single'].includes(settingsStore.settings.menu.menuMode)" />
|
||||
<HToggle v-model="settingsStore.settings.menu.switchMainMenuAndPageJump" :disabled="['single'].includes(settingsStore.settings.menu.mode)" />
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<div class="label">
|
||||
@@ -155,7 +155,7 @@ function handleCopy() {
|
||||
<div class="label">
|
||||
是否启用快捷键
|
||||
</div>
|
||||
<HToggle v-model="settingsStore.settings.menu.enableHotkeys" :disabled="['single'].includes(settingsStore.settings.menu.menuMode)" />
|
||||
<HToggle v-model="settingsStore.settings.menu.enableHotkeys" :disabled="['single'].includes(settingsStore.settings.menu.mode)" />
|
||||
</div>
|
||||
<div class="divider">
|
||||
顶栏
|
||||
@@ -327,6 +327,21 @@ function handleCopy() {
|
||||
</div>
|
||||
<HToggle v-model="settingsStore.settings.app.enableProgress" />
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<div class="label">
|
||||
哀悼模式
|
||||
<HTooltip text="该功能开启时,整站会变为灰色">
|
||||
<SvgIcon name="i-ri:question-line" />
|
||||
</HTooltip>
|
||||
</div>
|
||||
<HToggle v-model="settingsStore.settings.app.enableMournMode" />
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<div class="label">
|
||||
色弱模式
|
||||
</div>
|
||||
<HToggle v-model="settingsStore.settings.app.enableColorAmblyopiaMode" />
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<div class="label">
|
||||
动态标题
|
||||
@@ -351,7 +366,7 @@ function handleCopy() {
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
--at-apply: content-empty w-full h-1px bg-stone-2 dark:bg-stone-6;
|
||||
--at-apply: content-empty w-full h-1px bg-stone-2 dark-bg-stone-6;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,7 +374,7 @@ function handleCopy() {
|
||||
--at-apply: flex items-center justify-center gap-4 pb-4;
|
||||
|
||||
.mode {
|
||||
--at-apply: relative w-16 h-12 rounded-2 ring-1 ring-stone-2 dark:ring-stone-7 cursor-pointer transition;
|
||||
--at-apply: relative w-16 h-12 rounded-2 ring-1 ring-stone-2 dark-ring-stone-7 cursor-pointer transition;
|
||||
|
||||
&.active {
|
||||
--at-apply: ring-ui-primary ring-2;
|
||||
@@ -380,7 +395,7 @@ function handleCopy() {
|
||||
}
|
||||
|
||||
.mode-container {
|
||||
--at-apply: bg-ui-primary/20 border-dashed border-ui-primary;
|
||||
--at-apply: bg-ui-primary/20 border-width-1.5 border-dashed border-ui-primary;
|
||||
|
||||
&::before {
|
||||
--at-apply: content-empty absolute w-full h-full;
|
||||
@@ -428,7 +443,7 @@ function handleCopy() {
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
--at-apply: flex items-center justify-between gap-4 px-4 py-2 rounded-2 transition hover:bg-stone-1 dark:hover:bg-stone-9;
|
||||
--at-apply: flex items-center justify-between gap-4 px-4 py-2 rounded-2 transition hover-bg-stone-1 dark-hover-bg-stone-9;
|
||||
|
||||
.label {
|
||||
--at-apply: flex items-center flex-shrink-0 gap-2 text-sm;
|
||||
|
||||
@@ -5,11 +5,11 @@ defineOptions({
|
||||
|
||||
const transitionClass = {
|
||||
enterActiveClass: 'ease-out duration-300',
|
||||
enterFromClass: 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95',
|
||||
enterToClass: 'opacity-100 translate-y-0 sm:scale-100',
|
||||
enterFromClass: 'opacity-0 translate-y-4 lg-translate-y-0 lg-scale-95',
|
||||
enterToClass: 'opacity-100 translate-y-0 lg-scale-100',
|
||||
leaveActiveClass: 'ease-in duration-200',
|
||||
leaveFromClass: 'opacity-100 translate-y-0 sm:scale-100',
|
||||
leaveToClass: 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95',
|
||||
leaveFromClass: 'opacity-100 translate-y-0 lg-scale-100',
|
||||
leaveToClass: 'opacity-0 translate-y-4 lg-translate-y-0 lg-scale-95',
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -37,7 +37,7 @@ function handleClick() {
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition v-bind="transitionClass">
|
||||
<div v-if="scrollTop && scrollTop >= 200" class="fixed bottom-4 right-4 z-1000 h-12 w-12 flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg ring-1 ring-stone-3 ring-inset dark:bg-dark hover:bg-stone-1 dark:ring-stone-7 dark:hover:bg-dark/50" @click="handleClick">
|
||||
<div v-if="scrollTop && scrollTop >= 200" class="fixed bottom-4 right-4 z-1000 h-12 w-12 flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg ring-1 ring-stone-3 ring-inset dark-bg-dark hover-bg-stone-1 dark-ring-stone-7 dark-hover-bg-dark/50" @click="handleClick">
|
||||
<SvgIcon name="i-icon-park-outline:to-top-one" :size="24" />
|
||||
</div>
|
||||
</Transition>
|
||||
|
||||
@@ -22,14 +22,14 @@ function onClick() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="breadcrumb-item flex items-center text-dark dark:text-white">
|
||||
<div class="breadcrumb-item flex items-center text-dark dark-text-white">
|
||||
<span class="separator mx-2">
|
||||
{{ separator }}
|
||||
</span>
|
||||
<span
|
||||
class="text flex items-center opacity-60"
|
||||
:class="{
|
||||
'is-link cursor-pointer transition-opacity hover:opacity-100': !!props.to,
|
||||
'is-link cursor-pointer transition-opacity hover-opacity-100': !!props.to,
|
||||
}" @click="onClick"
|
||||
>
|
||||
<slot />
|
||||
|
||||
@@ -31,7 +31,7 @@ const settingsStore = useSettingsStore()
|
||||
}
|
||||
|
||||
a {
|
||||
--at-apply: text-center no-underline text-stone-5 hover:text-dark dark:hover:text-light transition;
|
||||
--at-apply: text-center no-underline text-stone-5 hover-text-dark dark-hover-text-light transition;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -17,42 +17,42 @@ const menuRef = ref()
|
||||
|
||||
// 顶部模式鼠标滚动
|
||||
function handlerMouserScroll(event: WheelEvent) {
|
||||
menuRef.value.scrollBy({
|
||||
left: (event.deltaY || event.detail) > 0 ? 50 : -50,
|
||||
})
|
||||
if (event.deltaY || event.detail !== 0) {
|
||||
menuRef.value.scrollBy({
|
||||
left: (event.deltaY || event.detail) > 0 ? 50 : -50,
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Transition name="header">
|
||||
<header v-if="settingsStore.mode === 'pc' && settingsStore.settings.menu.menuMode === 'head'">
|
||||
<header v-if="settingsStore.mode === 'pc' && settingsStore.settings.menu.mode === 'head'">
|
||||
<div class="header-container">
|
||||
<div class="main">
|
||||
<Logo class="title" />
|
||||
<div ref="menuRef" class="menu-container" @wheel.prevent="handlerMouserScroll">
|
||||
<!-- 顶部模式 -->
|
||||
<div class="menu flex of-hidden transition-all">
|
||||
<template v-for="(item, index) in menuStore.allMenus" :key="index">
|
||||
<Logo class="title" />
|
||||
<div ref="menuRef" class="menu-container" @wheel.prevent="handlerMouserScroll">
|
||||
<!-- 顶部模式 -->
|
||||
<div class="menu h-full flex of-hidden transition-all">
|
||||
<template v-for="(item, index) in menuStore.allMenus" :key="index">
|
||||
<div
|
||||
class="menu-item relative mx-1 py-2 transition-all" :class="{
|
||||
active: index === menuStore.actived,
|
||||
}"
|
||||
>
|
||||
<div
|
||||
class="menu-item relative transition-all" :class="{
|
||||
active: index === menuStore.actived,
|
||||
}"
|
||||
v-if="item.children && item.children.length !== 0" class="group menu-item-container h-full w-full flex cursor-pointer items-center justify-between gap-1 px-3 text-[var(--g-header-menu-color)] transition-all hover-(bg-[var(--g-header-menu-hover-bg)] text-[var(--g-header-menu-hover-color)])" :class="{
|
||||
'text-[var(--g-header-menu-active-color)]! bg-[var(--g-header-menu-active-bg)]!': index === menuStore.actived,
|
||||
}" :title="typeof item.meta?.title === 'function' ? item.meta?.title() : item.meta?.title" @click="switchTo(index)"
|
||||
>
|
||||
<div
|
||||
v-if="item.children && item.children.length !== 0" class="group menu-item-container h-full w-full flex cursor-pointer items-center justify-between gap-1 px-3 text-[var(--g-header-menu-color)] transition-all hover:(bg-[var(--g-header-menu-hover-bg)] text-[var(--g-header-menu-hover-color)])" :class="{
|
||||
'text-[var(--g-header-menu-active-color)]! bg-[var(--g-header-menu-active-bg)]!': index === menuStore.actived,
|
||||
}" :title="typeof item.meta?.title === 'function' ? item.meta?.title() : item.meta?.title" @click="switchTo(index)"
|
||||
>
|
||||
<div class="inline-flex flex-1 items-center justify-center gap-1">
|
||||
<SvgIcon v-if="item.meta?.icon" :name="item.meta?.icon" :size="20" class="menu-item-container-icon transition-transform group-hover:scale-120" async />
|
||||
<span class="w-full flex-1 truncate text-sm transition-height transition-opacity transition-width">
|
||||
{{ typeof item.meta?.title === 'function' ? item.meta?.title() : item.meta?.title }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="inline-flex flex-1 items-center justify-center gap-1">
|
||||
<SvgIcon v-if="item.meta?.icon" :name="item.meta?.icon" class="menu-item-container-icon transition-transform group-hover-scale-120" />
|
||||
<span class="w-full flex-1 truncate text-sm transition-height transition-opacity transition-width">
|
||||
{{ typeof item.meta?.title === 'function' ? item.meta?.title() : item.meta?.title }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<ToolbarRightSide />
|
||||
@@ -81,74 +81,71 @@ header {
|
||||
|
||||
.header-container {
|
||||
display: flex;
|
||||
gap: 30px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0 auto;
|
||||
|
||||
.main {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
:deep(a.title) {
|
||||
position: relative;
|
||||
flex: 0;
|
||||
width: inherit;
|
||||
height: inherit;
|
||||
padding: inherit;
|
||||
background-color: inherit;
|
||||
|
||||
:deep(a.title) {
|
||||
position: relative;
|
||||
width: inherit;
|
||||
height: inherit;
|
||||
padding: inherit;
|
||||
background-color: inherit;
|
||||
|
||||
.logo {
|
||||
width: initial;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 20px;
|
||||
color: var(--g-header-color);
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-container {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
padding: 0 20px;
|
||||
margin: 0 30px;
|
||||
overflow-x: auto;
|
||||
mask-image: linear-gradient(to right, transparent, #000 20px, #000 calc(100% - 20px), transparent);
|
||||
|
||||
// firefox隐藏滚动条
|
||||
scrollbar-width: none;
|
||||
|
||||
// chrome隐藏滚动条
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.menu {
|
||||
display: inline-flex;
|
||||
height: 100%;
|
||||
|
||||
:deep(.menu-item) {
|
||||
.menu-item-container {
|
||||
color: var(--g-header-menu-color);
|
||||
|
||||
&:hover {
|
||||
color: var(--g-header-menu-hover-color);
|
||||
background-color: var(--g-header-menu-hover-bg);
|
||||
}
|
||||
.logo {
|
||||
width: initial;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
&.active .menu-item-container {
|
||||
color: var(--g-header-menu-active-color);
|
||||
background-color: var(--g-header-menu-active-bg);
|
||||
span {
|
||||
font-size: 20px;
|
||||
color: var(--g-header-color);
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-container {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
padding: 0 20px;
|
||||
overflow-x: auto;
|
||||
mask-image: linear-gradient(to right, transparent, #000 20px, #000 calc(100% - 20px), transparent);
|
||||
|
||||
// firefox隐藏滚动条
|
||||
scrollbar-width: none;
|
||||
|
||||
// chrome隐藏滚动条
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.menu {
|
||||
display: inline-flex;
|
||||
height: 100%;
|
||||
|
||||
:deep(.menu-item) {
|
||||
.menu-item-container {
|
||||
color: var(--g-header-menu-color);
|
||||
|
||||
&:hover {
|
||||
color: var(--g-header-menu-hover-color);
|
||||
background-color: var(--g-header-menu-hover-bg);
|
||||
}
|
||||
|
||||
.menu-item-container-icon {
|
||||
font-size: 20px !important;
|
||||
}
|
||||
}
|
||||
|
||||
&.active .menu-item-container {
|
||||
color: var(--g-header-menu-active-color);
|
||||
background-color: var(--g-header-menu-active-bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ onMounted(() => {
|
||||
<template>
|
||||
<HDialog v-model="isShow" title="快捷键介绍">
|
||||
<div class="px-4">
|
||||
<div class="grid gap-2 md:grid-cols-2">
|
||||
<div class="grid gap-2 sm-grid-cols-2">
|
||||
<div>
|
||||
<h2 class="m-0 text-lg font-bold">
|
||||
全局
|
||||
@@ -38,7 +38,7 @@ onMounted(() => {
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-if="settingsStore.settings.menu.enableHotkeys && ['side', 'head'].includes(settingsStore.settings.menu.menuMode)">
|
||||
<div v-if="settingsStore.settings.menu.enableHotkeys && ['side', 'head'].includes(settingsStore.settings.menu.mode)">
|
||||
<h2 class="m-0 text-lg font-bold">
|
||||
主导航
|
||||
</h2>
|
||||
|
||||
@@ -15,30 +15,32 @@ const { switchTo } = useMenu()
|
||||
|
||||
<template>
|
||||
<Transition name="main-sidebar">
|
||||
<div v-if="settingsStore.settings.menu.menuMode === 'side' || (settingsStore.mode === 'mobile' && settingsStore.settings.menu.menuMode !== 'single')" class="main-sidebar-container">
|
||||
<div v-if="settingsStore.settings.menu.mode === 'side' || (settingsStore.mode === 'mobile' && settingsStore.settings.menu.mode !== 'single')" class="main-sidebar-container">
|
||||
<Logo :show-title="false" class="sidebar-logo" />
|
||||
<!-- 侧边栏模式(含主导航) -->
|
||||
<div class="menu flex flex-col of-hidden transition-all">
|
||||
<template v-for="(item, index) in menuStore.allMenus" :key="index">
|
||||
<div
|
||||
class="menu-item relative transition-all" :class="{
|
||||
active: index === menuStore.actived,
|
||||
}"
|
||||
>
|
||||
<div class="menu">
|
||||
<!-- 侧边栏模式(含主导航) -->
|
||||
<div class="w-full flex flex-col of-hidden py-1 transition-all -mt-2">
|
||||
<template v-for="(item, index) in menuStore.allMenus" :key="index">
|
||||
<div
|
||||
v-if="item.children && item.children.length !== 0" class="group menu-item-container h-full w-full flex cursor-pointer items-center justify-between gap-1 py-4 text-[var(--g-main-sidebar-menu-color)] transition-all hover:(bg-[var(--g-main-sidebar-menu-hover-bg)] text-[var(--g-main-sidebar-menu-hover-color)]) px-2!" :class="{
|
||||
'text-[var(--g-main-sidebar-menu-active-color)]! bg-[var(--g-main-sidebar-menu-active-bg)]!': index === menuStore.actived,
|
||||
}" :title="typeof item.meta?.title === 'function' ? item.meta?.title() : item.meta?.title" @click="switchTo(index)"
|
||||
class="menu-item relative px-2 py-1 transition-all" :class="{
|
||||
active: index === menuStore.actived,
|
||||
}"
|
||||
>
|
||||
<div class="w-full inline-flex flex-1 flex-col items-center justify-center gap-[2px]">
|
||||
<SvgIcon v-if="item.meta?.icon" :name="item.meta?.icon" :size="20" class="menu-item-container-icon transition-transform group-hover:scale-120" async />
|
||||
<span class="w-full flex-1 truncate text-center text-sm transition-height transition-opacity transition-width">
|
||||
{{ typeof item.meta?.title === 'function' ? item.meta?.title() : item.meta?.title }}
|
||||
</span>
|
||||
<div
|
||||
v-if="item.children && item.children.length !== 0" class="group menu-item-container h-full w-full flex cursor-pointer items-center justify-between gap-1 py-4 text-[var(--g-main-sidebar-menu-color)] transition-all hover-(bg-[var(--g-main-sidebar-menu-hover-bg)] text-[var(--g-main-sidebar-menu-hover-color)]) px-2!" :class="{
|
||||
'text-[var(--g-main-sidebar-menu-active-color)]! bg-[var(--g-main-sidebar-menu-active-bg)]!': index === menuStore.actived,
|
||||
}" :title="typeof item.meta?.title === 'function' ? item.meta?.title() : item.meta?.title" @click="switchTo(index)"
|
||||
>
|
||||
<div class="w-full inline-flex flex-1 flex-col items-center justify-center gap-[2px]">
|
||||
<SvgIcon v-if="item.meta?.icon" :name="item.meta?.icon" class="menu-item-container-icon transition-transform group-hover-scale-120" />
|
||||
<span class="w-full flex-1 truncate text-center text-sm transition-height transition-opacity transition-width">
|
||||
{{ typeof item.meta?.title === 'function' ? item.meta?.title() : item.meta?.title }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
@@ -86,7 +88,7 @@ const { switchTo } = useMenu()
|
||||
}
|
||||
|
||||
.menu-item-container-icon {
|
||||
font-size: 24px !important;
|
||||
font-size: 20px !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,16 +162,16 @@ provide(rootMenuInjectionKey, reactive({
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-col of-hidden transition-all" :class="{
|
||||
'w-[200px]': !isMenuPopup && props.mode === 'vertical',
|
||||
'w-[64px]': isMenuPopup && props.mode === 'vertical',
|
||||
'h-[80px]': props.mode === 'horizontal',
|
||||
'flex-row! w-auto': isMenuPopup && props.mode === 'horizontal',
|
||||
class="h-full w-full flex flex-col of-hidden transition-all" :class="{
|
||||
'flex-row! w-auto!': isMenuPopup && props.mode === 'horizontal',
|
||||
'py-1': props.mode === 'vertical',
|
||||
}"
|
||||
>
|
||||
<template v-for="(item, index) in menu" :key="index">
|
||||
<SubMenu v-if="item.children?.length" :menu="item" :unique-key="[item.path ?? JSON.stringify(item)]" />
|
||||
<Item v-else :item="item" :unique-key="[item.path ?? JSON.stringify(item)]" @click="handleMenuItemClick(item.path ?? JSON.stringify(item))" />
|
||||
<template v-for="item in menu" :key="item.path ?? JSON.stringify(item)">
|
||||
<template v-if="item.meta?.menu !== false">
|
||||
<SubMenu v-if="item.children?.length" :menu="item" :unique-key="[item.path ?? JSON.stringify(item)]" />
|
||||
<Item v-else :item="item" :unique-key="[item.path ?? JSON.stringify(item)]" @click="handleMenuItemClick(item.path ?? JSON.stringify(item))" />
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
import type { SubMenuItemProps } from './types'
|
||||
import { rootMenuInjectionKey } from './types'
|
||||
|
||||
defineOptions({
|
||||
name: 'SubMenuItem',
|
||||
})
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<SubMenuItemProps>(),
|
||||
{
|
||||
@@ -40,7 +44,9 @@ defineExpose({
|
||||
<template>
|
||||
<div
|
||||
ref="itemRef" class="menu-item relative transition-all" :class="{
|
||||
active: isItemActive,
|
||||
'active': isItemActive,
|
||||
'py-1 px-2': (rootMenu.isMenuPopup && rootMenu.props.mode === 'vertical') || (rootMenu.isMenuPopup && level !== 0 && rootMenu.props.mode === 'horizontal') || !rootMenu.isMenuPopup,
|
||||
'px-1 py-2': rootMenu.isMenuPopup && level === 0 && rootMenu.props.mode === 'horizontal',
|
||||
}"
|
||||
>
|
||||
<router-link v-slot="{ href, navigate }" custom :to="uniqueKey.at(-1) ?? ''">
|
||||
@@ -52,7 +58,7 @@ defineExpose({
|
||||
target: item.meta?.link ? '_blank' : '_self',
|
||||
class: 'no-underline',
|
||||
}),
|
||||
}" class="group menu-item-container h-full w-full flex cursor-pointer items-center justify-between gap-1 px-5 py-4 text-[var(--g-sub-sidebar-menu-color)] transition-all hover:(bg-[var(--g-sub-sidebar-menu-hover-bg)] text-[var(--g-sub-sidebar-menu-hover-color)])" :class="{
|
||||
}" class="group menu-item-container h-full w-full flex cursor-pointer items-center justify-between gap-1 px-4 py-3 text-[var(--g-sub-sidebar-menu-color)] transition-all hover-(bg-[var(--g-sub-sidebar-menu-hover-bg)] text-[var(--g-sub-sidebar-menu-hover-color)])" :class="{
|
||||
'text-[var(--g-sub-sidebar-menu-active-color)]! bg-[var(--g-sub-sidebar-menu-active-bg)]!': isItemActive,
|
||||
'px-3!': rootMenu.isMenuPopup && level === 0,
|
||||
}" :title="typeof item.meta?.title === 'function' ? item.meta?.title() : item.meta?.title" v-on="{
|
||||
@@ -68,7 +74,7 @@ defineExpose({
|
||||
'w-full': rootMenu.isMenuPopup && level === 0 && rootMenu.props.showCollapseName && rootMenu.props.mode === 'vertical',
|
||||
}" :style="indentStyle"
|
||||
>
|
||||
<SvgIcon v-if="props.item.meta?.icon" :name="props.item.meta.icon" :size="20" class="menu-item-container-icon transition-transform group-hover:scale-120" async />
|
||||
<SvgIcon v-if="props.item.meta?.icon" :name="props.item.meta.icon" :size="18" class="menu-item-container-icon transition-transform group-hover-scale-120" />
|
||||
<span
|
||||
v-if="!(rootMenu.isMenuPopup && level === 0 && !rootMenu.props.showCollapseName)" class="w-0 flex-1 truncate text-sm transition-height transition-opacity transition-width"
|
||||
:class="{
|
||||
|
||||
@@ -96,7 +96,7 @@ const transitionClass = computed(() => {
|
||||
const hasChildren = computed(() => {
|
||||
let flag = true
|
||||
if (props.menu.children) {
|
||||
if (props.menu.children.every((item: any) => item.meta?.sidebar === false)) {
|
||||
if (props.menu.children.every((item: any) => item.meta?.menu === false)) {
|
||||
flag = false
|
||||
}
|
||||
}
|
||||
@@ -147,6 +147,9 @@ function handleMouseenter() {
|
||||
subMenuRef.value!.getElement()!.style.height = `${window.innerHeight - top}px`
|
||||
}
|
||||
}
|
||||
if (left + subMenuRef.value!.getElement()!.offsetWidth > document.documentElement.clientWidth) {
|
||||
left = el.getBoundingClientRect().left - el.getBoundingClientRect().width
|
||||
}
|
||||
subMenuRef.value!.getElement()!.style.top = `${top}px`
|
||||
subMenuRef.value!.getElement()!.style.left = `${left}px`
|
||||
})
|
||||
@@ -184,12 +187,13 @@ function handleMouseleave() {
|
||||
<OverlayScrollbarsComponent
|
||||
v-if="opened" ref="subMenuRef" :options="{ scrollbars: { visibility: 'hidden' } }" defer class="sub-menu" :class="{
|
||||
'bg-[var(--g-sub-sidebar-bg)]': rootMenu.isMenuPopup,
|
||||
'ring-1 ring-stone-2 dark:ring-stone-8 shadow-xl fixed z-3000 w-[200px]': rootMenu.isMenuPopup,
|
||||
'mx-2': rootMenu.isMenuPopup && (rootMenu.props.mode === 'vertical' || level !== 0),
|
||||
'ring-1 ring-stone-2 dark-ring-stone-8 shadow-xl fixed z-3000 w-[200px]': rootMenu.isMenuPopup,
|
||||
'mx-1': rootMenu.isMenuPopup && (rootMenu.props.mode === 'vertical' || level !== 0),
|
||||
'py-1': rootMenu.isMenuPopup,
|
||||
}"
|
||||
>
|
||||
<template v-for="item in menu.children" :key="item.path ?? JSON.stringify(item)">
|
||||
<SubMenu v-if="item.meta?.sidebar !== false" :unique-key="[...uniqueKey, item.path ?? JSON.stringify(item)]" :menu="item" :level="level + 1" />
|
||||
<SubMenu v-if="item.meta?.menu !== false" :unique-key="[...uniqueKey, item.path ?? JSON.stringify(item)]" :menu="item" :level="level + 1" />
|
||||
</template>
|
||||
</OverlayScrollbarsComponent>
|
||||
</Transition>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createInjectionKey } from '@/utils/injectionKeys'
|
||||
import type { Menu } from '#/global'
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -31,7 +30,7 @@ export interface MenuInjection {
|
||||
handleSubMenuClick: (index: string, indexPath: string[]) => void
|
||||
}
|
||||
|
||||
export const rootMenuInjectionKey = createInjectionKey<MenuInjection>('rootMenu')
|
||||
export const rootMenuInjectionKey = Symbol('rootMenu') as InjectionKey<MenuInjection>
|
||||
|
||||
export interface SubMenuProps {
|
||||
uniqueKey: string[]
|
||||
|
||||
@@ -4,13 +4,11 @@ import type { OverlayScrollbarsComponentRef } from 'overlayscrollbars-vue'
|
||||
import { OverlayScrollbarsComponent } from 'overlayscrollbars-vue'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import hotkeys from 'hotkeys-js'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import Breadcrumb from '../Breadcrumb/index.vue'
|
||||
import BreadcrumbItem from '../Breadcrumb/item.vue'
|
||||
import { resolveRoutePath } from '@/utils'
|
||||
import eventBus from '@/utils/eventBus'
|
||||
import useSettingsStore from '@/store/modules/settings'
|
||||
import useRouteStore from '@/store/modules/route'
|
||||
import useMenuStore from '@/store/modules/menu'
|
||||
import type { Menu } from '@/types/global'
|
||||
|
||||
@@ -30,17 +28,16 @@ const overlayTransitionClass = ref({
|
||||
const transitionClass = computed(() => {
|
||||
return {
|
||||
enter: 'ease-out duration-300',
|
||||
enterFrom: 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95',
|
||||
enterTo: 'opacity-100 translate-y-0 sm:scale-100',
|
||||
enterFrom: 'opacity-0 translate-y-4 lg-translate-y-0 lg-scale-95',
|
||||
enterTo: 'opacity-100 translate-y-0 lg-scale-100',
|
||||
leave: 'ease-in duration-200',
|
||||
leaveFrom: 'opacity-100 translate-y-0 sm:scale-100',
|
||||
leaveTo: 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95',
|
||||
leaveFrom: 'opacity-100 translate-y-0 lg-scale-100',
|
||||
leaveTo: 'opacity-0 translate-y-4 lg-translate-y-0 lg-scale-95',
|
||||
}
|
||||
})
|
||||
|
||||
const router = useRouter()
|
||||
const settingsStore = useSettingsStore()
|
||||
const routeStore = useRouteStore()
|
||||
const menuStore = useMenuStore()
|
||||
|
||||
interface listTypes {
|
||||
@@ -149,34 +146,27 @@ onMounted(() => {
|
||||
|
||||
function initSourceList() {
|
||||
sourceList.value = []
|
||||
if (settingsStore.settings.app.routeBaseOn !== 'filesystem') {
|
||||
routeStore.routes.forEach((item) => {
|
||||
item.children && getSourceList(item.children as RouteRecordRaw[])
|
||||
})
|
||||
}
|
||||
else {
|
||||
menuStore.menus.forEach((item) => {
|
||||
getSourceListByMenus(item.children)
|
||||
})
|
||||
}
|
||||
menuStore.allMenus.forEach((item) => {
|
||||
getSourceListByMenus(item.children)
|
||||
})
|
||||
}
|
||||
|
||||
function hasChildren(item: RouteRecordRaw) {
|
||||
function hasChildren(item: Menu.recordRaw) {
|
||||
let flag = true
|
||||
if (item.children?.every(i => i.meta?.sidebar === false)) {
|
||||
if (item.children?.every(i => i.meta?.menu === false)) {
|
||||
flag = false
|
||||
}
|
||||
return flag
|
||||
}
|
||||
function getSourceList(arr: RouteRecordRaw[], basePath?: string, icon?: string, breadcrumb?: { title?: string | (() => string) }[]) {
|
||||
function getSourceListByMenus(arr: Menu.recordRaw[], basePath?: string, icon?: string, breadcrumb?: { title?: string | (() => string) }[]) {
|
||||
arr.forEach((item) => {
|
||||
if (item.meta?.sidebar !== false) {
|
||||
if (item.meta?.menu !== false) {
|
||||
const breadcrumbTemp = cloneDeep(breadcrumb) || []
|
||||
if (item.children && hasChildren(item)) {
|
||||
breadcrumbTemp.push({
|
||||
title: item.meta?.title,
|
||||
})
|
||||
getSourceList(item.children, resolveRoutePath(basePath, item.path), item.meta?.icon ?? icon, breadcrumbTemp)
|
||||
getSourceListByMenus(item.children, resolveRoutePath(basePath, item.path), item.meta?.icon ?? icon, breadcrumbTemp)
|
||||
}
|
||||
else {
|
||||
breadcrumbTemp.push({
|
||||
@@ -193,28 +183,6 @@ function getSourceList(arr: RouteRecordRaw[], basePath?: string, icon?: string,
|
||||
}
|
||||
})
|
||||
}
|
||||
function getSourceListByMenus(arr: Menu.recordRaw[], icon?: string, breadcrumb?: { title?: string | (() => string) }[]) {
|
||||
arr.forEach((item) => {
|
||||
const breadcrumbTemp = cloneDeep(breadcrumb) || []
|
||||
if (item.children && item.children.length > 0) {
|
||||
breadcrumbTemp.push({
|
||||
title: item.meta?.title,
|
||||
})
|
||||
getSourceListByMenus(item.children, item.meta?.icon ?? icon, breadcrumbTemp)
|
||||
}
|
||||
else {
|
||||
breadcrumbTemp.push({
|
||||
title: item.meta?.title,
|
||||
})
|
||||
sourceList.value.push({
|
||||
icon: item.meta?.icon ?? icon,
|
||||
title: item.meta?.title,
|
||||
path: item.path as string,
|
||||
breadcrumb: breadcrumbTemp,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function keyUp() {
|
||||
if (resultList.value.length) {
|
||||
@@ -277,23 +245,23 @@ function pageJump(path: listTypes['path'], link: listTypes['link']) {
|
||||
<TransitionRoot as="template" :show="isShow">
|
||||
<Dialog :initial-focus="searchInputRef" class="fixed inset-0 z-2000 flex" @close="isShow && eventBus.emit('global-search-toggle')">
|
||||
<TransitionChild as="template" v-bind="overlayTransitionClass">
|
||||
<div class="fixed inset-0 bg-stone-200/75 backdrop-blur-sm transition-opacity dark:bg-stone-8/75" />
|
||||
<div class="fixed inset-0 bg-stone-200/75 backdrop-blur-sm transition-opacity dark-bg-stone-8/75" />
|
||||
</TransitionChild>
|
||||
<div class="fixed inset-0">
|
||||
<div class="h-full flex items-end justify-center p-4 text-center sm:items-center sm:p-0">
|
||||
<div class="h-full flex items-end justify-center p-4 text-center lg-items-center">
|
||||
<TransitionChild as="template" v-bind="transitionClass">
|
||||
<DialogPanel class="relative h-full max-h-4/5 w-full flex flex-col text-left sm:max-w-2xl">
|
||||
<div class="flex flex-col overflow-y-auto rounded-xl bg-white shadow-xl dark:bg-stone-8">
|
||||
<div class="flex items-center px-4 py-3" border-b="~ solid stone-2 dark:stone-7">
|
||||
<DialogPanel class="relative h-full max-h-4/5 w-full flex flex-col text-left lg-max-w-2xl">
|
||||
<div class="flex flex-col overflow-y-auto rounded-xl bg-white shadow-xl dark-bg-stone-8">
|
||||
<div class="flex items-center px-4 py-3" border-b="~ solid stone-2 dark-stone-7">
|
||||
<SvgIcon name="i-ep:search" :size="18" class="text-stone-5" />
|
||||
<input ref="searchInputRef" v-model="searchInput" placeholder="搜索页面,支持标题、URL模糊查询" class="w-full border-0 rounded-md bg-transparent px-3 text-base text-dark dark:text-white focus:outline-none placeholder-stone-4 dark:placeholder-stone-5" @keydown.esc="eventBus.emit('global-search-toggle')" @keydown.up.prevent="keyUp" @keydown.down.prevent="keyDown" @keydown.enter.prevent="keyEnter">
|
||||
<input ref="searchInputRef" v-model="searchInput" placeholder="搜索页面,支持标题、URL模糊查询" class="w-full border-0 rounded-md bg-transparent px-3 text-base text-dark dark-text-white focus-outline-none placeholder-stone-4 dark-placeholder-stone-5" @keydown.esc="eventBus.emit('global-search-toggle')" @keydown.up.prevent="keyUp" @keydown.down.prevent="keyDown" @keydown.enter.prevent="keyEnter">
|
||||
</div>
|
||||
<DialogDescription class="relative m-0 of-y-hidden">
|
||||
<OverlayScrollbarsComponent ref="searchResultRef" :options="{ scrollbars: { autoHide: 'leave', autoHideDelay: 300 } }" defer class="h-full">
|
||||
<template v-if="resultList.length > 0">
|
||||
<a v-for="(item, index) in resultList" ref="searchResultItemRef" :key="item.path" class="flex cursor-pointer items-center" :class="{ 'bg-stone-2/40 dark:bg-stone-7/40': index === actived }" :data-index="index" @click="pageJump(item.path, item.link)" @mouseover="actived = index">
|
||||
<a v-for="(item, index) in resultList" ref="searchResultItemRef" :key="item.path" class="flex cursor-pointer items-center" :class="{ 'bg-stone-2/40 dark-bg-stone-7/40': index === actived }" :data-index="index" @click="pageJump(item.path, item.link)" @mouseover="actived = index">
|
||||
<SvgIcon v-if="item.icon" :name="item.icon" :size="20" class="basis-16 transition" :class="{ 'scale-120 text-ui-primary': index === actived }" />
|
||||
<div class="flex flex-1 flex-col gap-1 truncate px-4 py-3" border-l="~ solid stone-2 dark:stone-7">
|
||||
<div class="flex flex-1 flex-col gap-1 truncate px-4 py-3" border-l="~ solid stone-2 dark-stone-7">
|
||||
<div class="truncate text-base font-bold">{{ (typeof item.title === 'function' ? item.title() : item.title) ?? '[ 无标题 ]' }}</div>
|
||||
<Breadcrumb v-if="item.breadcrumb.length" class="truncate">
|
||||
<BreadcrumbItem v-for="(bc, bcIndex) in item.breadcrumb" :key="bcIndex" class="text-xs">
|
||||
@@ -313,7 +281,7 @@ function pageJump(path: listTypes['path'], link: listTypes['link']) {
|
||||
</template>
|
||||
</OverlayScrollbarsComponent>
|
||||
</DialogDescription>
|
||||
<div v-if="settingsStore.mode === 'pc'" class="flex justify-between px-4 py-3" border-t="~ solid stone-2 dark:stone-7">
|
||||
<div v-if="settingsStore.mode === 'pc'" class="flex justify-between px-4 py-3" border-t="~ solid stone-2 dark-stone-7">
|
||||
<div class="flex gap-8">
|
||||
<div class="inline-flex items-center gap-1 text-xs">
|
||||
<HKbd>
|
||||
|
||||
@@ -25,30 +25,48 @@ function onSidebarScroll() {
|
||||
showShadowBottom.value = Math.ceil(scrollTop + clientHeight) < scrollHeight
|
||||
}
|
||||
|
||||
const enableSidebar = computed(() => {
|
||||
return settingsStore.mode === 'mobile' || (
|
||||
menuStore.sidebarMenus.length !== 0
|
||||
&& !menuStore.sidebarMenus.every(item => item.meta?.menu === false)
|
||||
)
|
||||
})
|
||||
|
||||
watch(enableSidebar, (val) => {
|
||||
if (val) {
|
||||
nextTick(() => {
|
||||
onSidebarScroll()
|
||||
})
|
||||
}
|
||||
}, {
|
||||
immediate: true,
|
||||
})
|
||||
|
||||
const menuRef = ref()
|
||||
|
||||
onMounted(() => {
|
||||
onSidebarScroll()
|
||||
const { height } = useElementSize(menuRef)
|
||||
watch(() => height.value, () => {
|
||||
if (height.value > 0) {
|
||||
onSidebarScroll()
|
||||
}
|
||||
}, {
|
||||
immediate: true,
|
||||
})
|
||||
if (enableSidebar.value) {
|
||||
const { height } = useElementSize(menuRef)
|
||||
watch(() => height.value, () => {
|
||||
if (height.value > 0) {
|
||||
onSidebarScroll()
|
||||
}
|
||||
}, {
|
||||
immediate: true,
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="sub-sidebar-container" :class="{
|
||||
v-if="enableSidebar" class="sub-sidebar-container" :class="{
|
||||
'is-collapse': settingsStore.mode === 'pc' && settingsStore.settings.menu.subMenuCollapse,
|
||||
}"
|
||||
>
|
||||
<Logo
|
||||
:show-logo="settingsStore.settings.menu.menuMode === 'single'" class="sidebar-logo" :class="{
|
||||
'sidebar-logo-bg': settingsStore.settings.menu.menuMode === 'single',
|
||||
:show-logo="settingsStore.settings.menu.mode === 'single'" class="sidebar-logo" :class="{
|
||||
'sidebar-logo-bg': settingsStore.settings.menu.mode === 'single',
|
||||
}"
|
||||
/>
|
||||
<div
|
||||
@@ -61,14 +79,18 @@ onMounted(() => {
|
||||
<TransitionGroup name="sub-sidebar">
|
||||
<template v-for="(mainItem, mainIndex) in menuStore.allMenus" :key="mainIndex">
|
||||
<div v-show="mainIndex === menuStore.actived">
|
||||
<Menu :menu="mainItem.children" :value="route.meta.activeMenu || route.path" :default-openeds="menuStore.defaultOpenedPaths" :accordion="settingsStore.settings.menu.subMenuUniqueOpened" :collapse="settingsStore.mode === 'pc' && settingsStore.settings.menu.subMenuCollapse" class="menu" />
|
||||
<Menu
|
||||
:menu="mainItem.children" :value="route.meta.activeMenu || route.path" :default-openeds="menuStore.defaultOpenedPaths" :accordion="settingsStore.settings.menu.subMenuUniqueOpened" :collapse="settingsStore.mode === 'pc' && settingsStore.settings.menu.subMenuCollapse" class="menu" :class="{
|
||||
'-mt-2': !['head', 'single'].includes(settingsStore.settings.menu.mode),
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</TransitionGroup>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="settingsStore.mode === 'pc'" class="relative flex items-center px-4 py-3" :class="[settingsStore.settings.menu.subMenuCollapse ? 'justify-center' : 'justify-end']">
|
||||
<span v-show="settingsStore.settings.menu.enableSubMenuCollapseButton" class="flex-center cursor-pointer rounded bg-stone-1 p-2 transition dark:bg-stone-9 hover:bg-stone-2 dark:hover:bg-stone-8" :class="{ '-rotate-z-180': settingsStore.settings.menu.subMenuCollapse }" @click="settingsStore.toggleSidebarCollapse()">
|
||||
<span v-show="settingsStore.settings.menu.enableSubMenuCollapseButton" class="flex-center cursor-pointer rounded bg-stone-1 p-2 transition dark-bg-stone-9 hover-bg-stone-2 dark-hover-bg-stone-8" :class="{ '-rotate-z-180': settingsStore.settings.menu.subMenuCollapse }" @click="settingsStore.toggleSidebarCollapse()">
|
||||
<SvgIcon name="toolbar-collapse" />
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -58,11 +58,9 @@ function tabbarScrollTip() {
|
||||
}
|
||||
}
|
||||
function handlerMouserScroll(event: WheelEvent) {
|
||||
if (event.deltaY || event.detail !== 0) {
|
||||
tabsRef.value.scrollBy({
|
||||
left: (event.deltaY || event.detail) > 0 ? 50 : -50,
|
||||
})
|
||||
}
|
||||
tabsRef.value.scrollBy({
|
||||
left: event.deltaY || event.detail,
|
||||
})
|
||||
}
|
||||
function scrollTo(offsetLeft: number) {
|
||||
tabsRef.value.scrollTo({
|
||||
@@ -75,9 +73,9 @@ function onTabbarContextmenu(event: MouseEvent, routeItem: Tabbar.recordRaw) {
|
||||
ContextMenu.showContextMenu({
|
||||
x: event.x,
|
||||
y: event.y,
|
||||
zIndex: 1000,
|
||||
zIndex: 1050,
|
||||
iconFontClass: '',
|
||||
customClass: 'contextmenu-custom',
|
||||
customClass: 'tabbar-contextmenu',
|
||||
items: [
|
||||
{
|
||||
label: '重新加载',
|
||||
@@ -166,7 +164,7 @@ onMounted(() => {
|
||||
})
|
||||
})
|
||||
onUnmounted(() => {
|
||||
hotkeys.unbind('alt+q,alt+e,alt+w,alt+1,alt+2,alt+3,alt+4,alt+5,alt+6,alt+7,alt+8,alt+9,alt+0')
|
||||
hotkeys.unbind('alt+left,alt+right,alt+w,alt+1,alt+2,alt+3,alt+4,alt+5,alt+6,alt+7,alt+8,alt+9,alt+0')
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -187,8 +185,8 @@ onUnmounted(() => {
|
||||
<SvgIcon v-if="settingsStore.settings.tabbar.enableIcon && element.icon" :name="element.icon" class="icon" />
|
||||
{{ typeof element?.title === 'function' ? element.title() : element.title }}
|
||||
</div>
|
||||
<div v-if="tabbarStore.list.length > 1" class="action-icon">
|
||||
<SvgIcon name="i-ri:close-fill" @click.stop="tabbar.closeById(element.tabId)" />
|
||||
<div v-if="tabbarStore.list.length > 1" class="action-icon" @click.stop="tabbar.closeById(element.tabId)">
|
||||
<SvgIcon name="i-ri:close-fill" />
|
||||
</div>
|
||||
<div v-show="keys.alt && index < 9" class="hotkey-number">
|
||||
{{ index + 1 }}
|
||||
@@ -201,11 +199,11 @@ onUnmounted(() => {
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.mx-menu-ghost-host {
|
||||
.tabbar-contextmenu {
|
||||
z-index: 1000;
|
||||
|
||||
.mx-context-menu {
|
||||
--at-apply: fixed ring-1 ring-stone-2 dark:ring-stone-7 shadow-2xl;
|
||||
--at-apply: fixed ring-1 ring-stone-2 dark-ring-stone-7 shadow-2xl;
|
||||
|
||||
background-color: var(--g-container-bg);
|
||||
|
||||
@@ -213,7 +211,7 @@ onUnmounted(() => {
|
||||
--at-apply: transition-background-color;
|
||||
|
||||
&:not(.disabled):hover {
|
||||
--at-apply: cursor-pointer bg-stone-1 dark:bg-stone-9;
|
||||
--at-apply: cursor-pointer bg-stone-1 dark-bg-stone-9;
|
||||
}
|
||||
|
||||
span {
|
||||
@@ -221,8 +219,6 @@ onUnmounted(() => {
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 1em;
|
||||
margin-right: 10px;
|
||||
color: initial;
|
||||
}
|
||||
|
||||
@@ -236,7 +232,7 @@ onUnmounted(() => {
|
||||
background-color: var(--g-container-bg);
|
||||
|
||||
&::after {
|
||||
--at-apply: bg-stone-2 dark:bg-stone-7;
|
||||
--at-apply: bg-stone-2 dark-bg-stone-7;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -414,14 +410,14 @@ onUnmounted(() => {
|
||||
transform: translateY(-50%);
|
||||
|
||||
&:hover {
|
||||
--at-apply: ring-1 ring-stone-3 dark:ring-stone-7;
|
||||
--at-apply: ring-1 ring-stone-3 dark-ring-stone-7;
|
||||
|
||||
background-color: var(--g-bg);
|
||||
}
|
||||
}
|
||||
|
||||
.hotkey-number {
|
||||
--at-apply: ring-1 ring-stone-3 dark:ring-stone-7;
|
||||
--at-apply: ring-1 ring-stone-3 dark-ring-stone-7;
|
||||
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
|
||||
@@ -40,7 +40,7 @@ function toggleColorScheme(event: MouseEvent) {
|
||||
<HDropdown class="flex-center cursor-pointer px-2 py-1">
|
||||
<SvgIcon
|
||||
:name="{
|
||||
'': 'i-ri:computer-line',
|
||||
'': 'i-codicon:color-mode',
|
||||
'light': 'i-ri:sun-line',
|
||||
'dark': 'i-ri:moon-line',
|
||||
}[settingsStore.settings.app.colorScheme]" @click="toggleColorScheme"
|
||||
@@ -51,7 +51,7 @@ function toggleColorScheme(event: MouseEvent) {
|
||||
:options="[
|
||||
{ icon: 'i-ri:sun-line', label: '', value: 'light' },
|
||||
{ icon: 'i-ri:moon-line', label: '', value: 'dark' },
|
||||
{ icon: 'i-ri:computer-line', label: '', value: '' },
|
||||
{ icon: 'i-codicon:color-mode', label: '', value: '' },
|
||||
]"
|
||||
class="m-3"
|
||||
/>
|
||||
|
||||
@@ -12,9 +12,9 @@ const settingsStore = useSettingsStore()
|
||||
<template>
|
||||
<span class="flex-center cursor-pointer px-2 py-1" @click="eventBus.emit('global-search-toggle')">
|
||||
<SvgIcon v-if="settingsStore.mode === 'mobile'" name="i-ri:search-line" />
|
||||
<span v-else class="group inline-flex cursor-pointer items-center gap-1 whitespace-nowrap rounded-2 bg-stone-1 px-2 py-1.5 text-dark ring-stone-3 ring-inset transition dark:bg-stone-9 dark:text-white hover:ring-1 dark:ring-stone-7">
|
||||
<span v-else class="group inline-flex cursor-pointer items-center gap-1 whitespace-nowrap rounded-2 bg-stone-1 px-2 py-1.5 text-dark ring-stone-3 ring-inset transition dark-bg-stone-9 dark-text-white hover-ring-1 dark-ring-stone-7">
|
||||
<SvgIcon name="i-ri:search-line" />
|
||||
<span class="text-sm text-stone-5 transition group-hover:text-dark dark:group-hover:text-white">搜索</span>
|
||||
<span class="text-sm text-stone-5 transition group-hover-text-dark dark-group-hover-text-white">搜索</span>
|
||||
<HKbd v-if="settingsStore.settings.navSearch.enableHotkeys" class="ml-2">{{ settingsStore.os === 'mac' ? '⌥' : 'Alt' }} S</HKbd>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
@@ -15,7 +15,7 @@ const settingsStore = useSettingsStore()
|
||||
<div class="h-full flex items-center of-hidden pl-2 pr-16" style="mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 50px), transparent);">
|
||||
<LeftSide />
|
||||
</div>
|
||||
<div v-show="['side', 'single'].includes(settingsStore.settings.menu.menuMode)" class="h-full flex items-center px-2">
|
||||
<div v-show="['side', 'single'].includes(settingsStore.settings.menu.mode)" class="h-full flex items-center px-2">
|
||||
<RightSide />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -34,12 +34,13 @@ watch(() => userStore.avatar, () => {
|
||||
:items="[
|
||||
[
|
||||
{ label: settingsStore.settings.home.title, handle: () => router.push({ path: settingsStore.settings.home.fullPath }), hide: !settingsStore.settings.home.enable },
|
||||
{ label: '个人设置', handle: () => router.push({ name: 'personalSetting' }) },
|
||||
],
|
||||
[
|
||||
{ label: '快捷键介绍', handle: () => eventBus.emit('global-hotkeys-intro-toggle'), hide: settingsStore.mode !== 'pc' },
|
||||
],
|
||||
[
|
||||
{ label: '退出登录', handle: () => userStore.logout() },
|
||||
{ label: '退出登录', handle: () => userStore.logout(settingsStore.settings.home.fullPath) },
|
||||
],
|
||||
]" class="flex-center cursor-pointer px-2"
|
||||
>
|
||||
|
||||
@@ -11,7 +11,7 @@ const settingsStore = useSettingsStore()
|
||||
|
||||
const enableToolbar = computed(() => {
|
||||
return !(
|
||||
settingsStore.settings.menu.menuMode === 'head' && (
|
||||
settingsStore.settings.menu.mode === 'head' && (
|
||||
!settingsStore.settings.toolbar.breadcrumb || settingsStore.settings.app.routeBaseOn === 'filesystem'
|
||||
)
|
||||
)
|
||||
|
||||
@@ -26,7 +26,7 @@ function open() {
|
||||
<PageMain :key="route.meta.link" class="flex flex-1 flex-col justify-center">
|
||||
<div class="flex flex-col items-center">
|
||||
<SvgIcon name="i-icon-park-twotone:planet" :size="120" class="text-ui-primary/80" />
|
||||
<div class="my-2 text-xl text-dark dark:text-white">
|
||||
<div class="my-2 text-xl text-dark dark-text-white">
|
||||
是否访问此链接
|
||||
</div>
|
||||
<div class="my-2 max-w-[300px] cursor-pointer text-center text-[14px] text-stone-5" @click="route.meta.link && copy(route.meta.link)">
|
||||
|
||||
@@ -240,7 +240,7 @@ header:not(.header-leave-active) + .wrapper {
|
||||
}
|
||||
|
||||
.app-setting {
|
||||
--at-apply: text-white dark:text-dark bg-ui-primary;
|
||||
--at-apply: text-white dark-text-dark bg-ui-primary;
|
||||
|
||||
position: fixed;
|
||||
top: calc(50% + 250px);
|
||||
|
||||
@@ -13,11 +13,11 @@ const props = withDefaults(
|
||||
)
|
||||
|
||||
const buttonClass = computed(() => [
|
||||
'focus:outline-none focus-visible:outline-0 cursor-pointer disabled:cursor-not-allowed disabled:opacity-75 flex-shrink-0 gap-x-1.5 px-2.5 py-1.5 border-size-0 font-medium text-sm rounded-md select-none',
|
||||
'focus-outline-none focus-visible-outline-0 cursor-pointer disabled-cursor-not-allowed disabled-opacity-75 flex-shrink-0 gap-x-1.5 px-2.5 py-1.5 border-size-0 font-medium text-sm rounded-md select-none',
|
||||
props.block ? 'w-full flex justify-center items-center' : 'inline-flex items-center',
|
||||
props.outline
|
||||
? 'shadow-sm ring-1 ring-inset ring-ui-primary text-ui-primary bg-white dark:bg-dark hover:not-disabled:bg-ui-primary/10 dark:hover:not-disabled:bg-ui-primary/10 focus-visible:ring-2'
|
||||
: 'shadow-sm text-ui-text bg-ui-primary hover:bg-ui-primary/75 disabled:bg-ui-primary/90 focus-visible:ring-inset focus-visible:ring-2',
|
||||
? 'shadow-sm ring-1 ring-inset ring-ui-primary text-ui-primary bg-white dark-bg-dark hover-not-disabled-bg-ui-primary/10 dark-hover-not-disabled-bg-ui-primary/10 focus-visible-ring-2'
|
||||
: 'shadow-sm text-ui-text bg-ui-primary hover-bg-ui-primary/75 disabled-bg-ui-primary/90 focus-visible-ring-inset focus-visible-ring-2',
|
||||
])
|
||||
</script>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ withDefaults(
|
||||
)
|
||||
|
||||
const emits = defineEmits<{
|
||||
'change': [string | number | undefined]
|
||||
change: [string | number | undefined]
|
||||
}>()
|
||||
|
||||
const value = defineModel<string | number>()
|
||||
@@ -26,8 +26,8 @@ watch(value, (val) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="inline-flex select-none items-center justify-center of-hidden rounded-md bg-stone-3 dark:bg-stone-7">
|
||||
<button v-for="option in options" :key="option.value" :disabled="disabled || option.disabled" class="flex cursor-pointer items-center truncate border-size-0 bg-inherit px-2 py-1.5 text-sm disabled:cursor-not-allowed disabled:opacity-50 hover:not-disabled:(bg-ui-primary text-ui-text)" :class="{ 'text-ui-text bg-ui-primary': value === option.value }" @click="value = option.value">
|
||||
<div class="inline-flex select-none items-center justify-center of-hidden rounded-md bg-stone-3 dark-bg-stone-7">
|
||||
<button v-for="option in options" :key="option.value" :disabled="disabled || option.disabled" class="flex cursor-pointer items-center truncate border-size-0 bg-inherit px-2 py-1.5 text-sm disabled-cursor-not-allowed disabled-opacity-50 hover-not-disabled-(bg-ui-primary text-ui-text)" :class="{ 'text-ui-text bg-ui-primary': value === option.value }" @click="value = option.value">
|
||||
<SvgIcon v-if="option.icon" :name="option.icon" />
|
||||
<template v-else>
|
||||
{{ option.label }}
|
||||
|
||||
@@ -16,7 +16,7 @@ withDefaults(
|
||||
)
|
||||
|
||||
const emits = defineEmits<{
|
||||
'close': []
|
||||
close: []
|
||||
}>()
|
||||
|
||||
const isOpen = defineModel<boolean>({
|
||||
@@ -37,11 +37,11 @@ const overlayTransitionClass = ref({
|
||||
const transitionClass = computed(() => {
|
||||
return {
|
||||
enter: 'ease-out duration-300',
|
||||
enterFrom: 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95',
|
||||
enterTo: 'opacity-100 translate-y-0 sm:scale-100',
|
||||
enterFrom: 'opacity-0 translate-y-4 lg-translate-y-0 lg-scale-95',
|
||||
enterTo: 'opacity-100 translate-y-0 lg-scale-100',
|
||||
leave: 'ease-in duration-200',
|
||||
leaveFrom: 'opacity-100 translate-y-0 sm:scale-100',
|
||||
leaveTo: 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95',
|
||||
leaveFrom: 'opacity-100 translate-y-0 lg-scale-100',
|
||||
leaveTo: 'opacity-0 translate-y-4 lg-translate-y-0 lg-scale-95',
|
||||
}
|
||||
})
|
||||
|
||||
@@ -55,14 +55,14 @@ function close() {
|
||||
<TransitionRoot as="template" :appear="appear" :show="isOpen">
|
||||
<Dialog class="fixed inset-0 z-2000 flex" @close="!preventClose && close()">
|
||||
<TransitionChild as="template" :appear="appear" v-bind="overlayTransitionClass">
|
||||
<div class="fixed inset-0 bg-stone-2/75 transition-opacity dark:bg-stone-8/75" :class="{ 'backdrop-blur-sm': overlay }" />
|
||||
<div class="fixed inset-0 bg-stone-2/75 transition-opacity dark-bg-stone-8/75" :class="{ 'backdrop-blur-sm': overlay }" />
|
||||
</TransitionChild>
|
||||
<div class="fixed inset-0 overflow-y-auto">
|
||||
<div class="min-h-full flex items-end justify-center p-4 text-center sm:items-center sm:p-0">
|
||||
<div class="min-h-full flex items-end justify-center p-4 text-center lg-items-center">
|
||||
<TransitionChild as="template" :appear="appear" v-bind="transitionClass">
|
||||
<DialogPanel class="relative w-full flex flex-col overflow-hidden rounded-xl bg-white text-left shadow-xl sm:my-8 sm:max-w-lg dark:bg-stone-8">
|
||||
<DialogPanel class="relative w-full flex flex-col overflow-hidden rounded-xl bg-white text-left shadow-xl lg-my-8 lg-max-w-lg dark-bg-stone-8">
|
||||
<div flex="~ items-center justify-between" px-4 py-3 border-b="~ solid stone/15" text-6>
|
||||
<DialogTitle m-0 text-lg text-dark dark:text-white>
|
||||
<DialogTitle m-0 text-lg text-dark dark-text-white>
|
||||
{{ title }}
|
||||
</DialogTitle>
|
||||
<SvgIcon name="i-carbon:close" cursor-pointer @click="close" />
|
||||
|
||||
@@ -19,8 +19,8 @@ const myItems = computed(() => {
|
||||
<VMenu :show-triggers="['hover']" :auto-hide="false" :popper-triggers="['hover', 'click']" :delay="200" v-bind="$attrs">
|
||||
<slot />
|
||||
<template #popper>
|
||||
<div v-for="(item, index) in myItems" :key="index" class="p-1" border-b="~ solid stone-2 dark:stone-7 last:size-0">
|
||||
<button v-for="(v, i) in item" :key="i" :disabled="v.disabled" class="w-full flex cursor-pointer items-center gap-2 border-size-0 rounded-md bg-inherit px-2 py-1.5 text-sm text-dark disabled:cursor-not-allowed dark:text-white disabled:opacity-50 hover:not-disabled:bg-stone-1 dark:hover:not-disabled:bg-stone-9" @click="v.handle">
|
||||
<div v-for="(item, index) in myItems" :key="index" class="b-b-(1 stone-2 solid) p-1 dark-b-b-(1 stone-7) last-b-b-size-0">
|
||||
<button v-for="(v, i) in item" :key="i" :disabled="v.disabled" class="w-full flex cursor-pointer items-center gap-2 border-size-0 rounded-md bg-inherit px-2 py-1.5 text-sm text-dark disabled-cursor-not-allowed dark-text-white disabled-opacity-50 hover-not-disabled-bg-stone-1 dark-hover-not-disabled-bg-stone-9" @click="v.handle">
|
||||
{{ v.label }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -19,7 +19,7 @@ defineExpose({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative w-full lg:w-48">
|
||||
<input v-model="value" type="text" :placeholder="placeholder" :disabled="disabled" class="relative block w-full border-0 rounded-md bg-white px-2.5 py-1.5 text-sm shadow-sm ring-1 ring-stone-2 ring-inset disabled:cursor-not-allowed dark:bg-dark disabled:opacity-50 focus:outline-none focus:ring-2 dark:ring-stone-8 focus:ring-ui-primary placeholder-stone-4 dark:placeholder-stone-5">
|
||||
<div class="relative w-full lg-w-48">
|
||||
<input v-model="value" type="text" :placeholder="placeholder" :disabled="disabled" class="relative block w-full border-0 rounded-md bg-white px-2.5 py-1.5 text-sm shadow-sm ring-1 ring-stone-2 ring-inset disabled-cursor-not-allowed dark-bg-dark disabled-opacity-50 focus-outline-none focus-ring-2 dark-ring-stone-8 focus-ring-ui-primary placeholder-stone-4 dark-placeholder-stone-5">
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<kbd class="mr-[4px] h-6 min-w-[24px] inline-flex items-center justify-center rounded bg-stone-1 px-1 text-[12px] text-dark font-medium font-sans ring-1 ring-stone-3 ring-inset last:mr-0 dark:bg-dark-9 dark:text-white dark:ring-stone-7">
|
||||
<kbd class="mr-[4px] h-6 min-w-[24px] inline-flex items-center justify-center rounded bg-stone-1 px-1 text-[12px] text-dark font-medium font-sans ring-1 ring-stone-3 ring-inset last:mr-0 dark-bg-dark-9 dark-text-white dark-ring-stone-7">
|
||||
<slot />
|
||||
</kbd>
|
||||
</template>
|
||||
|
||||
@@ -28,7 +28,7 @@ const selected = computed({
|
||||
<template>
|
||||
<VMenu :triggers="['click']" :popper-triggers="['click']" :delay="0" :disabled="disabled" v-bind="$attrs">
|
||||
<div class="w-full inline-flex">
|
||||
<button class="relative block w-full flex cursor-default items-center gap-x-2 border-0 rounded-md bg-white px-2.5 py-1.5 pe-9 text-left text-sm shadow-sm ring-1 ring-stone-2 ring-inset lg:w-48 disabled:cursor-not-allowed dark:bg-dark focus:outline-none focus:ring-2 dark:ring-stone-8 focus:ring-ui-primary" :disabled="disabled">
|
||||
<button class="relative block w-full flex cursor-default items-center gap-x-2 border-0 rounded-md bg-white px-2.5 py-1.5 pe-9 text-left text-sm shadow-sm ring-1 ring-stone-2 ring-inset lg-w-48 disabled-cursor-not-allowed dark-bg-dark focus-outline-none focus-ring-2 dark-ring-stone-8 focus-ring-ui-primary" :disabled="disabled">
|
||||
<span class="block truncate">
|
||||
{{ selected.label }}
|
||||
</span>
|
||||
@@ -38,8 +38,8 @@ const selected = computed({
|
||||
</button>
|
||||
</div>
|
||||
<template #popper>
|
||||
<div class="max-h-60 w-full scroll-py-1 overflow-y-auto p-1 lg:w-48 focus:outline-none">
|
||||
<button v-for="option in options" :key="option.value" :disabled="option.disabled" class="w-full cursor-pointer truncate border-size-0 rounded-md bg-inherit px-2 py-1.5 text-left text-sm disabled:cursor-not-allowed hover:not-disabled:bg-stone-1 dark:hover:not-disabled:bg-stone-9" :class="{ 'font-bold': modelValue === option.value }" @click="selected = option">
|
||||
<div class="max-h-60 w-full scroll-py-1 overflow-y-auto p-1 lg-w-48 focus-outline-none">
|
||||
<button v-for="option in options" :key="option.value" :disabled="option.disabled" class="w-full cursor-pointer truncate border-size-0 rounded-md bg-inherit px-2 py-1.5 text-left text-sm disabled-cursor-not-allowed hover-not-disabled-bg-stone-1 dark-hover-not-disabled-bg-stone-9" :class="{ 'font-bold': modelValue === option.value }" @click="selected = option">
|
||||
{{ option.label }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -19,7 +19,7 @@ const props = withDefaults(
|
||||
)
|
||||
|
||||
const emits = defineEmits<{
|
||||
'close': []
|
||||
close: []
|
||||
}>()
|
||||
|
||||
const isOpen = defineModel<boolean>({
|
||||
@@ -58,12 +58,12 @@ function close() {
|
||||
<TransitionRoot as="template" :appear="appear" :show="isOpen">
|
||||
<Dialog class="fixed inset-0 z-2000 flex" :class="{ 'justify-end': side === 'right' }" @close="!preventClose && close()">
|
||||
<TransitionChild as="template" :appear="appear" v-bind="overlayTransitionClass">
|
||||
<div class="fixed inset-0 bg-stone-2/75 transition-opacity dark:bg-stone-8/75" :class="{ 'backdrop-blur-sm': overlay }" />
|
||||
<div class="fixed inset-0 bg-stone-2/75 transition-opacity dark-bg-stone-8/75" :class="{ 'backdrop-blur-sm': overlay }" />
|
||||
</TransitionChild>
|
||||
<TransitionChild as="template" :appear="appear" v-bind="transitionClass">
|
||||
<DialogPanel relative max-w-md w-full w-screen flex flex-1 flex-col bg-white dark:bg-stone-8 focus:outline-none>
|
||||
<DialogPanel relative max-w-md w-full w-screen flex flex-1 flex-col bg-white dark-bg-stone-8 focus-outline-none>
|
||||
<div flex="~ items-center justify-between" p-4 border-b="~ solid stone/15" text-6>
|
||||
<DialogTitle m-0 text-lg text-dark dark:text-white>
|
||||
<DialogTitle m-0 text-lg text-dark dark-text-white>
|
||||
{{ title }}
|
||||
</DialogTitle>
|
||||
<SvgIcon name="i-carbon:close" cursor-pointer @click="close" />
|
||||
|
||||
@@ -10,7 +10,7 @@ const props = defineProps<{
|
||||
}>()
|
||||
|
||||
const emits = defineEmits<{
|
||||
'change': [T]
|
||||
change: [T]
|
||||
}>()
|
||||
|
||||
const value = defineModel<T>()
|
||||
@@ -35,12 +35,12 @@ function handleChange(index: number) {
|
||||
|
||||
<template>
|
||||
<TabGroup :selected-index="selectedIndex" @change="handleChange">
|
||||
<TabList class="inline-flex select-none items-center justify-center rounded-md bg-stone-1 p-1 ring-1 ring-stone-2 dark:bg-stone-9 dark:ring-stone-8">
|
||||
<TabList class="inline-flex select-none items-center justify-center rounded-md bg-stone-1 p-1 ring-1 ring-stone-2 dark-bg-stone-9 dark-ring-stone-8">
|
||||
<Tab v-for="(option, index) in options" :key="index" v-slot="{ selected }" as="template">
|
||||
<button
|
||||
class="w-full inline-flex items-center justify-center gap-1 break-keep border-size-0 rounded-md bg-inherit px-2 py-1.5 text-sm text-dark ring-stone-2 ring-inset dark:text-white focus:outline-none focus:ring-2 dark:ring-stone-8" :class="{
|
||||
'cursor-default bg-white dark:bg-dark-9': selected,
|
||||
'cursor-pointer opacity-50 hover:(opacity-100)': !selected,
|
||||
class="w-full inline-flex items-center justify-center gap-1 break-keep border-size-0 rounded-md bg-inherit px-2 py-1.5 text-sm text-dark ring-stone-2 ring-inset dark-text-white focus-outline-none focus-ring-2 dark-ring-stone-8" :class="{
|
||||
'cursor-default bg-white dark-bg-dark-9': selected,
|
||||
'cursor-pointer opacity-50 hover-(opacity-100)': !selected,
|
||||
}"
|
||||
>
|
||||
<SvgIcon v-if="option.icon" :name="option.icon" class="flex-shrink-0" />
|
||||
|
||||
@@ -16,10 +16,10 @@ const enabled = defineModel<boolean>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Switch v-model="enabled" :disabled="disabled" class="relative h-5 w-10 inline-flex flex-shrink-0 cursor-pointer border-2 border-transparent rounded-full p-0 vertical-middle disabled:cursor-not-allowed disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:focus-visible:ring-offset-gray-900" :class="[enabled ? 'bg-ui-primary' : 'bg-stone-3 dark:bg-stone-7']">
|
||||
<span class="pointer-events-none relative inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out dark:bg-dark" :class="[enabled ? 'translate-x-5' : 'translate-x-0']">
|
||||
<Switch v-model="enabled" :disabled="disabled" class="relative h-5 w-10 inline-flex flex-shrink-0 cursor-pointer border-2 border-transparent rounded-full p-0 vertical-middle disabled-cursor-not-allowed disabled-opacity-50 focus-outline-none focus-visible-ring-2 focus-visible-ring-offset-2 focus-visible-ring-offset-white dark-focus-visible-ring-offset-gray-900" :class="[enabled ? 'bg-ui-primary' : 'bg-stone-3 dark-bg-stone-7']">
|
||||
<span class="pointer-events-none relative inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out dark-bg-dark" :class="[enabled ? 'translate-x-5' : 'translate-x-0']">
|
||||
<span class="absolute inset-0 h-full w-full flex items-center justify-center">
|
||||
<SvgIcon v-if="(enabled && onIcon) || (!enabled && offIcon)" :name="(enabled ? onIcon : offIcon) as string" class="h-3 w-3 text-stone-7 dark:text-stone-3" />
|
||||
<SvgIcon v-if="(enabled && onIcon) || (!enabled && offIcon)" :name="(enabled ? onIcon : offIcon) as string" class="h-3 w-3 text-stone-7 dark-text-stone-3" />
|
||||
</span>
|
||||
</span>
|
||||
</Switch>
|
||||
|
||||
+9
-6
@@ -30,7 +30,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
// 是否已根据权限动态生成并注册路由
|
||||
if (routeStore.isGenerate) {
|
||||
// 导航栏如果不是 single 模式,则需要根据 path 定位主导航的选中状态
|
||||
settingsStore.settings.menu.menuMode !== 'single' && menuStore.setActived(to.path)
|
||||
settingsStore.settings.menu.mode !== 'single' && menuStore.setActived(to.path)
|
||||
// 如果已登录状态下,进入登录页会强制跳转到主页
|
||||
if (to.name === 'login') {
|
||||
next({
|
||||
@@ -57,20 +57,22 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 获取用户权限
|
||||
settingsStore.settings.app.enablePermission && await userStore.getPermissions()
|
||||
// 生成动态路由
|
||||
switch (settingsStore.settings.app.routeBaseOn) {
|
||||
case 'frontend':
|
||||
await routeStore.generateRoutesAtFront(asyncRoutes)
|
||||
routeStore.generateRoutesAtFront(asyncRoutes)
|
||||
break
|
||||
case 'backend':
|
||||
await routeStore.generateRoutesAtBack()
|
||||
break
|
||||
case 'filesystem':
|
||||
await routeStore.generateRoutesAtFilesystem(asyncRoutesByFilesystem)
|
||||
routeStore.generateRoutesAtFilesystem(asyncRoutesByFilesystem)
|
||||
// 文件系统生成的路由,需要手动生成导航数据
|
||||
switch (settingsStore.settings.menu.baseOn) {
|
||||
case 'frontend':
|
||||
await menuStore.generateMenusAtFront()
|
||||
menuStore.generateMenusAtFront()
|
||||
break
|
||||
case 'backend':
|
||||
await menuStore.generateMenusAtBack()
|
||||
@@ -82,7 +84,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
// 记录的数据会在登出时会使用到,不使用 router.removeRoute 是考虑配置的路由可能不一定有设置 name ,则通过调用 router.addRoute() 返回的回调进行删除
|
||||
const removeRoutes: (() => void)[] = []
|
||||
routeStore.flatRoutes.forEach((route) => {
|
||||
if (!/^(https?:|mailto:|tel:)/.test(route.path)) {
|
||||
if (!/^(?:https?:|mailto:|tel:)/.test(route.path)) {
|
||||
removeRoutes.push(router.addRoute(route as RouteRecordRaw))
|
||||
}
|
||||
})
|
||||
@@ -136,7 +138,8 @@ router.afterEach((to, from) => {
|
||||
keepAliveStore.add(componentName)
|
||||
}
|
||||
else {
|
||||
console.warn('该页面组件未设置组件名,会导致缓存失效,请检查')
|
||||
// turbo-console-disable-next-line
|
||||
console.warn('[Fantastic-admin] 该页面组件未设置组件名,会导致缓存失效,请检查')
|
||||
}
|
||||
}
|
||||
// 判断离开页面是否开启缓存,如果开启,则根据缓存规则判断是否需要清空 keep-alive 全局状态里离开页面的 name 信息
|
||||
|
||||
@@ -5,6 +5,8 @@ import type { RecursiveRequired, Settings } from '#/global'
|
||||
const globalSettingsDefault: RecursiveRequired<Settings.all> = {
|
||||
app: {
|
||||
colorScheme: 'light',
|
||||
enableMournMode: false,
|
||||
enableColorAmblyopiaMode: false,
|
||||
enablePermission: false,
|
||||
enableProgress: true,
|
||||
enableDynamicTitle: false,
|
||||
@@ -20,7 +22,7 @@ const globalSettingsDefault: RecursiveRequired<Settings.all> = {
|
||||
},
|
||||
menu: {
|
||||
baseOn: 'frontend',
|
||||
menuMode: 'side',
|
||||
mode: 'side',
|
||||
switchMainMenuAndPageJump: false,
|
||||
subMenuUniqueOpened: true,
|
||||
subMenuCollapse: false,
|
||||
|
||||
+63
-53
@@ -1,11 +1,12 @@
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import useSettingsStore from './settings'
|
||||
import useUserStore from './user'
|
||||
import useRouteStore from './route'
|
||||
import { resolveRoutePath } from '@/utils'
|
||||
import apiApp from '@/api/modules/app'
|
||||
import menu from '@/menu'
|
||||
import type { Menu } from '#/global'
|
||||
import type { Menu, Route } from '#/global'
|
||||
|
||||
const useMenuStore = defineStore(
|
||||
// 唯一ID
|
||||
@@ -15,42 +16,71 @@ const useMenuStore = defineStore(
|
||||
const userStore = useUserStore()
|
||||
const routeStore = useRouteStore()
|
||||
|
||||
const menus = ref<Menu.recordMainRaw[]>([{
|
||||
meta: {},
|
||||
children: [],
|
||||
}])
|
||||
const filesystemMenusRaw = ref<Menu.recordMainRaw[]>([])
|
||||
const actived = ref(0)
|
||||
|
||||
// 将多级导航的每一级 path 都转换为完整路径
|
||||
function convertToFullPath(menu: any[], path: string = '') {
|
||||
return menu.map((item) => {
|
||||
item.path = resolveRoutePath(path, item.path)
|
||||
if (item.children) {
|
||||
item.children = convertToFullPath(item.children, item.path)
|
||||
// 将原始路由转换成导航菜单
|
||||
function convertRouteToMenu(routes: Route.recordMainRaw[]): Menu.recordMainRaw[] {
|
||||
const returnMenus: Menu.recordMainRaw[] = []
|
||||
routes.forEach((item) => {
|
||||
if (item.children.length > 0) {
|
||||
if (settingsStore.settings.menu.mode === 'single') {
|
||||
returnMenus.length === 0 && returnMenus.push({
|
||||
meta: {},
|
||||
children: [],
|
||||
})
|
||||
returnMenus[0].children.push(...convertRouteToMenuRecursive(item.children))
|
||||
}
|
||||
else {
|
||||
const menuItem: Menu.recordMainRaw = {
|
||||
meta: {
|
||||
title: item?.meta?.title,
|
||||
icon: item?.meta?.icon,
|
||||
auth: item?.meta?.auth,
|
||||
},
|
||||
children: [],
|
||||
}
|
||||
menuItem.children = convertRouteToMenuRecursive(item.children)
|
||||
returnMenus.push(menuItem)
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
return returnMenus
|
||||
}
|
||||
function convertRouteToMenuRecursive(routes: RouteRecordRaw[], basePath = ''): Menu.recordRaw[] {
|
||||
const returnMenus: Menu.recordRaw[] = []
|
||||
routes.forEach((item) => {
|
||||
const menuItem: Menu.recordRaw = {
|
||||
path: resolveRoutePath(basePath, item.path),
|
||||
meta: {
|
||||
title: item?.meta?.title,
|
||||
icon: item?.meta?.icon,
|
||||
defaultOpened: item?.meta?.defaultOpened,
|
||||
auth: item?.meta?.auth,
|
||||
menu: item?.meta?.menu,
|
||||
link: item?.meta?.link,
|
||||
},
|
||||
}
|
||||
if (item.children) {
|
||||
menuItem.children = convertRouteToMenuRecursive(item.children, menuItem.path)
|
||||
}
|
||||
returnMenus.push(menuItem)
|
||||
})
|
||||
return returnMenus
|
||||
}
|
||||
|
||||
// 完整导航数据
|
||||
const allMenus = computed(() => {
|
||||
let returnMenus: Menu.recordMainRaw[] = [{
|
||||
meta: {},
|
||||
children: [],
|
||||
}]
|
||||
let returnMenus: Menu.recordMainRaw[] = []
|
||||
if (settingsStore.settings.app.routeBaseOn !== 'filesystem') {
|
||||
if (settingsStore.settings.menu.menuMode === 'single') {
|
||||
returnMenus[0].children = []
|
||||
routeStore.routes.forEach((item) => {
|
||||
returnMenus[0].children?.push(...item.children as Menu.recordRaw[])
|
||||
})
|
||||
}
|
||||
else {
|
||||
returnMenus = routeStore.routes as Menu.recordMainRaw[]
|
||||
}
|
||||
returnMenus.map(item => convertToFullPath(item.children))
|
||||
returnMenus = convertRouteToMenu(routeStore.routesRaw)
|
||||
}
|
||||
else {
|
||||
returnMenus = menus.value
|
||||
returnMenus = filesystemMenusRaw.value
|
||||
}
|
||||
// 如果权限功能开启,则需要对导航数据进行筛选过滤
|
||||
if (settingsStore.settings.app.enablePermission) {
|
||||
returnMenus = filterAsyncMenus(returnMenus, userStore.permissions)
|
||||
}
|
||||
return returnMenus
|
||||
})
|
||||
@@ -71,7 +101,7 @@ const useMenuStore = defineStore(
|
||||
function getDeepestPath(menu: Menu.recordRaw, rootPath = '') {
|
||||
let retnPath = ''
|
||||
if (menu.children) {
|
||||
const item = menu.children.find(item => item.meta?.sidebar !== false)
|
||||
const item = menu.children.find(item => item.meta?.menu !== false)
|
||||
if (item) {
|
||||
retnPath = getDeepestPath(item, resolveRoutePath(rootPath, menu.path))
|
||||
}
|
||||
@@ -135,11 +165,12 @@ const useMenuStore = defineStore(
|
||||
menus.forEach((menu) => {
|
||||
if (hasPermission(permissions, menu)) {
|
||||
const tmpMenu = cloneDeep(menu)
|
||||
if (tmpMenu.children) {
|
||||
if (tmpMenu.children && tmpMenu.children.length > 0) {
|
||||
tmpMenu.children = filterAsyncMenus(tmpMenu.children, permissions) as Menu.recordRaw[]
|
||||
tmpMenu.children.length && res.push(tmpMenu)
|
||||
tmpMenu.children.length > 0 && res.push(tmpMenu)
|
||||
}
|
||||
else {
|
||||
delete tmpMenu.children
|
||||
res.push(tmpMenu)
|
||||
}
|
||||
}
|
||||
@@ -148,32 +179,12 @@ const useMenuStore = defineStore(
|
||||
}
|
||||
// 生成导航(前端生成)
|
||||
async function generateMenusAtFront() {
|
||||
let accessedMenus
|
||||
// 如果权限功能开启,则需要对导航数据进行筛选过滤
|
||||
if (settingsStore.settings.app.enablePermission) {
|
||||
const permissions = await userStore.getPermissions()
|
||||
accessedMenus = filterAsyncMenus(menu, permissions)
|
||||
}
|
||||
else {
|
||||
accessedMenus = cloneDeep(menu)
|
||||
}
|
||||
menus.value = accessedMenus.filter(item => item.children.length !== 0)
|
||||
filesystemMenusRaw.value = menu.filter(item => item.children.length !== 0)
|
||||
}
|
||||
// 生成导航(后端生成)
|
||||
async function generateMenusAtBack() {
|
||||
await apiApp.menuList().then(async (res) => {
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
let accessedMenus: Menu.recordMainRaw[]
|
||||
// 如果权限功能开启,则需要对导航数据进行筛选过滤
|
||||
if (settingsStore.settings.app.enablePermission) {
|
||||
const permissions = await userStore.getPermissions()
|
||||
accessedMenus = filterAsyncMenus(res.data, permissions)
|
||||
}
|
||||
else {
|
||||
accessedMenus = cloneDeep(res.data)
|
||||
}
|
||||
menus.value = accessedMenus.filter(item => item.children.length !== 0)
|
||||
filesystemMenusRaw.value = (res.data as Menu.recordMainRaw[]).filter(item => item.children.length !== 0)
|
||||
}).catch(() => {})
|
||||
}
|
||||
// 设置主导航
|
||||
@@ -192,7 +203,6 @@ const useMenuStore = defineStore(
|
||||
}
|
||||
|
||||
return {
|
||||
menus,
|
||||
actived,
|
||||
allMenus,
|
||||
sidebarMenus,
|
||||
|
||||
+35
-71
@@ -1,7 +1,6 @@
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import type { RouteMeta, RouteRecordRaw } from 'vue-router'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import useSettingsStore from './settings'
|
||||
import useUserStore from './user'
|
||||
import { resolveRoutePath } from '@/utils'
|
||||
import { systemRoutes } from '@/router/routes'
|
||||
import apiApp from '@/api/modules/app'
|
||||
@@ -12,7 +11,6 @@ const useRouteStore = defineStore(
|
||||
'route',
|
||||
() => {
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const isGenerate = ref(false)
|
||||
const routesRaw = ref<Route.recordMainRaw[]>([])
|
||||
@@ -27,16 +25,15 @@ const useRouteStore = defineStore(
|
||||
title: route.meta?.title,
|
||||
icon: route.meta?.icon,
|
||||
hide: !route.meta?.breadcrumb && route.meta?.breadcrumb === false,
|
||||
}], route.path, route.meta?.auth)
|
||||
}], route.path)
|
||||
}
|
||||
return route
|
||||
}
|
||||
function flatAsyncRoutesRecursive(routes: RouteRecordRaw[], breadcrumb: Route.breadcrumb[] = [], baseUrl = '', baseAuth: RouteMeta['auth']): RouteRecordRaw[] {
|
||||
function flatAsyncRoutesRecursive(routes: RouteRecordRaw[], breadcrumb: Route.breadcrumb[] = [], baseUrl = ''): RouteRecordRaw[] {
|
||||
const res: RouteRecordRaw[] = []
|
||||
routes.forEach((route) => {
|
||||
if (route.children) {
|
||||
const childrenBaseUrl = resolveRoutePath(baseUrl, route.path)
|
||||
const childrenBaseAuth = baseAuth ?? route.meta?.auth
|
||||
const tmpBreadcrumb = cloneDeep(breadcrumb)
|
||||
tmpBreadcrumb.push({
|
||||
path: childrenBaseUrl,
|
||||
@@ -49,11 +46,10 @@ const useRouteStore = defineStore(
|
||||
if (!tmpRoute.meta) {
|
||||
tmpRoute.meta = {}
|
||||
}
|
||||
tmpRoute.meta.auth = childrenBaseAuth
|
||||
tmpRoute.meta.breadcrumbNeste = tmpBreadcrumb
|
||||
delete tmpRoute.children
|
||||
res.push(tmpRoute)
|
||||
const childrenRoutes = flatAsyncRoutesRecursive(route.children, tmpBreadcrumb, childrenBaseUrl, childrenBaseAuth)
|
||||
const childrenRoutes = flatAsyncRoutesRecursive(route.children, tmpBreadcrumb, childrenBaseUrl)
|
||||
childrenRoutes.forEach((item) => {
|
||||
// 如果 path 一样则覆盖,因为子路由的 path 可能设置为空,导致和父路由一样,直接注册会提示路由重复
|
||||
if (res.some(v => v.path === item.path)) {
|
||||
@@ -82,7 +78,6 @@ const useRouteStore = defineStore(
|
||||
if (!tmpRoute.meta) {
|
||||
tmpRoute.meta = {}
|
||||
}
|
||||
tmpRoute.meta.auth = baseAuth ?? tmpRoute.meta?.auth
|
||||
tmpRoute.meta.breadcrumbNeste = tmpBreadcrumb
|
||||
res.push(tmpRoute)
|
||||
}
|
||||
@@ -119,63 +114,38 @@ const useRouteStore = defineStore(
|
||||
return routes
|
||||
})
|
||||
|
||||
// 判断是否有权限
|
||||
function hasPermission(permissions: string[], route: Route.recordMainRaw | RouteRecordRaw) {
|
||||
let isAuth = false
|
||||
if (route.meta?.auth) {
|
||||
isAuth = permissions.some((auth) => {
|
||||
if (typeof route.meta?.auth === 'string') {
|
||||
return route.meta.auth !== '' ? route.meta.auth === auth : true
|
||||
// TODO 将设置 meta.sidebar 的属性转换成 meta.menu ,过渡处理,未来将被弃用
|
||||
let isUsedDeprecatedAttribute = false
|
||||
function converDeprecatedAttribute<T extends Route.recordMainRaw[]>(routes: T): T {
|
||||
routes.forEach((route) => {
|
||||
route.children = converDeprecatedAttributeRecursive(route.children)
|
||||
})
|
||||
if (isUsedDeprecatedAttribute) {
|
||||
// turbo-console-disable-next-line
|
||||
console.warn('[Fantastic-admin] 路由配置中的 "sidebar" 属性即将被弃用, 请尽快替换为 "menu" 属性')
|
||||
}
|
||||
return routes
|
||||
}
|
||||
function converDeprecatedAttributeRecursive(routes: RouteRecordRaw[]) {
|
||||
if (routes) {
|
||||
routes.forEach((route) => {
|
||||
if (typeof route.meta?.sidebar === 'boolean') {
|
||||
isUsedDeprecatedAttribute = true
|
||||
route.meta.menu = route.meta.sidebar
|
||||
delete route.meta.sidebar
|
||||
}
|
||||
else if (typeof route.meta?.auth === 'object') {
|
||||
return route.meta.auth.length > 0 ? route.meta.auth.includes(auth) : true
|
||||
}
|
||||
else {
|
||||
return false
|
||||
if (route.children) {
|
||||
converDeprecatedAttributeRecursive(route.children)
|
||||
}
|
||||
})
|
||||
}
|
||||
else {
|
||||
isAuth = true
|
||||
}
|
||||
return isAuth
|
||||
return routes
|
||||
}
|
||||
// 根据权限过滤路由
|
||||
function filterAsyncRoutes<T extends Route.recordMainRaw[] | RouteRecordRaw[]>(routes: T, permissions: string[]): T {
|
||||
const res: any = []
|
||||
routes.forEach((route) => {
|
||||
if (hasPermission(permissions, route)) {
|
||||
const tmpRoute = cloneDeep(route)
|
||||
if (tmpRoute.children) {
|
||||
tmpRoute.children = filterAsyncRoutes(tmpRoute.children, permissions)
|
||||
tmpRoute.children.length && res.push(tmpRoute)
|
||||
}
|
||||
else {
|
||||
res.push(tmpRoute)
|
||||
}
|
||||
}
|
||||
})
|
||||
return res
|
||||
}
|
||||
const routes = computed(() => {
|
||||
let returnRoutes: Route.recordMainRaw[]
|
||||
// 如果权限功能开启,则需要对路由数据进行筛选过滤
|
||||
if (settingsStore.settings.app.enablePermission) {
|
||||
returnRoutes = filterAsyncRoutes(routesRaw.value as any, userStore.permissions)
|
||||
}
|
||||
else {
|
||||
returnRoutes = cloneDeep(routesRaw.value) as any
|
||||
}
|
||||
return returnRoutes
|
||||
})
|
||||
|
||||
// 根据权限动态生成路由(前端生成)
|
||||
async function generateRoutesAtFront(asyncRoutes: Route.recordMainRaw[]) {
|
||||
// 生成路由(前端生成)
|
||||
function generateRoutesAtFront(asyncRoutes: Route.recordMainRaw[]) {
|
||||
// 设置 routes 数据
|
||||
routesRaw.value = cloneDeep(asyncRoutes) as any
|
||||
if (settingsStore.settings.app.enablePermission) {
|
||||
await userStore.getPermissions()
|
||||
}
|
||||
routesRaw.value = converDeprecatedAttribute(cloneDeep(asyncRoutes) as any)
|
||||
isGenerate.value = true
|
||||
}
|
||||
// 格式化后端路由数据
|
||||
@@ -199,24 +169,18 @@ const useRouteStore = defineStore(
|
||||
return route
|
||||
})
|
||||
}
|
||||
// 根据权限动态生成路由(后端获取)
|
||||
// 生成路由(后端获取)
|
||||
async function generateRoutesAtBack() {
|
||||
await apiApp.routeList().then(async (res) => {
|
||||
await apiApp.routeList().then((res) => {
|
||||
// 设置 routes 数据
|
||||
routesRaw.value = formatBackRoutes(res.data) as any
|
||||
if (settingsStore.settings.app.enablePermission) {
|
||||
await userStore.getPermissions()
|
||||
}
|
||||
routesRaw.value = converDeprecatedAttribute(formatBackRoutes(res.data) as any)
|
||||
isGenerate.value = true
|
||||
}).catch(() => {})
|
||||
}
|
||||
// 根据权限动态生成路由(文件系统生成)
|
||||
async function generateRoutesAtFilesystem(asyncRoutes: RouteRecordRaw[]) {
|
||||
// 生成路由(文件系统生成)
|
||||
function generateRoutesAtFilesystem(asyncRoutes: RouteRecordRaw[]) {
|
||||
// 设置 routes 数据
|
||||
filesystemRoutesRaw.value = cloneDeep(asyncRoutes) as any
|
||||
if (settingsStore.settings.app.enablePermission) {
|
||||
await userStore.getPermissions()
|
||||
}
|
||||
isGenerate.value = true
|
||||
}
|
||||
// 记录 accessRoutes 路由,用于登出时删除路由
|
||||
@@ -236,7 +200,7 @@ const useRouteStore = defineStore(
|
||||
|
||||
return {
|
||||
isGenerate,
|
||||
routes,
|
||||
routesRaw,
|
||||
currentRemoveRoutes,
|
||||
flatRoutes,
|
||||
flatSystemRoutes,
|
||||
|
||||
@@ -39,8 +39,25 @@ const useSettingsStore = defineStore(
|
||||
break
|
||||
}
|
||||
}
|
||||
watch([
|
||||
() => settings.value.app.enableMournMode,
|
||||
() => settings.value.app.enableColorAmblyopiaMode,
|
||||
], (val) => {
|
||||
document.documentElement.style.removeProperty('filter')
|
||||
if (val[0] && val[1]) {
|
||||
document.documentElement.style.setProperty('filter', 'grayscale(100%) invert(80%)')
|
||||
}
|
||||
else if (val[0]) {
|
||||
document.documentElement.style.setProperty('filter', 'grayscale(100%)')
|
||||
}
|
||||
else if (val[1]) {
|
||||
document.documentElement.style.setProperty('filter', 'invert(80%)')
|
||||
}
|
||||
}, {
|
||||
immediate: true,
|
||||
})
|
||||
|
||||
watch(() => settings.value.menu.menuMode, (val) => {
|
||||
watch(() => settings.value.menu.mode, (val) => {
|
||||
document.body.setAttribute('data-menu-mode', val)
|
||||
}, {
|
||||
immediate: true,
|
||||
@@ -79,7 +96,7 @@ const useSettingsStore = defineStore(
|
||||
}
|
||||
else {
|
||||
// 如果是桌面设备,则根据页面宽度判断是否需要切换为移动端展示
|
||||
mode.value = width < 992 ? 'mobile' : 'pc'
|
||||
mode.value = width < 1024 ? 'mobile' : 'pc'
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -50,7 +50,7 @@ const useUserStore = defineStore(
|
||||
router.push({
|
||||
name: 'login',
|
||||
query: {
|
||||
...(router.currentRoute.value.path !== settingsStore.settings.home.fullPath && router.currentRoute.value.name !== 'login' && { redirect }),
|
||||
...(redirect !== settingsStore.settings.home.fullPath && router.currentRoute.value.name !== 'login' && { redirect }),
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -58,7 +58,6 @@ const useUserStore = defineStore(
|
||||
async function getPermissions() {
|
||||
const res = await apiUser.permission()
|
||||
permissions.value = res.data.permissions
|
||||
return permissions.value
|
||||
}
|
||||
// 修改密码
|
||||
async function editPassword(data: {
|
||||
|
||||
Vendored
+1
-1
@@ -1,10 +1,10 @@
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
// @ts-nocheck
|
||||
// Generated by unplugin-vue-components
|
||||
// Read more: https://github.com/vuejs/core/pull/3399
|
||||
export {}
|
||||
|
||||
/* prettier-ignore */
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
Auth: typeof import('./../components/Auth/index.vue')['default']
|
||||
|
||||
Vendored
+15
-4
@@ -1,4 +1,4 @@
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import type { RouteRecordName, RouteRecordRaw } from 'vue-router'
|
||||
|
||||
type RecursiveRequired<T> = {
|
||||
[P in keyof T]-?: RecursiveRequired<T[P]>
|
||||
@@ -16,6 +16,16 @@ declare namespace Settings {
|
||||
* @可选值 `'dark'` 暗黑模式
|
||||
*/
|
||||
colorScheme?: '' | 'light' | 'dark'
|
||||
/**
|
||||
* 是否开启哀悼模式
|
||||
* @默认值 `false`
|
||||
*/
|
||||
enableMournMode?: boolean
|
||||
/**
|
||||
* 是否开启色弱模式
|
||||
* @默认值 `false`
|
||||
*/
|
||||
enableColorAmblyopiaMode?: boolean
|
||||
/**
|
||||
* 是否开启权限功能
|
||||
* @默认值 `false`
|
||||
@@ -76,7 +86,7 @@ declare namespace Settings {
|
||||
* @可选值 `'head'` 顶部模式
|
||||
* @可选值 `'single'` 侧边栏模式(无主导航)
|
||||
*/
|
||||
menuMode?: 'side' | 'head' | 'single'
|
||||
mode?: 'side' | 'head' | 'single'
|
||||
/**
|
||||
* 切换主导航是否跳转页面
|
||||
* @默认值 `false`
|
||||
@@ -228,6 +238,7 @@ declare module 'vue-router' {
|
||||
defaultOpened?: boolean
|
||||
auth?: string | string[]
|
||||
sidebar?: boolean
|
||||
menu?: boolean
|
||||
breadcrumb?: boolean
|
||||
activeMenu?: string
|
||||
cache?: boolean | string | string[]
|
||||
@@ -263,7 +274,7 @@ declare namespace Menu {
|
||||
icon?: string
|
||||
defaultOpened?: boolean
|
||||
auth?: string | string[]
|
||||
sidebar?: boolean
|
||||
menu?: boolean
|
||||
link?: string
|
||||
}
|
||||
children?: recordRaw[]
|
||||
@@ -283,7 +294,7 @@ declare namespace Tabbar {
|
||||
interface recordRaw {
|
||||
tabId: string
|
||||
fullPath: string
|
||||
routeName?: RouteRecordRaw.name
|
||||
routeName?: RouteRecordName | null
|
||||
title?: string | (() => string)
|
||||
icon?: string
|
||||
name: string[]
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import type { InjectionKey } from 'vue'
|
||||
|
||||
export function createInjectionKey<T>(key: string): InjectionKey<T> {
|
||||
return key as any
|
||||
}
|
||||
|
||||
export const rootMenuInjectionKey = createInjectionKey<any>('rootMenu')
|
||||
@@ -5,7 +5,7 @@ if (import.meta.env.PROD) {
|
||||
const copyright_main_style = `${copyright_common_style} background: #e24329;`
|
||||
const copyright_sub_style = `${copyright_common_style} background: #707070;`
|
||||
if ((navigator.language).toLowerCase() === 'zh-cn') {
|
||||
console.info('%c由%cFantastic-admin%c驱动', copyright_sub_style, copyright_main_style, copyright_sub_style, '\nhttps://fantastic-admin.gitee.io')
|
||||
console.info('%c由%cFantastic-admin%c驱动', copyright_sub_style, copyright_main_style, copyright_sub_style, '\nhttps://fantastic-admin.github.io')
|
||||
}
|
||||
else {
|
||||
console.info('%cPowered by%cFantastic-admin', copyright_sub_style, copyright_main_style, '\nhttps://fantastic-admin.github.io')
|
||||
|
||||
@@ -38,13 +38,13 @@ function goBack() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="absolute left-[50%] top-[50%] flex flex-col items-center justify-between lg:flex-row -translate-x-50% -translate-y-50% lg:gap-12">
|
||||
<SvgIcon name="404" class="text-[300px] lg:text-[400px]" />
|
||||
<div class="absolute left-[50%] top-[50%] flex flex-col items-center justify-between lg-flex-row -translate-x-50% -translate-y-50% lg-gap-12">
|
||||
<SvgIcon name="404" class="text-[300px] lg-text-[400px]" />
|
||||
<div class="flex flex-col gap-4">
|
||||
<h1 class="m-0 text-6xl font-sans">
|
||||
404
|
||||
</h1>
|
||||
<div class="desc mx-0 text-xl text-stone-5">
|
||||
<div class="mx-0 text-xl text-stone-5">
|
||||
抱歉,你访问的页面不存在
|
||||
</div>
|
||||
<div>
|
||||
|
||||
+18
-30
@@ -25,12 +25,12 @@ const fantasticAdminInfo = ref({
|
||||
imageVisible: false,
|
||||
index: 0,
|
||||
data: [
|
||||
'https://fantastic-admin.gitee.io/preview1.png',
|
||||
'https://fantastic-admin.gitee.io/preview2.png',
|
||||
'https://fantastic-admin.gitee.io/preview3.png',
|
||||
'https://fantastic-admin.gitee.io/preview4.png',
|
||||
'https://fantastic-admin.gitee.io/preview5.png',
|
||||
'https://fantastic-admin.gitee.io/preview6.png',
|
||||
'https://fantastic-admin.github.io/preview1.png',
|
||||
'https://fantastic-admin.github.io/preview2.png',
|
||||
'https://fantastic-admin.github.io/preview3.png',
|
||||
'https://fantastic-admin.github.io/preview4.png',
|
||||
'https://fantastic-admin.github.io/preview5.png',
|
||||
'https://fantastic-admin.github.io/preview6.png',
|
||||
],
|
||||
})
|
||||
|
||||
@@ -38,12 +38,12 @@ const oneStepAdminInfo = ref({
|
||||
imageVisible: false,
|
||||
index: 0,
|
||||
data: [
|
||||
'https://one-step-admin.gitee.io/preview1.png',
|
||||
'https://one-step-admin.gitee.io/preview2.png',
|
||||
'https://one-step-admin.gitee.io/preview3.png',
|
||||
'https://one-step-admin.gitee.io/preview4.png',
|
||||
'https://one-step-admin.gitee.io/preview5.png',
|
||||
'https://one-step-admin.gitee.io/preview6.png',
|
||||
'https://one-step-admin.github.io/preview1.png',
|
||||
'https://one-step-admin.github.io/preview2.png',
|
||||
'https://one-step-admin.github.io/preview3.png',
|
||||
'https://one-step-admin.github.io/preview4.png',
|
||||
'https://one-step-admin.github.io/preview5.png',
|
||||
'https://one-step-admin.github.io/preview6.png',
|
||||
],
|
||||
})
|
||||
|
||||
@@ -70,7 +70,7 @@ function open(url: string) {
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<HButton outline @click="open('https://fantastic-admin.gitee.io')">
|
||||
<HButton outline @click="open('https://fantastic-admin.github.io')">
|
||||
<SvgIcon name="i-ri:file-text-line" />
|
||||
开发文档
|
||||
</HButton>
|
||||
@@ -89,9 +89,6 @@ function open(url: string) {
|
||||
</HButton>
|
||||
</HDropdownMenu>
|
||||
</PageHeader>
|
||||
<PageMain class="rounded-lg text-white" style="background: linear-gradient(50deg, rgb(14 76 253), rgb(106 142 255));">
|
||||
全新版本 V4.0 正式发布,支持替换 UI 组件库,点击查看<span class="cursor-pointer px-1 text-yellow font-bold hover:op-70" @click="open('https://fantastic-admin.gitee.io/guide/v4.html')">V4.0 更新介绍</span>。
|
||||
</PageMain>
|
||||
<div class="w-full flex flex-col gap-4 px-4 xl:flex-row">
|
||||
<PageMain class="ecology">
|
||||
<template #title>
|
||||
@@ -105,12 +102,9 @@ function open(url: string) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="ml-auto">
|
||||
<HButton @click="open('https://hooray.gitee.io/fantastic-startkit')">
|
||||
<HButton @click="open('https://hooray.github.io/fantastic-startkit')">
|
||||
访问官网
|
||||
</HButton>
|
||||
<HButton outline class="ml-2" @click="open('https://hooray.github.io/fantastic-startkit')">
|
||||
备用地址
|
||||
</HButton>
|
||||
</div>
|
||||
</template>
|
||||
<ul class="m-0 pr-8 text-size-sm leading-6">
|
||||
@@ -122,7 +116,7 @@ function open(url: string) {
|
||||
<PageMain class="ecology">
|
||||
<template #title>
|
||||
<div class="title-info">
|
||||
<img src="https://fantastic-admin.gitee.io/logo.png">
|
||||
<img src="https://fantastic-admin.github.io/logo.png">
|
||||
<div>
|
||||
<h1 class="c-[#e60000]">
|
||||
Fantastic-admin
|
||||
@@ -131,12 +125,9 @@ function open(url: string) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="ml-auto">
|
||||
<HButton @click="open('https://fantastic-admin.gitee.io')">
|
||||
<HButton @click="open('https://fantastic-admin.github.io')">
|
||||
访问官网
|
||||
</HButton>
|
||||
<HButton outline class="ml-2" @click="open('https://fantastic-admin.github.io')">
|
||||
备用地址
|
||||
</HButton>
|
||||
</div>
|
||||
</template>
|
||||
<ElCarousel trigger="click" indicator-position="none" :interval="5000" height="250px">
|
||||
@@ -149,7 +140,7 @@ function open(url: string) {
|
||||
<PageMain class="ecology">
|
||||
<template #title>
|
||||
<div class="title-info">
|
||||
<img src="https://one-step-admin.gitee.io/logo.png">
|
||||
<img src="https://one-step-admin.github.io/logo.png">
|
||||
<div>
|
||||
<h1 class="c-[#67c23a]">
|
||||
One-step-admin
|
||||
@@ -158,12 +149,9 @@ function open(url: string) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="ml-auto">
|
||||
<HButton @click="open('https://one-step-admin.gitee.io')">
|
||||
<HButton @click="open('https://one-step-admin.github.io')">
|
||||
访问官网
|
||||
</HButton>
|
||||
<HButton outline class="ml-2" @click="open('https://one-step-admin.github.io')">
|
||||
备用地址
|
||||
</HButton>
|
||||
</div>
|
||||
</template>
|
||||
<ElCarousel trigger="click" indicator-position="none" :interval="5000" height="250px">
|
||||
|
||||
+61
-40
@@ -26,6 +26,9 @@ const banner = new URL('../assets/images/login-banner.png', import.meta.url).hre
|
||||
const logo = new URL('../assets/images/logo.png', import.meta.url).href
|
||||
const title = import.meta.env.VITE_APP_TITLE
|
||||
|
||||
// 登录方式,default 账号密码登录,qrcode 扫码登录
|
||||
const loginType = ref('default')
|
||||
|
||||
// 表单类型,login 登录,register 注册,reset 重置密码
|
||||
const formType = ref('login')
|
||||
const loading = ref(false)
|
||||
@@ -48,7 +51,7 @@ const loginRules = ref<FormRules>({
|
||||
],
|
||||
})
|
||||
function handleLogin() {
|
||||
loginFormRef.value && loginFormRef.value.validate((valid) => {
|
||||
loginFormRef.value?.validate((valid) => {
|
||||
if (valid) {
|
||||
loading.value = true
|
||||
userStore.login(loginForm.value).then(() => {
|
||||
@@ -105,7 +108,7 @@ function handleRegister() {
|
||||
message: '注册模块仅提供界面演示,无实际功能,需开发者自行扩展',
|
||||
type: 'warning',
|
||||
})
|
||||
registerFormRef.value && registerFormRef.value.validate((valid) => {
|
||||
registerFormRef.value?.validate((valid) => {
|
||||
if (valid) {
|
||||
// 这里编写业务代码
|
||||
}
|
||||
@@ -136,7 +139,7 @@ function handleReset() {
|
||||
message: '重置密码仅提供界面演示,无实际功能,需开发者自行扩展',
|
||||
type: 'info',
|
||||
})
|
||||
resetFormRef.value && resetFormRef.value.validate((valid) => {
|
||||
resetFormRef.value?.validate((valid) => {
|
||||
if (valid) {
|
||||
// 这里编写业务代码
|
||||
}
|
||||
@@ -159,44 +162,62 @@ function testAccount(account: string) {
|
||||
<img :src="banner" class="banner">
|
||||
</div>
|
||||
<ElForm v-show="formType === 'login'" ref="loginFormRef" :model="loginForm" :rules="loginRules" class="login-form">
|
||||
<div class="title-container">
|
||||
<h3 class="title">
|
||||
欢迎来到 {{ title }} ! 👋🏻
|
||||
</h3>
|
||||
</div>
|
||||
<div>
|
||||
<ElFormItem prop="account">
|
||||
<ElInput v-model="loginForm.account" placeholder="用户名" type="text" tabindex="1">
|
||||
<template #prefix>
|
||||
<SvgIcon name="i-ri:user-3-fill" />
|
||||
</template>
|
||||
</ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem prop="password">
|
||||
<ElInput v-model="loginForm.password" type="password" placeholder="密码" tabindex="2" autocomplete="new-password" show-password @keyup.enter="handleLogin">
|
||||
<template #prefix>
|
||||
<SvgIcon name="i-ri:lock-2-fill" />
|
||||
</template>
|
||||
</ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="flex-bar">
|
||||
<ElCheckbox v-model="loginForm.remember">
|
||||
记住我
|
||||
</ElCheckbox>
|
||||
<ElLink type="primary" :underline="false" @click="formType = 'reset'">
|
||||
忘记密码了?
|
||||
</ElLink>
|
||||
</div>
|
||||
<ElButton :loading="loading" type="primary" size="large" style="width: 100%;" @click.prevent="handleLogin">
|
||||
登录
|
||||
</ElButton>
|
||||
<div class="sub-link">
|
||||
<span class="text">还没有帐号?</span>
|
||||
<ElLink type="primary" :underline="false" @click="formType = 'register'">
|
||||
创建新帐号
|
||||
</ElLink>
|
||||
<div class="mb-6">
|
||||
<HTabList
|
||||
v-model="loginType" :options="[
|
||||
{ label: '账号密码登录', value: 'default' },
|
||||
{ label: '扫码登录', value: 'qrcode' },
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
<template v-if="loginType === 'default'">
|
||||
<div class="title-container">
|
||||
<h3 class="title">
|
||||
欢迎来到 {{ title }} ! 👋🏻
|
||||
</h3>
|
||||
</div>
|
||||
<div>
|
||||
<ElFormItem prop="account">
|
||||
<ElInput v-model="loginForm.account" placeholder="用户名" type="text" tabindex="1">
|
||||
<template #prefix>
|
||||
<SvgIcon name="i-ri:user-3-fill" />
|
||||
</template>
|
||||
</ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem prop="password">
|
||||
<ElInput v-model="loginForm.password" type="password" placeholder="密码" tabindex="2" autocomplete="new-password" show-password @keyup.enter="handleLogin">
|
||||
<template #prefix>
|
||||
<SvgIcon name="i-ri:lock-2-fill" />
|
||||
</template>
|
||||
</ElInput>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="flex-bar">
|
||||
<ElCheckbox v-model="loginForm.remember">
|
||||
记住我
|
||||
</ElCheckbox>
|
||||
<ElLink type="primary" :underline="false" @click="formType = 'reset'">
|
||||
忘记密码了?
|
||||
</ElLink>
|
||||
</div>
|
||||
<ElButton :loading="loading" type="primary" size="large" style="width: 100%;" @click.prevent="handleLogin">
|
||||
登录
|
||||
</ElButton>
|
||||
<div class="sub-link">
|
||||
<span class="text">还没有帐号?</span>
|
||||
<ElLink type="primary" :underline="false" @click="formType = 'register'">
|
||||
创建新帐号
|
||||
</ElLink>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="loginType === 'qrcode'">
|
||||
<div class="flex flex-col items-center">
|
||||
<el-image src="https://s2.loli.net/2024/04/26/GsahtuIZ9XOg5jr.png" class="h-[250px] w-[250px]" />
|
||||
<div class="mt-2 op-50">
|
||||
请使用微信扫码登录
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div style="margin-top: 20px; margin-bottom: -20px; text-align: center;">
|
||||
<ElDivider>演示账号一键登录</ElDivider>
|
||||
<ElButton type="primary" size="small" plain @click="testAccount('admin')">
|
||||
|
||||
+2
-3
@@ -17,8 +17,7 @@ export default async ({ mode, command }) => {
|
||||
}
|
||||
})
|
||||
return defineConfig({
|
||||
base: './',
|
||||
// 开发服务器选项 https://cn.vitejs.dev/config/#server-options
|
||||
// 开发服务器选项 https://cn.vitejs.dev/config/server-options
|
||||
server: {
|
||||
open: true,
|
||||
port: 9000,
|
||||
@@ -30,7 +29,7 @@ export default async ({ mode, command }) => {
|
||||
},
|
||||
},
|
||||
},
|
||||
// 构建选项 https://cn.vitejs.dev/config/#server-fsserve-root
|
||||
// 构建选项 https://cn.vitejs.dev/config/build-options
|
||||
build: {
|
||||
outDir: mode === 'production' ? 'dist' : `dist-${mode}`,
|
||||
sourcemap: env.VITE_BUILD_SOURCEMAP === 'true',
|
||||
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
import fs from 'node:fs'
|
||||
import dayjs from 'dayjs'
|
||||
import type { PluginOption } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
import vueLegacy from '@vitejs/plugin-legacy'
|
||||
import VueDevTools from 'vite-plugin-vue-devtools'
|
||||
import autoImport from 'unplugin-auto-import/vite'
|
||||
import components from 'unplugin-vue-components/vite'
|
||||
import Unocss from 'unocss/vite'
|
||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
||||
import { vitePluginFakeServer } from 'vite-plugin-fake-server'
|
||||
import Layouts from 'vite-plugin-vue-meta-layouts'
|
||||
import Pages from 'vite-plugin-pages'
|
||||
import { compression } from 'vite-plugin-compression2'
|
||||
import archiver from 'archiver'
|
||||
import TurboConsole from 'unplugin-turbo-console/vite'
|
||||
import banner from 'vite-plugin-banner'
|
||||
import boxen from 'boxen'
|
||||
import picocolors from 'picocolors'
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
export default function createVitePlugins(viteEnv, isBuild = false) {
|
||||
const vitePlugins: (PluginOption | PluginOption[])[] = [
|
||||
vue(),
|
||||
vueJsx(),
|
||||
vueLegacy({
|
||||
renderLegacyChunks: false,
|
||||
modernPolyfills: [
|
||||
'es.array.at',
|
||||
'es.array.find-last',
|
||||
],
|
||||
}),
|
||||
|
||||
// https://github.com/vuejs/devtools-next
|
||||
viteEnv.VITE_OPEN_DEVTOOLS === 'true' && VueDevTools(),
|
||||
|
||||
// https://github.com/unplugin/unplugin-auto-import
|
||||
autoImport({
|
||||
imports: [
|
||||
'vue',
|
||||
'vue-router',
|
||||
'pinia',
|
||||
],
|
||||
dts: './src/types/auto-imports.d.ts',
|
||||
dirs: [
|
||||
'./src/utils/composables/**',
|
||||
],
|
||||
}),
|
||||
|
||||
// https://github.com/unplugin/unplugin-vue-components
|
||||
components({
|
||||
dirs: [
|
||||
'src/components',
|
||||
'src/layouts/ui-kit',
|
||||
],
|
||||
include: [/\.vue$/, /\.vue\?vue/, /\.tsx$/],
|
||||
dts: './src/types/components.d.ts',
|
||||
}),
|
||||
|
||||
Unocss(),
|
||||
|
||||
// https://github.com/vbenjs/vite-plugin-svg-icons
|
||||
createSvgIconsPlugin({
|
||||
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons/')],
|
||||
symbolId: 'icon-[dir]-[name]',
|
||||
svgoOptions: isBuild,
|
||||
}),
|
||||
|
||||
// https://github.com/condorheroblog/vite-plugin-fake-server
|
||||
vitePluginFakeServer({
|
||||
logger: !isBuild,
|
||||
include: 'src/mock',
|
||||
infixName: false,
|
||||
enableProd: isBuild && viteEnv.VITE_BUILD_MOCK === 'true',
|
||||
}),
|
||||
|
||||
// https://github.com/dishait/vite-plugin-vue-meta-layouts
|
||||
Layouts({
|
||||
defaultLayout: 'index',
|
||||
}),
|
||||
|
||||
// https://github.com/hannoeru/vite-plugin-pages
|
||||
Pages({
|
||||
dirs: 'src/views',
|
||||
exclude: [
|
||||
'**/components/**/*.vue',
|
||||
],
|
||||
}),
|
||||
|
||||
// https://github.com/nonzzz/vite-plugin-compression
|
||||
isBuild && viteEnv.VITE_BUILD_COMPRESS.split(',').includes('gzip') && compression(),
|
||||
isBuild && viteEnv.VITE_BUILD_COMPRESS.split(',').includes('brotli') && compression({
|
||||
exclude: [/\.(br)$/, /\.(gz)$/],
|
||||
algorithm: 'brotliCompress',
|
||||
}),
|
||||
|
||||
(function () {
|
||||
let outDir: string
|
||||
return {
|
||||
name: 'vite-plugin-archiver',
|
||||
apply: 'build',
|
||||
configResolved(resolvedConfig) {
|
||||
outDir = resolvedConfig.build.outDir
|
||||
},
|
||||
async closeBundle() {
|
||||
if (['zip', 'tar'].includes(viteEnv.VITE_BUILD_ARCHIVE)) {
|
||||
await sleep(1000)
|
||||
const archive = archiver(viteEnv.VITE_BUILD_ARCHIVE, {
|
||||
...(viteEnv.VITE_BUILD_ARCHIVE === 'zip' && { zlib: { level: 9 } }),
|
||||
...(viteEnv.VITE_BUILD_ARCHIVE === 'tar' && { gzip: true, gzipOptions: { level: 9 } }),
|
||||
})
|
||||
const output = fs.createWriteStream(`${outDir}.${dayjs().format('YYYY-MM-DD-HH-mm-ss')}.${viteEnv.VITE_BUILD_ARCHIVE === 'zip' ? 'zip' : 'tar.gz'}`)
|
||||
archive.pipe(output)
|
||||
archive.directory(outDir, false)
|
||||
archive.finalize()
|
||||
}
|
||||
},
|
||||
}
|
||||
})(),
|
||||
|
||||
// https://github.com/unplugin/unplugin-turbo-console
|
||||
TurboConsole(),
|
||||
|
||||
// https://github.com/chengpeiquan/vite-plugin-banner
|
||||
banner(`
|
||||
/**
|
||||
* 由 Fantastic-admin 提供技术支持
|
||||
* Powered by Fantastic-admin
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
`),
|
||||
|
||||
{
|
||||
name: 'vite-plugin-debug-plugin',
|
||||
transform: (code, id) => {
|
||||
if (/src\/main.ts$/.test(id)) {
|
||||
if (viteEnv.VITE_APP_DEBUG_TOOL === 'eruda') {
|
||||
code = code.concat(`
|
||||
import eruda from 'eruda'
|
||||
eruda.init()
|
||||
`)
|
||||
}
|
||||
else if (viteEnv.VITE_APP_DEBUG_TOOL === 'vconsole') {
|
||||
code = code.concat(`
|
||||
import VConsole from 'vconsole'
|
||||
new VConsole()
|
||||
`)
|
||||
}
|
||||
return {
|
||||
code,
|
||||
map: null,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: 'vite-plugin-disable-devtool',
|
||||
transform: (code, id) => {
|
||||
if (/src\/main.ts$/.test(id)) {
|
||||
if (viteEnv.VITE_APP_DISABLE_DEVTOOL === 'true') {
|
||||
code = code.concat(`
|
||||
import DisableDevtool from 'disable-devtool'
|
||||
DisableDevtool()
|
||||
`)
|
||||
}
|
||||
return {
|
||||
code,
|
||||
map: null,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: 'vite-plugin-terminal-info',
|
||||
apply: 'serve',
|
||||
async buildStart() {
|
||||
const { bold, green, cyan, bgGreen, underline } = picocolors
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
boxen(
|
||||
`${bold(green(`由 ${bgGreen('Fantastic-admin')} 驱动`))}\n\n${underline('https://fantastic-admin.github.io')}\n\n当前使用:${cyan('基础版')}`,
|
||||
{
|
||||
padding: 1,
|
||||
margin: 1,
|
||||
borderStyle: 'double',
|
||||
textAlignment: 'center',
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
},
|
||||
]
|
||||
return vitePlugins
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import boxen from 'boxen'
|
||||
import picocolors from 'picocolors'
|
||||
import type { Plugin } from 'vite'
|
||||
|
||||
export default function appInfo(): Plugin {
|
||||
return {
|
||||
name: 'appInfo',
|
||||
apply: 'serve',
|
||||
async buildStart() {
|
||||
const { bold, green, cyan, bgGreen, underline } = picocolors
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
boxen(
|
||||
`${bold(green(`由 ${bgGreen('Fantastic-admin')} 驱动`))}\n\n${underline('https://fantastic-admin.gitee.io')}\n\n当前使用:${cyan('基础版')}`,
|
||||
{
|
||||
padding: 1,
|
||||
margin: 1,
|
||||
borderStyle: 'double',
|
||||
textAlignment: 'center',
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
import fs from 'node:fs'
|
||||
import dayjs from 'dayjs'
|
||||
import archiver from 'archiver'
|
||||
import type { Plugin } from 'vite'
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
export default function createArchiver(env): Plugin {
|
||||
const { VITE_BUILD_ARCHIVE } = env
|
||||
let outDir: string
|
||||
return {
|
||||
name: 'vite-plugin-archiver',
|
||||
apply: 'build',
|
||||
configResolved(resolvedConfig) {
|
||||
outDir = resolvedConfig.build.outDir
|
||||
},
|
||||
async closeBundle() {
|
||||
if (['zip', 'tar'].includes(VITE_BUILD_ARCHIVE)) {
|
||||
await sleep(1000)
|
||||
const archive = archiver(VITE_BUILD_ARCHIVE, {
|
||||
...(VITE_BUILD_ARCHIVE === 'zip' && { zlib: { level: 9 } }),
|
||||
...(VITE_BUILD_ARCHIVE === 'tar' && { gzip: true, gzipOptions: { level: 9 } }),
|
||||
})
|
||||
const output = fs.createWriteStream(`${outDir}.${dayjs().format('YYYY-MM-DD-HH-mm-ss')}.${VITE_BUILD_ARCHIVE === 'zip' ? 'zip' : 'tar.gz'}`)
|
||||
archive.pipe(output)
|
||||
archive.directory(outDir, false)
|
||||
archive.finalize()
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import autoImport from 'unplugin-auto-import/vite'
|
||||
|
||||
export default function createAutoImport() {
|
||||
return autoImport({
|
||||
imports: [
|
||||
'vue',
|
||||
'vue-router',
|
||||
'pinia',
|
||||
],
|
||||
dts: './src/types/auto-imports.d.ts',
|
||||
dirs: [
|
||||
'./src/utils/composables/**',
|
||||
],
|
||||
})
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import banner from 'vite-plugin-banner'
|
||||
|
||||
export default function createBanner() {
|
||||
return banner(`
|
||||
/**
|
||||
* 由 Fantastic-admin 提供技术支持
|
||||
* Powered by Fantastic-admin
|
||||
* Gitee https://fantastic-admin.gitee.io
|
||||
* Github https://fantastic-admin.github.io
|
||||
*/
|
||||
`)
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import components from 'unplugin-vue-components/vite'
|
||||
|
||||
export default function createComponents() {
|
||||
return components({
|
||||
dirs: [
|
||||
'src/components',
|
||||
'src/layouts/ui-kit',
|
||||
],
|
||||
include: [/\.vue$/, /\.vue\?vue/, /\.tsx$/],
|
||||
dts: './src/types/components.d.ts',
|
||||
})
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { compression } from 'vite-plugin-compression2'
|
||||
import type { PluginOption } from 'vite'
|
||||
|
||||
export default function createCompression(env, isBuild) {
|
||||
const plugin: (PluginOption | PluginOption[])[] = []
|
||||
if (isBuild) {
|
||||
const { VITE_BUILD_COMPRESS } = env
|
||||
const compressList = VITE_BUILD_COMPRESS.split(',')
|
||||
if (compressList.includes('gzip')) {
|
||||
plugin.push(
|
||||
compression(),
|
||||
)
|
||||
}
|
||||
if (compressList.includes('brotli')) {
|
||||
plugin.push(
|
||||
compression({
|
||||
exclude: [/\.(br)$/, /\.(gz)$/],
|
||||
algorithm: 'brotliCompress',
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
return plugin
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import TurboConsole from 'unplugin-turbo-console/vite'
|
||||
|
||||
export default function createConsole() {
|
||||
return TurboConsole()
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import VueDevTools from 'vite-plugin-vue-devtools'
|
||||
|
||||
export default function createDevtools(env) {
|
||||
const { VITE_OPEN_DEVTOOLS } = env
|
||||
return VITE_OPEN_DEVTOOLS === 'true' && VueDevTools()
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
import type { PluginOption } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
import vueLegacy from '@vitejs/plugin-legacy'
|
||||
import appInfo from './app-info'
|
||||
|
||||
import createDevtools from './devtools'
|
||||
import createAutoImport from './auto-import'
|
||||
import createComponents from './components'
|
||||
import createUnocss from './unocss'
|
||||
import createSvgIcon from './svg-icon'
|
||||
import createMock from './mock'
|
||||
import createLayouts from './layouts'
|
||||
import createPages from './pages'
|
||||
import createCompression from './compression'
|
||||
import createArchiver from './archiver'
|
||||
import createConsole from './console'
|
||||
import createBanner from './banner'
|
||||
|
||||
export default function createVitePlugins(viteEnv, isBuild = false) {
|
||||
const vitePlugins: (PluginOption | PluginOption[])[] = [
|
||||
appInfo(),
|
||||
vue(),
|
||||
vueJsx(),
|
||||
vueLegacy({
|
||||
renderLegacyChunks: false,
|
||||
modernPolyfills: [
|
||||
'es.array.at',
|
||||
'es.array.find-last',
|
||||
],
|
||||
}),
|
||||
]
|
||||
vitePlugins.push(createDevtools(viteEnv))
|
||||
vitePlugins.push(createAutoImport())
|
||||
vitePlugins.push(createComponents())
|
||||
vitePlugins.push(createUnocss())
|
||||
vitePlugins.push(createSvgIcon(isBuild))
|
||||
vitePlugins.push(createMock(viteEnv, isBuild))
|
||||
vitePlugins.push(createLayouts())
|
||||
vitePlugins.push(createPages())
|
||||
vitePlugins.push(...createCompression(viteEnv, isBuild))
|
||||
vitePlugins.push(createArchiver(viteEnv))
|
||||
vitePlugins.push(createConsole())
|
||||
vitePlugins.push(createBanner())
|
||||
return vitePlugins
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import Layouts from 'vite-plugin-vue-meta-layouts'
|
||||
|
||||
export default function createLayouts() {
|
||||
return Layouts({
|
||||
defaultLayout: 'index',
|
||||
})
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import { vitePluginFakeServer } from 'vite-plugin-fake-server'
|
||||
|
||||
export default function createMock(env, isBuild) {
|
||||
const { VITE_BUILD_MOCK } = env
|
||||
return vitePluginFakeServer({
|
||||
logger: !isBuild,
|
||||
include: 'src/mock',
|
||||
infixName: false,
|
||||
enableProd: isBuild && VITE_BUILD_MOCK === 'true',
|
||||
})
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import Pages from 'vite-plugin-pages'
|
||||
|
||||
export default function createPages() {
|
||||
return Pages({
|
||||
dirs: 'src/views',
|
||||
exclude: [
|
||||
'**/components/**/*.vue',
|
||||
],
|
||||
})
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
||||
|
||||
export default function createSvgIcon(isBuild) {
|
||||
return createSvgIconsPlugin({
|
||||
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons/')],
|
||||
symbolId: 'icon-[dir]-[name]',
|
||||
svgoOptions: isBuild,
|
||||
})
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import Unocss from 'unocss/vite'
|
||||
|
||||
export default function createUnocss() {
|
||||
return Unocss()
|
||||
}
|
||||
Reference in New Issue
Block a user