Compare commits

..
61 Commits
Author SHA1 Message Date
Hooray Hu dac7f4b0c1 chore: release v4.11.0 2024-09-01 20:42:20 +08:00
Hooray Hu d83b21715b chore: 更新依赖 2024-09-01 19:11:02 +08:00
Hooray Hu a57c62765b revert: 移除 unocss 自定义 shortcuts 2024-08-28 14:01:47 +08:00
Hooray Hu 2b38152485 refactor: 路由导航守卫移入到单独文件维护 2024-08-27 10:56:00 +08:00
Hooray Hu 57e982ed61 refactor: 布局相关css变量移入到布局组件中维护 2024-08-27 10:35:09 +08:00
Hooray Hu 2fe0fc95ee feat: 引入 postcss-nested 2024-08-26 23:16:32 +08:00
Hooray Hu fab5d0539b chore: 更换域名 2024-08-19 16:02:09 +08:00
Hooray Hu e79bd1dc50 feat: SvgIcon 组件支持传入本地图片,网络图片增加载入和失败状态 2024-08-14 17:49:03 +08:00
Hooray Hu 1e155369b2 fix: 修复带参路由无法记录到标签栏中 2024-08-08 16:15:49 +08:00
Hooray Hu cb230f77bd refactor!: 重构登录页面 2024-08-06 02:18:25 +08:00
Hooray Hu 6f59ddf6b8 feat: 扩充 unocss 自定义 shortcuts 2024-08-05 14:43:03 +08:00
Hooray Hu 7668bd5063 chore: release v4.10.0 2024-08-03 22:16:45 +08:00
Hooray Hu 5e3fa9a567 chore: 更新依赖 2024-08-03 22:01:11 +08:00
Hooray Hu 571190cd78 refactor: 手动登出时不带上重定向地址 2024-07-31 15:39:18 +08:00
Hooray Hu bd5c921bca feat: FileUpload 组件文件列表增加下载功能 2024-07-31 13:53:01 +08:00
Max Sky b236df4e30 微软 Microsoft 拼写错误 (#41) 2024-07-30 17:39:06 +08:00
Hooray Hu 657bec97f6 refactor: 导航菜单尺寸调整 2024-07-21 18:19:46 +08:00
Hooray Hu 5d0141011b chore: 更新依赖 2024-07-18 11:28:31 +08:00
Hooray Hu b8e53fb259 chore: eslint 规则调整 2024-07-11 19:56:58 +08:00
Hooray Hu 66c0e4f8c7 feat: 上传组件增加自定义上传 2024-07-09 18:02:02 +08:00
Hooray Hu 7457fcc23e refactor: vite插件合并到单个文件中维护 2024-07-08 16:40:54 +08:00
Hooray Hu 9a7331f32f refactor!: 移除createInjectionKey函数 2024-07-05 17:42:40 +08:00
Hooray Hu 87819b4b5d chore: 移除无用代码 2024-07-05 15:14:39 +08:00
Hooray Hu d00fc26616 refactor: 环境变量 VITE_APP_DISABLE_DEVTOOL 改成用 vite 插件的方式注入代码中 2024-07-03 23:25:36 +08:00
Hooray Hu 647edd7207 refactor: 环境变量 VITE_APP_DEBUG_TOOL 改成用 vite 插件的方式注入代码中 2024-07-03 23:01:46 +08:00
Hooray Hu 23d36432da feat: 次导航支持隐藏 2024-07-02 00:34:36 +08:00
Hooray Hu 2fdc4f18ca chore: release v4.9.0 2024-06-29 12:51:03 +08:00
Hooray Hu 961df08e2b chore: 更新依赖 2024-06-29 12:50:50 +08:00
Hooray Hu 1d62ac7558 style: HDropdownMenu 组件样式调整 2024-06-28 14:21:26 +08:00
Hooray Hu 456ef83081 feat: 新增哀悼模式和色弱模式 2024-06-28 10:06:56 +08:00
Hooray Hu 90b588028a feat: 增加禁用开发者工具环境变量 2024-06-26 10:45:45 +08:00
Hooray Hu 9e444c83f8 fix: 修复主导航 children 为空时报错 2024-06-25 00:44:07 +08:00
Hooray Hu 57fcd2785c refactor!: 配置项 menu.menuMode 变更为 menu.mode 2024-06-24 17:16:27 +08:00
Hooray Hu 3c8b4881b4 fix: 修复vscode失效配置 2024-06-24 15:55:31 +08:00
Hooray Hu e32d0561c7 chore: 更新readme 2024-06-21 09:58:18 +08:00
Hooray Hu d303776825 chore: 更新依赖 2024-06-15 22:53:45 +08:00
Hooray Hu 3ef0f69bcc chore: 样式微调 2024-06-12 14:10:48 +08:00
Hooray Hu b00477d5fa chore: release v4.8.2 2024-06-07 10:48:33 +08:00
Hooray Hu fe00fa1e6f chore: 更新依赖 2024-06-07 10:32:36 +08:00
Hooray Hu f0679a1d59 chore: 更新readme 2024-06-04 16:12:39 +08:00
Hooray Hu 4c4f811f39 chore: 修改 unocss 写法 2024-05-29 14:29:55 +08:00
Hooray Hu 03e5e99896 perf: 优化标签栏滚动体验 2024-05-28 16:50:02 +08:00
Hooray Hu fda48176ee chore: 更新依赖,修改 unocss 写法 2024-05-22 15:42:16 +08:00
Hooray Hu b639b487db chore: release v4.8.1 2024-05-20 10:04:30 +08:00
Hooray Hu dbd93ffb7f chore: 更新依赖 2024-05-20 10:00:02 +08:00
Hooray Hu daf9b1b2e2 chore: vite base 使用默认设置 2024-05-16 10:50:35 +08:00
Hooray Hu e023671bac fix: 修复后端返回路由数据中 children 为空数组导致菜单无法正常生成 2024-05-14 10:14:30 +08:00
Hooray Hu e6265a7c64 chore: 增加node版本控制文件 2024-05-09 09:51:38 +08:00
Hooray Hu 8c629050ba chore: 更换链接 2024-05-07 09:52:18 +08:00
Hooray Hu c7d2a857f7 chore: release v4.8.0 2024-05-01 12:44:53 +08:00
Hooray Hu b19344a1c1 chore: 更新依赖 2024-05-01 12:35:15 +08:00
Hooray Hu b632b4d3a8 refactor: 调整标签页操作按钮点击区域 2024-04-29 17:51:56 +08:00
Hooray Hu 98d21845ce feat: 登录页增加扫码登录参考 2024-04-26 11:27:16 +08:00
Hooray Hu bbeeac41ce chore: 移除无用代码 2024-04-24 17:26:10 +08:00
Hooray Hu 449495f03d fix: 修复类型定义 2024-04-23 10:27:33 +08:00
Hooray Hu 14583bbaa5 fix: 标签栏解绑错误快捷键 2024-04-15 09:52:33 +08:00
Hooray Hu 045ab02bb2 chore: 主页微调 2024-04-11 00:49:53 +08:00
Hooray Hu b883133dc6 refactor: 明暗图标替换 2024-04-09 17:20:49 +08:00
Hooray Hu 5269dba56b fix: 标签栏右键菜单自定义样式没在指定 class 范围内生效 2024-04-09 16:55:09 +08:00
Hooray Hu 4911affd28 refactor!: 路由 meta.auth 保持元信息默认合并行为,路由访问改为通过 route.matched 进行逐级鉴权 2024-04-09 15:14:00 +08:00
Hooray Hu cb53f4c84e fix: 修复一级路由设置 meta.menu: false 无效 2024-04-05 14:43:44 +08:00
97 changed files with 10437 additions and 9599 deletions
+2
View File
@@ -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
+2
View File
@@ -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
+2
View File
@@ -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
+1
View File
@@ -0,0 +1 @@
20
+1 -1
View File
@@ -1,5 +1,5 @@
{
"eslint.experimental.useFlatConfig": true,
"eslint.useFlatConfig": true,
"prettier.enable": false,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
+35 -23
View File
@@ -1,5 +1,5 @@
<p align="center">
<img src="https://fantastic-admin.github.io/logo.png" width="200" height="200" />
<img src="https://fantastic-admin.hurui.me/logo.png" width="200" height="200" />
</p>
<h1 align="center">Fantastic-admin</h1>
@@ -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.hurui.me" target="_blank">官网</a>
<span>&nbsp;|&nbsp;</span>
<a href="https://fantastic-admin.github.io/support.html" target="_blank">技术支持</a>
<span>&nbsp;|&nbsp;</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>&nbsp;|&nbsp;</span>
购买
<sup><a href="https://fantastic-admin.github.io/buy.html" target="_blank">专业版</a></sup>
<a href="https://fantastic-admin.pages.dev" target="_blank">备用地址</a>
<p>
<p align="center">
@@ -53,14 +46,14 @@
<table>
<tr>
<td><img src="https://fantastic-admin.github.io/preview1.png" /></td>
<td><img src="https://fantastic-admin.github.io/preview2.png" /></td>
<td><img src="https://fantastic-admin.github.io/preview3.png" /></td>
<td><img src="https://fantastic-admin.hurui.me/preview1.png" /></td>
<td><img src="https://fantastic-admin.hurui.me/preview2.png" /></td>
<td><img src="https://fantastic-admin.hurui.me/preview3.png" /></td>
</tr>
<tr>
<td><img src="https://fantastic-admin.github.io/preview4.png" /></td>
<td><img src="https://fantastic-admin.github.io/preview5.png" /></td>
<td><img src="https://fantastic-admin.github.io/preview6.png" /></td>
<td><img src="https://fantastic-admin.hurui.me/preview4.png" /></td>
<td><img src="https://fantastic-admin.hurui.me/preview5.png" /></td>
<td><img src="https://fantastic-admin.hurui.me/preview6.png" /></td>
</tr>
</table>
@@ -96,7 +89,7 @@
<table>
<tr>
<th colspan="3" align="center">
<a href="https://one-step-admin.github.io" target="_blank">One-step-admin</a>
<a href="https://one-step-admin.hurui.me" target="_blank">One-step-admin</a>
</th>
</tr>
<tr>
@@ -105,13 +98,32 @@
</th>
</tr>
<tr>
<td><img src="https://one-step-admin.github.io/preview1.png" /></td>
<td><img src="https://one-step-admin.github.io/preview2.png" /></td>
<td><img src="https://one-step-admin.github.io/preview3.png" /></td>
<td><img src="https://one-step-admin.hurui.me/preview1.png" /></td>
<td><img src="https://one-step-admin.hurui.me/preview2.png" /></td>
<td><img src="https://one-step-admin.hurui.me/preview3.png" /></td>
</tr>
<tr>
<td><img src="https://one-step-admin.github.io/preview4.png" /></td>
<td><img src="https://one-step-admin.github.io/preview5.png" /></td>
<td><img src="https://one-step-admin.github.io/preview6.png" /></td>
<td><img src="https://one-step-admin.hurui.me/preview4.png" /></td>
<td><img src="https://one-step-admin.hurui.me/preview5.png" /></td>
<td><img src="https://one-step-admin.hurui.me/preview6.png" /></td>
</tr>
</table>
<table>
<tr>
<th colspan="4" align="center">
<a href="https://fantastic-mobile.hurui.me" target="_blank">Fantastic-mobile</a>
</th>
</tr>
<tr>
<th colspan="4" align="center">
一款自成一派的移动端 H5 框架
</th>
</tr>
<tr>
<td><img src="https://fantastic-mobile.hurui.me/preview1.png" /></td>
<td><img src="https://fantastic-mobile.hurui.me/preview2.png" /></td>
<td><img src="https://fantastic-mobile.hurui.me/preview3.png" /></td>
<td><img src="https://fantastic-mobile.hurui.me/preview4.png" /></td>
</tr>
</table>
+4 -1
View File
@@ -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
View File
@@ -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" />
+58 -54
View File
@@ -1,8 +1,8 @@
{
"type": "module",
"version": "4.7.0",
"version": "4.11.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,88 @@
"release": "bumpp"
},
"dependencies": {
"@headlessui/vue": "^1.7.19",
"@imengyu/vue3-context-menu": "^1.3.9",
"@vueuse/core": "^10.9.0",
"@vueuse/integrations": "^10.9.0",
"axios": "^1.6.8",
"dayjs": "^1.11.10",
"@headlessui/vue": "^1.7.22",
"@imengyu/vue3-context-menu": "^1.4.2",
"@vueuse/components": "^11.0.3",
"@vueuse/core": "^11.0.3",
"@vueuse/integrations": "^11.0.3",
"axios": "^1.7.7",
"dayjs": "^1.11.13",
"defu": "^6.1.4",
"element-plus": "^2.6.3",
"eruda": "^3.0.1",
"disable-devtool": "^0.3.7",
"element-plus": "^2.8.1",
"eruda": "^3.2.3",
"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.6.1",
"overlayscrollbars-vue": "^0.5.8",
"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.12.0",
"path-to-regexp": "^7.1.0",
"pinia": "^2.2.2",
"qs": "^6.13.0",
"scule": "^1.3.0",
"vconsole": "^3.15.1",
"vue": "^3.4.21",
"vue": "^3.4.38",
"vue-m-message": "^4.0.2",
"vue-router": "^4.3.0"
"vue-router": "^4.4.3"
},
"devDependencies": {
"@antfu/eslint-config": "2.11.6",
"@iconify/json": "^2.2.196",
"@iconify/vue": "^4.1.1",
"@stylistic/stylelint-config": "^1.0.1",
"@antfu/eslint-config": "2.24.1",
"@iconify/json": "^2.2.243",
"@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.14",
"@unocss/eslint-plugin": "^0.58.8",
"@vitejs/plugin-legacy": "^5.3.2",
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@types/path-browserify": "^1.0.3",
"@types/qs": "^6.9.15",
"@unocss/eslint-plugin": "^0.62.3",
"@vitejs/plugin-legacy": "^5.4.2",
"@vitejs/plugin-vue": "^5.1.3",
"@vitejs/plugin-vue-jsx": "^4.0.1",
"archiver": "^7.0.1",
"autoprefixer": "^10.4.19",
"boxen": "^7.1.1",
"bumpp": "^9.4.0",
"cz-git": "^1.9.1",
"eslint": "^8.57.0",
"autoprefixer": "^10.4.20",
"boxen": "^8.0.1",
"bumpp": "^9.5.2",
"cz-git": "^1.9.4",
"eslint": "^9.9.1",
"esno": "^4.7.0",
"fs-extra": "^11.2.0",
"http-server": "^14.1.1",
"inquirer": "^9.2.17",
"lint-staged": "^15.2.2",
"npm-run-all": "^4.1.5",
"picocolors": "^1.0.0",
"inquirer": "^10.1.8",
"lint-staged": "^15.2.9",
"npm-run-all2": "^6.2.2",
"picocolors": "^1.0.1",
"plop": "^4.0.1",
"sass": "^1.72.0",
"postcss": "^8.4.42",
"postcss-nested": "^6.2.0",
"sass": "^1.77.8",
"simple-git-hooks": "^2.11.1",
"stylelint": "^16.3.1",
"stylelint-config-recess-order": "^5.0.0",
"stylelint-config-standard-scss": "^13.0.0",
"stylelint": "^16.9.0",
"stylelint-config-recess-order": "^5.1.0",
"stylelint-config-standard-scss": "^13.1.0",
"stylelint-config-standard-vue": "^1.0.0",
"stylelint-scss": "^6.2.1",
"svgo": "^3.2.0",
"terser": "^5.30.0",
"typescript": "^5.4.3",
"unocss": "^0.58.8",
"unplugin-auto-import": "^0.17.5",
"unplugin-turbo-console": "^1.5.1",
"unplugin-vue-components": "^0.26.0",
"vite": "^5.2.7",
"stylelint-scss": "^6.5.1",
"svgo": "^3.3.2",
"typescript": "^5.5.4",
"unocss": "^0.62.3",
"unocss-preset-scrollbar": "^0.3.1",
"unplugin-auto-import": "^0.18.2",
"unplugin-turbo-console": "^1.10.1",
"unplugin-vue-components": "^0.27.4",
"vite": "^5.4.2",
"vite-plugin-banner": "^0.7.1",
"vite-plugin-compression2": "^1.0.0",
"vite-plugin-compression2": "^1.2.0",
"vite-plugin-fake-server": "^2.1.1",
"vite-plugin-pages": "^0.32.1",
"vite-plugin-pages": "^0.32.3",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-vue-devtools": "^7.0.25",
"vite-plugin-vue-meta-layouts": "^0.4.2",
"vue-tsc": "^2.0.7"
"vite-plugin-vue-devtools": "^7.3.9",
"vite-plugin-vue-meta-layouts": "^0.4.3",
"vue-tsc": "^2.1.4"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged",
+2 -2
View File
@@ -12,6 +12,6 @@ defineOptions({
</div>
</template>
<style lang="scss" scoped>
// 样式
<style scoped>
/* 样式 */
</style>
+2 -2
View File
@@ -17,6 +17,6 @@ defineOptions({
</div>
</template>
<style lang="scss" scoped>
// 样式
<style scoped>
/* 样式 */
</style>
+8889 -8312
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -1,5 +1,6 @@
export default {
plugins: {
autoprefixer: {},
'autoprefixer': {},
'postcss-nested': {},
},
}
+8 -29
View File
@@ -1,30 +1,18 @@
<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'
const route = useRoute()
const settingsStore = useSettingsStore()
const { auth } = useAuth()
// 侧边栏主导航当前实际宽度
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')) {
actualWidth = 0
}
return `${actualWidth}px`
})
// 侧边栏次导航当前实际宽度
const subSidebarActualWidth = computed(() => {
let actualWidth = Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--g-sub-sidebar-width'))
if (settingsStore.settings.menu.subMenuCollapse && settingsStore.mode !== 'mobile') {
actualWidth = Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--g-sub-sidebar-collapse-width'))
}
return `${actualWidth}px`
const isAuth = computed(() => {
return route.matched.every((item) => {
return auth(item.meta.auth ?? '')
})
})
// 设置网页 title
@@ -53,21 +41,12 @@ onMounted(() => {
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 }"
:style="{
'--g-main-sidebar-actual-width': mainSidebarActualWidth,
'--g-sub-sidebar-actual-width': subSidebarActualWidth,
}"
>
<component :is="Component" v-if="auth(route.meta.auth ?? '')" />
<RouterView v-slot="{ Component }">
<component :is="Component" v-if="isAuth" />
<NotAllowed v-else />
</RouterView>
<SystemInfo />
@@ -1,22 +1,28 @@
// 页面布局 CSS 变量
/* 页面布局 CSS 变量 */
:root {
// 头部高度
/* 头部高度 */
--g-header-height: 60px;
// 侧边栏宽度
/* 侧边栏宽度 */
--g-main-sidebar-width: 80px;
--g-sub-sidebar-width: 220px;
--g-sub-sidebar-collapse-width: 64px;
// 侧边栏 Logo 区域高度
/* 侧边栏 Logo 区域高度 */
--g-sidebar-logo-height: 50px;
// 标签栏高度
/* 标签栏高度 */
--g-tabbar-height: 50px;
// 工具栏高度
/* 工具栏高度 */
--g-toolbar-height: 50px;
}
// 明暗模式 CSS 变量
/* 明暗模式 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 +37,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 +47,6 @@
&::view-transition-new(root) {
z-index: 1;
}
--g-box-shadow-color: rgb(0 0 0 / 72%);
}
}
@@ -87,22 +91,21 @@ body {
box-sizing: inherit;
}
// 右侧内容区针对fixed元素,有横向铺满的需求,可在fixed元素上设置 [data-fixed-calc-width]
/* 右侧内容区针对fixed元素,有横向铺满的需求,可在fixed元素上设置 [data-fixed-calc-width] */
[data-fixed-calc-width] {
position: fixed;
right: 0;
left: 50%;
width: calc(100% - var(--g-main-sidebar-actual-width) - var(--g-sub-sidebar-actual-width));
transform: translateX(-50%) translateX(calc(var(--g-main-sidebar-actual-width) / 2)) translateX(calc(var(--g-sub-sidebar-actual-width) / 2));
}
[data-mode="mobile"] {
[data-fixed-calc-width] {
[data-mode="mobile"] & {
width: 100% !important;
transform: translateX(-50%) !important;
}
}
// textarea 字体跟随系统
/* textarea 字体跟随系统 */
textarea {
font-family: inherit;
}
@@ -110,12 +113,12 @@ textarea {
/* Overrides Floating Vue */
.v-popper--theme-dropdown,
.v-popper--theme-tooltip {
--at-apply: inline-flex;
--uno: inline-flex;
}
.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;
--uno: 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,12 +127,12 @@ textarea {
.v-popper--theme-dropdown .v-popper__arrow-inner {
visibility: visible;
--at-apply: border-white dark:border-stone-8;
--uno: border-white dark-border-stone-8;
}
.v-popper--theme-tooltip .v-popper__arrow-outer,
.v-popper--theme-dropdown .v-popper__arrow-outer {
--at-apply: border-stone/20;
--uno: border-stone/20;
}
.v-popper--theme-tooltip.v-popper--shown,
+1 -1
View File
@@ -7,9 +7,9 @@
} @else {
/* stylelint-disable-next-line value-no-vendor-prefix */
display: -webkit-box;
overflow: hidden;
-webkit-box-orient: vertical;
-webkit-line-clamp: $line;
overflow: hidden;
}
}
+27 -1
View File
@@ -17,6 +17,7 @@ const props = withDefaults(
files?: UploadUserFile[]
notip?: boolean
ext?: string[]
httpRequest?: UploadProps['httpRequest']
}>(),
{
name: 'file',
@@ -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
@@ -88,7 +114,7 @@ const onSuccess: UploadProps['onSuccess'] = (res, file, fileList) => {
</ElUpload>
</template>
<style lang="scss" scoped>
<style scoped>
:deep(.el-upload.is-drag) {
display: inline-block;
+1 -1
View File
@@ -34,7 +34,7 @@ function onScroll() {
</div>
</template>
<style lang="scss" scoped>
<style scoped>
.fixed-action-bar {
box-shadow: 0 0 1px 0 var(--g-box-shadow-color);
+1 -1
View File
@@ -34,7 +34,7 @@ const realHeight = computed(() => {
</ElImage>
</template>
<style lang="scss" scoped>
<style scoped>
.el-image {
background-color: var(--el-fill-color);
border-radius: 5px;
+11 -5
View File
@@ -18,6 +18,7 @@ const props = withDefaults(
placeholder?: string
notip?: boolean
ext?: string[]
httpRequest?: UploadProps['httpRequest']
}>(),
{
name: 'file',
@@ -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"
>
@@ -134,7 +136,7 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
</div>
</template>
<style lang="scss" scoped>
<style scoped>
.upload-container {
line-height: initial;
}
@@ -158,14 +160,16 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
transition: opacity 0.3s;
.actions {
position: absolute;
top: 50%;
left: 50%;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
width: 100px;
height: 100px;
@include position-center(xy);
transform: translateX(-50%) translateY(-50%);
span {
width: 50%;
@@ -233,9 +237,11 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
}
.el-progress {
position: absolute;
top: 50%;
left: 50%;
z-index: 1;
@include position-center(xy);
transform: translateX(-50%) translateY(-50%);
.el-progress__text {
color: var(--el-text-color-placeholder);
+11 -5
View File
@@ -19,6 +19,7 @@ const props = withDefaults(
placeholder?: string
notip?: boolean
ext?: string[]
httpRequest?: UploadProps['httpRequest']
}>(),
{
name: 'file',
@@ -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"
>
@@ -151,7 +153,7 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
</div>
</template>
<style lang="scss" scoped>
<style scoped>
.upload-container {
line-height: initial;
}
@@ -178,14 +180,16 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
transition: opacity 0.3s;
.actions {
position: absolute;
top: 50%;
left: 50%;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
width: 100px;
height: 100px;
@include position-center(xy);
transform: translateX(-50%) translateY(-50%);
span {
width: 50%;
@@ -258,9 +262,11 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
}
.el-progress {
position: absolute;
top: 50%;
left: 50%;
z-index: 1;
@include position-center(xy);
transform: translateX(-50%) translateY(-50%);
.el-progress__text {
color: var(--el-text-color-placeholder);
+172
View File
@@ -0,0 +1,172 @@
<script setup lang="ts">
import type { FormInstance, FormRules } from 'element-plus'
import useUserStore from '@/store/modules/user'
defineOptions({
name: 'LoginForm',
})
const props = defineProps<{
account?: string
}>()
const emits = defineEmits<{
onLogin: [account: string]
onRegister: [account: string]
onResetPassword: [account: string]
}>()
const userStore = useUserStore()
const title = import.meta.env.VITE_APP_TITLE
const loading = ref(false)
// 登录方式,default 账号密码登录,qrcode 扫码登录
const type = ref('default')
const formRef = ref<FormInstance>()
const form = ref({
account: props.account ?? localStorage.login_account ?? '',
password: '',
remember: !!localStorage.login_account,
})
const rules = ref<FormRules>({
account: [
{ required: true, trigger: 'blur', message: '请输入用户名' },
],
password: [
{ required: true, trigger: 'blur', message: '请输入密码' },
{ min: 6, max: 18, trigger: 'blur', message: '密码长度为6到18位' },
],
})
function handleLogin() {
formRef.value?.validate((valid) => {
if (valid) {
loading.value = true
userStore.login(form.value).then(() => {
if (form.value.remember) {
localStorage.setItem('login_account', form.value.account)
}
else {
localStorage.removeItem('login_account')
}
emits('onLogin', form.value.account)
}).finally(() => {
loading.value = false
})
}
})
}
function testAccount(account: string) {
form.value.account = account
form.value.password = '123456'
handleLogin()
}
</script>
<template>
<ElForm ref="formRef" :model="form" :rules="rules" class="min-h-500px w-full flex-col-stretch-center p-12">
<div class="mb-6">
<HTabList
v-model="type" :options="[
{ label: '账号密码登录', value: 'default' },
{ label: '扫码登录', value: 'qrcode' },
]"
/>
</div>
<template v-if="type === 'default'">
<h3 class="mb-8 text-xl color-[var(--el-text-color-primary)] font-bold">
欢迎使用 {{ title }} ! 👋🏻
</h3>
<div>
<ElFormItem prop="account">
<ElInput v-model="form.account" placeholder="用户名" type="text" tabindex="1">
<template #prefix>
<SvgIcon name="i-ri:user-3-fill" />
</template>
</ElInput>
</ElFormItem>
<ElFormItem prop="password">
<ElInput v-model="form.password" type="password" placeholder="密码" tabindex="2" show-password @keyup.enter="handleLogin">
<template #prefix>
<SvgIcon name="i-ri:lock-2-fill" />
</template>
</ElInput>
</ElFormItem>
</div>
<div class="mb-4 flex-center-between">
<ElCheckbox v-model="form.remember">
记住我
</ElCheckbox>
<ElLink type="primary" :underline="false" @click="emits('onResetPassword', form.account)">
忘记密码了?
</ElLink>
</div>
<ElButton :loading="loading" type="primary" size="large" style="width: 100%;" @click.prevent="handleLogin">
登录
</ElButton>
<div class="mt-4 flex-center gap-2 text-sm color-[var(--el-text-color-secondary)]">
还没有帐号?
<ElLink type="primary" :underline="false" @click="emits('onRegister', form.account)">
创建新帐号
</ElLink>
</div>
</template>
<template v-else-if="type === 'qrcode'">
<div class="flex-col-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 class="mt-4 text-center -mb-4">
<ElDivider>演示账号一键登录</ElDivider>
<ElButton type="primary" size="small" plain @click="testAccount('admin')">
admin
</ElButton>
<ElButton size="small" plain @click="testAccount('test')">
test
</ElButton>
</div>
</ElForm>
</template>
<style scoped>
:deep(input[type="password"]::-ms-reveal) {
display: none;
}
.el-form-item {
margin-bottom: 24px;
:deep(.el-input) {
width: 100%;
height: 48px;
line-height: inherit;
input {
height: 48px;
}
.el-input__prefix,
.el-input__suffix {
display: flex;
align-items: center;
}
.el-input__prefix {
left: 10px;
}
.el-input__suffix {
right: 10px;
}
}
}
:deep(.el-divider__text) {
white-space: nowrap;
background-color: var(--g-container-bg);
}
</style>
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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>
+148
View File
@@ -0,0 +1,148 @@
<script setup lang="ts">
import type { FormInstance, FormRules } from 'element-plus'
import { ElMessage } from 'element-plus'
defineOptions({
name: 'RegisterForm',
})
const props = defineProps<{
account?: string
}>()
const emits = defineEmits<{
onLogin: [account: string]
onRegister: [account: string]
}>()
const loading = ref(false)
const formRef = ref<FormInstance>()
const form = ref({
account: props.account ?? '',
captcha: '',
password: '',
checkPassword: '',
})
const rules = ref<FormRules>({
account: [
{ required: true, trigger: 'blur', message: '请输入用户名' },
],
captcha: [
{ required: true, trigger: 'blur', message: () => '请输入验证码' },
],
password: [
{ required: true, trigger: 'blur', message: '请输入密码' },
{ min: 6, max: 18, trigger: 'blur', message: '密码长度为6到18位' },
],
checkPassword: [
{ required: true, trigger: 'blur', message: '请再次输入密码' },
{
validator: (rule, value, callback) => {
if (value !== form.value.password) {
callback(new Error('两次输入的密码不一致'))
}
else {
callback()
}
},
},
],
})
function handleRegister() {
ElMessage({
message: '注册模块仅提供界面演示,无实际功能,需开发者自行扩展',
type: 'warning',
})
formRef.value?.validate((valid) => {
if (valid) {
// 这里编写业务代码
emits('onRegister', form.value.account)
}
})
}
</script>
<template>
<ElForm ref="formRef" :model="form" :rules="rules" class="min-h-500px w-full flex-col-stretch-center p-12">
<h3 class="mb-8 text-xl color-[var(--el-text-color-primary)] font-bold">
探索从这里开始! 🚀
</h3>
<div>
<ElFormItem prop="account">
<ElInput v-model="form.account" placeholder="用户名" tabindex="1">
<template #prefix>
<SvgIcon name="i-ri:user-3-fill" />
</template>
</ElInput>
</ElFormItem>
<ElFormItem prop="captcha">
<ElInput v-model="form.captcha" placeholder="验证码" tabindex="2">
<template #prefix>
<SvgIcon name="i-ic:baseline-verified-user" />
</template>
<template #append>
<ElButton>发送验证码</ElButton>
</template>
</ElInput>
</ElFormItem>
<ElFormItem prop="password">
<ElInput v-model="form.password" type="password" placeholder="密码" tabindex="3" show-password>
<template #prefix>
<SvgIcon name="i-ri:lock-2-fill" />
</template>
</ElInput>
</ElFormItem>
<ElFormItem prop="checkPassword">
<ElInput v-model="form.checkPassword" type="password" placeholder="确认密码" tabindex="4" show-password>
<template #prefix>
<SvgIcon name="i-ri:lock-2-fill" />
</template>
</ElInput>
</ElFormItem>
</div>
<ElButton :loading="loading" type="primary" size="large" style="width: 100%; margin-top: 20px;" @click.prevent="handleRegister">
注册
</ElButton>
<div class="mt-4 flex-center gap-2 text-sm color-[var(--el-text-color-secondary)]">
已经有帐号?
<ElLink type="primary" :underline="false" @click="emits('onLogin', form.account)">
去登录
</ElLink>
</div>
</ElForm>
</template>
<style scoped>
:deep(input[type="password"]::-ms-reveal) {
display: none;
}
.el-form-item {
margin-bottom: 24px;
:deep(.el-input) {
width: 100%;
height: 48px;
line-height: inherit;
input {
height: 48px;
}
.el-input__prefix,
.el-input__suffix {
display: flex;
align-items: center;
}
.el-input__prefix {
left: 10px;
}
.el-input__suffix {
right: 10px;
}
}
}
</style>
+126
View File
@@ -0,0 +1,126 @@
<script setup lang="ts">
import type { FormInstance, FormRules } from 'element-plus'
import { ElMessage } from 'element-plus'
defineOptions({
name: 'ResetPasswordForm',
})
const props = defineProps<{
account?: string
}>()
const emits = defineEmits<{
onLogin: [account: string]
onResetPassword: [account: string]
}>()
const loading = ref(false)
const formRef = ref<FormInstance>()
const form = ref({
account: props.account ?? localStorage.login_account ?? '',
captcha: '',
newPassword: '',
})
const rules = ref<FormRules>({
account: [
{ required: true, trigger: 'blur', message: '请输入用户名' },
],
captcha: [
{ required: true, trigger: 'blur', message: '请输入验证码' },
],
newPassword: [
{ required: true, trigger: 'blur', message: '请输入新密码' },
{ min: 6, max: 18, trigger: 'blur', message: '密码长度为6到18位' },
],
})
function handleReset() {
ElMessage({
message: '重置密码仅提供界面演示,无实际功能,需开发者自行扩展',
type: 'info',
})
formRef.value?.validate((valid) => {
if (valid) {
// 这里编写业务代码
emits('onResetPassword', form.value.account)
}
})
}
</script>
<template>
<ElForm ref="formRef" :model="form" :rules="rules" class="min-h-500px w-full flex-col-stretch-center p-12">
<h3 class="mb-8 text-xl color-[var(--el-text-color-primary)] font-bold">
忘记密码了? 🔒
</h3>
<div>
<ElFormItem prop="account">
<ElInput v-model="form.account" placeholder="用户名" type="text" tabindex="1">
<template #prefix>
<SvgIcon name="i-ri:user-3-fill" />
</template>
</ElInput>
</ElFormItem>
<ElFormItem prop="captcha">
<ElInput v-model="form.captcha" placeholder="验证码" type="text" tabindex="2">
<template #prefix>
<SvgIcon name="i-ic:baseline-verified-user" />
</template>
<template #append>
<ElButton>发送验证码</ElButton>
</template>
</ElInput>
</ElFormItem>
<ElFormItem prop="newPassword">
<ElInput v-model="form.newPassword" type="password" placeholder="新密码" tabindex="3" show-password>
<template #prefix>
<SvgIcon name="i-ri:lock-2-fill" />
</template>
</ElInput>
</ElFormItem>
</div>
<ElButton :loading="loading" type="primary" size="large" style="width: 100%; margin-top: 20px;" @click.prevent="handleReset">
确认
</ElButton>
<div class="mt-4 flex-center gap-2 text-sm color-[var(--el-text-color-secondary)]">
<ElLink type="primary" :underline="false" @click="emits('onLogin', form.account)">
去登录
</ElLink>
</div>
</ElForm>
</template>
<style scoped>
:deep(input[type="password"]::-ms-reveal) {
display: none;
}
.el-form-item {
margin-bottom: 24px;
:deep(.el-input) {
width: 100%;
height: 48px;
line-height: inherit;
input {
height: 48px;
}
.el-input__prefix,
.el-input__suffix {
display: flex;
align-items: center;
}
.el-input__prefix {
left: 10px;
}
.el-input__suffix {
right: 10px;
}
}
}
</style>
+16 -4
View File
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { UseImage } from '@vueuse/components'
import { Icon } from '@iconify/vue'
defineOptions({
@@ -14,7 +15,10 @@ const props = defineProps<{
}>()
const outputType = computed(() => {
if (/^https?:\/\//.test(props.name)) {
const hasPathFeatures = (str: string) => {
return /^\.{1,2}\//.test(str) || str.startsWith('/') || str.includes('/')
}
if (/^https?:\/\//.test(props.name) || hasPathFeatures(props.name) || !props.name) {
return 'img'
}
else if (/i-[^:]+:[^:]+/.test(props.name)) {
@@ -56,11 +60,19 @@ const style = computed(() => {
</script>
<template>
<i class="relative h-[1em] w-[1em] flex-inline items-center justify-center fill-current leading-[1em]" :class="{ [name]: outputType === 'unocss' }" :style="style">
<Icon v-if="outputType === 'iconify'" :icon="name" />
<i class="relative h-[1em] w-[1em] flex-inline items-center justify-center fill-current leading-[1em]" :style="style">
<i v-if="outputType === 'unocss'" class="h-[1em] w-[1em]" :class="name" />
<Icon v-else-if="outputType === 'iconify'" :icon="name" />
<svg v-else-if="outputType === 'svg'" class="h-[1em] w-[1em]" aria-hidden="true">
<use :xlink:href="`#icon-${name}`" />
</svg>
<img v-else-if="outputType === 'img'" :src="name" class="h-[1em] w-[1em]">
<UseImage v-else-if="outputType === 'img'" :src="name" class="h-[1em] w-[1em]">
<template #loading>
<i class="i-line-md:loading-loop h-[1em] w-[1em]" />
</template>
<template #error>
<i class="i-tdesign:image-error h-[1em] w-[1em]" />
</template>
</UseImage>
</i>
</template>
+2 -10
View File
@@ -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>
+44 -29
View File
@@ -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">
动态标题
@@ -345,96 +360,96 @@ function handleCopy() {
</HSlideover>
</template>
<style lang="scss" scoped>
<style scoped>
.divider {
--at-apply: flex items-center justify-between gap-4 my-4 whitespace-nowrap text-sm font-500;
--uno: flex items-center justify-between gap-4 my-4 whitespace-nowrap text-sm font-500;
&::before,
&::after {
--at-apply: content-empty w-full h-1px bg-stone-2 dark:bg-stone-6;
--uno: content-empty w-full h-1px bg-stone-2 dark-bg-stone-6;
}
}
.menu-mode {
--at-apply: flex items-center justify-center gap-4 pb-4;
--uno: 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;
--uno: 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;
--uno: ring-ui-primary ring-2;
}
&::before,
&::after,
.mode-container {
--at-apply: absolute pointer-events-none;
--uno: absolute pointer-events-none;
}
&::before {
--at-apply: content-empty bg-ui-primary;
--uno: content-empty bg-ui-primary;
}
&::after {
--at-apply: content-empty bg-ui-primary/60;
--uno: content-empty bg-ui-primary/60;
}
.mode-container {
--at-apply: bg-ui-primary/20 border-dashed border-ui-primary;
--uno: bg-ui-primary/20 border-width-1.5 border-dashed border-ui-primary;
&::before {
--at-apply: content-empty absolute w-full h-full;
--uno: content-empty absolute w-full h-full;
}
}
&-side {
&::before {
--at-apply: top-2 bottom-2 left-2 w-2 rounded-tl-1 rounded-bl-1;
--uno: top-2 bottom-2 left-2 w-2 rounded-tl-1 rounded-bl-1;
}
&::after {
--at-apply: top-2 bottom-2 left-4.5 w-3;
--uno: top-2 bottom-2 left-4.5 w-3;
}
.mode-container {
--at-apply: inset-t-2 inset-r-2 inset-b-2 inset-l-8 rounded-tr-1 rounded-br-1;
--uno: inset-t-2 inset-r-2 inset-b-2 inset-l-8 rounded-tr-1 rounded-br-1;
}
}
&-head {
&::before {
--at-apply: top-2 left-2 right-2 h-2 rounded-tl-1 rounded-tr-1;
--uno: top-2 left-2 right-2 h-2 rounded-tl-1 rounded-tr-1;
}
&::after {
--at-apply: top-4.5 left-2 bottom-2 w-3 rounded-bl-1;
--uno: top-4.5 left-2 bottom-2 w-3 rounded-bl-1;
}
.mode-container {
--at-apply: inset-t-4.5 inset-r-2 inset-b-2 inset-l-5.5 rounded-br-1;
--uno: inset-t-4.5 inset-r-2 inset-b-2 inset-l-5.5 rounded-br-1;
}
}
&-single {
&::after {
--at-apply: top-2 left-2 bottom-2 w-3 rounded-tl-1 rounded-bl-1;
--uno: top-2 left-2 bottom-2 w-3 rounded-tl-1 rounded-bl-1;
}
.mode-container {
--at-apply: inset-t-2 inset-r-2 inset-b-2 inset-l-5.5 rounded-tr-1 rounded-br-1;
--uno: inset-t-2 inset-r-2 inset-b-2 inset-l-5.5 rounded-tr-1 rounded-br-1;
}
}
}
}
.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;
--uno: 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;
--uno: flex items-center flex-shrink-0 gap-2 text-sm;
i {
--at-apply: text-xl text-orange cursor-help;
--uno: text-xl text-orange cursor-help;
}
}
}
+5 -5
View File
@@ -5,11 +5,11 @@ defineOptions({
const transitionClass = {
enterActiveClass: 'ease-out duration-300',
enterFromClass: 'opacity-0 translate-y-4 lg:translate-y-0 lg:scale-95',
enterToClass: 'opacity-100 translate-y-0 lg: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 lg:scale-100',
leaveToClass: 'opacity-0 translate-y-4 lg:translate-y-0 lg: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>
+1 -1
View File
@@ -4,7 +4,7 @@
</div>
</template>
<style lang="scss" scoped>
<style scoped>
:deep(.breadcrumb-item) {
&:first-child {
.separator {
+2 -2
View File
@@ -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 />
+4 -4
View File
@@ -21,17 +21,17 @@ const settingsStore = useSettingsStore()
</footer>
</template>
<style lang="scss" scoped>
<style scoped>
.copyright {
--at-apply: flex items-center justify-center flex-wrap my-4 px-4 text-sm text-stone-5;
--uno: flex items-center justify-center flex-wrap my-4 px-4 text-sm text-stone-5;
span,
a {
--at-apply: px-1;
--uno: px-1;
}
a {
--at-apply: text-center no-underline text-stone-5 hover:text-dark dark:hover:text-light transition;
--uno: text-center no-underline text-stone-5 hover-text-dark dark-hover-text-light transition;
}
}
</style>
+12 -16
View File
@@ -27,25 +27,25 @@ function handlerMouserScroll(event: WheelEvent) {
<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">
<Logo class="title" />
<div ref="menuRef" class="menu-container" @wheel.prevent="handlerMouserScroll">
<div ref="menuRef" class="menu-container scrollbar-none" @wheel.prevent="handlerMouserScroll">
<!-- 顶部模式 -->
<div class="menu flex of-hidden transition-all">
<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 transition-all" :class="{
class="menu-item relative mx-1 py-2 transition-all" :class="{
active: index === menuStore.actived,
}"
>
<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="{
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 />
<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>
@@ -61,7 +61,7 @@ function handlerMouserScroll(event: WheelEvent) {
</Transition>
</template>
<style lang="scss" scoped>
<style scoped>
header {
position: fixed;
top: 0;
@@ -115,14 +115,6 @@ header {
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%;
@@ -135,6 +127,10 @@ header {
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 {
@@ -147,7 +143,7 @@ header {
}
}
// 头部动画
/* 头部动画 */
.header-enter-active,
.header-leave-active {
transition: transform 0.3s;
@@ -20,7 +20,7 @@ onMounted(() => {
<template>
<HDialog v-model="isShow" title="快捷键介绍">
<div class="px-4">
<div class="grid gap-2 sm: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>
+24 -30
View File
@@ -15,36 +15,38 @@ 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 scrollbar-none">
<!-- 侧边栏模式(含主导航) -->
<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>
</template>
<style lang="scss" scoped>
<style scoped>
.main-sidebar-container {
position: relative;
z-index: 1;
@@ -67,14 +69,6 @@ const { switchTo } = useMenu()
overflow: hidden auto;
overscroll-behavior: contain;
// firefox隐藏滚动条
scrollbar-width: none;
// chrome隐藏滚动条
&::-webkit-scrollbar {
display: none;
}
:deep(.menu-item) {
.menu-item-container {
padding-block: 8px;
@@ -86,7 +80,7 @@ const { switchTo } = useMenu()
}
.menu-item-container-icon {
font-size: 24px !important;
font-size: 20px !important;
}
}
@@ -98,7 +92,7 @@ const { switchTo } = useMenu()
}
}
// 主侧边栏动画
/* 主侧边栏动画 */
.main-sidebar-enter-active,
.main-sidebar-leave-active {
transition: 0.3s;
+7 -7
View File
@@ -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 in menu" :key="item.path ?? JSON.stringify(item)">
<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-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>
+9 -3
View File
@@ -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="{
+6 -2
View File
@@ -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,8 +187,9 @@ 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)">
+1 -2
View File
@@ -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[]
+13 -13
View File
@@ -28,11 +28,11 @@ const overlayTransitionClass = ref({
const transitionClass = computed(() => {
return {
enter: 'ease-out duration-300',
enterFrom: 'opacity-0 translate-y-4 lg:translate-y-0 lg:scale-95',
enterTo: 'opacity-100 translate-y-0 lg: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 lg:scale-100',
leaveTo: 'opacity-0 translate-y-4 lg:translate-y-0 lg:scale-95',
leaveFrom: 'opacity-100 translate-y-0 lg-scale-100',
leaveTo: 'opacity-0 translate-y-4 lg-translate-y-0 lg-scale-95',
}
})
@@ -245,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 lg:items-center">
<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 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">
<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">
@@ -281,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>
+39 -25
View File
@@ -25,34 +25,52 @@ 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
ref="subSidebarRef" class="sub-sidebar flex-1 transition-shadow-300" :class="{
ref="subSidebarRef" class="sub-sidebar flex-1 transition-shadow-300 scrollbar-none" :class="{
'shadow-top': showShadowTop,
'shadow-bottom': showShadowBottom,
}" @scroll="onSidebarScroll"
@@ -61,21 +79,25 @@ 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>
</div>
</template>
<style lang="scss" scoped>
<style scoped>
.sub-sidebar-container {
position: absolute;
top: 0;
@@ -118,14 +140,6 @@ onMounted(() => {
overflow: hidden auto;
overscroll-behavior: contain;
// firefox隐藏滚动条
scrollbar-width: none;
// chrome隐藏滚动条
&::-webkit-scrollbar {
display: none;
}
&.shadow-top {
box-shadow: inset 0 10px 10px -10px var(--g-box-shadow-color), inset 0 0 0 transparent;
}
@@ -144,7 +158,7 @@ onMounted(() => {
}
}
// 次侧边栏动画
/* 次侧边栏动画 */
.sub-sidebar-enter-active {
transition: 0.2s;
}
+38 -52
View File
@@ -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({
@@ -77,7 +75,7 @@ function onTabbarContextmenu(event: MouseEvent, routeItem: Tabbar.recordRaw) {
y: event.y,
zIndex: 1050,
iconFontClass: '',
customClass: 'contextmenu-custom',
customClass: 'tabbar-contextmenu',
items: [
{
label: '重新加载',
@@ -166,13 +164,13 @@ 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>
<template>
<div class="tabbar-container">
<div ref="tabsRef" class="tabs" @wheel.prevent="handlerMouserScroll">
<div ref="tabsRef" class="tabs scrollbar-none" @wheel.prevent="handlerMouserScroll">
<TransitionGroup ref="tabContainerRef" name="tabbar" tag="div" class="tab-container">
<div
v-for="(element, index) in tabbarStore.list" :key="element.tabId"
@@ -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 }}
@@ -200,48 +198,44 @@ onUnmounted(() => {
</div>
</template>
<style lang="scss">
.mx-menu-ghost-host {
z-index: 1000;
<style>
.tabbar-contextmenu {
--uno: fixed ring-1 ring-stone-2 dark-ring-stone-7 shadow-2xl;
.mx-context-menu {
--at-apply: fixed ring-1 ring-stone-2 dark:ring-stone-7 shadow-2xl;
background-color: var(--g-container-bg);
background-color: var(--g-container-bg);
.mx-context-menu-items .mx-context-menu-item {
--uno: transition-background-color;
.mx-context-menu-items .mx-context-menu-item {
--at-apply: transition-background-color;
&:not(.disabled):hover {
--at-apply: cursor-pointer bg-stone-1 dark:bg-stone-9;
}
span {
color: initial;
}
.icon {
color: initial;
}
&.disabled span,
&.disabled .icon {
opacity: 0.25;
}
&:not(.disabled):hover {
--uno: cursor-pointer bg-stone-1 dark-bg-stone-9;
}
.mx-context-menu-item-sperator {
background-color: var(--g-container-bg);
span {
color: initial;
}
&::after {
--at-apply: bg-stone-2 dark:bg-stone-7;
}
.icon {
color: initial;
}
&.disabled span,
&.disabled .icon {
opacity: 0.25;
}
}
.mx-context-menu-item-sperator {
background-color: var(--g-container-bg);
&::after {
--uno: bg-stone-2 dark-bg-stone-7;
}
}
}
</style>
<style lang="scss" scoped>
<style scoped>
.tabbar-container {
position: relative;
height: var(--g-tabbar-height);
@@ -255,14 +249,6 @@ onUnmounted(() => {
overflow-y: hidden;
white-space: nowrap;
// firefox隐藏滚动条
scrollbar-width: none;
// chrome隐藏滚动条
&::-webkit-scrollbar {
display: none;
}
.tab-container {
display: inline-block;
@@ -412,14 +398,14 @@ onUnmounted(() => {
transform: translateY(-50%);
&:hover {
--at-apply: ring-1 ring-stone-3 dark:ring-stone-7;
--uno: 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;
--uno: ring-1 ring-stone-3 dark-ring-stone-7;
position: absolute;
top: 50%;
@@ -442,7 +428,7 @@ onUnmounted(() => {
}
}
// 标签栏动画
/* 标签栏动画 */
.tabs {
.tabbar-move,
.tabbar-enter-active,
@@ -45,8 +45,8 @@ function pathCompile(path: string) {
</Breadcrumb>
</template>
<style lang="scss" scoped>
// 面包屑动画
<style scoped>
/* 面包屑动画 */
.breadcrumb-enter-active {
transition: transform 0.3s, opacity 0.3s;
}
@@ -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,13 +15,13 @@ 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>
</template>
<style lang="scss" scoped>
<style scoped>
.toolbar-container {
height: var(--g-toolbar-height);
background-color: var(--g-container-bg);
@@ -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"
>
+2 -2
View File
@@ -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'
)
)
@@ -53,7 +53,7 @@ watch(scrollTop, (val, oldVal) => {
</div>
</template>
<style lang="scss" scoped>
<style scoped>
.topbar-container {
position: absolute;
top: 0;
+2 -2
View File
@@ -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)">
@@ -46,7 +46,7 @@ function open() {
</div>
</template>
<style lang="scss" scoped>
<style scoped>
.slide-right-enter-active {
transition: 0.2s;
}
+30 -4
View File
@@ -28,6 +28,27 @@ const menuStore = useMenuStore()
const mainPage = useMainPage()
const menu = useMenu()
// 侧边栏主导航当前实际宽度
const mainSidebarActualWidth = computed(() => {
let actualWidth = Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--g-main-sidebar-width'))
if (settingsStore.settings.menu.mode === 'single' || (settingsStore.settings.menu.mode === 'head' && settingsStore.mode !== 'mobile')) {
actualWidth = 0
}
return `${actualWidth}px`
})
// 侧边栏次导航当前实际宽度
const subSidebarActualWidth = computed(() => {
let actualWidth = Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--g-sub-sidebar-width'))
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`
})
const isLink = computed(() => !!routeInfo.meta.link)
watch(() => settingsStore.settings.menu.subMenuCollapse, (val) => {
@@ -72,7 +93,12 @@ const enableAppSetting = import.meta.env.VITE_APP_SETTING === 'true'
</script>
<template>
<div class="layout">
<div
class="layout" :style="{
'--g-main-sidebar-actual-width': mainSidebarActualWidth,
'--g-sub-sidebar-actual-width': subSidebarActualWidth,
}"
>
<div id="app-main">
<Header />
<div class="wrapper">
@@ -109,7 +135,7 @@ const enableAppSetting = import.meta.env.VITE_APP_SETTING === 'true'
</div>
</template>
<style lang="scss" scoped>
<style scoped>
[data-mode="mobile"] {
.sidebar-container {
transform: translateX(calc((var(--g-main-sidebar-width) + var(--g-sub-sidebar-width)) * -1));
@@ -240,7 +266,7 @@ header:not(.header-leave-active) + .wrapper {
}
.app-setting {
--at-apply: text-white dark:text-dark bg-ui-primary;
--uno: text-white dark-text-dark bg-ui-primary;
position: fixed;
top: calc(50% + 250px);
@@ -271,7 +297,7 @@ header:not(.header-leave-active) + .wrapper {
}
}
// 主内容区动画
/* 主内容区动画 */
.slide-right-enter-active {
transition: 0.2s;
}
+3 -3
View File
@@ -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>
+2 -2
View File
@@ -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 }}
+8 -8
View File
@@ -37,11 +37,11 @@ const overlayTransitionClass = ref({
const transitionClass = computed(() => {
return {
enter: 'ease-out duration-300',
enterFrom: 'opacity-0 translate-y-4 lg:translate-y-0 lg:scale-95',
enterTo: 'opacity-100 translate-y-0 lg: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 lg:scale-100',
leaveTo: 'opacity-0 translate-y-4 lg:translate-y-0 lg: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 lg:items-center">
<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 lg:my-8 lg: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" />
+2 -2
View File
@@ -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>
+2 -2
View File
@@ -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 -1
View File
@@ -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>
+3 -3
View File
@@ -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>
+3 -3
View File
@@ -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" />
+4 -4
View File
@@ -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 whitespace-nowrap 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" />
+3 -3
View File
@@ -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>
+1 -1
View File
@@ -26,7 +26,7 @@ import icons from '@/iconify/index.json'
import 'virtual:uno.css'
// 全局样式
import '@/assets/styles/globals.scss'
import '@/assets/styles/globals.css'
const app = createApp(App)
app.use(FloatingVue, {
+1 -1
View File
@@ -12,7 +12,7 @@ export default defineFakeRoute([
data: Mock.mock({
account: body.account,
token: `${body.account}_@string`,
avatar: 'https://fantastic-admin.github.io/logo.png',
avatar: 'https://fantastic-admin.hurui.me/logo.png',
}),
}
},
+210
View File
@@ -0,0 +1,210 @@
import type { RouteRecordRaw, Router } from 'vue-router'
import { useNProgress } from '@vueuse/integrations/useNProgress'
import '@/assets/styles/nprogress.css'
import { asyncRoutes, asyncRoutesByFilesystem } from './routes'
import useSettingsStore from '@/store/modules/settings'
import useUserStore from '@/store/modules/user'
import useRouteStore from '@/store/modules/route'
import useMenuStore from '@/store/modules/menu'
import useKeepAliveStore from '@/store/modules/keepAlive'
function setupRoutes(router: Router) {
router.beforeEach(async (to, from, next) => {
const settingsStore = useSettingsStore()
const userStore = useUserStore()
const routeStore = useRouteStore()
const menuStore = useMenuStore()
// 是否已登录
if (userStore.isLogin) {
// 是否已根据权限动态生成并注册路由
if (routeStore.isGenerate) {
// 导航栏如果不是 single 模式,则需要根据 path 定位主导航的选中状态
settingsStore.settings.menu.mode !== 'single' && menuStore.setActived(to.path)
// 如果已登录状态下,进入登录页会强制跳转到主页
if (to.name === 'login') {
next({
path: settingsStore.settings.home.fullPath,
replace: true,
})
}
// 如果未开启主页,但进入的是主页,则会进入侧边栏导航第一个模块
else if (!settingsStore.settings.home.enable && to.fullPath === settingsStore.settings.home.fullPath) {
if (menuStore.sidebarMenus.length > 0) {
next({
path: menuStore.sidebarMenusFirstDeepestPath,
replace: true,
})
}
// 如果侧边栏导航第一个模块均无法命中,则还是进入主页
else {
next()
}
}
// 正常访问页面
else {
next()
}
}
else {
// 获取用户权限
settingsStore.settings.app.enablePermission && await userStore.getPermissions()
// 生成动态路由
switch (settingsStore.settings.app.routeBaseOn) {
case 'frontend':
routeStore.generateRoutesAtFront(asyncRoutes)
break
case 'backend':
await routeStore.generateRoutesAtBack()
break
case 'filesystem':
routeStore.generateRoutesAtFilesystem(asyncRoutesByFilesystem)
// 文件系统生成的路由,需要手动生成导航数据
switch (settingsStore.settings.menu.baseOn) {
case 'frontend':
menuStore.generateMenusAtFront()
break
case 'backend':
await menuStore.generateMenusAtBack()
break
}
break
}
// 注册并记录路由数据
// 记录的数据会在登出时会使用到,不使用 router.removeRoute 是考虑配置的路由可能不一定有设置 name ,则通过调用 router.addRoute() 返回的回调进行删除
const removeRoutes: (() => void)[] = []
routeStore.flatRoutes.forEach((route) => {
if (!/^(?:https?:|mailto:|tel:)/.test(route.path)) {
removeRoutes.push(router.addRoute(route as RouteRecordRaw))
}
})
if (settingsStore.settings.app.routeBaseOn !== 'filesystem') {
routeStore.flatSystemRoutes.forEach((route) => {
removeRoutes.push(router.addRoute(route as RouteRecordRaw))
})
}
routeStore.setCurrentRemoveRoutes(removeRoutes)
// 动态路由生成并注册后,重新进入当前路由
next({
path: to.path,
query: to.query,
replace: true,
})
}
}
else {
if (to.name !== 'login') {
next({
name: 'login',
query: {
redirect: to.fullPath !== settingsStore.settings.home.fullPath ? to.fullPath : undefined,
},
})
}
else {
next()
}
}
})
}
// 进度条
function setupProgress(router: Router) {
const { isLoading } = useNProgress()
router.beforeEach((to, from, next) => {
const settingsStore = useSettingsStore()
if (settingsStore.settings.app.enableProgress) {
isLoading.value = true
}
next()
})
router.afterEach(() => {
const settingsStore = useSettingsStore()
if (settingsStore.settings.app.enableProgress) {
isLoading.value = false
}
})
}
// 标题
function setupTitle(router: Router) {
router.afterEach((to) => {
const settingsStore = useSettingsStore()
if (settingsStore.settings.app.routeBaseOn !== 'filesystem') {
settingsStore.setTitle(to.meta.breadcrumbNeste?.at(-1)?.title ?? to.meta.title)
}
else {
settingsStore.setTitle(to.meta.title)
}
})
}
// 页面缓存
function setupKeepAlive(router: Router) {
router.afterEach((to, from) => {
const keepAliveStore = useKeepAliveStore()
// 判断当前页面是否开启缓存,如果开启,则将当前页面的 name 信息存入 keep-alive 全局状态
if (to.meta.cache) {
const componentName = to.matched.at(-1)?.components?.default.name
if (componentName) {
keepAliveStore.add(componentName)
}
else {
// turbo-console-disable-next-line
console.warn('[Fantastic-admin] 该页面组件未设置组件名,会导致缓存失效,请检查')
}
}
// 判断离开页面是否开启缓存,如果开启,则根据缓存规则判断是否需要清空 keep-alive 全局状态里离开页面的 name 信息
if (from.meta.cache) {
const componentName = from.matched.at(-1)?.components?.default.name
if (componentName) {
// 通过 meta.cache 判断针对哪些页面进行缓存
switch (typeof from.meta.cache) {
case 'string':
if (from.meta.cache !== to.name) {
keepAliveStore.remove(componentName)
}
break
case 'object':
if (!from.meta.cache.includes(to.name as string)) {
keepAliveStore.remove(componentName)
}
break
}
// 通过 meta.noCache 判断针对哪些页面不需要进行缓存
if (from.meta.noCache) {
switch (typeof from.meta.noCache) {
case 'string':
if (from.meta.noCache === to.name) {
keepAliveStore.remove(componentName)
}
break
case 'object':
if (from.meta.noCache.includes(to.name as string)) {
keepAliveStore.remove(componentName)
}
break
}
}
// 如果进入的是 reload 页面,则也将离开页面的缓存清空
if (to.name === 'reload') {
keepAliveStore.remove(componentName)
}
}
}
})
}
// 其他
function setupOther(router: Router) {
router.afterEach(() => {
document.documentElement.scrollTop = 0
})
}
export default function setupGuards(router: Router) {
setupRoutes(router)
setupProgress(router)
setupTitle(router)
setupKeepAlive(router)
setupOther(router)
}
+4 -174
View File
@@ -1,186 +1,16 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import { useNProgress } from '@vueuse/integrations/useNProgress'
import '@/assets/styles/nprogress.scss'
import setupGuards from './guards'
// 路由相关数据
import { asyncRoutes, asyncRoutesByFilesystem, constantRoutes, constantRoutesByFilesystem } from './routes'
import { constantRoutes, constantRoutesByFilesystem } from './routes'
import pinia from '@/store'
import useSettingsStore from '@/store/modules/settings'
import useKeepAliveStore from '@/store/modules/keepAlive'
import useUserStore from '@/store/modules/user'
import useRouteStore from '@/store/modules/route'
import useMenuStore from '@/store/modules/menu'
const { isLoading } = useNProgress()
const router = createRouter({
history: createWebHashHistory(),
routes: useSettingsStore(pinia).settings.app.routeBaseOn === 'filesystem' ? constantRoutesByFilesystem : constantRoutes as RouteRecordRaw[],
routes: useSettingsStore(pinia).settings.app.routeBaseOn === 'filesystem' ? constantRoutesByFilesystem : constantRoutes,
})
router.beforeEach(async (to, from, next) => {
const settingsStore = useSettingsStore()
const userStore = useUserStore()
const routeStore = useRouteStore()
const menuStore = useMenuStore()
settingsStore.settings.app.enableProgress && (isLoading.value = true)
// 是否已登录
if (userStore.isLogin) {
// 是否已根据权限动态生成并注册路由
if (routeStore.isGenerate) {
// 导航栏如果不是 single 模式,则需要根据 path 定位主导航的选中状态
settingsStore.settings.menu.menuMode !== 'single' && menuStore.setActived(to.path)
// 如果已登录状态下,进入登录页会强制跳转到主页
if (to.name === 'login') {
next({
path: settingsStore.settings.home.fullPath,
replace: true,
})
}
// 如果未开启主页,但进入的是主页,则会进入侧边栏导航第一个模块
else if (!settingsStore.settings.home.enable && to.fullPath === settingsStore.settings.home.fullPath) {
if (menuStore.sidebarMenus.length > 0) {
next({
path: menuStore.sidebarMenusFirstDeepestPath,
replace: true,
})
}
// 如果侧边栏导航第一个模块均无法命中,则还是进入主页
else {
next()
}
}
// 正常访问页面
else {
next()
}
}
else {
// 获取用户权限
settingsStore.settings.app.enablePermission && await userStore.getPermissions()
// 生成动态路由
switch (settingsStore.settings.app.routeBaseOn) {
case 'frontend':
routeStore.generateRoutesAtFront(asyncRoutes)
break
case 'backend':
await routeStore.generateRoutesAtBack()
break
case 'filesystem':
routeStore.generateRoutesAtFilesystem(asyncRoutesByFilesystem)
// 文件系统生成的路由,需要手动生成导航数据
switch (settingsStore.settings.menu.baseOn) {
case 'frontend':
menuStore.generateMenusAtFront()
break
case 'backend':
await menuStore.generateMenusAtBack()
break
}
break
}
// 注册并记录路由数据
// 记录的数据会在登出时会使用到,不使用 router.removeRoute 是考虑配置的路由可能不一定有设置 name ,则通过调用 router.addRoute() 返回的回调进行删除
const removeRoutes: (() => void)[] = []
routeStore.flatRoutes.forEach((route) => {
if (!/^(https?:|mailto:|tel:)/.test(route.path)) {
removeRoutes.push(router.addRoute(route as RouteRecordRaw))
}
})
if (settingsStore.settings.app.routeBaseOn !== 'filesystem') {
routeStore.flatSystemRoutes.forEach((route) => {
removeRoutes.push(router.addRoute(route as RouteRecordRaw))
})
}
routeStore.setCurrentRemoveRoutes(removeRoutes)
// 动态路由生成并注册后,重新进入当前路由
next({
path: to.path,
query: to.query,
replace: true,
})
}
}
else {
if (to.name !== 'login') {
next({
name: 'login',
query: {
redirect: to.fullPath !== settingsStore.settings.home.fullPath ? to.fullPath : undefined,
},
})
}
else {
next()
}
}
})
router.afterEach((to, from) => {
const settingsStore = useSettingsStore()
const keepAliveStore = useKeepAliveStore()
settingsStore.settings.app.enableProgress && (isLoading.value = false)
// 设置页面 title
if (settingsStore.settings.app.routeBaseOn !== 'filesystem') {
settingsStore.setTitle(to.meta.breadcrumbNeste?.at(-1)?.title ?? to.meta.title)
}
else {
settingsStore.setTitle(to.meta.title)
}
/**
* 处理普通页面的缓存
*/
// 判断当前页面是否开启缓存,如果开启,则将当前页面的 name 信息存入 keep-alive 全局状态
if (to.meta.cache) {
const componentName = to.matched.at(-1)?.components?.default.name
if (componentName) {
keepAliveStore.add(componentName)
}
else {
// turbo-console-disable-next-line
console.warn('[Fantastic-admin] 该页面组件未设置组件名,会导致缓存失效,请检查')
}
}
// 判断离开页面是否开启缓存,如果开启,则根据缓存规则判断是否需要清空 keep-alive 全局状态里离开页面的 name 信息
if (from.meta.cache) {
const componentName = from.matched.at(-1)?.components?.default.name
if (componentName) {
// 通过 meta.cache 判断针对哪些页面进行缓存
switch (typeof from.meta.cache) {
case 'string':
if (from.meta.cache !== to.name) {
keepAliveStore.remove(componentName)
}
break
case 'object':
if (!from.meta.cache.includes(to.name as string)) {
keepAliveStore.remove(componentName)
}
break
}
// 通过 meta.noCache 判断针对哪些页面不需要进行缓存
if (from.meta.noCache) {
switch (typeof from.meta.noCache) {
case 'string':
if (from.meta.noCache === to.name) {
keepAliveStore.remove(componentName)
}
break
case 'object':
if (from.meta.noCache.includes(to.name as string)) {
keepAliveStore.remove(componentName)
}
break
}
}
// 如果进入的是 reload 页面,则也将离开页面的缓存清空
if (to.name === 'reload') {
keepAliveStore.remove(componentName)
}
}
}
document.documentElement.scrollTop = 0
})
setupGuards(router)
export default router
+3 -1
View File
@@ -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,
+22 -19
View File
@@ -23,24 +23,26 @@ const useMenuStore = defineStore(
function convertRouteToMenu(routes: Route.recordMainRaw[]): Menu.recordMainRaw[] {
const returnMenus: Menu.recordMainRaw[] = []
routes.forEach((item) => {
if (settingsStore.settings.menu.menuMode === '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: [],
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)
}
menuItem.children = convertRouteToMenuRecursive(item.children)
returnMenus.push(menuItem)
}
})
return returnMenus
@@ -163,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)
}
}
+4 -7
View File
@@ -1,5 +1,5 @@
import { cloneDeep } from 'lodash-es'
import type { RouteMeta, RouteRecordRaw } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import useSettingsStore from './settings'
import { resolveRoutePath } from '@/utils'
import { systemRoutes } from '@/router/routes'
@@ -25,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 || baseAuth === '' || baseAuth?.length === 0 ? route.meta?.auth : baseAuth
const tmpBreadcrumb = cloneDeep(breadcrumb)
tmpBreadcrumb.push({
path: childrenBaseUrl,
@@ -47,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)) {
@@ -80,7 +78,6 @@ const useRouteStore = defineStore(
if (!tmpRoute.meta) {
tmpRoute.meta = {}
}
tmpRoute.meta.auth = !baseAuth || baseAuth === '' || baseAuth?.length === 0 ? tmpRoute.meta?.auth : baseAuth
tmpRoute.meta.breadcrumbNeste = tmpBreadcrumb
res.push(tmpRoute)
}
+18 -1
View File
@@ -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,
+1 -7
View File
@@ -24,19 +24,13 @@ const useTabbarStore = defineStore(
if (route.name !== 'reload') {
// 记录查找到的标签页
const findTab = list.value.find((item) => {
if (item.routeName) {
return item.routeName === route.name
}
else {
return item.tabId === tabId
}
return item.tabId === tabId
})
// 新增标签页
if (!findTab) {
const listItem = {
tabId,
fullPath: route.fullPath,
routeName: route.name,
title: typeof meta?.title === 'function' ? meta.title() : meta?.title,
icon: meta?.icon ?? meta?.breadcrumbNeste?.findLast(item => item.icon)?.icon,
name: names,
+1 -1
View File
@@ -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 }),
},
})
}
+4 -1
View File
@@ -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']
@@ -26,10 +26,13 @@ declare module 'vue' {
ImagePreview: typeof import('./../components/ImagePreview/index.vue')['default']
ImagesUpload: typeof import('./../components/ImagesUpload/index.vue')['default']
ImageUpload: typeof import('./../components/ImageUpload/index.vue')['default']
LoginForm: typeof import('./../components/LoginForm/index.vue')['default']
NotAllowed: typeof import('./../components/NotAllowed/index.vue')['default']
PageHeader: typeof import('./../components/PageHeader/index.vue')['default']
PageMain: typeof import('./../components/PageMain/index.vue')['default']
PcasCascader: typeof import('./../components/PcasCascader/index.vue')['default']
RegisterForm: typeof import('./../components/RegisterForm/index.vue')['default']
ResetPasswordForm: typeof import('./../components/ResetPasswordForm/index.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
SearchBar: typeof import('./../components/SearchBar/index.vue')['default']
+12 -3
View File
@@ -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`
@@ -284,7 +294,6 @@ declare namespace Tabbar {
interface recordRaw {
tabId: string
fullPath: string
routeName?: RouteRecordRaw.name
title?: string | (() => string)
icon?: string
name: string[]
-7
View File
@@ -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')
+2 -2
View File
@@ -5,10 +5,10 @@ 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.hurui.me')
}
else {
console.info('%cPowered by%cFantastic-admin', copyright_sub_style, copyright_main_style, '\nhttps://fantastic-admin.github.io')
console.info('%cPowered by%cFantastic-admin', copyright_sub_style, copyright_main_style, '\nhttps://fantastic-admin.hurui.me')
}
}
+3 -3
View File
@@ -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>
+25 -37
View File
@@ -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.hurui.me/preview1.png',
'https://fantastic-admin.hurui.me/preview2.png',
'https://fantastic-admin.hurui.me/preview3.png',
'https://fantastic-admin.hurui.me/preview4.png',
'https://fantastic-admin.hurui.me/preview5.png',
'https://fantastic-admin.hurui.me/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.hurui.me/preview1.png',
'https://one-step-admin.hurui.me/preview2.png',
'https://one-step-admin.hurui.me/preview3.png',
'https://one-step-admin.hurui.me/preview4.png',
'https://one-step-admin.hurui.me/preview5.png',
'https://one-step-admin.hurui.me/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.hurui.me')">
<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.hurui.me/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.hurui.me')">
访问官网
</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.hurui.me/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.hurui.me')">
访问官网
</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">
@@ -177,30 +165,30 @@ function open(url: string) {
</div>
</template>
<style lang="scss" scoped>
<style scoped>
.text-emphasis {
text-emphasis-style: "❤";
}
.ecology {
--at-apply: flex-1 m-0;
--uno: flex-1 m-0;
:deep(.title-container) {
--at-apply: flex items-center justify-between flex-wrap gap-4;
--uno: flex items-center justify-between flex-wrap gap-4;
.title-info {
--at-apply: flex items-center gap-4;
--uno: flex items-center gap-4;
img {
--at-apply: block w-12 h-12;
--uno: block w-12 h-12;
}
h1 {
--at-apply: m-0 text-2xl;
--uno: m-0 text-2xl;
}
h2 {
--at-apply: m-0 text-base text-stone-5 font-normal;
--uno: m-0 text-base text-stone-5 font-normal;
}
}
}
+69 -386
View File
@@ -6,11 +6,8 @@ meta:
</route>
<script setup lang="ts">
import type { FormInstance, FormRules } from 'element-plus'
import { ElMessage } from 'element-plus'
import Copyright from '@/layouts/components/Copyright/index.vue'
import useSettingsStore from '@/store/modules/settings'
import useUserStore from '@/store/modules/user'
defineOptions({
name: 'Login',
@@ -18,303 +15,67 @@ defineOptions({
const route = useRoute()
const router = useRouter()
const settingsStore = useSettingsStore()
const userStore = useUserStore()
const banner = new URL('../assets/images/login-banner.png', import.meta.url).href
const logo = new URL('../assets/images/logo.png', import.meta.url).href
const title = import.meta.env.VITE_APP_TITLE
// 表单类型,login 登录,register 注册,reset 重置密码
const formType = ref('login')
const loading = ref(false)
const redirect = ref(route.query.redirect?.toString() ?? settingsStore.settings.home.fullPath)
// 登录
const loginFormRef = ref<FormInstance>()
const loginForm = ref({
account: localStorage.login_account || '',
password: '',
remember: !!localStorage.login_account,
})
const loginRules = ref<FormRules>({
account: [
{ required: true, trigger: 'blur', message: '请输入用户名' },
],
password: [
{ required: true, trigger: 'blur', message: '请输入密码' },
{ min: 6, max: 18, trigger: 'blur', message: '密码长度为6到18位' },
],
})
function handleLogin() {
loginFormRef.value && loginFormRef.value.validate((valid) => {
if (valid) {
loading.value = true
userStore.login(loginForm.value).then(() => {
loading.value = false
if (loginForm.value.remember) {
localStorage.setItem('login_account', loginForm.value.account)
}
else {
localStorage.removeItem('login_account')
}
router.push(redirect.value)
}).catch(() => {
loading.value = false
})
}
})
}
// 注册
const registerFormRef = ref<FormInstance>()
const registerForm = ref({
account: '',
captcha: '',
password: '',
checkPassword: '',
})
const registerRules = ref<FormRules>({
account: [
{ required: true, trigger: 'blur', message: '请输入用户名' },
],
captcha: [
{ required: true, trigger: 'blur', message: '请输入验证码' },
],
password: [
{ required: true, trigger: 'blur', message: '请输入密码' },
{ min: 6, max: 18, trigger: 'blur', message: '密码长度为6到18位' },
],
checkPassword: [
{ required: true, trigger: 'blur', message: '请再次输入密码' },
{
validator: (rule, value, callback) => {
if (value !== registerForm.value.password) {
callback(new Error('两次输入的密码不一致'))
}
else {
callback()
}
},
},
],
})
function handleRegister() {
ElMessage({
message: '注册模块仅提供界面演示,无实际功能,需开发者自行扩展',
type: 'warning',
})
registerFormRef.value && registerFormRef.value.validate((valid) => {
if (valid) {
// 这里编写业务代码
}
})
}
// 重置密码
const resetFormRef = ref<FormInstance>()
const resetForm = ref({
account: localStorage.login_account,
captcha: '',
newPassword: '',
})
const resetRules = ref<FormRules>({
account: [
{ required: true, trigger: 'blur', message: '请输入用户名' },
],
captcha: [
{ required: true, trigger: 'blur', message: '请输入验证码' },
],
newPassword: [
{ required: true, trigger: 'blur', message: '请输入新密码' },
{ min: 6, max: 18, trigger: 'blur', message: '密码长度为6到18位' },
],
})
function handleReset() {
ElMessage({
message: '重置密码仅提供界面演示,无实际功能,需开发者自行扩展',
type: 'info',
})
resetFormRef.value && resetFormRef.value.validate((valid) => {
if (valid) {
// 这里编写业务代码
}
})
}
function testAccount(account: string) {
loginForm.value.account = account
loginForm.value.password = '123456'
handleLogin()
}
const account = ref<string>()
// 表单类型
const formType = ref<'login' | 'register' | 'resetPassword'>('login')
const formRef = ref()
</script>
<template>
<div>
<div class="bg-banner" />
<div id="login-box">
<div class="login-banner">
<img :src="logo" class="logo">
<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>
<div style="margin-top: 20px; margin-bottom: -20px; text-align: center;">
<ElDivider>演示账号一键登录</ElDivider>
<ElButton type="primary" size="small" plain @click="testAccount('admin')">
admin
</ElButton>
<ElButton size="small" plain @click="testAccount('test')">
test
</ElButton>
</div>
</ElForm>
<ElForm v-show="formType === 'register'" ref="registerFormRef" :model="registerForm" :rules="registerRules" class="login-form" auto-complete="on">
<div class="title-container">
<h3 class="title">
探索从这里开始! 🚀
</h3>
</div>
<div>
<ElFormItem prop="account">
<ElInput v-model="registerForm.account" placeholder="用户名" tabindex="1">
<template #prefix>
<SvgIcon name="i-ri:user-3-fill" />
</template>
</ElInput>
</ElFormItem>
<ElFormItem prop="captcha">
<ElInput v-model="registerForm.captcha" placeholder="验证码" tabindex="2">
<template #prefix>
<SvgIcon name="i-ic:baseline-verified-user" />
</template>
<template #append>
<ElButton>发送验证码</ElButton>
</template>
</ElInput>
</ElFormItem>
<ElFormItem prop="password">
<ElInput v-model="registerForm.password" type="password" placeholder="密码" tabindex="3" show-password>
<template #prefix>
<SvgIcon name="i-ri:lock-2-fill" />
</template>
</ElInput>
</ElFormItem>
<ElFormItem prop="checkPassword">
<ElInput v-model="registerForm.checkPassword" type="password" placeholder="确认密码" tabindex="4" show-password>
<template #prefix>
<SvgIcon name="i-ri:lock-2-fill" />
</template>
</ElInput>
</ElFormItem>
</div>
<ElButton :loading="loading" type="primary" size="large" style="width: 100%; margin-top: 20px;" @click.prevent="handleRegister">
注册
</ElButton>
<div class="sub-link">
<span class="text">已经有帐号?</span>
<ElLink type="primary" :underline="false" @click="formType = 'login'">
去登录
</ElLink>
</div>
</ElForm>
<ElForm v-show="formType === 'reset'" ref="resetFormRef" :model="resetForm" :rules="resetRules" class="login-form">
<div class="title-container">
<h3 class="title">
忘记密码了? 🔒
</h3>
</div>
<div>
<ElFormItem prop="account">
<ElInput v-model="resetForm.account" placeholder="用户名" type="text" tabindex="1">
<template #prefix>
<SvgIcon name="i-ri:user-3-fill" />
</template>
</ElInput>
</ElFormItem>
<ElFormItem prop="captcha">
<ElInput v-model="resetForm.captcha" placeholder="验证码" type="text" tabindex="2">
<template #prefix>
<SvgIcon name="i-ic:baseline-verified-user" />
</template>
<template #append>
<ElButton>发送验证码</ElButton>
</template>
</ElInput>
</ElFormItem>
<ElFormItem prop="newPassword">
<ElInput v-model="resetForm.newPassword" type="password" placeholder="新密码" tabindex="3" show-password>
<template #prefix>
<SvgIcon name="i-ri:lock-2-fill" />
</template>
</ElInput>
</ElFormItem>
</div>
<ElButton :loading="loading" type="primary" size="large" style="width: 100%; margin-top: 20px;" @click.prevent="handleReset">
确认
</ElButton>
<div class="sub-link">
<ElLink type="primary" :underline="false" @click="formType = 'login'">
去登录
</ElLink>
</div>
</ElForm>
<div class="bg-banner" />
<div class="login-box">
<div class="login-banner">
<img src="@/assets/images/logo.png" class="absolute left-4 top-4 h-30px rounded ring ring-stone-2 dark-ring-stone-8">
<img src="@/assets/images/login-banner.png" class="banner">
</div>
<div class="login-form flex-col-center">
<Transition name="fade" mode="out-in">
<LoginForm
v-if="formType === 'login'"
ref="formRef"
:account
@on-login="router.push(redirect)"
@on-register="(account) => { formType = 'register'; account = account }"
@on-reset-password="(account) => { formType = 'resetPassword'; account = account }"
/>
<RegisterForm
v-else-if="formType === 'register'"
ref="formRef"
:account
@on-register="(account) => { formType = 'login'; account = account }"
@on-login="formType = 'login'"
/>
<ResetPasswordForm
v-else-if="formType === 'resetPassword'"
ref="formRef"
:account
@on-reset-password="(account) => { formType = 'login'; account = account }"
@on-login="formType = 'login'"
/>
</Transition>
</div>
<Copyright />
</div>
<Copyright />
</template>
<style lang="scss" scoped>
<style scoped>
.bg-banner {
position: fixed;
z-index: 0;
width: 100%;
height: 100%;
background: radial-gradient(circle at center, var(--g-container-bg), var(--g-bg));
}
[data-mode="mobile"] {
#login-box {
.login-box {
position: relative;
top: inherit;
left: inherit;
flex-direction: column;
justify-content: start;
width: 100%;
height: 100%;
border-radius: 0;
box-shadow: none;
transform: translateX(0) translateY(0);
.login-banner {
width: 100%;
@@ -334,8 +95,6 @@ function testAccount(account: string) {
.login-form {
width: 100%;
min-height: auto;
padding: 30px;
}
}
@@ -344,29 +103,19 @@ function testAccount(account: string) {
}
}
:deep(input[type="password"]::-ms-reveal) {
display: none;
}
.bg-banner {
position: fixed;
z-index: 0;
width: 100%;
height: 100%;
background: radial-gradient(circle at center, var(--g-container-bg), var(--g-bg));
}
#login-box {
.login-box {
position: absolute;
top: 50%;
left: 50%;
display: flex;
justify-content: space-between;
overflow: hidden;
background-color: var(--g-container-bg);
border-radius: 10px;
box-shadow: var(--el-box-shadow);
transform: translateX(-50%) translateY(-50%);
[data-mode="pc"] & {
top: 50%;
left: 50%;
border-radius: 10px;
box-shadow: var(--el-box-shadow);
transform: translateX(-50%) translateY(-50%);
}
.login-banner {
position: relative;
@@ -375,92 +124,16 @@ function testAccount(account: string) {
background-color: var(--g-bg);
.banner {
width: 100%;
@include position-center(y);
}
.logo {
position: absolute;
top: 20px;
left: 20px;
height: 30px;
border-radius: 4px;
box-shadow: var(--el-box-shadow-light);
top: 50%;
width: 100%;
transform: translateY(-50%);
}
}
.login-form {
display: flex;
flex-direction: column;
justify-content: center;
width: 500px;
min-height: 500px;
padding: 50px;
overflow: hidden;
.title-container {
position: relative;
.title {
margin: 0 auto 30px;
font-size: 1.3em;
font-weight: bold;
color: var(--el-text-color-primary);
}
}
}
.el-form-item {
margin-bottom: 24px;
:deep(.el-input) {
width: 100%;
height: 48px;
line-height: inherit;
input {
height: 48px;
}
.el-input__prefix,
.el-input__suffix {
display: flex;
align-items: center;
}
.el-input__prefix {
left: 10px;
}
.el-input__suffix {
right: 10px;
}
}
}
:deep(.el-divider__text) {
background-color: var(--g-container-bg);
}
.flex-bar {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
}
.sub-link {
display: flex;
align-items: center;
justify-content: center;
margin-top: 20px;
font-size: 14px;
color: var(--el-text-color-secondary);
.text {
margin-right: 10px;
}
transition: height 0.15s ease;
}
}
@@ -471,4 +144,14 @@ function testAccount(account: string) {
padding: 20px;
margin: 0;
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.15s ease;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
</style>
+19 -4
View File
@@ -10,6 +10,7 @@ import {
transformerVariantGroup,
} from 'unocss'
import { entriesToCss, toArray } from '@unocss/core'
import { presetScrollbar } from 'unocss-preset-scrollbar'
import { darkTheme, lightTheme } from './themes'
export default defineConfig<Theme>({
@@ -22,10 +23,23 @@ export default defineConfig<Theme>({
},
},
shortcuts: [
{
'flex-center': 'flex justify-center items-center',
'flex-col-center': 'flex flex-col justify-center items-center',
},
[/^flex-?(col)?-(start|end|center|baseline|stretch)-?(start|end|center|between|around|evenly|left|right)?$/, ([, col, items, justify]) => {
const cls = ['flex']
if (col === 'col') {
cls.push('flex-col')
}
if (items === 'center' && !justify) {
cls.push('items-center')
cls.push('justify-center')
}
else {
cls.push(`items-${items}`)
if (justify) {
cls.push(`justify-${justify}`)
}
}
return cls.join(' ')
}],
],
preflights: [
{
@@ -60,6 +74,7 @@ export default defineConfig<Theme>({
},
}),
presetTypography(),
presetScrollbar(),
],
transformers: [
transformerDirectives(),
+2 -3
View File
@@ -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
View File
@@ -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.hurui.me
*/
`),
{
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.hurui.me')}\n\n当前使用:${cyan('基础版')}`,
{
padding: 1,
margin: 1,
borderStyle: 'double',
textAlignment: 'center',
},
),
)
},
},
]
return vitePlugins
}
-25
View File
@@ -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',
},
),
)
},
}
}
-33
View File
@@ -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()
}
},
}
}
-15
View File
@@ -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/**',
],
})
}
-12
View File
@@ -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
*/
`)
}
-12
View File
@@ -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',
})
}
-24
View File
@@ -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
}
-5
View File
@@ -1,5 +0,0 @@
import TurboConsole from 'unplugin-turbo-console/vite'
export default function createConsole() {
return TurboConsole()
}
-6
View File
@@ -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()
}
-46
View File
@@ -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
}
-7
View File
@@ -1,7 +0,0 @@
import Layouts from 'vite-plugin-vue-meta-layouts'
export default function createLayouts() {
return Layouts({
defaultLayout: 'index',
})
}
-11
View File
@@ -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',
})
}
-10
View File
@@ -1,10 +0,0 @@
import Pages from 'vite-plugin-pages'
export default function createPages() {
return Pages({
dirs: 'src/views',
exclude: [
'**/components/**/*.vue',
],
})
}
-11
View File
@@ -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,
})
}
-5
View File
@@ -1,5 +0,0 @@
import Unocss from 'unocss/vite'
export default function createUnocss() {
return Unocss()
}