mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 08:36:19 +08:00
Compare commits
120 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b8182b6c30 | ||
![]() |
87e5b0522e | ||
![]() |
488ccb5976 | ||
![]() |
bbc426caa0 | ||
![]() |
44440d0951 | ||
![]() |
5999a862b6 | ||
![]() |
d31535cd98 | ||
![]() |
35eef33779 | ||
![]() |
422936a981 | ||
![]() |
a64a06bf59 | ||
![]() |
43d95cc587 | ||
![]() |
faf18d0143 | ||
![]() |
4b94d62145 | ||
![]() |
cf130b293d | ||
![]() |
566f357dfa | ||
![]() |
f78cc319ab | ||
![]() |
06ba7cb224 | ||
![]() |
353e8be289 | ||
![]() |
c2d59dea69 | ||
![]() |
e600d78cb9 | ||
![]() |
d23db32f04 | ||
![]() |
1180291c1a | ||
![]() |
0cf4509c70 | ||
![]() |
ad3963ff70 | ||
![]() |
fe7df5ad3b | ||
![]() |
d7d7466524 | ||
![]() |
6688a6b3c2 | ||
![]() |
39e41d05be | ||
![]() |
862bbd8344 | ||
![]() |
23768ea620 | ||
![]() |
f60796f961 | ||
![]() |
7f4c733fa3 | ||
![]() |
1b172b0329 | ||
![]() |
88d2b3e569 | ||
![]() |
625862e082 | ||
![]() |
bfaa2780ab | ||
![]() |
d262b7b6c0 | ||
![]() |
93b48ef244 | ||
![]() |
860fc15ce6 | ||
![]() |
646598afba | ||
![]() |
234544c40d | ||
![]() |
307a71fb35 | ||
![]() |
477a05c26c | ||
![]() |
0df8c5c02c | ||
![]() |
d1ca09c7bb | ||
![]() |
ff3c5f8581 | ||
![]() |
240f0b5f8d | ||
![]() |
6f3d50984f | ||
![]() |
c491b9e021 | ||
![]() |
6cd9937c03 | ||
![]() |
f89f4f32c7 | ||
![]() |
c432e0ac33 | ||
![]() |
719c9a8f2d | ||
![]() |
a0fbe0b21a | ||
![]() |
f7fa69d33b | ||
![]() |
7c45aeb868 | ||
![]() |
850a6af1e0 | ||
![]() |
d5a210f53f | ||
![]() |
6c4a742627 | ||
![]() |
45987fc1e3 | ||
![]() |
ea962e75d0 | ||
![]() |
24d14c2841 | ||
![]() |
8b961a9d7f | ||
![]() |
9856bc88d2 | ||
![]() |
68465b5fbf | ||
![]() |
0ea0f204cb | ||
![]() |
1b65254383 | ||
![]() |
0a99f27127 | ||
![]() |
304b1b2efc | ||
![]() |
f923f59070 | ||
![]() |
437cb02e11 | ||
![]() |
ba539f6793 | ||
![]() |
078f255e1a | ||
![]() |
ba4662522e | ||
![]() |
8fe87b10dc | ||
![]() |
2dbd323b2a | ||
![]() |
8ad2b8665d | ||
![]() |
518b869f9d | ||
![]() |
2d019b3c8a | ||
![]() |
ab44926ec8 | ||
![]() |
f0edad8a51 | ||
![]() |
f8ce3fdf1f | ||
![]() |
60c615ce8a | ||
![]() |
324cdd8259 | ||
![]() |
9ad4f96e38 | ||
![]() |
47d162e6e4 | ||
![]() |
d37e2f599c | ||
![]() |
402eaf4275 | ||
![]() |
0fcc42a2fb | ||
![]() |
28b54b587a | ||
![]() |
4173264805 | ||
![]() |
46540a7329 | ||
![]() |
13fd0ea16c | ||
![]() |
f7016466ee | ||
![]() |
0cd865e211 | ||
![]() |
64428b9b11 | ||
![]() |
aed31a5a4e | ||
![]() |
b3e196f001 | ||
![]() |
b2c117f544 | ||
![]() |
01391ee5a1 | ||
![]() |
3572ce1538 | ||
![]() |
d1e1256202 | ||
![]() |
b7776c5148 | ||
![]() |
2d1519eca7 | ||
![]() |
93b5618b52 | ||
![]() |
639d2e1525 | ||
![]() |
26646d42f7 | ||
![]() |
17fa8eb93b | ||
![]() |
8250894a50 | ||
![]() |
a72b8acaf9 | ||
![]() |
a46c85d77d | ||
![]() |
fdc5b02c30 | ||
![]() |
476aa068d7 | ||
![]() |
bb6057cac3 | ||
![]() |
abbbbfb955 | ||
![]() |
79c87c9f46 | ||
![]() |
f815dcf3ae | ||
![]() |
1197efea26 | ||
![]() |
2a83f1d666 | ||
![]() |
4b3d2d21ed |
2
.github/release-drafter.yml
vendored
2
.github/release-drafter.yml
vendored
@@ -16,7 +16,7 @@ categories:
|
|||||||
- title: '🐞 Bug Fixes'
|
- title: '🐞 Bug Fixes'
|
||||||
labels:
|
labels:
|
||||||
- 'bug'
|
- 'bug'
|
||||||
- title: '📈 Performance'
|
- title: '📈 Performance & Enhancement'
|
||||||
labels:
|
labels:
|
||||||
- 'perf'
|
- 'perf'
|
||||||
- 'enhancement'
|
- 'enhancement'
|
||||||
|
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@@ -19,6 +19,7 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
post-update:
|
post-update:
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
# if: ${{ github.actor == 'dependabot[bot]' }}
|
# if: ${{ github.actor == 'dependabot[bot]' }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
|
2
.github/workflows/changeset-version.yml
vendored
2
.github/workflows/changeset-version.yml
vendored
@@ -18,7 +18,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
version:
|
version:
|
||||||
if: (github.event.pull_request.merged || github.event_name == 'workflow_dispatch') && github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
|
if: (github.event.pull_request.merged || github.event_name == 'workflow_dispatch') && github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') && github.repository == 'vbenjs/vue-vben-admin'
|
||||||
# if: github.repository == 'vbenjs/vue-vben-admin'
|
# if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -17,6 +17,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
name: Test
|
name: Test
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -55,6 +56,7 @@ jobs:
|
|||||||
|
|
||||||
lint:
|
lint:
|
||||||
name: Lint
|
name: Lint
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -77,6 +79,7 @@ jobs:
|
|||||||
|
|
||||||
check:
|
check:
|
||||||
name: Check
|
name: Check
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
strategy:
|
strategy:
|
||||||
@@ -106,6 +109,7 @@ jobs:
|
|||||||
|
|
||||||
ci-ok:
|
ci-ok:
|
||||||
name: CI OK
|
name: CI OK
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [test, check, lint]
|
needs: [test, check, lint]
|
||||||
env:
|
env:
|
||||||
|
1
.github/workflows/codeql.yml
vendored
1
.github/workflows/codeql.yml
vendored
@@ -22,6 +22,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
analyze:
|
analyze:
|
||||||
name: Analyze (${{ matrix.language }})
|
name: Analyze (${{ matrix.language }})
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
||||||
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
||||||
# - https://gh.io/supported-runners-and-hardware-resources
|
# - https://gh.io/supported-runners-and-hardware-resources
|
||||||
|
10
.github/workflows/deploy.yml
vendored
10
.github/workflows/deploy.yml
vendored
@@ -8,7 +8,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy-playground-ftp:
|
deploy-playground-ftp:
|
||||||
name: Deploy Push Playground Ftp
|
name: Deploy Push Playground Ftp
|
||||||
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
|
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') && github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -39,7 +39,7 @@ jobs:
|
|||||||
|
|
||||||
deploy-docs-ftp:
|
deploy-docs-ftp:
|
||||||
name: Deploy Push Docs Ftp
|
name: Deploy Push Docs Ftp
|
||||||
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
|
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') && github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -63,7 +63,7 @@ jobs:
|
|||||||
|
|
||||||
deploy-antd-ftp:
|
deploy-antd-ftp:
|
||||||
name: Deploy Push Antd Ftp
|
name: Deploy Push Antd Ftp
|
||||||
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
|
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') && github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -94,7 +94,7 @@ jobs:
|
|||||||
|
|
||||||
deploy-ele-ftp:
|
deploy-ele-ftp:
|
||||||
name: Deploy Push Element Ftp
|
name: Deploy Push Element Ftp
|
||||||
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
|
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') && github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -125,7 +125,7 @@ jobs:
|
|||||||
|
|
||||||
deploy-naive-ftp:
|
deploy-naive-ftp:
|
||||||
name: Deploy Push Naive Ftp
|
name: Deploy Push Naive Ftp
|
||||||
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
|
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') && github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
|
1
.github/workflows/draft.yml
vendored
1
.github/workflows/draft.yml
vendored
@@ -17,6 +17,7 @@ jobs:
|
|||||||
# write permission is required for autolabeler
|
# write permission is required for autolabeler
|
||||||
# otherwise, read permission is required at least
|
# otherwise, read permission is required at least
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: release-drafter/release-drafter@v6
|
- uses: release-drafter/release-drafter@v6
|
||||||
|
20
.github/workflows/issue-close-require.yml
vendored
20
.github/workflows/issue-close-require.yml
vendored
@@ -3,23 +3,29 @@ name: Issue Close Require
|
|||||||
|
|
||||||
# 触发条件:每天零点
|
# 触发条件:每天零点
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * *'
|
- cron: '0 0 * * *'
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
contents: write
|
contents: write
|
||||||
|
issues: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
close-issues:
|
close-issues:
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# 步骤1:关闭未活动的 Issues
|
# 关闭未活动的 Issues
|
||||||
- name: Close Inactive Issues
|
- name: Close Inactive Issues
|
||||||
uses: actions-cool/issues-helper@v3
|
uses: actions/stale@v9
|
||||||
with:
|
with:
|
||||||
actions: 'close-issues' # 执行动作:关闭 Issues
|
days-before-stale: -1 # Issues and PR will never be flagged stale automatically.
|
||||||
token: ${{ secrets.GITHUB_TOKEN }} # GitHub Token,用于认证
|
stale-issue-label: needs-reproduction # Label that flags an issue as stale.
|
||||||
labels: 'needs reproduction' # 目标标签
|
only-labels: needs-reproduction # Only process these issues
|
||||||
inactive-day: 3 # 未活动天数阈值
|
days-before-issue-close: 3
|
||||||
|
ignore-updates: true
|
||||||
|
remove-stale-when-updated: false
|
||||||
|
close-issue-message: This issue was closed because it was open for 3 days without a valid reproduction.
|
||||||
|
close-issue-label: closed-by-action
|
||||||
|
1
.github/workflows/issue-labeled.yml
vendored
1
.github/workflows/issue-labeled.yml
vendored
@@ -13,6 +13,7 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
reply-labeled:
|
reply-labeled:
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: remove enhancement pending
|
- name: remove enhancement pending
|
||||||
|
3
.github/workflows/lock.yml
vendored
3
.github/workflows/lock.yml
vendored
@@ -11,12 +11,13 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
action:
|
action:
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: dessant/lock-threads@v5
|
- uses: dessant/lock-threads@v5
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
issue-inactive-days: '30'
|
issue-inactive-days: '14'
|
||||||
issue-lock-reason: ''
|
issue-lock-reason: ''
|
||||||
pr-inactive-days: '30'
|
pr-inactive-days: '30'
|
||||||
pr-lock-reason: ''
|
pr-lock-reason: ''
|
||||||
|
1
.github/workflows/release-tag.yml
vendored
1
.github/workflows/release-tag.yml
vendored
@@ -15,6 +15,7 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Create Release
|
name: Create Release
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
3
.github/workflows/semantic-pull-request.yml
vendored
3
.github/workflows/semantic-pull-request.yml
vendored
@@ -9,8 +9,9 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Semantic Pull Request
|
name: Semantic Pull Request
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Validate PR title
|
- name: Validate PR title
|
||||||
uses: amannn/action-semantic-pull-request@v5
|
uses: amannn/action-semantic-pull-request@v5
|
||||||
|
1
.github/workflows/stale.yml
vendored
1
.github/workflows/stale.yml
vendored
@@ -6,6 +6,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stale:
|
stale:
|
||||||
|
if: github.repository == 'vbenjs/vue-vben-admin'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v9
|
- uses: actions/stale@v9
|
||||||
|
@@ -3,4 +3,4 @@ ports:
|
|||||||
onOpen: open-preview
|
onOpen: open-preview
|
||||||
tasks:
|
tasks:
|
||||||
- init: corepack enable && pnpm install
|
- init: corepack enable && pnpm install
|
||||||
command: pnpm run dev
|
command: pnpm run dev:play
|
||||||
|
4
.vscode/extensions.json
vendored
4
.vscode/extensions.json
vendored
@@ -19,7 +19,9 @@
|
|||||||
// i18n 插件
|
// i18n 插件
|
||||||
"Lokalise.i18n-ally",
|
"Lokalise.i18n-ally",
|
||||||
// CSS 变量提示
|
// CSS 变量提示
|
||||||
"vunguyentuan.vscode-css-variables"
|
"vunguyentuan.vscode-css-variables",
|
||||||
|
// 在 package.json 中显示 PNPM catalog 的版本
|
||||||
|
"antfu.pnpm-catalog-lens"
|
||||||
],
|
],
|
||||||
"unwantedRecommendations": [
|
"unwantedRecommendations": [
|
||||||
// 和 volar 冲突
|
// 和 volar 冲突
|
||||||
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -197,11 +197,14 @@
|
|||||||
"playground/src/locales/langs",
|
"playground/src/locales/langs",
|
||||||
"apps/*/src/locales/langs"
|
"apps/*/src/locales/langs"
|
||||||
],
|
],
|
||||||
"i18n-ally.pathMatcher": "{locale}.json",
|
"i18n-ally.pathMatcher": "{locale}/{namespace}.{ext}",
|
||||||
"i18n-ally.enabledParsers": ["json", "ts", "js", "yaml"],
|
"i18n-ally.enabledParsers": ["json"],
|
||||||
"i18n-ally.sourceLanguage": "en",
|
"i18n-ally.sourceLanguage": "en",
|
||||||
"i18n-ally.displayLanguage": "zh-CN",
|
"i18n-ally.displayLanguage": "zh-CN",
|
||||||
"i18n-ally.enabledFrameworks": ["vue", "react"],
|
"i18n-ally.enabledFrameworks": ["vue", "react"],
|
||||||
|
"i18n-ally.keystyle": "nested",
|
||||||
|
"i18n-ally.sortKeys": true,
|
||||||
|
"i18n-ally.namespace": true,
|
||||||
|
|
||||||
// 控制相关文件嵌套展示
|
// 控制相关文件嵌套展示
|
||||||
"explorer.fileNesting.enabled": true,
|
"explorer.fileNesting.enabled": true,
|
||||||
@@ -216,7 +219,6 @@
|
|||||||
"tailwind.config.mjs": "postcss.*"
|
"tailwind.config.mjs": "postcss.*"
|
||||||
},
|
},
|
||||||
"commentTranslate.hover.enabled": false,
|
"commentTranslate.hover.enabled": false,
|
||||||
"i18n-ally.keystyle": "nested",
|
|
||||||
"commentTranslate.multiLineMerge": true,
|
"commentTranslate.multiLineMerge": true,
|
||||||
"vue.server.hybridMode": true,
|
"vue.server.hybridMode": true,
|
||||||
"typescript.tsdk": "node_modules/typescript/lib"
|
"typescript.tsdk": "node_modules/typescript/lib"
|
||||||
|
@@ -125,6 +125,10 @@ pnpm build
|
|||||||
|
|
||||||
[@Vben](https://github.com/anncwb)
|
[@Vben](https://github.com/anncwb)
|
||||||
|
|
||||||
|
## スター歴史
|
||||||
|
|
||||||
|
[](https://star-history.com/#vbenjs/vue-vben-admin&Date)
|
||||||
|
|
||||||
## 寄付
|
## 寄付
|
||||||
|
|
||||||
このプロジェクトが役に立つと思われた場合、作者にコーヒーを一杯おごってサポートを示すことができます!
|
このプロジェクトが役に立つと思われた場合、作者にコーヒーを一杯おごってサポートを示すことができます!
|
||||||
|
@@ -124,13 +124,17 @@ Support modern browsers, not IE
|
|||||||
|
|
||||||
[@Vben](https://github.com/anncwb)
|
[@Vben](https://github.com/anncwb)
|
||||||
|
|
||||||
|
## Star History
|
||||||
|
|
||||||
|
[](https://star-history.com/#vbenjs/vue-vben-admin&Date)
|
||||||
|
|
||||||
## Donate
|
## Donate
|
||||||
|
|
||||||
If you think this project is helpful to you, you can help the author buy a cup of coffee to show your support!
|
If you think this project is helpful to you, you can help the author buy a cup of coffee to show your support!
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<a style="display: block;width: 100px;height: 50px;line-height: 50px; color: #fff;text-align: center; background: #408aed;border-radius: 4px;" href="https://www.paypal.com/paypalme/cvvben">Paypal Me</a>
|
<a style="display: block;width: 100px;height: 50px;line-height: 50px; color: #fff;text-align: center; background: #408aee;border-radius: 4px;" href="https://www.paypal.com/paypalme/cvvben">Paypal Me</a>
|
||||||
|
|
||||||
## Contributor
|
## Contributor
|
||||||
|
|
||||||
|
@@ -77,6 +77,10 @@ pnpm dev
|
|||||||
pnpm build
|
pnpm build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 更新日志
|
||||||
|
|
||||||
|
[CHANGELOG](https://github.com/vbenjs/vue-vben-admin/releases)
|
||||||
|
|
||||||
## 如何贡献
|
## 如何贡献
|
||||||
|
|
||||||
非常欢迎你的加入 或者提交一个 Pull Request。
|
非常欢迎你的加入 或者提交一个 Pull Request。
|
||||||
@@ -120,6 +124,10 @@ pnpm build
|
|||||||
|
|
||||||
[@Vben](https://github.com/anncwb)
|
[@Vben](https://github.com/anncwb)
|
||||||
|
|
||||||
|
## Star History
|
||||||
|
|
||||||
|
[](https://star-history.com/#vbenjs/vue-vben-admin&Date)
|
||||||
|
|
||||||
## 捐赠
|
## 捐赠
|
||||||
|
|
||||||
如果你觉得这个项目对你有帮助,你可以帮作者买一杯咖啡表示支持!
|
如果你觉得这个项目对你有帮助,你可以帮作者买一杯咖啡表示支持!
|
||||||
@@ -128,10 +136,6 @@ pnpm build
|
|||||||
|
|
||||||
<a style="display: block;width: 100px;height: 50px;line-height: 50px; color: #fff;text-align: center; background: #408aed;border-radius: 4px;" href="https://www.paypal.com/paypalme/cvvben">Paypal Me</a>
|
<a style="display: block;width: 100px;height: 50px;line-height: 50px; color: #fff;text-align: center; background: #408aed;border-radius: 4px;" href="https://www.paypal.com/paypalme/cvvben">Paypal Me</a>
|
||||||
|
|
||||||
## 更新日志
|
|
||||||
|
|
||||||
[CHANGELOG](https://github.com/vbenjs/vue-vben-admin/releases)
|
|
||||||
|
|
||||||
## Contributor
|
## Contributor
|
||||||
|
|
||||||
<a href="https://github.com/vbenjs/vue-vben-admin/graphs/contributors">
|
<a href="https://github.com/vbenjs/vue-vben-admin/graphs/contributors">
|
||||||
|
@@ -21,7 +21,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
|
|
||||||
if (!findUser) {
|
if (!findUser) {
|
||||||
clearRefreshTokenCookie(event);
|
clearRefreshTokenCookie(event);
|
||||||
return forbiddenResponse(event);
|
return forbiddenResponse(event, 'Username or password is incorrect.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const accessToken = generateAccessToken(findUser);
|
const accessToken = generateAccessToken(findUser);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { verifyAccessToken } from '~/utils/jwt-utils';
|
import { verifyAccessToken } from '~/utils/jwt-utils';
|
||||||
import { unAuthorizedResponse } from '~/utils/response';
|
import { unAuthorizedResponse } from '~/utils/response';
|
||||||
|
|
||||||
export default eventHandler((event) => {
|
export default eventHandler(async (event) => {
|
||||||
const userinfo = verifyAccessToken(event);
|
const userinfo = verifyAccessToken(event);
|
||||||
if (!userinfo) {
|
if (!userinfo) {
|
||||||
return unAuthorizedResponse(event);
|
return unAuthorizedResponse(event);
|
||||||
|
48
apps/backend-mock/api/table/list.ts
Normal file
48
apps/backend-mock/api/table/list.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { faker } from '@faker-js/faker';
|
||||||
|
import { verifyAccessToken } from '~/utils/jwt-utils';
|
||||||
|
import { unAuthorizedResponse } from '~/utils/response';
|
||||||
|
|
||||||
|
function generateMockDataList(count: number) {
|
||||||
|
const dataList = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
const dataItem = {
|
||||||
|
id: faker.string.uuid(),
|
||||||
|
imageUrl: faker.image.avatar(),
|
||||||
|
imageUrl2: faker.image.avatar(),
|
||||||
|
open: faker.datatype.boolean(),
|
||||||
|
status: faker.helpers.arrayElement(['success', 'error', 'warning']),
|
||||||
|
productName: faker.commerce.productName(),
|
||||||
|
price: faker.commerce.price(),
|
||||||
|
currency: faker.finance.currencyCode(),
|
||||||
|
quantity: faker.number.int({ min: 1, max: 100 }),
|
||||||
|
available: faker.datatype.boolean(),
|
||||||
|
category: faker.commerce.department(),
|
||||||
|
releaseDate: faker.date.past(),
|
||||||
|
rating: faker.number.float({ min: 1, max: 5 }),
|
||||||
|
description: faker.commerce.productDescription(),
|
||||||
|
weight: faker.number.float({ min: 0.1, max: 10 }),
|
||||||
|
color: faker.color.human(),
|
||||||
|
inProduction: faker.datatype.boolean(),
|
||||||
|
tags: Array.from({ length: 3 }, () => faker.commerce.productAdjective()),
|
||||||
|
};
|
||||||
|
|
||||||
|
dataList.push(dataItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
const mockData = generateMockDataList(100);
|
||||||
|
|
||||||
|
export default eventHandler(async (event) => {
|
||||||
|
const userinfo = verifyAccessToken(event);
|
||||||
|
if (!userinfo) {
|
||||||
|
return unAuthorizedResponse(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
await sleep(600);
|
||||||
|
|
||||||
|
const { page, pageSize } = getQuery(event);
|
||||||
|
return usePageResponseSuccess(page as string, pageSize as string, mockData);
|
||||||
|
});
|
@@ -6,6 +6,5 @@ export default eventHandler((event) => {
|
|||||||
if (!userinfo) {
|
if (!userinfo) {
|
||||||
return unAuthorizedResponse(event);
|
return unAuthorizedResponse(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return useResponseSuccess(userinfo);
|
return useResponseSuccess(userinfo);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import errorHandler from './error';
|
import errorHandler from './error';
|
||||||
|
|
||||||
|
process.env.COMPATIBILITY_DATE = new Date().toISOString();
|
||||||
export default defineNitroConfig({
|
export default defineNitroConfig({
|
||||||
devErrorHandler: errorHandler,
|
devErrorHandler: errorHandler,
|
||||||
errorHandler: '~/error',
|
errorHandler: '~/error',
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
"start": "nitro dev"
|
"start": "nitro dev"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@faker-js/faker": "catalog:",
|
||||||
"jsonwebtoken": "catalog:",
|
"jsonwebtoken": "catalog:",
|
||||||
"nitropack": "catalog:"
|
"nitropack": "catalog:"
|
||||||
},
|
},
|
||||||
|
@@ -86,7 +86,7 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
|
|||||||
component: '/demos/access/admin-visible',
|
component: '/demos/access/admin-visible',
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:button-cursor',
|
icon: 'mdi:button-cursor',
|
||||||
title: 'page.demos.access.adminVisible',
|
title: 'demos.access.adminVisible',
|
||||||
},
|
},
|
||||||
name: 'AccessAdminVisibleDemo',
|
name: 'AccessAdminVisibleDemo',
|
||||||
path: '/demos/access/admin-visible',
|
path: '/demos/access/admin-visible',
|
||||||
@@ -95,7 +95,7 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
|
|||||||
component: '/demos/access/super-visible',
|
component: '/demos/access/super-visible',
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:button-cursor',
|
icon: 'mdi:button-cursor',
|
||||||
title: 'page.demos.access.superVisible',
|
title: 'demos.access.superVisible',
|
||||||
},
|
},
|
||||||
name: 'AccessSuperVisibleDemo',
|
name: 'AccessSuperVisibleDemo',
|
||||||
path: '/demos/access/super-visible',
|
path: '/demos/access/super-visible',
|
||||||
@@ -104,7 +104,7 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
|
|||||||
component: '/demos/access/user-visible',
|
component: '/demos/access/user-visible',
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:button-cursor',
|
icon: 'mdi:button-cursor',
|
||||||
title: 'page.demos.access.userVisible',
|
title: 'demos.access.userVisible',
|
||||||
},
|
},
|
||||||
name: 'AccessUserVisibleDemo',
|
name: 'AccessUserVisibleDemo',
|
||||||
path: '/demos/access/user-visible',
|
path: '/demos/access/user-visible',
|
||||||
@@ -118,7 +118,7 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
|
|||||||
icon: 'ic:baseline-view-in-ar',
|
icon: 'ic:baseline-view-in-ar',
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
order: 1000,
|
order: 1000,
|
||||||
title: 'page.demos.title',
|
title: 'demos.title',
|
||||||
},
|
},
|
||||||
name: 'Demos',
|
name: 'Demos',
|
||||||
path: '/demos',
|
path: '/demos',
|
||||||
@@ -129,7 +129,7 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
|
|||||||
path: '/demosaccess',
|
path: '/demosaccess',
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:cloud-key-outline',
|
icon: 'mdi:cloud-key-outline',
|
||||||
title: 'page.demos.access.backendPermissions',
|
title: 'demos.access.backendPermissions',
|
||||||
},
|
},
|
||||||
redirect: '/demos/access/page-control',
|
redirect: '/demos/access/page-control',
|
||||||
children: [
|
children: [
|
||||||
@@ -139,7 +139,7 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
|
|||||||
component: '/demos/access/index',
|
component: '/demos/access/index',
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:page-previous-outline',
|
icon: 'mdi:page-previous-outline',
|
||||||
title: 'page.demos.access.pageAccess',
|
title: 'demos.access.pageAccess',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -148,7 +148,7 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
|
|||||||
component: '/demos/access/button-control',
|
component: '/demos/access/button-control',
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:button-cursor',
|
icon: 'mdi:button-cursor',
|
||||||
title: 'page.demos.access.buttonControl',
|
title: 'demos.access.buttonControl',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -159,7 +159,7 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
|
|||||||
authority: ['no-body'],
|
authority: ['no-body'],
|
||||||
icon: 'mdi:button-cursor',
|
icon: 'mdi:button-cursor',
|
||||||
menuVisibleWithForbidden: true,
|
menuVisibleWithForbidden: true,
|
||||||
title: 'page.demos.access.menuVisible403',
|
title: 'demos.access.menuVisible403',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
roleWithMenus[role],
|
roleWithMenus[role],
|
||||||
|
@@ -9,6 +9,27 @@ export function useResponseSuccess<T = any>(data: T) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function usePageResponseSuccess<T = any>(
|
||||||
|
page: number | string,
|
||||||
|
pageSize: number | string,
|
||||||
|
list: T[],
|
||||||
|
{ message = 'ok' } = {},
|
||||||
|
) {
|
||||||
|
const pageData = pagination(
|
||||||
|
Number.parseInt(`${page}`),
|
||||||
|
Number.parseInt(`${pageSize}`),
|
||||||
|
list,
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...useResponseSuccess({
|
||||||
|
items: pageData,
|
||||||
|
total: list.length,
|
||||||
|
}),
|
||||||
|
message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function useResponseError(message: string, error: any = null) {
|
export function useResponseError(message: string, error: any = null) {
|
||||||
return {
|
return {
|
||||||
code: -1,
|
code: -1,
|
||||||
@@ -18,12 +39,30 @@ export function useResponseError(message: string, error: any = null) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function forbiddenResponse(event: H3Event<EventHandlerRequest>) {
|
export function forbiddenResponse(
|
||||||
|
event: H3Event<EventHandlerRequest>,
|
||||||
|
message = 'Forbidden Exception',
|
||||||
|
) {
|
||||||
setResponseStatus(event, 403);
|
setResponseStatus(event, 403);
|
||||||
return useResponseError('ForbiddenException', 'Forbidden Exception');
|
return useResponseError(message, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function unAuthorizedResponse(event: H3Event<EventHandlerRequest>) {
|
export function unAuthorizedResponse(event: H3Event<EventHandlerRequest>) {
|
||||||
setResponseStatus(event, 401);
|
setResponseStatus(event, 401);
|
||||||
return useResponseError('UnauthorizedException', 'Unauthorized Exception');
|
return useResponseError('Unauthorized Exception', 'Unauthorized Exception');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function sleep(ms: number) {
|
||||||
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function pagination<T = any>(
|
||||||
|
pageNo: number,
|
||||||
|
pageSize: number,
|
||||||
|
array: T[],
|
||||||
|
): T[] {
|
||||||
|
const offset = (pageNo - 1) * Number(pageSize);
|
||||||
|
return offset + Number(pageSize) >= array.length
|
||||||
|
? array.slice(offset)
|
||||||
|
: array.slice(offset, offset + Number(pageSize));
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vben/web-antd",
|
"name": "@vben/web-antd",
|
||||||
"version": "5.3.0",
|
"version": "5.4.4",
|
||||||
"homepage": "https://vben.pro",
|
"homepage": "https://vben.pro",
|
||||||
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
|
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
127
apps/web-antd/src/adapter/component/index.ts
Normal file
127
apps/web-antd/src/adapter/component/index.ts
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
|
||||||
|
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { BaseFormComponentType } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import type { Component, SetupContext } from 'vue';
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { globalShareState } from '@vben/common-ui';
|
||||||
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
|
import {
|
||||||
|
AutoComplete,
|
||||||
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
CheckboxGroup,
|
||||||
|
DatePicker,
|
||||||
|
Divider,
|
||||||
|
Input,
|
||||||
|
InputNumber,
|
||||||
|
InputPassword,
|
||||||
|
Mentions,
|
||||||
|
notification,
|
||||||
|
Radio,
|
||||||
|
RadioGroup,
|
||||||
|
RangePicker,
|
||||||
|
Rate,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Switch,
|
||||||
|
Textarea,
|
||||||
|
TimePicker,
|
||||||
|
TreeSelect,
|
||||||
|
Upload,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
|
const withDefaultPlaceholder = <T extends Component>(
|
||||||
|
component: T,
|
||||||
|
type: 'input' | 'select',
|
||||||
|
) => {
|
||||||
|
return (props: any, { attrs, slots }: Omit<SetupContext, 'expose'>) => {
|
||||||
|
const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`);
|
||||||
|
return h(component, { ...props, ...attrs, placeholder }, slots);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
|
||||||
|
export type ComponentType =
|
||||||
|
| 'AutoComplete'
|
||||||
|
| 'Checkbox'
|
||||||
|
| 'CheckboxGroup'
|
||||||
|
| 'DatePicker'
|
||||||
|
| 'DefaultButton'
|
||||||
|
| 'Divider'
|
||||||
|
| 'Input'
|
||||||
|
| 'InputNumber'
|
||||||
|
| 'InputPassword'
|
||||||
|
| 'Mentions'
|
||||||
|
| 'PrimaryButton'
|
||||||
|
| 'Radio'
|
||||||
|
| 'RadioGroup'
|
||||||
|
| 'RangePicker'
|
||||||
|
| 'Rate'
|
||||||
|
| 'Select'
|
||||||
|
| 'Space'
|
||||||
|
| 'Switch'
|
||||||
|
| 'Textarea'
|
||||||
|
| 'TimePicker'
|
||||||
|
| 'TreeSelect'
|
||||||
|
| 'Upload'
|
||||||
|
| BaseFormComponentType;
|
||||||
|
|
||||||
|
async function initComponentAdapter() {
|
||||||
|
const components: Partial<Record<ComponentType, Component>> = {
|
||||||
|
// 如果你的组件体积比较大,可以使用异步加载
|
||||||
|
// Button: () =>
|
||||||
|
// import('xxx').then((res) => res.Button),
|
||||||
|
|
||||||
|
AutoComplete,
|
||||||
|
Checkbox,
|
||||||
|
CheckboxGroup,
|
||||||
|
DatePicker,
|
||||||
|
// 自定义默认按钮
|
||||||
|
DefaultButton: (props, { attrs, slots }) => {
|
||||||
|
return h(Button, { ...props, attrs, type: 'default' }, slots);
|
||||||
|
},
|
||||||
|
Divider,
|
||||||
|
Input: withDefaultPlaceholder(Input, 'input'),
|
||||||
|
InputNumber: withDefaultPlaceholder(InputNumber, 'input'),
|
||||||
|
InputPassword: withDefaultPlaceholder(InputPassword, 'input'),
|
||||||
|
Mentions: withDefaultPlaceholder(Mentions, 'input'),
|
||||||
|
// 自定义主要按钮
|
||||||
|
PrimaryButton: (props, { attrs, slots }) => {
|
||||||
|
return h(Button, { ...props, attrs, type: 'primary' }, slots);
|
||||||
|
},
|
||||||
|
Radio,
|
||||||
|
RadioGroup,
|
||||||
|
RangePicker,
|
||||||
|
Rate,
|
||||||
|
Select: withDefaultPlaceholder(Select, 'select'),
|
||||||
|
Space,
|
||||||
|
Switch,
|
||||||
|
Textarea: withDefaultPlaceholder(Textarea, 'input'),
|
||||||
|
TimePicker,
|
||||||
|
TreeSelect: withDefaultPlaceholder(TreeSelect, 'select'),
|
||||||
|
Upload,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 将组件注册到全局共享状态中
|
||||||
|
globalShareState.setComponents(components);
|
||||||
|
|
||||||
|
// 定义全局共享状态中的消息提示
|
||||||
|
globalShareState.defineMessage({
|
||||||
|
// 复制成功消息提示
|
||||||
|
copyPreferencesSuccess: (title, content) => {
|
||||||
|
notification.success({
|
||||||
|
description: content,
|
||||||
|
message: title,
|
||||||
|
placement: 'bottomRight',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export { initComponentAdapter };
|
@@ -1,94 +1,14 @@
|
|||||||
import type {
|
import type {
|
||||||
BaseFormComponentType,
|
|
||||||
VbenFormSchema as FormSchema,
|
VbenFormSchema as FormSchema,
|
||||||
VbenFormProps,
|
VbenFormProps,
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import { h } from 'vue';
|
import type { ComponentType } from './component';
|
||||||
|
|
||||||
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
|
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
import {
|
setupVbenForm<ComponentType>({
|
||||||
AutoComplete,
|
|
||||||
Button,
|
|
||||||
Checkbox,
|
|
||||||
CheckboxGroup,
|
|
||||||
DatePicker,
|
|
||||||
Divider,
|
|
||||||
Input,
|
|
||||||
InputNumber,
|
|
||||||
InputPassword,
|
|
||||||
Mentions,
|
|
||||||
Radio,
|
|
||||||
RadioGroup,
|
|
||||||
RangePicker,
|
|
||||||
Rate,
|
|
||||||
Select,
|
|
||||||
Space,
|
|
||||||
Switch,
|
|
||||||
Textarea,
|
|
||||||
TimePicker,
|
|
||||||
TreeSelect,
|
|
||||||
Upload,
|
|
||||||
} from 'ant-design-vue';
|
|
||||||
|
|
||||||
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
|
|
||||||
export type FormComponentType =
|
|
||||||
| 'AutoComplete'
|
|
||||||
| 'Checkbox'
|
|
||||||
| 'CheckboxGroup'
|
|
||||||
| 'DatePicker'
|
|
||||||
| 'Divider'
|
|
||||||
| 'Input'
|
|
||||||
| 'InputNumber'
|
|
||||||
| 'InputPassword'
|
|
||||||
| 'Mentions'
|
|
||||||
| 'Radio'
|
|
||||||
| 'RadioGroup'
|
|
||||||
| 'RangePicker'
|
|
||||||
| 'Rate'
|
|
||||||
| 'Select'
|
|
||||||
| 'Space'
|
|
||||||
| 'Switch'
|
|
||||||
| 'Textarea'
|
|
||||||
| 'TimePicker'
|
|
||||||
| 'TreeSelect'
|
|
||||||
| 'Upload'
|
|
||||||
| BaseFormComponentType;
|
|
||||||
|
|
||||||
// 初始化表单组件,并注册到form组件内部
|
|
||||||
setupVbenForm<FormComponentType>({
|
|
||||||
components: {
|
|
||||||
AutoComplete,
|
|
||||||
Checkbox,
|
|
||||||
CheckboxGroup,
|
|
||||||
DatePicker,
|
|
||||||
// 自定义默认的重置按钮
|
|
||||||
DefaultResetActionButton: (props, { attrs, slots }) => {
|
|
||||||
return h(Button, { ...props, attrs, type: 'default' }, slots);
|
|
||||||
},
|
|
||||||
// 自定义默认的提交按钮
|
|
||||||
DefaultSubmitActionButton: (props, { attrs, slots }) => {
|
|
||||||
return h(Button, { ...props, attrs, type: 'primary' }, slots);
|
|
||||||
},
|
|
||||||
Divider,
|
|
||||||
Input,
|
|
||||||
InputNumber,
|
|
||||||
InputPassword,
|
|
||||||
Mentions,
|
|
||||||
Radio,
|
|
||||||
RadioGroup,
|
|
||||||
RangePicker,
|
|
||||||
Rate,
|
|
||||||
Select,
|
|
||||||
Space,
|
|
||||||
Switch,
|
|
||||||
Textarea,
|
|
||||||
TimePicker,
|
|
||||||
TreeSelect,
|
|
||||||
Upload,
|
|
||||||
},
|
|
||||||
config: {
|
config: {
|
||||||
// ant design vue组件库默认都是 v-model:value
|
// ant design vue组件库默认都是 v-model:value
|
||||||
baseModelPropName: 'value',
|
baseModelPropName: 'value',
|
||||||
@@ -105,23 +25,23 @@ setupVbenForm<FormComponentType>({
|
|||||||
// 输入项目必填国际化适配
|
// 输入项目必填国际化适配
|
||||||
required: (value, _params, ctx) => {
|
required: (value, _params, ctx) => {
|
||||||
if (value === undefined || value === null || value.length === 0) {
|
if (value === undefined || value === null || value.length === 0) {
|
||||||
return $t('formRules.required', [ctx.label]);
|
return $t('ui.formRules.required', [ctx.label]);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
// 选择项目必填国际化适配
|
// 选择项目必填国际化适配
|
||||||
selectRequired: (value, _params, ctx) => {
|
selectRequired: (value, _params, ctx) => {
|
||||||
if (value === undefined || value === null) {
|
if (value === undefined || value === null) {
|
||||||
return $t('formRules.selectRequired', [ctx.label]);
|
return $t('ui.formRules.selectRequired', [ctx.label]);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const useVbenForm = useForm<FormComponentType>;
|
const useVbenForm = useForm<ComponentType>;
|
||||||
|
|
||||||
export { useVbenForm, z };
|
export { useVbenForm, z };
|
||||||
|
|
||||||
export type VbenFormSchema = FormSchema<FormComponentType>;
|
export type VbenFormSchema = FormSchema<ComponentType>;
|
||||||
export type { VbenFormProps };
|
export type { VbenFormProps };
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
export * from './form';
|
|
67
apps/web-antd/src/adapter/vxe-table.ts
Normal file
67
apps/web-antd/src/adapter/vxe-table.ts
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
|
||||||
|
|
||||||
|
import { Button, Image } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from './form';
|
||||||
|
|
||||||
|
setupVbenVxeTable({
|
||||||
|
configVxeTable: (vxeUI) => {
|
||||||
|
vxeUI.setConfig({
|
||||||
|
grid: {
|
||||||
|
align: 'center',
|
||||||
|
border: false,
|
||||||
|
columnConfig: {
|
||||||
|
resizable: true,
|
||||||
|
},
|
||||||
|
minHeight: 180,
|
||||||
|
formConfig: {
|
||||||
|
// 全局禁用vxe-table的表单配置,使用formOptions
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
autoLoad: true,
|
||||||
|
response: {
|
||||||
|
result: 'items',
|
||||||
|
total: 'total',
|
||||||
|
list: 'items',
|
||||||
|
},
|
||||||
|
showActiveMsg: true,
|
||||||
|
showResponseMsg: false,
|
||||||
|
},
|
||||||
|
round: true,
|
||||||
|
showOverflow: true,
|
||||||
|
size: 'small',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格配置项可以用 cellRender: { name: 'CellImage' },
|
||||||
|
vxeUI.renderer.add('CellImage', {
|
||||||
|
renderTableDefault(_renderOpts, params) {
|
||||||
|
const { column, row } = params;
|
||||||
|
return h(Image, { src: row[column.field] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格配置项可以用 cellRender: { name: 'CellLink' },
|
||||||
|
vxeUI.renderer.add('CellLink', {
|
||||||
|
renderTableDefault(renderOpts) {
|
||||||
|
const { props } = renderOpts;
|
||||||
|
return h(
|
||||||
|
Button,
|
||||||
|
{ size: 'small', type: 'link' },
|
||||||
|
{ default: () => props?.text },
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
|
||||||
|
// vxeUI.formats.add
|
||||||
|
},
|
||||||
|
useVbenForm,
|
||||||
|
});
|
||||||
|
|
||||||
|
export { useVbenVxeGrid };
|
||||||
|
|
||||||
|
export type * from '@vben/plugins/vxe-table';
|
@@ -3,17 +3,13 @@ import { baseRequestClient, requestClient } from '#/api/request';
|
|||||||
export namespace AuthApi {
|
export namespace AuthApi {
|
||||||
/** 登录接口参数 */
|
/** 登录接口参数 */
|
||||||
export interface LoginParams {
|
export interface LoginParams {
|
||||||
password: string;
|
password?: string;
|
||||||
username: string;
|
username?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 登录接口返回值 */
|
/** 登录接口返回值 */
|
||||||
export interface LoginResult {
|
export interface LoginResult {
|
||||||
accessToken: string;
|
accessToken: string;
|
||||||
desc: string;
|
|
||||||
realName: string;
|
|
||||||
userId: string;
|
|
||||||
username: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RefreshTokenResult {
|
export interface RefreshTokenResult {
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* 该文件可自行根据业务逻辑进行调整
|
* 该文件可自行根据业务逻辑进行调整
|
||||||
*/
|
*/
|
||||||
|
import type { HttpResponse } from '@vben/request';
|
||||||
|
|
||||||
import { useAppConfig } from '@vben/hooks';
|
import { useAppConfig } from '@vben/hooks';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
import {
|
import {
|
||||||
@@ -68,15 +70,16 @@ function createRequestClient(baseURL: string) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// response数据解构
|
// response数据解构
|
||||||
client.addResponseInterceptor({
|
client.addResponseInterceptor<HttpResponse>({
|
||||||
fulfilled: (response) => {
|
fulfilled: (response) => {
|
||||||
const { data: responseData, status } = response;
|
const { data: responseData, status } = response;
|
||||||
|
|
||||||
const { code, data, message: msg } = responseData;
|
const { code, data } = responseData;
|
||||||
if (status >= 200 && status < 400 && code === 0) {
|
if (status >= 200 && status < 400 && code === 0) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
throw new Error(`Error ${status}: ${msg}`);
|
|
||||||
|
throw Object.assign({}, response, { response });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -93,7 +96,14 @@ function createRequestClient(baseURL: string) {
|
|||||||
|
|
||||||
// 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
|
// 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
|
||||||
client.addResponseInterceptor(
|
client.addResponseInterceptor(
|
||||||
errorMessageResponseInterceptor((msg: string) => message.error(msg)),
|
errorMessageResponseInterceptor((msg: string, error) => {
|
||||||
|
// 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
|
||||||
|
// 当前mock接口返回的错误字段是 error 或者 message
|
||||||
|
const responseData = error?.response?.data ?? {};
|
||||||
|
const errorMessage = responseData?.error ?? responseData?.message ?? '';
|
||||||
|
// 如果没有错误信息,则会根据状态码进行提示
|
||||||
|
message.error(errorMessage || msg);
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
|
@@ -1,16 +1,23 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp, watchEffect } from 'vue';
|
||||||
|
|
||||||
import { registerAccessDirective } from '@vben/access';
|
import { registerAccessDirective } from '@vben/access';
|
||||||
|
import { preferences } from '@vben/preferences';
|
||||||
import { initStores } from '@vben/stores';
|
import { initStores } from '@vben/stores';
|
||||||
import '@vben/styles';
|
import '@vben/styles';
|
||||||
import '@vben/styles/antd';
|
import '@vben/styles/antd';
|
||||||
|
|
||||||
import { setupI18n } from '#/locales';
|
import { useTitle } from '@vueuse/core';
|
||||||
|
|
||||||
|
import { $t, setupI18n } from '#/locales';
|
||||||
|
|
||||||
|
import { initComponentAdapter } from './adapter/component';
|
||||||
import App from './app.vue';
|
import App from './app.vue';
|
||||||
import { router } from './router';
|
import { router } from './router';
|
||||||
|
|
||||||
async function bootstrap(namespace: string) {
|
async function bootstrap(namespace: string) {
|
||||||
|
// 初始化组件适配器
|
||||||
|
await initComponentAdapter();
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
// 国际化 i18n 配置
|
// 国际化 i18n 配置
|
||||||
@@ -25,6 +32,16 @@ async function bootstrap(namespace: string) {
|
|||||||
// 配置路由及路由守卫
|
// 配置路由及路由守卫
|
||||||
app.use(router);
|
app.use(router);
|
||||||
|
|
||||||
|
// 动态更新标题
|
||||||
|
watchEffect(() => {
|
||||||
|
if (preferences.app.dynamicTitle) {
|
||||||
|
const routeTitle = router.currentRoute.value.meta?.title;
|
||||||
|
const pageTitle =
|
||||||
|
(routeTitle ? `${$t(routeTitle)} - ` : '') + preferences.app.name;
|
||||||
|
useTitle(pageTitle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { NotificationItem } from '@vben/layouts';
|
import type { NotificationItem } from '@vben/layouts';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { AuthenticationLoginExpiredModal } from '@vben/common-ui';
|
import { AuthenticationLoginExpiredModal } from '@vben/common-ui';
|
||||||
import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants';
|
import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants';
|
||||||
|
import { useWatermark } from '@vben/hooks';
|
||||||
import { BookOpenText, CircleHelp, MdiGithub } from '@vben/icons';
|
import { BookOpenText, CircleHelp, MdiGithub } from '@vben/icons';
|
||||||
import {
|
import {
|
||||||
BasicLayout,
|
BasicLayout,
|
||||||
@@ -54,6 +55,7 @@ const notifications = ref<NotificationItem[]>([
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
const accessStore = useAccessStore();
|
const accessStore = useAccessStore();
|
||||||
|
const { destroyWatermark, updateWatermark } = useWatermark();
|
||||||
const showDot = computed(() =>
|
const showDot = computed(() =>
|
||||||
notifications.value.some((item) => !item.isRead),
|
notifications.value.some((item) => !item.isRead),
|
||||||
);
|
);
|
||||||
@@ -66,7 +68,7 @@ const menus = computed(() => [
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
icon: BookOpenText,
|
icon: BookOpenText,
|
||||||
text: $t('widgets.document'),
|
text: $t('ui.widgets.document'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
handler: () => {
|
handler: () => {
|
||||||
@@ -84,7 +86,7 @@ const menus = computed(() => [
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
icon: CircleHelp,
|
icon: CircleHelp,
|
||||||
text: $t('widgets.qa'),
|
text: $t('ui.widgets.qa'),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -103,6 +105,21 @@ function handleNoticeClear() {
|
|||||||
function handleMakeAll() {
|
function handleMakeAll() {
|
||||||
notifications.value.forEach((item) => (item.isRead = true));
|
notifications.value.forEach((item) => (item.isRead = true));
|
||||||
}
|
}
|
||||||
|
watch(
|
||||||
|
() => preferences.app.watermark,
|
||||||
|
async (enable) => {
|
||||||
|
if (enable) {
|
||||||
|
await updateWatermark({
|
||||||
|
content: `${userStore.userInfo?.username}`,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
destroyWatermark();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@@ -4,7 +4,11 @@ import type { Locale } from 'ant-design-vue/es/locale';
|
|||||||
import type { App } from 'vue';
|
import type { App } from 'vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import { $t, setupI18n as coreSetup, loadLocalesMap } from '@vben/locales';
|
import {
|
||||||
|
$t,
|
||||||
|
setupI18n as coreSetup,
|
||||||
|
loadLocalesMapFromDir,
|
||||||
|
} from '@vben/locales';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
|
|
||||||
import antdEnLocale from 'ant-design-vue/es/locale/en_US';
|
import antdEnLocale from 'ant-design-vue/es/locale/en_US';
|
||||||
@@ -13,10 +17,12 @@ import dayjs from 'dayjs';
|
|||||||
|
|
||||||
const antdLocale = ref<Locale>(antdDefaultLocale);
|
const antdLocale = ref<Locale>(antdDefaultLocale);
|
||||||
|
|
||||||
const modules = import.meta.glob('./langs/*.json');
|
const modules = import.meta.glob('./langs/**/*.json');
|
||||||
|
|
||||||
const localesMap = loadLocalesMap(modules);
|
|
||||||
|
|
||||||
|
const localesMap = loadLocalesMapFromDir(
|
||||||
|
/\.\/langs\/([^/]+)\/(.*)\.json$/,
|
||||||
|
modules,
|
||||||
|
);
|
||||||
/**
|
/**
|
||||||
* 加载应用特有的语言包
|
* 加载应用特有的语言包
|
||||||
* 这里也可以改造为从服务端获取翻译数据
|
* 这里也可以改造为从服务端获取翻译数据
|
||||||
@@ -45,14 +51,14 @@ async function loadThirdPartyMessage(lang: SupportedLanguagesType) {
|
|||||||
async function loadDayjsLocale(lang: SupportedLanguagesType) {
|
async function loadDayjsLocale(lang: SupportedLanguagesType) {
|
||||||
let locale;
|
let locale;
|
||||||
switch (lang) {
|
switch (lang) {
|
||||||
case 'zh-CN': {
|
|
||||||
locale = await import('dayjs/locale/zh-cn');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'en-US': {
|
case 'en-US': {
|
||||||
locale = await import('dayjs/locale/en');
|
locale = await import('dayjs/locale/en');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'zh-CN': {
|
||||||
|
locale = await import('dayjs/locale/zh-cn');
|
||||||
|
break;
|
||||||
|
}
|
||||||
// 默认使用英语
|
// 默认使用英语
|
||||||
default: {
|
default: {
|
||||||
locale = await import('dayjs/locale/en');
|
locale = await import('dayjs/locale/en');
|
||||||
@@ -71,14 +77,14 @@ async function loadDayjsLocale(lang: SupportedLanguagesType) {
|
|||||||
*/
|
*/
|
||||||
async function loadAntdLocale(lang: SupportedLanguagesType) {
|
async function loadAntdLocale(lang: SupportedLanguagesType) {
|
||||||
switch (lang) {
|
switch (lang) {
|
||||||
case 'zh-CN': {
|
|
||||||
antdLocale.value = antdDefaultLocale;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'en-US': {
|
case 'en-US': {
|
||||||
antdLocale.value = antdEnLocale;
|
antdLocale.value = antdEnLocale;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'zh-CN': {
|
||||||
|
antdLocale.value = antdDefaultLocale;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"page": {
|
|
||||||
"demos": {
|
|
||||||
"title": "Demos",
|
|
||||||
"antd": "Ant Design Vue"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
12
apps/web-antd/src/locales/langs/en-US/demos.json
Normal file
12
apps/web-antd/src/locales/langs/en-US/demos.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"title": "Demos",
|
||||||
|
"antd": "Ant Design Vue",
|
||||||
|
"vben": {
|
||||||
|
"title": "Project",
|
||||||
|
"about": "About",
|
||||||
|
"document": "Document",
|
||||||
|
"antdv": "Ant Design Vue Version",
|
||||||
|
"naive-ui": "Naive UI Version",
|
||||||
|
"element-plus": "Element Plus Version"
|
||||||
|
}
|
||||||
|
}
|
14
apps/web-antd/src/locales/langs/en-US/page.json
Normal file
14
apps/web-antd/src/locales/langs/en-US/page.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"auth": {
|
||||||
|
"login": "Login",
|
||||||
|
"register": "Register",
|
||||||
|
"codeLogin": "Code Login",
|
||||||
|
"qrcodeLogin": "Qr Code Login",
|
||||||
|
"forgetPassword": "Forget Password"
|
||||||
|
},
|
||||||
|
"dashboard": {
|
||||||
|
"title": "Dashboard",
|
||||||
|
"analytics": "Analytics",
|
||||||
|
"workspace": "Workspace"
|
||||||
|
}
|
||||||
|
}
|
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"page": {
|
|
||||||
"demos": {
|
|
||||||
"title": "演示",
|
|
||||||
"antd": "Ant Design Vue"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
12
apps/web-antd/src/locales/langs/zh-CN/demos.json
Normal file
12
apps/web-antd/src/locales/langs/zh-CN/demos.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"title": "演示",
|
||||||
|
"antd": "Ant Design Vue",
|
||||||
|
"vben": {
|
||||||
|
"title": "项目",
|
||||||
|
"about": "关于",
|
||||||
|
"document": "文档",
|
||||||
|
"antdv": "Ant Design Vue 版本",
|
||||||
|
"naive-ui": "Naive UI 版本",
|
||||||
|
"element-plus": "Element Plus 版本"
|
||||||
|
}
|
||||||
|
}
|
14
apps/web-antd/src/locales/langs/zh-CN/page.json
Normal file
14
apps/web-antd/src/locales/langs/zh-CN/page.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"auth": {
|
||||||
|
"login": "登录",
|
||||||
|
"register": "注册",
|
||||||
|
"codeLogin": "验证码登录",
|
||||||
|
"qrcodeLogin": "二维码登录",
|
||||||
|
"forgetPassword": "忘记密码"
|
||||||
|
},
|
||||||
|
"dashboard": {
|
||||||
|
"title": "概览",
|
||||||
|
"analytics": "分析页",
|
||||||
|
"workspace": "工作台"
|
||||||
|
}
|
||||||
|
}
|
@@ -5,10 +5,7 @@ import { preferences } from '@vben/preferences';
|
|||||||
import { useAccessStore, useUserStore } from '@vben/stores';
|
import { useAccessStore, useUserStore } from '@vben/stores';
|
||||||
import { startProgress, stopProgress } from '@vben/utils';
|
import { startProgress, stopProgress } from '@vben/utils';
|
||||||
|
|
||||||
import { useTitle } from '@vueuse/core';
|
import { accessRoutes, coreRouteNames } from '#/router/routes';
|
||||||
|
|
||||||
import { $t } from '#/locales';
|
|
||||||
import { coreRouteNames, dynamicRoutes } from '#/router/routes';
|
|
||||||
import { useAuthStore } from '#/store';
|
import { useAuthStore } from '#/store';
|
||||||
|
|
||||||
import { generateAccess } from './access';
|
import { generateAccess } from './access';
|
||||||
@@ -34,21 +31,12 @@ function setupCommonGuard(router: Router) {
|
|||||||
router.afterEach((to) => {
|
router.afterEach((to) => {
|
||||||
// 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
|
// 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
|
||||||
|
|
||||||
if (preferences.tabbar.enable) {
|
loadedPaths.add(to.path);
|
||||||
loadedPaths.add(to.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 关闭页面加载进度条
|
// 关闭页面加载进度条
|
||||||
if (preferences.transition.progress) {
|
if (preferences.transition.progress) {
|
||||||
stopProgress();
|
stopProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 动态修改标题
|
|
||||||
if (preferences.app.dynamicTitle) {
|
|
||||||
const { title } = to.meta;
|
|
||||||
// useTitle(`${$t(title)} - ${preferences.app.name}`);
|
|
||||||
useTitle(`${$t(title)} - ${preferences.app.name}`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +95,7 @@ function setupAccessGuard(router: Router) {
|
|||||||
roles: userRoles,
|
roles: userRoles,
|
||||||
router,
|
router,
|
||||||
// 则会在菜单中显示,但是访问会被重定向到403
|
// 则会在菜单中显示,但是访问会被重定向到403
|
||||||
routes: dynamicRoutes,
|
routes: accessRoutes,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 保存菜单信息和路由信息
|
// 保存菜单信息和路由信息
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import type { RouteRecordRaw } from 'vue-router';
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
|
|
||||||
import { DEFAULT_HOME_PATH } from '@vben/constants';
|
import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
|
||||||
|
|
||||||
import { AuthPageLayout } from '#/layouts';
|
import { AuthPageLayout } from '#/layouts';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
@@ -32,17 +32,19 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
{
|
{
|
||||||
component: AuthPageLayout,
|
component: AuthPageLayout,
|
||||||
meta: {
|
meta: {
|
||||||
|
hideInTab: true,
|
||||||
title: 'Authentication',
|
title: 'Authentication',
|
||||||
},
|
},
|
||||||
name: 'Authentication',
|
name: 'Authentication',
|
||||||
path: '/auth',
|
path: '/auth',
|
||||||
|
redirect: LOGIN_PATH,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: 'Login',
|
name: 'Login',
|
||||||
path: 'login',
|
path: 'login',
|
||||||
component: Login,
|
component: Login,
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.login'),
|
title: $t('page.auth.login'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -50,7 +52,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
path: 'code-login',
|
path: 'code-login',
|
||||||
component: () => import('#/views/_core/authentication/code-login.vue'),
|
component: () => import('#/views/_core/authentication/code-login.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.codeLogin'),
|
title: $t('page.auth.codeLogin'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -59,7 +61,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
component: () =>
|
component: () =>
|
||||||
import('#/views/_core/authentication/qrcode-login.vue'),
|
import('#/views/_core/authentication/qrcode-login.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.qrcodeLogin'),
|
title: $t('page.auth.qrcodeLogin'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -68,7 +70,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
component: () =>
|
component: () =>
|
||||||
import('#/views/_core/authentication/forget-password.vue'),
|
import('#/views/_core/authentication/forget-password.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.forgetPassword'),
|
title: $t('page.auth.forgetPassword'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -76,7 +78,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
path: 'register',
|
path: 'register',
|
||||||
component: () => import('#/views/_core/authentication/register.vue'),
|
component: () => import('#/views/_core/authentication/register.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.register'),
|
title: $t('page.auth.register'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@@ -10,12 +10,16 @@ const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', {
|
|||||||
|
|
||||||
// 有需要可以自行打开注释,并创建文件夹
|
// 有需要可以自行打开注释,并创建文件夹
|
||||||
// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true });
|
// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true });
|
||||||
|
// const staticRouteFiles = import.meta.glob('./static/**/*.ts', { eager: true });
|
||||||
|
|
||||||
/** 动态路由 */
|
/** 动态路由 */
|
||||||
const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
|
const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
|
||||||
|
|
||||||
/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统 */
|
/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
|
||||||
// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
|
// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
|
||||||
|
/** 不需要权限的菜单列表(会显示在菜单中) */
|
||||||
|
// const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
|
||||||
|
const staticRoutes: RouteRecordRaw[] = [];
|
||||||
const externalRoutes: RouteRecordRaw[] = [];
|
const externalRoutes: RouteRecordRaw[] = [];
|
||||||
|
|
||||||
/** 路由列表,由基本路由+静态路由组成 */
|
/** 路由列表,由基本路由+静态路由组成 */
|
||||||
@@ -28,4 +32,5 @@ const routes: RouteRecordRaw[] = [
|
|||||||
/** 基本路由列表,这些路由不需要进入权限拦截 */
|
/** 基本路由列表,这些路由不需要进入权限拦截 */
|
||||||
const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
|
const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
|
||||||
|
|
||||||
export { coreRouteNames, dynamicRoutes, routes };
|
const accessRoutes = [...dynamicRoutes, ...staticRoutes];
|
||||||
|
export { accessRoutes, coreRouteNames, routes };
|
||||||
|
@@ -10,14 +10,14 @@ const routes: RouteRecordRaw[] = [
|
|||||||
icon: 'ic:baseline-view-in-ar',
|
icon: 'ic:baseline-view-in-ar',
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
order: 1000,
|
order: 1000,
|
||||||
title: $t('page.demos.title'),
|
title: $t('demos.title'),
|
||||||
},
|
},
|
||||||
name: 'Demos',
|
name: 'Demos',
|
||||||
path: '/demos',
|
path: '/demos',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.demos.antd'),
|
title: $t('demos.antd'),
|
||||||
},
|
},
|
||||||
name: 'AntDesignDemos',
|
name: 'AntDesignDemos',
|
||||||
path: '/demos/ant-design',
|
path: '/demos/ant-design',
|
||||||
|
@@ -18,7 +18,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
badgeType: 'dot',
|
badgeType: 'dot',
|
||||||
icon: VBEN_LOGO_URL,
|
icon: VBEN_LOGO_URL,
|
||||||
order: 9999,
|
order: 9999,
|
||||||
title: $t('page.vben.title'),
|
title: $t('demos.vben.title'),
|
||||||
},
|
},
|
||||||
name: 'VbenProject',
|
name: 'VbenProject',
|
||||||
path: '/vben-admin',
|
path: '/vben-admin',
|
||||||
@@ -29,7 +29,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
component: () => import('#/views/_core/about/index.vue'),
|
component: () => import('#/views/_core/about/index.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'lucide:copyright',
|
icon: 'lucide:copyright',
|
||||||
title: $t('page.vben.about'),
|
title: $t('demos.vben.about'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
icon: 'lucide:book-open-text',
|
icon: 'lucide:book-open-text',
|
||||||
link: VBEN_DOC_URL,
|
link: VBEN_DOC_URL,
|
||||||
title: $t('page.vben.document'),
|
title: $t('demos.vben.document'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -60,7 +60,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
badgeType: 'dot',
|
badgeType: 'dot',
|
||||||
icon: 'logos:naiveui',
|
icon: 'logos:naiveui',
|
||||||
link: VBEN_NAIVE_PREVIEW_URL,
|
link: VBEN_NAIVE_PREVIEW_URL,
|
||||||
title: $t('page.vben.naive-ui'),
|
title: $t('demos.vben.naive-ui'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -71,7 +71,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
badgeType: 'dot',
|
badgeType: 'dot',
|
||||||
icon: 'logos:element',
|
icon: 'logos:element',
|
||||||
link: VBEN_ELE_PREVIEW_URL,
|
link: VBEN_ELE_PREVIEW_URL,
|
||||||
title: $t('page.vben.element-plus'),
|
title: $t('demos.vben.element-plus'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import type { LoginAndRegisterParams } from '@vben/common-ui';
|
import type { Recordable, UserInfo } from '@vben/types';
|
||||||
import type { UserInfo } from '@vben/types';
|
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
@@ -26,7 +25,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
* @param params 登录表单数据
|
* @param params 登录表单数据
|
||||||
*/
|
*/
|
||||||
async function authLogin(
|
async function authLogin(
|
||||||
params: LoginAndRegisterParams,
|
params: Recordable<any>,
|
||||||
onSuccess?: () => Promise<void> | void,
|
onSuccess?: () => Promise<void> | void,
|
||||||
) {
|
) {
|
||||||
// 异步处理用户登录操作并获取 accessToken
|
// 异步处理用户登录操作并获取 accessToken
|
||||||
@@ -84,7 +83,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
resetAllStores();
|
resetAllStores();
|
||||||
accessStore.setLoginExpired(false);
|
accessStore.setLoginExpired(false);
|
||||||
|
|
||||||
// 回登陆页带上当前路由地址
|
// 回登录页带上当前路由地址
|
||||||
await router.replace({
|
await router.replace({
|
||||||
path: LOGIN_PATH,
|
path: LOGIN_PATH,
|
||||||
query: redirect
|
query: redirect
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { LoginCodeParams, VbenFormSchema } from '@vben/common-ui';
|
import type { VbenFormSchema } from '@vben/common-ui';
|
||||||
|
import type { Recordable } from '@vben/types';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
* Asynchronously handle the login process
|
* Asynchronously handle the login process
|
||||||
* @param values 登录表单数据
|
* @param values 登录表单数据
|
||||||
*/
|
*/
|
||||||
async function handleLogin(values: LoginCodeParams) {
|
async function handleLogin(values: Recordable<any>) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(values);
|
console.log(values);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VbenFormSchema } from '@vben/common-ui';
|
import type { VbenFormSchema } from '@vben/common-ui';
|
||||||
|
import type { Recordable } from '@vben/types';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleSubmit(value: string) {
|
function handleSubmit(value: Recordable<any>) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('reset email:', value);
|
console.log('reset email:', value);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { LoginAndRegisterParams, VbenFormSchema } from '@vben/common-ui';
|
import type { VbenFormSchema } from '@vben/common-ui';
|
||||||
|
import type { Recordable } from '@vben/types';
|
||||||
|
|
||||||
import { computed, h, ref } from 'vue';
|
import { computed, h, ref } from 'vue';
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
rules(values) {
|
rules(values) {
|
||||||
const { password } = values;
|
const { password } = values;
|
||||||
return z
|
return z
|
||||||
.string()
|
.string({ required_error: $t('authentication.passwordTip') })
|
||||||
.min(1, { message: $t('authentication.passwordTip') })
|
.min(1, { message: $t('authentication.passwordTip') })
|
||||||
.refine((value) => value === password, {
|
.refine((value) => value === password, {
|
||||||
message: $t('authentication.confirmPasswordTip'),
|
message: $t('authentication.confirmPasswordTip'),
|
||||||
@@ -55,7 +56,6 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
},
|
},
|
||||||
fieldName: 'confirmPassword',
|
fieldName: 'confirmPassword',
|
||||||
label: $t('authentication.confirmPassword'),
|
label: $t('authentication.confirmPassword'),
|
||||||
rules: z.string().min(1, { message: $t('authentication.passwordTip') }),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'VbenCheckbox',
|
component: 'VbenCheckbox',
|
||||||
@@ -67,15 +67,10 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
h(
|
h(
|
||||||
'a',
|
'a',
|
||||||
{
|
{
|
||||||
class:
|
class: 'vben-link ml-1 ',
|
||||||
'cursor-pointer text-primary ml-1 hover:text-primary-hover',
|
|
||||||
href: '',
|
href: '',
|
||||||
},
|
},
|
||||||
[
|
`${$t('authentication.privacyPolicy')} & ${$t('authentication.terms')}`,
|
||||||
$t('authentication.privacyPolicy'),
|
|
||||||
'&',
|
|
||||||
$t('authentication.terms'),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
}),
|
}),
|
||||||
@@ -86,7 +81,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleSubmit(value: LoginAndRegisterParams) {
|
function handleSubmit(value: Recordable<any>) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('register submit:', value);
|
console.log('register submit:', value);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vben/web-ele",
|
"name": "@vben/web-ele",
|
||||||
"version": "5.3.0",
|
"version": "5.4.4",
|
||||||
"homepage": "https://vben.pro",
|
"homepage": "https://vben.pro",
|
||||||
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
|
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
104
apps/web-ele/src/adapter/component/index.ts
Normal file
104
apps/web-ele/src/adapter/component/index.ts
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
/**
|
||||||
|
* 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
|
||||||
|
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { BaseFormComponentType } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import type { Component, SetupContext } from 'vue';
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { globalShareState } from '@vben/common-ui';
|
||||||
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
|
import {
|
||||||
|
ElButton,
|
||||||
|
ElCheckbox,
|
||||||
|
ElCheckboxGroup,
|
||||||
|
ElDivider,
|
||||||
|
ElInput,
|
||||||
|
ElInputNumber,
|
||||||
|
ElNotification,
|
||||||
|
ElRadioGroup,
|
||||||
|
ElSelect,
|
||||||
|
ElSpace,
|
||||||
|
ElSwitch,
|
||||||
|
ElTimePicker,
|
||||||
|
ElTreeSelect,
|
||||||
|
ElUpload,
|
||||||
|
} from 'element-plus';
|
||||||
|
|
||||||
|
const withDefaultPlaceholder = <T extends Component>(
|
||||||
|
component: T,
|
||||||
|
type: 'input' | 'select',
|
||||||
|
) => {
|
||||||
|
return (props: any, { attrs, slots }: Omit<SetupContext, 'expose'>) => {
|
||||||
|
const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`);
|
||||||
|
return h(component, { ...props, ...attrs, placeholder }, slots);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
|
||||||
|
export type ComponentType =
|
||||||
|
| 'Checkbox'
|
||||||
|
| 'CheckboxGroup'
|
||||||
|
| 'DatePicker'
|
||||||
|
| 'Divider'
|
||||||
|
| 'Input'
|
||||||
|
| 'InputNumber'
|
||||||
|
| 'RadioGroup'
|
||||||
|
| 'Select'
|
||||||
|
| 'Space'
|
||||||
|
| 'Switch'
|
||||||
|
| 'TimePicker'
|
||||||
|
| 'TreeSelect'
|
||||||
|
| 'Upload'
|
||||||
|
| BaseFormComponentType;
|
||||||
|
|
||||||
|
async function initComponentAdapter() {
|
||||||
|
const components: Partial<Record<ComponentType, Component>> = {
|
||||||
|
// 如果你的组件体积比较大,可以使用异步加载
|
||||||
|
// Button: () =>
|
||||||
|
// import('xxx').then((res) => res.Button),
|
||||||
|
|
||||||
|
Checkbox: ElCheckbox,
|
||||||
|
CheckboxGroup: ElCheckboxGroup,
|
||||||
|
// 自定义默认按钮
|
||||||
|
DefaulButton: (props, { attrs, slots }) => {
|
||||||
|
return h(ElButton, { ...props, attrs, type: 'info' }, slots);
|
||||||
|
},
|
||||||
|
// 自定义主要按钮
|
||||||
|
PrimaryButton: (props, { attrs, slots }) => {
|
||||||
|
return h(ElButton, { ...props, attrs, type: 'primary' }, slots);
|
||||||
|
},
|
||||||
|
Divider: ElDivider,
|
||||||
|
Input: withDefaultPlaceholder(ElInput, 'input'),
|
||||||
|
InputNumber: withDefaultPlaceholder(ElInputNumber, 'input'),
|
||||||
|
RadioGroup: ElRadioGroup,
|
||||||
|
Select: withDefaultPlaceholder(ElSelect, 'select'),
|
||||||
|
Space: ElSpace,
|
||||||
|
Switch: ElSwitch,
|
||||||
|
TimePicker: ElTimePicker,
|
||||||
|
TreeSelect: withDefaultPlaceholder(ElTreeSelect, 'select'),
|
||||||
|
Upload: ElUpload,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 将组件注册到全局共享状态中
|
||||||
|
globalShareState.setComponents(components);
|
||||||
|
|
||||||
|
// 定义全局共享状态中的消息提示
|
||||||
|
globalShareState.defineMessage({
|
||||||
|
// 复制成功消息提示
|
||||||
|
copyPreferencesSuccess: (title, content) => {
|
||||||
|
ElNotification({
|
||||||
|
title,
|
||||||
|
message: content,
|
||||||
|
position: 'bottom-right',
|
||||||
|
duration: 0,
|
||||||
|
type: 'success',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export { initComponentAdapter };
|
@@ -1,71 +1,14 @@
|
|||||||
import type {
|
import type {
|
||||||
BaseFormComponentType,
|
|
||||||
VbenFormSchema as FormSchema,
|
VbenFormSchema as FormSchema,
|
||||||
VbenFormProps,
|
VbenFormProps,
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import { h } from 'vue';
|
import type { ComponentType } from './component';
|
||||||
|
|
||||||
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
|
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
import {
|
setupVbenForm<ComponentType>({
|
||||||
ElButton,
|
|
||||||
ElCheckbox,
|
|
||||||
ElCheckboxGroup,
|
|
||||||
ElDivider,
|
|
||||||
ElInput,
|
|
||||||
ElInputNumber,
|
|
||||||
ElRadioGroup,
|
|
||||||
ElSelect,
|
|
||||||
ElSpace,
|
|
||||||
ElSwitch,
|
|
||||||
ElTimePicker,
|
|
||||||
ElTreeSelect,
|
|
||||||
ElUpload,
|
|
||||||
} from 'element-plus';
|
|
||||||
// 业务表单组件适配
|
|
||||||
|
|
||||||
export type FormComponentType =
|
|
||||||
| 'Checkbox'
|
|
||||||
| 'CheckboxGroup'
|
|
||||||
| 'DatePicker'
|
|
||||||
| 'Divider'
|
|
||||||
| 'Input'
|
|
||||||
| 'InputNumber'
|
|
||||||
| 'RadioGroup'
|
|
||||||
| 'Select'
|
|
||||||
| 'Space'
|
|
||||||
| 'Switch'
|
|
||||||
| 'TimePicker'
|
|
||||||
| 'TreeSelect'
|
|
||||||
| 'Upload'
|
|
||||||
| BaseFormComponentType;
|
|
||||||
|
|
||||||
// 初始化表单组件,并注册到form组件内部
|
|
||||||
setupVbenForm<FormComponentType>({
|
|
||||||
components: {
|
|
||||||
Checkbox: ElCheckbox,
|
|
||||||
CheckboxGroup: ElCheckboxGroup,
|
|
||||||
// 自定义默认的重置按钮
|
|
||||||
DefaultResetActionButton: (props, { attrs, slots }) => {
|
|
||||||
return h(ElButton, { ...props, attrs, type: 'info' }, slots);
|
|
||||||
},
|
|
||||||
// 自定义默认的提交按钮
|
|
||||||
DefaultSubmitActionButton: (props, { attrs, slots }) => {
|
|
||||||
return h(ElButton, { ...props, attrs, type: 'primary' }, slots);
|
|
||||||
},
|
|
||||||
Divider: ElDivider,
|
|
||||||
Input: ElInput,
|
|
||||||
InputNumber: ElInputNumber,
|
|
||||||
RadioGroup: ElRadioGroup,
|
|
||||||
Select: ElSelect,
|
|
||||||
Space: ElSpace,
|
|
||||||
Switch: ElSwitch,
|
|
||||||
TimePicker: ElTimePicker,
|
|
||||||
TreeSelect: ElTreeSelect,
|
|
||||||
Upload: ElUpload,
|
|
||||||
},
|
|
||||||
config: {
|
config: {
|
||||||
modelPropNameMap: {
|
modelPropNameMap: {
|
||||||
Upload: 'fileList',
|
Upload: 'fileList',
|
||||||
@@ -74,22 +17,22 @@ setupVbenForm<FormComponentType>({
|
|||||||
defineRules: {
|
defineRules: {
|
||||||
required: (value, _params, ctx) => {
|
required: (value, _params, ctx) => {
|
||||||
if (value === undefined || value === null || value.length === 0) {
|
if (value === undefined || value === null || value.length === 0) {
|
||||||
return $t('formRules.required', [ctx.label]);
|
return $t('ui.formRules.required', [ctx.label]);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
selectRequired: (value, _params, ctx) => {
|
selectRequired: (value, _params, ctx) => {
|
||||||
if (value === undefined || value === null) {
|
if (value === undefined || value === null) {
|
||||||
return $t('formRules.selectRequired', [ctx.label]);
|
return $t('ui.formRules.selectRequired', [ctx.label]);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const useVbenForm = useForm<FormComponentType>;
|
const useVbenForm = useForm<ComponentType>;
|
||||||
|
|
||||||
export { useVbenForm, z };
|
export { useVbenForm, z };
|
||||||
|
|
||||||
export type VbenFormSchema = FormSchema<FormComponentType>;
|
export type VbenFormSchema = FormSchema<ComponentType>;
|
||||||
export type { VbenFormProps };
|
export type { VbenFormProps };
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
export * from './form';
|
|
68
apps/web-ele/src/adapter/vxe-table.ts
Normal file
68
apps/web-ele/src/adapter/vxe-table.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
|
||||||
|
|
||||||
|
import { ElButton, ElImage } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from './form';
|
||||||
|
|
||||||
|
setupVbenVxeTable({
|
||||||
|
configVxeTable: (vxeUI) => {
|
||||||
|
vxeUI.setConfig({
|
||||||
|
grid: {
|
||||||
|
align: 'center',
|
||||||
|
border: false,
|
||||||
|
columnConfig: {
|
||||||
|
resizable: true,
|
||||||
|
},
|
||||||
|
minHeight: 180,
|
||||||
|
formConfig: {
|
||||||
|
// 全局禁用vxe-table的表单配置,使用formOptions
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
autoLoad: true,
|
||||||
|
response: {
|
||||||
|
result: 'items',
|
||||||
|
total: 'total',
|
||||||
|
list: 'items',
|
||||||
|
},
|
||||||
|
showActiveMsg: true,
|
||||||
|
showResponseMsg: false,
|
||||||
|
},
|
||||||
|
round: true,
|
||||||
|
showOverflow: true,
|
||||||
|
size: 'small',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格配置项可以用 cellRender: { name: 'CellImage' },
|
||||||
|
vxeUI.renderer.add('CellImage', {
|
||||||
|
renderTableDefault(_renderOpts, params) {
|
||||||
|
const { column, row } = params;
|
||||||
|
const src = row[column.field];
|
||||||
|
return h(ElImage, { src, previewSrcList: [src] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格配置项可以用 cellRender: { name: 'CellLink' },
|
||||||
|
vxeUI.renderer.add('CellLink', {
|
||||||
|
renderTableDefault(renderOpts) {
|
||||||
|
const { props } = renderOpts;
|
||||||
|
return h(
|
||||||
|
ElButton,
|
||||||
|
{ size: 'small', link: true },
|
||||||
|
{ default: () => props?.text },
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
|
||||||
|
// vxeUI.formats.add
|
||||||
|
},
|
||||||
|
useVbenForm,
|
||||||
|
});
|
||||||
|
|
||||||
|
export { useVbenVxeGrid };
|
||||||
|
|
||||||
|
export type * from '@vben/plugins/vxe-table';
|
@@ -3,17 +3,13 @@ import { baseRequestClient, requestClient } from '#/api/request';
|
|||||||
export namespace AuthApi {
|
export namespace AuthApi {
|
||||||
/** 登录接口参数 */
|
/** 登录接口参数 */
|
||||||
export interface LoginParams {
|
export interface LoginParams {
|
||||||
password: string;
|
password?: string;
|
||||||
username: string;
|
username?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 登录接口返回值 */
|
/** 登录接口返回值 */
|
||||||
export interface LoginResult {
|
export interface LoginResult {
|
||||||
accessToken: string;
|
accessToken: string;
|
||||||
desc: string;
|
|
||||||
realName: string;
|
|
||||||
userId: string;
|
|
||||||
username: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RefreshTokenResult {
|
export interface RefreshTokenResult {
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* 该文件可自行根据业务逻辑进行调整
|
* 该文件可自行根据业务逻辑进行调整
|
||||||
*/
|
*/
|
||||||
|
import type { HttpResponse } from '@vben/request';
|
||||||
|
|
||||||
import { useAppConfig } from '@vben/hooks';
|
import { useAppConfig } from '@vben/hooks';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
import {
|
import {
|
||||||
@@ -68,15 +70,15 @@ function createRequestClient(baseURL: string) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// response数据解构
|
// response数据解构
|
||||||
client.addResponseInterceptor({
|
client.addResponseInterceptor<HttpResponse>({
|
||||||
fulfilled: (response) => {
|
fulfilled: (response) => {
|
||||||
const { data: responseData, status } = response;
|
const { data: responseData, status } = response;
|
||||||
|
|
||||||
const { code, data, message: msg } = responseData;
|
const { code, data } = responseData;
|
||||||
if (status >= 200 && status < 400 && code === 0) {
|
if (status >= 200 && status < 400 && code === 0) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
throw new Error(`Error ${status}: ${msg}`);
|
throw Object.assign({}, response, { response });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -93,7 +95,14 @@ function createRequestClient(baseURL: string) {
|
|||||||
|
|
||||||
// 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
|
// 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
|
||||||
client.addResponseInterceptor(
|
client.addResponseInterceptor(
|
||||||
errorMessageResponseInterceptor((msg: string) => ElMessage.error(msg)),
|
errorMessageResponseInterceptor((msg: string, error) => {
|
||||||
|
// 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
|
||||||
|
// 当前mock接口返回的错误字段是 error 或者 message
|
||||||
|
const responseData = error?.response?.data ?? {};
|
||||||
|
const errorMessage = responseData?.error ?? responseData?.message ?? '';
|
||||||
|
// 如果没有错误信息,则会根据状态码进行提示
|
||||||
|
ElMessage.error(errorMessage || msg);
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
|
@@ -1,16 +1,22 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp, watchEffect } from 'vue';
|
||||||
|
|
||||||
import { registerAccessDirective } from '@vben/access';
|
import { registerAccessDirective } from '@vben/access';
|
||||||
|
import { preferences } from '@vben/preferences';
|
||||||
import { initStores } from '@vben/stores';
|
import { initStores } from '@vben/stores';
|
||||||
import '@vben/styles';
|
import '@vben/styles';
|
||||||
import '@vben/styles/ele';
|
import '@vben/styles/ele';
|
||||||
|
|
||||||
import { setupI18n } from '#/locales';
|
import { useTitle } from '@vueuse/core';
|
||||||
|
|
||||||
|
import { $t, setupI18n } from '#/locales';
|
||||||
|
|
||||||
|
import { initComponentAdapter } from './adapter/component';
|
||||||
import App from './app.vue';
|
import App from './app.vue';
|
||||||
import { router } from './router';
|
import { router } from './router';
|
||||||
|
|
||||||
async function bootstrap(namespace: string) {
|
async function bootstrap(namespace: string) {
|
||||||
|
// 初始化组件适配器
|
||||||
|
await initComponentAdapter();
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
// 国际化 i18n 配置
|
// 国际化 i18n 配置
|
||||||
@@ -25,6 +31,16 @@ async function bootstrap(namespace: string) {
|
|||||||
// 配置路由及路由守卫
|
// 配置路由及路由守卫
|
||||||
app.use(router);
|
app.use(router);
|
||||||
|
|
||||||
|
// 动态更新标题
|
||||||
|
watchEffect(() => {
|
||||||
|
if (preferences.app.dynamicTitle) {
|
||||||
|
const routeTitle = router.currentRoute.value.meta?.title;
|
||||||
|
const pageTitle =
|
||||||
|
(routeTitle ? `${$t(routeTitle)} - ` : '') + preferences.app.name;
|
||||||
|
useTitle(pageTitle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { NotificationItem } from '@vben/layouts';
|
import type { NotificationItem } from '@vben/layouts';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { AuthenticationLoginExpiredModal } from '@vben/common-ui';
|
import { AuthenticationLoginExpiredModal } from '@vben/common-ui';
|
||||||
import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants';
|
import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants';
|
||||||
|
import { useWatermark } from '@vben/hooks';
|
||||||
import { BookOpenText, CircleHelp, MdiGithub } from '@vben/icons';
|
import { BookOpenText, CircleHelp, MdiGithub } from '@vben/icons';
|
||||||
import {
|
import {
|
||||||
BasicLayout,
|
BasicLayout,
|
||||||
@@ -54,6 +55,7 @@ const notifications = ref<NotificationItem[]>([
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
const accessStore = useAccessStore();
|
const accessStore = useAccessStore();
|
||||||
|
const { destroyWatermark, updateWatermark } = useWatermark();
|
||||||
const showDot = computed(() =>
|
const showDot = computed(() =>
|
||||||
notifications.value.some((item) => !item.isRead),
|
notifications.value.some((item) => !item.isRead),
|
||||||
);
|
);
|
||||||
@@ -66,7 +68,7 @@ const menus = computed(() => [
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
icon: BookOpenText,
|
icon: BookOpenText,
|
||||||
text: $t('widgets.document'),
|
text: $t('ui.widgets.document'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
handler: () => {
|
handler: () => {
|
||||||
@@ -84,7 +86,7 @@ const menus = computed(() => [
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
icon: CircleHelp,
|
icon: CircleHelp,
|
||||||
text: $t('widgets.qa'),
|
text: $t('ui.widgets.qa'),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -103,6 +105,21 @@ function handleNoticeClear() {
|
|||||||
function handleMakeAll() {
|
function handleMakeAll() {
|
||||||
notifications.value.forEach((item) => (item.isRead = true));
|
notifications.value.forEach((item) => (item.isRead = true));
|
||||||
}
|
}
|
||||||
|
watch(
|
||||||
|
() => preferences.app.watermark,
|
||||||
|
async (enable) => {
|
||||||
|
if (enable) {
|
||||||
|
await updateWatermark({
|
||||||
|
content: `${userStore.userInfo?.username}`,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
destroyWatermark();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@@ -4,7 +4,11 @@ import type { Language } from 'element-plus/es/locale';
|
|||||||
import type { App } from 'vue';
|
import type { App } from 'vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import { $t, setupI18n as coreSetup, loadLocalesMap } from '@vben/locales';
|
import {
|
||||||
|
$t,
|
||||||
|
setupI18n as coreSetup,
|
||||||
|
loadLocalesMapFromDir,
|
||||||
|
} from '@vben/locales';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
@@ -13,10 +17,12 @@ import defaultLocale from 'element-plus/es/locale/lang/zh-cn';
|
|||||||
|
|
||||||
const elementLocale = ref<Language>(defaultLocale);
|
const elementLocale = ref<Language>(defaultLocale);
|
||||||
|
|
||||||
const modules = import.meta.glob('./langs/*.json');
|
const modules = import.meta.glob('./langs/**/*.json');
|
||||||
|
|
||||||
const localesMap = loadLocalesMap(modules);
|
|
||||||
|
|
||||||
|
const localesMap = loadLocalesMapFromDir(
|
||||||
|
/\.\/langs\/([^/]+)\/(.*)\.json$/,
|
||||||
|
modules,
|
||||||
|
);
|
||||||
/**
|
/**
|
||||||
* 加载应用特有的语言包
|
* 加载应用特有的语言包
|
||||||
* 这里也可以改造为从服务端获取翻译数据
|
* 这里也可以改造为从服务端获取翻译数据
|
||||||
@@ -45,14 +51,14 @@ async function loadThirdPartyMessage(lang: SupportedLanguagesType) {
|
|||||||
async function loadDayjsLocale(lang: SupportedLanguagesType) {
|
async function loadDayjsLocale(lang: SupportedLanguagesType) {
|
||||||
let locale;
|
let locale;
|
||||||
switch (lang) {
|
switch (lang) {
|
||||||
case 'zh-CN': {
|
|
||||||
locale = await import('dayjs/locale/zh-cn');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'en-US': {
|
case 'en-US': {
|
||||||
locale = await import('dayjs/locale/en');
|
locale = await import('dayjs/locale/en');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'zh-CN': {
|
||||||
|
locale = await import('dayjs/locale/zh-cn');
|
||||||
|
break;
|
||||||
|
}
|
||||||
// 默认使用英语
|
// 默认使用英语
|
||||||
default: {
|
default: {
|
||||||
locale = await import('dayjs/locale/en');
|
locale = await import('dayjs/locale/en');
|
||||||
@@ -71,14 +77,14 @@ async function loadDayjsLocale(lang: SupportedLanguagesType) {
|
|||||||
*/
|
*/
|
||||||
async function loadElementLocale(lang: SupportedLanguagesType) {
|
async function loadElementLocale(lang: SupportedLanguagesType) {
|
||||||
switch (lang) {
|
switch (lang) {
|
||||||
case 'zh-CN': {
|
|
||||||
elementLocale.value = defaultLocale;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'en-US': {
|
case 'en-US': {
|
||||||
elementLocale.value = enLocale;
|
elementLocale.value = enLocale;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'zh-CN': {
|
||||||
|
elementLocale.value = defaultLocale;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"page": {
|
|
||||||
"demos": {
|
|
||||||
"title": "Demos",
|
|
||||||
"element-plus": "Element Plus"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
12
apps/web-ele/src/locales/langs/en-US/demos.json
Normal file
12
apps/web-ele/src/locales/langs/en-US/demos.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"title": "Demos",
|
||||||
|
"elementPlus": "Element Plus",
|
||||||
|
"vben": {
|
||||||
|
"title": "Project",
|
||||||
|
"about": "About",
|
||||||
|
"document": "Document",
|
||||||
|
"antdv": "Ant Design Vue Version",
|
||||||
|
"naive-ui": "Naive UI Version",
|
||||||
|
"element-plus": "Element Plus Version"
|
||||||
|
}
|
||||||
|
}
|
14
apps/web-ele/src/locales/langs/en-US/page.json
Normal file
14
apps/web-ele/src/locales/langs/en-US/page.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"auth": {
|
||||||
|
"login": "Login",
|
||||||
|
"register": "Register",
|
||||||
|
"codeLogin": "Code Login",
|
||||||
|
"qrcodeLogin": "Qr Code Login",
|
||||||
|
"forgetPassword": "Forget Password"
|
||||||
|
},
|
||||||
|
"dashboard": {
|
||||||
|
"title": "Dashboard",
|
||||||
|
"analytics": "Analytics",
|
||||||
|
"workspace": "Workspace"
|
||||||
|
}
|
||||||
|
}
|
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"page": {
|
|
||||||
"demos": {
|
|
||||||
"title": "演示",
|
|
||||||
"element-plus": "Element Plus"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
12
apps/web-ele/src/locales/langs/zh-CN/demos.json
Normal file
12
apps/web-ele/src/locales/langs/zh-CN/demos.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"title": "演示",
|
||||||
|
"elementPlus": "Element Plus",
|
||||||
|
"vben": {
|
||||||
|
"title": "项目",
|
||||||
|
"about": "关于",
|
||||||
|
"document": "文档",
|
||||||
|
"antdv": "Ant Design Vue 版本",
|
||||||
|
"naive-ui": "Naive UI 版本",
|
||||||
|
"element-plus": "Element Plus 版本"
|
||||||
|
}
|
||||||
|
}
|
14
apps/web-ele/src/locales/langs/zh-CN/page.json
Normal file
14
apps/web-ele/src/locales/langs/zh-CN/page.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"auth": {
|
||||||
|
"login": "登录",
|
||||||
|
"register": "注册",
|
||||||
|
"codeLogin": "验证码登录",
|
||||||
|
"qrcodeLogin": "二维码登录",
|
||||||
|
"forgetPassword": "忘记密码"
|
||||||
|
},
|
||||||
|
"dashboard": {
|
||||||
|
"title": "概览",
|
||||||
|
"analytics": "分析页",
|
||||||
|
"workspace": "工作台"
|
||||||
|
}
|
||||||
|
}
|
@@ -5,10 +5,7 @@ import { preferences } from '@vben/preferences';
|
|||||||
import { useAccessStore, useUserStore } from '@vben/stores';
|
import { useAccessStore, useUserStore } from '@vben/stores';
|
||||||
import { startProgress, stopProgress } from '@vben/utils';
|
import { startProgress, stopProgress } from '@vben/utils';
|
||||||
|
|
||||||
import { useTitle } from '@vueuse/core';
|
import { accessRoutes, coreRouteNames } from '#/router/routes';
|
||||||
|
|
||||||
import { $t } from '#/locales';
|
|
||||||
import { coreRouteNames, dynamicRoutes } from '#/router/routes';
|
|
||||||
import { useAuthStore } from '#/store';
|
import { useAuthStore } from '#/store';
|
||||||
|
|
||||||
import { generateAccess } from './access';
|
import { generateAccess } from './access';
|
||||||
@@ -34,21 +31,12 @@ function setupCommonGuard(router: Router) {
|
|||||||
router.afterEach((to) => {
|
router.afterEach((to) => {
|
||||||
// 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
|
// 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
|
||||||
|
|
||||||
if (preferences.tabbar.enable) {
|
loadedPaths.add(to.path);
|
||||||
loadedPaths.add(to.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 关闭页面加载进度条
|
// 关闭页面加载进度条
|
||||||
if (preferences.transition.progress) {
|
if (preferences.transition.progress) {
|
||||||
stopProgress();
|
stopProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 动态修改标题
|
|
||||||
if (preferences.app.dynamicTitle) {
|
|
||||||
const { title } = to.meta;
|
|
||||||
// useTitle(`${$t(title)} - ${preferences.app.name}`);
|
|
||||||
useTitle(`${$t(title)} - ${preferences.app.name}`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +95,7 @@ function setupAccessGuard(router: Router) {
|
|||||||
roles: userRoles,
|
roles: userRoles,
|
||||||
router,
|
router,
|
||||||
// 则会在菜单中显示,但是访问会被重定向到403
|
// 则会在菜单中显示,但是访问会被重定向到403
|
||||||
routes: dynamicRoutes,
|
routes: accessRoutes,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 保存菜单信息和路由信息
|
// 保存菜单信息和路由信息
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import type { RouteRecordRaw } from 'vue-router';
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
|
|
||||||
import { DEFAULT_HOME_PATH } from '@vben/constants';
|
import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
|
||||||
|
|
||||||
import { AuthPageLayout } from '#/layouts';
|
import { AuthPageLayout } from '#/layouts';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
@@ -32,17 +32,19 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
{
|
{
|
||||||
component: AuthPageLayout,
|
component: AuthPageLayout,
|
||||||
meta: {
|
meta: {
|
||||||
|
hideInTab: true,
|
||||||
title: 'Authentication',
|
title: 'Authentication',
|
||||||
},
|
},
|
||||||
name: 'Authentication',
|
name: 'Authentication',
|
||||||
path: '/auth',
|
path: '/auth',
|
||||||
|
redirect: LOGIN_PATH,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: 'Login',
|
name: 'Login',
|
||||||
path: 'login',
|
path: 'login',
|
||||||
component: Login,
|
component: Login,
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.login'),
|
title: $t('page.auth.login'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -50,7 +52,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
path: 'code-login',
|
path: 'code-login',
|
||||||
component: () => import('#/views/_core/authentication/code-login.vue'),
|
component: () => import('#/views/_core/authentication/code-login.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.codeLogin'),
|
title: $t('page.auth.codeLogin'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -59,7 +61,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
component: () =>
|
component: () =>
|
||||||
import('#/views/_core/authentication/qrcode-login.vue'),
|
import('#/views/_core/authentication/qrcode-login.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.qrcodeLogin'),
|
title: $t('page.auth.qrcodeLogin'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -68,7 +70,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
component: () =>
|
component: () =>
|
||||||
import('#/views/_core/authentication/forget-password.vue'),
|
import('#/views/_core/authentication/forget-password.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.forgetPassword'),
|
title: $t('page.auth.forgetPassword'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -76,7 +78,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
path: 'register',
|
path: 'register',
|
||||||
component: () => import('#/views/_core/authentication/register.vue'),
|
component: () => import('#/views/_core/authentication/register.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.register'),
|
title: $t('page.auth.register'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@@ -10,12 +10,16 @@ const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', {
|
|||||||
|
|
||||||
// 有需要可以自行打开注释,并创建文件夹
|
// 有需要可以自行打开注释,并创建文件夹
|
||||||
// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true });
|
// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true });
|
||||||
|
// const staticRouteFiles = import.meta.glob('./static/**/*.ts', { eager: true });
|
||||||
|
|
||||||
/** 动态路由 */
|
/** 动态路由 */
|
||||||
const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
|
const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
|
||||||
|
|
||||||
/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统 */
|
/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
|
||||||
// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
|
// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
|
||||||
|
/** 不需要权限的菜单列表(会显示在菜单中) */
|
||||||
|
// const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
|
||||||
|
const staticRoutes: RouteRecordRaw[] = [];
|
||||||
const externalRoutes: RouteRecordRaw[] = [];
|
const externalRoutes: RouteRecordRaw[] = [];
|
||||||
|
|
||||||
/** 路由列表,由基本路由+静态路由组成 */
|
/** 路由列表,由基本路由+静态路由组成 */
|
||||||
@@ -28,4 +32,5 @@ const routes: RouteRecordRaw[] = [
|
|||||||
/** 基本路由列表,这些路由不需要进入权限拦截 */
|
/** 基本路由列表,这些路由不需要进入权限拦截 */
|
||||||
const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
|
const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
|
||||||
|
|
||||||
export { coreRouteNames, dynamicRoutes, routes };
|
const accessRoutes = [...dynamicRoutes, ...staticRoutes];
|
||||||
|
export { accessRoutes, coreRouteNames, routes };
|
||||||
|
@@ -10,14 +10,14 @@ const routes: RouteRecordRaw[] = [
|
|||||||
icon: 'ic:baseline-view-in-ar',
|
icon: 'ic:baseline-view-in-ar',
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
order: 1000,
|
order: 1000,
|
||||||
title: $t('page.demos.title'),
|
title: $t('demos.title'),
|
||||||
},
|
},
|
||||||
name: 'Demos',
|
name: 'Demos',
|
||||||
path: '/demos',
|
path: '/demos',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.demos.element-plus'),
|
title: $t('demos.elementPlus'),
|
||||||
},
|
},
|
||||||
name: 'NaiveDemos',
|
name: 'NaiveDemos',
|
||||||
path: '/demos/element',
|
path: '/demos/element',
|
||||||
|
@@ -19,7 +19,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
badgeType: 'dot',
|
badgeType: 'dot',
|
||||||
icon: VBEN_LOGO_URL,
|
icon: VBEN_LOGO_URL,
|
||||||
order: 9999,
|
order: 9999,
|
||||||
title: $t('page.vben.title'),
|
title: $t('demos.vben.title'),
|
||||||
},
|
},
|
||||||
name: 'VbenProject',
|
name: 'VbenProject',
|
||||||
path: '/vben-admin',
|
path: '/vben-admin',
|
||||||
@@ -30,7 +30,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
component: () => import('#/views/_core/about/index.vue'),
|
component: () => import('#/views/_core/about/index.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'lucide:copyright',
|
icon: 'lucide:copyright',
|
||||||
title: $t('page.vben.about'),
|
title: $t('demos.vben.about'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -40,7 +40,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
icon: 'lucide:book-open-text',
|
icon: 'lucide:book-open-text',
|
||||||
link: VBEN_DOC_URL,
|
link: VBEN_DOC_URL,
|
||||||
title: $t('page.vben.document'),
|
title: $t('demos.vben.document'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -61,7 +61,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
badgeType: 'dot',
|
badgeType: 'dot',
|
||||||
icon: 'logos:naiveui',
|
icon: 'logos:naiveui',
|
||||||
link: VBEN_NAIVE_PREVIEW_URL,
|
link: VBEN_NAIVE_PREVIEW_URL,
|
||||||
title: $t('page.vben.naive-ui'),
|
title: $t('demos.vben.naive-ui'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -72,7 +72,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
badgeType: 'dot',
|
badgeType: 'dot',
|
||||||
icon: SvgAntdvLogoIcon,
|
icon: SvgAntdvLogoIcon,
|
||||||
link: VBEN_ANT_PREVIEW_URL,
|
link: VBEN_ANT_PREVIEW_URL,
|
||||||
title: $t('page.vben.antdv'),
|
title: $t('demos.vben.antdv'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import type { LoginAndRegisterParams } from '@vben/common-ui';
|
import type { Recordable, UserInfo } from '@vben/types';
|
||||||
import type { UserInfo } from '@vben/types';
|
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
@@ -26,7 +25,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
* @param params 登录表单数据
|
* @param params 登录表单数据
|
||||||
*/
|
*/
|
||||||
async function authLogin(
|
async function authLogin(
|
||||||
params: LoginAndRegisterParams,
|
params: Recordable<any>,
|
||||||
onSuccess?: () => Promise<void> | void,
|
onSuccess?: () => Promise<void> | void,
|
||||||
) {
|
) {
|
||||||
// 异步处理用户登录操作并获取 accessToken
|
// 异步处理用户登录操作并获取 accessToken
|
||||||
@@ -85,7 +84,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
resetAllStores();
|
resetAllStores();
|
||||||
accessStore.setLoginExpired(false);
|
accessStore.setLoginExpired(false);
|
||||||
|
|
||||||
// 回登陆页带上当前路由地址
|
// 回登录页带上当前路由地址
|
||||||
await router.replace({
|
await router.replace({
|
||||||
path: LOGIN_PATH,
|
path: LOGIN_PATH,
|
||||||
query: redirect
|
query: redirect
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { LoginCodeParams, VbenFormSchema } from '@vben/common-ui';
|
import type { VbenFormSchema } from '@vben/common-ui';
|
||||||
|
import type { Recordable } from '@vben/types';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
* Asynchronously handle the login process
|
* Asynchronously handle the login process
|
||||||
* @param values 登录表单数据
|
* @param values 登录表单数据
|
||||||
*/
|
*/
|
||||||
async function handleLogin(values: LoginCodeParams) {
|
async function handleLogin(values: Recordable<any>) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(values);
|
console.log(values);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VbenFormSchema } from '@vben/common-ui';
|
import type { VbenFormSchema } from '@vben/common-ui';
|
||||||
|
import type { Recordable } from '@vben/types';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleSubmit(value: string) {
|
function handleSubmit(value: Recordable<any>) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('reset email:', value);
|
console.log('reset email:', value);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { LoginAndRegisterParams, VbenFormSchema } from '@vben/common-ui';
|
import type { VbenFormSchema } from '@vben/common-ui';
|
||||||
|
import type { Recordable } from '@vben/types';
|
||||||
|
|
||||||
import { computed, h, ref } from 'vue';
|
import { computed, h, ref } from 'vue';
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
rules(values) {
|
rules(values) {
|
||||||
const { password } = values;
|
const { password } = values;
|
||||||
return z
|
return z
|
||||||
.string()
|
.string({ required_error: $t('authentication.passwordTip') })
|
||||||
.min(1, { message: $t('authentication.passwordTip') })
|
.min(1, { message: $t('authentication.passwordTip') })
|
||||||
.refine((value) => value === password, {
|
.refine((value) => value === password, {
|
||||||
message: $t('authentication.confirmPasswordTip'),
|
message: $t('authentication.confirmPasswordTip'),
|
||||||
@@ -55,7 +56,6 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
},
|
},
|
||||||
fieldName: 'confirmPassword',
|
fieldName: 'confirmPassword',
|
||||||
label: $t('authentication.confirmPassword'),
|
label: $t('authentication.confirmPassword'),
|
||||||
rules: z.string().min(1, { message: $t('authentication.passwordTip') }),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'VbenCheckbox',
|
component: 'VbenCheckbox',
|
||||||
@@ -67,15 +67,10 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
h(
|
h(
|
||||||
'a',
|
'a',
|
||||||
{
|
{
|
||||||
class:
|
class: 'vben-link ml-1 ',
|
||||||
'cursor-pointer text-primary ml-1 hover:text-primary-hover',
|
|
||||||
href: '',
|
href: '',
|
||||||
},
|
},
|
||||||
[
|
`${$t('authentication.privacyPolicy')} & ${$t('authentication.terms')}`,
|
||||||
$t('authentication.privacyPolicy'),
|
|
||||||
'&',
|
|
||||||
$t('authentication.terms'),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
}),
|
}),
|
||||||
@@ -86,7 +81,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleSubmit(value: LoginAndRegisterParams) {
|
function handleSubmit(value: Recordable<any>) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('register submit:', value);
|
console.log('register submit:', value);
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@ import {
|
|||||||
ElMessage,
|
ElMessage,
|
||||||
ElNotification,
|
ElNotification,
|
||||||
ElSpace,
|
ElSpace,
|
||||||
|
ElTable,
|
||||||
} from 'element-plus';
|
} from 'element-plus';
|
||||||
|
|
||||||
type NotificationType = 'error' | 'info' | 'success' | 'warning';
|
type NotificationType = 'error' | 'info' | 'success' | 'warning';
|
||||||
@@ -38,6 +39,14 @@ function notify(type: NotificationType) {
|
|||||||
type,
|
type,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const tableData = [
|
||||||
|
{ prop1: '1', prop2: 'A' },
|
||||||
|
{ prop1: '2', prop2: 'B' },
|
||||||
|
{ prop1: '3', prop2: 'C' },
|
||||||
|
{ prop1: '4', prop2: 'D' },
|
||||||
|
{ prop1: '5', prop2: 'E' },
|
||||||
|
{ prop1: '6', prop2: 'F' },
|
||||||
|
];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -48,6 +57,7 @@ function notify(type: NotificationType) {
|
|||||||
<ElCard class="mb-5">
|
<ElCard class="mb-5">
|
||||||
<template #header> 按钮 </template>
|
<template #header> 按钮 </template>
|
||||||
<ElSpace>
|
<ElSpace>
|
||||||
|
<ElButton text>Text</ElButton>
|
||||||
<ElButton>Default</ElButton>
|
<ElButton>Default</ElButton>
|
||||||
<ElButton type="primary"> Primary </ElButton>
|
<ElButton type="primary"> Primary </ElButton>
|
||||||
<ElButton type="info"> Info </ElButton>
|
<ElButton type="info"> Info </ElButton>
|
||||||
@@ -74,5 +84,11 @@ function notify(type: NotificationType) {
|
|||||||
<ElButton type="success" @click="notify('success')"> 成功 </ElButton>
|
<ElButton type="success" @click="notify('success')"> 成功 </ElButton>
|
||||||
</ElSpace>
|
</ElSpace>
|
||||||
</ElCard>
|
</ElCard>
|
||||||
|
<ElCard class="mb-5">
|
||||||
|
<ElTable :data="tableData" stripe>
|
||||||
|
<ElTable.TableColumn label="测试列1" prop="prop1" />
|
||||||
|
<ElTable.TableColumn label="测试列2" prop="prop2" />
|
||||||
|
</ElTable>
|
||||||
|
</ElCard>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vben/web-naive",
|
"name": "@vben/web-naive",
|
||||||
"version": "5.3.0",
|
"version": "5.4.4",
|
||||||
"homepage": "https://vben.pro",
|
"homepage": "https://vben.pro",
|
||||||
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
|
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
103
apps/web-naive/src/adapter/component/index.ts
Normal file
103
apps/web-naive/src/adapter/component/index.ts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
/**
|
||||||
|
* 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
|
||||||
|
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { BaseFormComponentType } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import type { Component, SetupContext } from 'vue';
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { globalShareState } from '@vben/common-ui';
|
||||||
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
|
import {
|
||||||
|
NButton,
|
||||||
|
NCheckbox,
|
||||||
|
NCheckboxGroup,
|
||||||
|
NDatePicker,
|
||||||
|
NDivider,
|
||||||
|
NInput,
|
||||||
|
NInputNumber,
|
||||||
|
NRadioGroup,
|
||||||
|
NSelect,
|
||||||
|
NSpace,
|
||||||
|
NSwitch,
|
||||||
|
NTimePicker,
|
||||||
|
NTreeSelect,
|
||||||
|
NUpload,
|
||||||
|
} from 'naive-ui';
|
||||||
|
|
||||||
|
import { message } from '#/adapter/naive';
|
||||||
|
|
||||||
|
const withDefaultPlaceholder = <T extends Component>(
|
||||||
|
component: T,
|
||||||
|
type: 'input' | 'select',
|
||||||
|
) => {
|
||||||
|
return (props: any, { attrs, slots }: Omit<SetupContext, 'expose'>) => {
|
||||||
|
const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`);
|
||||||
|
return h(component, { ...props, ...attrs, placeholder }, slots);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
|
||||||
|
export type ComponentType =
|
||||||
|
| 'Checkbox'
|
||||||
|
| 'CheckboxGroup'
|
||||||
|
| 'DatePicker'
|
||||||
|
| 'Divider'
|
||||||
|
| 'Input'
|
||||||
|
| 'InputNumber'
|
||||||
|
| 'RadioGroup'
|
||||||
|
| 'Select'
|
||||||
|
| 'Space'
|
||||||
|
| 'Switch'
|
||||||
|
| 'TimePicker'
|
||||||
|
| 'TreeSelect'
|
||||||
|
| 'Upload'
|
||||||
|
| BaseFormComponentType;
|
||||||
|
|
||||||
|
async function initComponentAdapter() {
|
||||||
|
const components: Partial<Record<ComponentType, Component>> = {
|
||||||
|
// 如果你的组件体积比较大,可以使用异步加载
|
||||||
|
// Button: () =>
|
||||||
|
// import('xxx').then((res) => res.Button),
|
||||||
|
|
||||||
|
Checkbox: NCheckbox,
|
||||||
|
CheckboxGroup: NCheckboxGroup,
|
||||||
|
DatePicker: NDatePicker,
|
||||||
|
// 自定义默认按钮
|
||||||
|
DefaultButton: (props, { attrs, slots }) => {
|
||||||
|
return h(NButton, { ...props, attrs, type: 'default' }, slots);
|
||||||
|
},
|
||||||
|
// 自定义主要按钮
|
||||||
|
PrimaryButton: (props, { attrs, slots }) => {
|
||||||
|
return h(NButton, { ...props, attrs, type: 'primary' }, slots);
|
||||||
|
},
|
||||||
|
Divider: NDivider,
|
||||||
|
Input: withDefaultPlaceholder(NInput, 'input'),
|
||||||
|
InputNumber: withDefaultPlaceholder(NInputNumber, 'input'),
|
||||||
|
RadioGroup: NRadioGroup,
|
||||||
|
Select: withDefaultPlaceholder(NSelect, 'select'),
|
||||||
|
Space: NSpace,
|
||||||
|
Switch: NSwitch,
|
||||||
|
TimePicker: NTimePicker,
|
||||||
|
TreeSelect: withDefaultPlaceholder(NTreeSelect, 'select'),
|
||||||
|
Upload: NUpload,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 将组件注册到全局共享状态中
|
||||||
|
globalShareState.setComponents(components);
|
||||||
|
|
||||||
|
// 定义全局共享状态中的消息提示
|
||||||
|
globalShareState.defineMessage({
|
||||||
|
// 复制成功消息提示
|
||||||
|
copyPreferencesSuccess: (title, content) => {
|
||||||
|
message.success(content || title, {
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export { initComponentAdapter };
|
@@ -1,78 +1,19 @@
|
|||||||
import type {
|
import type {
|
||||||
BaseFormComponentType,
|
|
||||||
VbenFormSchema as FormSchema,
|
VbenFormSchema as FormSchema,
|
||||||
VbenFormProps,
|
VbenFormProps,
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import { h } from 'vue';
|
import type { ComponentType } from './component';
|
||||||
|
|
||||||
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
|
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
import {
|
setupVbenForm<ComponentType>({
|
||||||
NButton,
|
|
||||||
NCheckbox,
|
|
||||||
NCheckboxGroup,
|
|
||||||
NDatePicker,
|
|
||||||
NDivider,
|
|
||||||
NInput,
|
|
||||||
NInputNumber,
|
|
||||||
NRadioGroup,
|
|
||||||
NSelect,
|
|
||||||
NSpace,
|
|
||||||
NSwitch,
|
|
||||||
NTimePicker,
|
|
||||||
NTreeSelect,
|
|
||||||
NUpload,
|
|
||||||
} from 'naive-ui';
|
|
||||||
// 业务表单组件适配
|
|
||||||
|
|
||||||
export type FormComponentType =
|
|
||||||
| 'Checkbox'
|
|
||||||
| 'CheckboxGroup'
|
|
||||||
| 'DatePicker'
|
|
||||||
| 'Divider'
|
|
||||||
| 'Input'
|
|
||||||
| 'InputNumber'
|
|
||||||
| 'RadioGroup'
|
|
||||||
| 'Select'
|
|
||||||
| 'Space'
|
|
||||||
| 'Switch'
|
|
||||||
| 'TimePicker'
|
|
||||||
| 'TreeSelect'
|
|
||||||
| 'Upload'
|
|
||||||
| BaseFormComponentType;
|
|
||||||
|
|
||||||
// 初始化表单组件,并注册到form组件内部
|
|
||||||
setupVbenForm<FormComponentType>({
|
|
||||||
components: {
|
|
||||||
Checkbox: NCheckbox,
|
|
||||||
CheckboxGroup: NCheckboxGroup,
|
|
||||||
DatePicker: NDatePicker,
|
|
||||||
// 自定义默认的重置按钮
|
|
||||||
DefaultResetActionButton: (props, { attrs, slots }) => {
|
|
||||||
return h(NButton, { ...props, attrs, text: false, type: 'info' }, slots);
|
|
||||||
},
|
|
||||||
// 自定义默认的提交按钮
|
|
||||||
DefaultSubmitActionButton: (props, { attrs, slots }) => {
|
|
||||||
return h(
|
|
||||||
NButton,
|
|
||||||
{ ...props, attrs, text: false, type: 'primary' },
|
|
||||||
slots,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
Divider: NDivider,
|
|
||||||
Input: NInput,
|
|
||||||
InputNumber: NInputNumber,
|
|
||||||
RadioGroup: NRadioGroup,
|
|
||||||
Select: NSelect,
|
|
||||||
Space: NSpace,
|
|
||||||
Switch: NSwitch,
|
|
||||||
TimePicker: NTimePicker,
|
|
||||||
TreeSelect: NTreeSelect,
|
|
||||||
Upload: NUpload,
|
|
||||||
},
|
|
||||||
config: {
|
config: {
|
||||||
|
// naive-ui组件不接受onChang事件,所以需要禁用
|
||||||
|
disabledOnChangeListener: true,
|
||||||
|
// naive-ui组件的空值为null,不能是undefined,否则重置表单时不生效
|
||||||
|
emptyStateValue: null,
|
||||||
baseModelPropName: 'value',
|
baseModelPropName: 'value',
|
||||||
modelPropNameMap: {
|
modelPropNameMap: {
|
||||||
Checkbox: 'checked',
|
Checkbox: 'checked',
|
||||||
@@ -83,22 +24,22 @@ setupVbenForm<FormComponentType>({
|
|||||||
defineRules: {
|
defineRules: {
|
||||||
required: (value, _params, ctx) => {
|
required: (value, _params, ctx) => {
|
||||||
if (value === undefined || value === null || value.length === 0) {
|
if (value === undefined || value === null || value.length === 0) {
|
||||||
return $t('formRules.required', [ctx.label]);
|
return $t('ui.formRules.required', [ctx.label]);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
selectRequired: (value, _params, ctx) => {
|
selectRequired: (value, _params, ctx) => {
|
||||||
if (value === undefined || value === null) {
|
if (value === undefined || value === null) {
|
||||||
return $t('formRules.selectRequired', [ctx.label]);
|
return $t('ui.formRules.selectRequired', [ctx.label]);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const useVbenForm = useForm<FormComponentType>;
|
const useVbenForm = useForm<ComponentType>;
|
||||||
|
|
||||||
export { useVbenForm, z };
|
export { useVbenForm, z };
|
||||||
|
|
||||||
export type VbenFormSchema = FormSchema<FormComponentType>;
|
export type VbenFormSchema = FormSchema<ComponentType>;
|
||||||
export type { VbenFormProps };
|
export type { VbenFormProps };
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
export * from './form';
|
|
||||||
export * from './naive';
|
|
67
apps/web-naive/src/adapter/vxe-table.ts
Normal file
67
apps/web-naive/src/adapter/vxe-table.ts
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
|
||||||
|
|
||||||
|
import { NButton, NImage } from 'naive-ui';
|
||||||
|
|
||||||
|
import { useVbenForm } from './form';
|
||||||
|
|
||||||
|
setupVbenVxeTable({
|
||||||
|
configVxeTable: (vxeUI) => {
|
||||||
|
vxeUI.setConfig({
|
||||||
|
grid: {
|
||||||
|
align: 'center',
|
||||||
|
border: false,
|
||||||
|
columnConfig: {
|
||||||
|
resizable: true,
|
||||||
|
},
|
||||||
|
minHeight: 180,
|
||||||
|
formConfig: {
|
||||||
|
// 全局禁用vxe-table的表单配置,使用formOptions
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
autoLoad: true,
|
||||||
|
response: {
|
||||||
|
result: 'items',
|
||||||
|
total: 'total',
|
||||||
|
list: 'items',
|
||||||
|
},
|
||||||
|
showActiveMsg: true,
|
||||||
|
showResponseMsg: false,
|
||||||
|
},
|
||||||
|
round: true,
|
||||||
|
showOverflow: true,
|
||||||
|
size: 'small',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格配置项可以用 cellRender: { name: 'CellImage' },
|
||||||
|
vxeUI.renderer.add('CellImage', {
|
||||||
|
renderTableDefault(_renderOpts, params) {
|
||||||
|
const { column, row } = params;
|
||||||
|
return h(NImage, { src: row[column.field] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格配置项可以用 cellRender: { name: 'CellLink' },
|
||||||
|
vxeUI.renderer.add('CellLink', {
|
||||||
|
renderTableDefault(renderOpts) {
|
||||||
|
const { props } = renderOpts;
|
||||||
|
return h(
|
||||||
|
NButton,
|
||||||
|
{ size: 'small', type: 'primary', quaternary: true },
|
||||||
|
{ default: () => props?.text },
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
|
||||||
|
// vxeUI.formats.add
|
||||||
|
},
|
||||||
|
useVbenForm,
|
||||||
|
});
|
||||||
|
|
||||||
|
export { useVbenVxeGrid };
|
||||||
|
|
||||||
|
export type * from '@vben/plugins/vxe-table';
|
@@ -3,17 +3,13 @@ import { baseRequestClient, requestClient } from '#/api/request';
|
|||||||
export namespace AuthApi {
|
export namespace AuthApi {
|
||||||
/** 登录接口参数 */
|
/** 登录接口参数 */
|
||||||
export interface LoginParams {
|
export interface LoginParams {
|
||||||
password: string;
|
password?: string;
|
||||||
username: string;
|
username?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 登录接口返回值 */
|
/** 登录接口返回值 */
|
||||||
export interface LoginResult {
|
export interface LoginResult {
|
||||||
accessToken: string;
|
accessToken: string;
|
||||||
desc: string;
|
|
||||||
realName: string;
|
|
||||||
userId: string;
|
|
||||||
username: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RefreshTokenResult {
|
export interface RefreshTokenResult {
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* 该文件可自行根据业务逻辑进行调整
|
* 该文件可自行根据业务逻辑进行调整
|
||||||
*/
|
*/
|
||||||
|
import type { HttpResponse } from '@vben/request';
|
||||||
|
|
||||||
import { useAppConfig } from '@vben/hooks';
|
import { useAppConfig } from '@vben/hooks';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
import {
|
import {
|
||||||
@@ -10,7 +12,7 @@ import {
|
|||||||
} from '@vben/request';
|
} from '@vben/request';
|
||||||
import { useAccessStore } from '@vben/stores';
|
import { useAccessStore } from '@vben/stores';
|
||||||
|
|
||||||
import { message } from '#/adapter';
|
import { message } from '#/adapter/naive';
|
||||||
import { useAuthStore } from '#/store';
|
import { useAuthStore } from '#/store';
|
||||||
|
|
||||||
import { refreshTokenApi } from './core';
|
import { refreshTokenApi } from './core';
|
||||||
@@ -67,15 +69,15 @@ function createRequestClient(baseURL: string) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// response数据解构
|
// response数据解构
|
||||||
client.addResponseInterceptor({
|
client.addResponseInterceptor<HttpResponse>({
|
||||||
fulfilled: (response) => {
|
fulfilled: (response) => {
|
||||||
const { data: responseData, status } = response;
|
const { data: responseData, status } = response;
|
||||||
|
|
||||||
const { code, data, message: msg } = responseData;
|
const { code, data } = responseData;
|
||||||
if (status >= 200 && status < 400 && code === 0) {
|
if (status >= 200 && status < 400 && code === 0) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
throw new Error(`Error ${status}: ${msg}`);
|
throw Object.assign({}, response, { response });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -92,7 +94,14 @@ function createRequestClient(baseURL: string) {
|
|||||||
|
|
||||||
// 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
|
// 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
|
||||||
client.addResponseInterceptor(
|
client.addResponseInterceptor(
|
||||||
errorMessageResponseInterceptor((msg: string) => message.error(msg)),
|
errorMessageResponseInterceptor((msg: string, error) => {
|
||||||
|
// 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
|
||||||
|
// 当前mock接口返回的错误字段是 error 或者 message
|
||||||
|
const responseData = error?.response?.data ?? {};
|
||||||
|
const errorMessage = responseData?.error ?? responseData?.message ?? '';
|
||||||
|
// 如果没有错误信息,则会根据状态码进行提示
|
||||||
|
message.error(errorMessage || msg);
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
|
@@ -1,15 +1,21 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp, watchEffect } from 'vue';
|
||||||
|
|
||||||
import { registerAccessDirective } from '@vben/access';
|
import { registerAccessDirective } from '@vben/access';
|
||||||
|
import { preferences } from '@vben/preferences';
|
||||||
import { initStores } from '@vben/stores';
|
import { initStores } from '@vben/stores';
|
||||||
import '@vben/styles';
|
import '@vben/styles';
|
||||||
|
|
||||||
import { setupI18n } from '#/locales';
|
import { useTitle } from '@vueuse/core';
|
||||||
|
|
||||||
|
import { $t, setupI18n } from '#/locales';
|
||||||
|
|
||||||
|
import { initComponentAdapter } from './adapter/component';
|
||||||
import App from './app.vue';
|
import App from './app.vue';
|
||||||
import { router } from './router';
|
import { router } from './router';
|
||||||
|
|
||||||
async function bootstrap(namespace: string) {
|
async function bootstrap(namespace: string) {
|
||||||
|
// 初始化组件适配器
|
||||||
|
initComponentAdapter();
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
// 国际化 i18n 配置
|
// 国际化 i18n 配置
|
||||||
@@ -24,6 +30,16 @@ async function bootstrap(namespace: string) {
|
|||||||
// 配置路由及路由守卫
|
// 配置路由及路由守卫
|
||||||
app.use(router);
|
app.use(router);
|
||||||
|
|
||||||
|
// 动态更新标题
|
||||||
|
watchEffect(() => {
|
||||||
|
if (preferences.app.dynamicTitle) {
|
||||||
|
const routeTitle = router.currentRoute.value.meta?.title;
|
||||||
|
const pageTitle =
|
||||||
|
(routeTitle ? `${$t(routeTitle)} - ` : '') + preferences.app.name;
|
||||||
|
useTitle(pageTitle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { NotificationItem } from '@vben/layouts';
|
import type { NotificationItem } from '@vben/layouts';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { AuthenticationLoginExpiredModal } from '@vben/common-ui';
|
import { AuthenticationLoginExpiredModal } from '@vben/common-ui';
|
||||||
import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants';
|
import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants';
|
||||||
|
import { useWatermark } from '@vben/hooks';
|
||||||
import { BookOpenText, CircleHelp, MdiGithub } from '@vben/icons';
|
import { BookOpenText, CircleHelp, MdiGithub } from '@vben/icons';
|
||||||
import {
|
import {
|
||||||
BasicLayout,
|
BasicLayout,
|
||||||
@@ -54,6 +55,7 @@ const notifications = ref<NotificationItem[]>([
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
const accessStore = useAccessStore();
|
const accessStore = useAccessStore();
|
||||||
|
const { destroyWatermark, updateWatermark } = useWatermark();
|
||||||
const showDot = computed(() =>
|
const showDot = computed(() =>
|
||||||
notifications.value.some((item) => !item.isRead),
|
notifications.value.some((item) => !item.isRead),
|
||||||
);
|
);
|
||||||
@@ -66,7 +68,7 @@ const menus = computed(() => [
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
icon: BookOpenText,
|
icon: BookOpenText,
|
||||||
text: $t('widgets.document'),
|
text: $t('ui.widgets.document'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
handler: () => {
|
handler: () => {
|
||||||
@@ -84,7 +86,7 @@ const menus = computed(() => [
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
icon: CircleHelp,
|
icon: CircleHelp,
|
||||||
text: $t('widgets.qa'),
|
text: $t('ui.widgets.qa'),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -103,6 +105,22 @@ function handleNoticeClear() {
|
|||||||
function handleMakeAll() {
|
function handleMakeAll() {
|
||||||
notifications.value.forEach((item) => (item.isRead = true));
|
notifications.value.forEach((item) => (item.isRead = true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => preferences.app.watermark,
|
||||||
|
async (enable) => {
|
||||||
|
if (enable) {
|
||||||
|
await updateWatermark({
|
||||||
|
content: `${userStore.userInfo?.username}`,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
destroyWatermark();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@@ -2,12 +2,19 @@ import type { LocaleSetupOptions, SupportedLanguagesType } from '@vben/locales';
|
|||||||
|
|
||||||
import type { App } from 'vue';
|
import type { App } from 'vue';
|
||||||
|
|
||||||
import { $t, setupI18n as coreSetup, loadLocalesMap } from '@vben/locales';
|
import {
|
||||||
|
$t,
|
||||||
|
setupI18n as coreSetup,
|
||||||
|
loadLocalesMapFromDir,
|
||||||
|
} from '@vben/locales';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
|
|
||||||
const modules = import.meta.glob('./langs/*.json');
|
const modules = import.meta.glob('./langs/**/*.json');
|
||||||
|
|
||||||
const localesMap = loadLocalesMap(modules);
|
const localesMap = loadLocalesMapFromDir(
|
||||||
|
/\.\/langs\/([^/]+)\/(.*)\.json$/,
|
||||||
|
modules,
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载应用特有的语言包
|
* 加载应用特有的语言包
|
||||||
|
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"page": {
|
|
||||||
"demos": {
|
|
||||||
"title": "Demos",
|
|
||||||
"naive": "Naive UI",
|
|
||||||
"table": "Table"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
13
apps/web-naive/src/locales/langs/en-US/demos.json
Normal file
13
apps/web-naive/src/locales/langs/en-US/demos.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"title": "Demos",
|
||||||
|
"naive": "Naive UI",
|
||||||
|
"table": "Table",
|
||||||
|
"vben": {
|
||||||
|
"title": "Project",
|
||||||
|
"about": "About",
|
||||||
|
"document": "Document",
|
||||||
|
"antdv": "Ant Design Vue Version",
|
||||||
|
"naive-ui": "Naive UI Version",
|
||||||
|
"element-plus": "Element Plus Version"
|
||||||
|
}
|
||||||
|
}
|
14
apps/web-naive/src/locales/langs/en-US/page.json
Normal file
14
apps/web-naive/src/locales/langs/en-US/page.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"auth": {
|
||||||
|
"login": "Login",
|
||||||
|
"register": "Register",
|
||||||
|
"codeLogin": "Code Login",
|
||||||
|
"qrcodeLogin": "Qr Code Login",
|
||||||
|
"forgetPassword": "Forget Password"
|
||||||
|
},
|
||||||
|
"dashboard": {
|
||||||
|
"title": "Dashboard",
|
||||||
|
"analytics": "Analytics",
|
||||||
|
"workspace": "Workspace"
|
||||||
|
}
|
||||||
|
}
|
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"page": {
|
|
||||||
"demos": {
|
|
||||||
"title": "演示",
|
|
||||||
"naive": "Naive UI",
|
|
||||||
"table": "Table"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
13
apps/web-naive/src/locales/langs/zh-CN/demos.json
Normal file
13
apps/web-naive/src/locales/langs/zh-CN/demos.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"title": "演示",
|
||||||
|
"naive": "Naive UI",
|
||||||
|
"table": "Table",
|
||||||
|
"vben": {
|
||||||
|
"title": "项目",
|
||||||
|
"about": "关于",
|
||||||
|
"document": "文档",
|
||||||
|
"antdv": "Ant Design Vue 版本",
|
||||||
|
"naive-ui": "Naive UI 版本",
|
||||||
|
"element-plus": "Element Plus 版本"
|
||||||
|
}
|
||||||
|
}
|
14
apps/web-naive/src/locales/langs/zh-CN/page.json
Normal file
14
apps/web-naive/src/locales/langs/zh-CN/page.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"auth": {
|
||||||
|
"login": "登录",
|
||||||
|
"register": "注册",
|
||||||
|
"codeLogin": "验证码登录",
|
||||||
|
"qrcodeLogin": "二维码登录",
|
||||||
|
"forgetPassword": "忘记密码"
|
||||||
|
},
|
||||||
|
"dashboard": {
|
||||||
|
"title": "概览",
|
||||||
|
"analytics": "分析页",
|
||||||
|
"workspace": "工作台"
|
||||||
|
}
|
||||||
|
}
|
@@ -6,7 +6,7 @@ import type {
|
|||||||
import { generateAccessible } from '@vben/access';
|
import { generateAccessible } from '@vben/access';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
|
|
||||||
import { message } from '#/adapter';
|
import { message } from '#/adapter/naive';
|
||||||
import { getAllMenusApi } from '#/api';
|
import { getAllMenusApi } from '#/api';
|
||||||
import { BasicLayout, IFrameView } from '#/layouts';
|
import { BasicLayout, IFrameView } from '#/layouts';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
@@ -5,10 +5,7 @@ import { preferences } from '@vben/preferences';
|
|||||||
import { useAccessStore, useUserStore } from '@vben/stores';
|
import { useAccessStore, useUserStore } from '@vben/stores';
|
||||||
import { startProgress, stopProgress } from '@vben/utils';
|
import { startProgress, stopProgress } from '@vben/utils';
|
||||||
|
|
||||||
import { useTitle } from '@vueuse/core';
|
import { accessRoutes, coreRouteNames } from '#/router/routes';
|
||||||
|
|
||||||
import { $t } from '#/locales';
|
|
||||||
import { coreRouteNames, dynamicRoutes } from '#/router/routes';
|
|
||||||
import { useAuthStore } from '#/store';
|
import { useAuthStore } from '#/store';
|
||||||
|
|
||||||
import { generateAccess } from './access';
|
import { generateAccess } from './access';
|
||||||
@@ -34,21 +31,12 @@ function setupCommonGuard(router: Router) {
|
|||||||
router.afterEach((to) => {
|
router.afterEach((to) => {
|
||||||
// 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
|
// 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
|
||||||
|
|
||||||
if (preferences.tabbar.enable) {
|
loadedPaths.add(to.path);
|
||||||
loadedPaths.add(to.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 关闭页面加载进度条
|
// 关闭页面加载进度条
|
||||||
if (preferences.transition.progress) {
|
if (preferences.transition.progress) {
|
||||||
stopProgress();
|
stopProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 动态修改标题
|
|
||||||
if (preferences.app.dynamicTitle) {
|
|
||||||
const { title } = to.meta;
|
|
||||||
// useTitle(`${$t(title)} - ${preferences.app.name}`);
|
|
||||||
useTitle(`${$t(title)} - ${preferences.app.name}`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +94,7 @@ function setupAccessGuard(router: Router) {
|
|||||||
roles: userRoles,
|
roles: userRoles,
|
||||||
router,
|
router,
|
||||||
// 则会在菜单中显示,但是访问会被重定向到403
|
// 则会在菜单中显示,但是访问会被重定向到403
|
||||||
routes: dynamicRoutes,
|
routes: accessRoutes,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 保存菜单信息和路由信息
|
// 保存菜单信息和路由信息
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import type { RouteRecordRaw } from 'vue-router';
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
|
|
||||||
import { DEFAULT_HOME_PATH } from '@vben/constants';
|
import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
|
||||||
|
|
||||||
import { AuthPageLayout } from '#/layouts';
|
import { AuthPageLayout } from '#/layouts';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
@@ -32,17 +32,19 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
{
|
{
|
||||||
component: AuthPageLayout,
|
component: AuthPageLayout,
|
||||||
meta: {
|
meta: {
|
||||||
|
hideInTab: true,
|
||||||
title: 'Authentication',
|
title: 'Authentication',
|
||||||
},
|
},
|
||||||
name: 'Authentication',
|
name: 'Authentication',
|
||||||
path: '/auth',
|
path: '/auth',
|
||||||
|
redirect: LOGIN_PATH,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: 'Login',
|
name: 'Login',
|
||||||
path: 'login',
|
path: 'login',
|
||||||
component: Login,
|
component: Login,
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.login'),
|
title: $t('page.auth.login'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -50,7 +52,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
path: 'code-login',
|
path: 'code-login',
|
||||||
component: () => import('#/views/_core/authentication/code-login.vue'),
|
component: () => import('#/views/_core/authentication/code-login.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.codeLogin'),
|
title: $t('page.auth.codeLogin'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -59,7 +61,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
component: () =>
|
component: () =>
|
||||||
import('#/views/_core/authentication/qrcode-login.vue'),
|
import('#/views/_core/authentication/qrcode-login.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.qrcodeLogin'),
|
title: $t('page.auth.qrcodeLogin'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -68,7 +70,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
component: () =>
|
component: () =>
|
||||||
import('#/views/_core/authentication/forget-password.vue'),
|
import('#/views/_core/authentication/forget-password.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.forgetPassword'),
|
title: $t('page.auth.forgetPassword'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -76,7 +78,7 @@ const coreRoutes: RouteRecordRaw[] = [
|
|||||||
path: 'register',
|
path: 'register',
|
||||||
component: () => import('#/views/_core/authentication/register.vue'),
|
component: () => import('#/views/_core/authentication/register.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.core.register'),
|
title: $t('page.auth.register'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@@ -10,12 +10,16 @@ const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', {
|
|||||||
|
|
||||||
// 有需要可以自行打开注释,并创建文件夹
|
// 有需要可以自行打开注释,并创建文件夹
|
||||||
// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true });
|
// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true });
|
||||||
|
// const staticRouteFiles = import.meta.glob('./static/**/*.ts', { eager: true });
|
||||||
|
|
||||||
/** 动态路由 */
|
/** 动态路由 */
|
||||||
const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
|
const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
|
||||||
|
|
||||||
/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统 */
|
/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
|
||||||
// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
|
// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
|
||||||
|
/** 不需要权限的菜单列表(会显示在菜单中) */
|
||||||
|
// const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
|
||||||
|
const staticRoutes: RouteRecordRaw[] = [];
|
||||||
const externalRoutes: RouteRecordRaw[] = [];
|
const externalRoutes: RouteRecordRaw[] = [];
|
||||||
|
|
||||||
/** 路由列表,由基本路由+静态路由组成 */
|
/** 路由列表,由基本路由+静态路由组成 */
|
||||||
@@ -28,4 +32,5 @@ const routes: RouteRecordRaw[] = [
|
|||||||
/** 基本路由列表,这些路由不需要进入权限拦截 */
|
/** 基本路由列表,这些路由不需要进入权限拦截 */
|
||||||
const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
|
const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
|
||||||
|
|
||||||
export { coreRouteNames, dynamicRoutes, routes };
|
const accessRoutes = [...dynamicRoutes, ...staticRoutes];
|
||||||
|
export { accessRoutes, coreRouteNames, routes };
|
||||||
|
@@ -10,14 +10,14 @@ const routes: RouteRecordRaw[] = [
|
|||||||
icon: 'ic:baseline-view-in-ar',
|
icon: 'ic:baseline-view-in-ar',
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
order: 1000,
|
order: 1000,
|
||||||
title: $t('page.demos.title'),
|
title: $t('demos.title'),
|
||||||
},
|
},
|
||||||
name: 'Demos',
|
name: 'Demos',
|
||||||
path: '/demos',
|
path: '/demos',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
meta: {
|
meta: {
|
||||||
title: $t('page.demos.naive'),
|
title: $t('demos.naive'),
|
||||||
},
|
},
|
||||||
name: 'NaiveDemos',
|
name: 'NaiveDemos',
|
||||||
path: '/demos/naive',
|
path: '/demos/naive',
|
||||||
@@ -25,8 +25,7 @@ const routes: RouteRecordRaw[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'mdi:shield-key-outline',
|
title: $t('demos.table'),
|
||||||
title: $t('page.demos.table'),
|
|
||||||
},
|
},
|
||||||
name: 'Table',
|
name: 'Table',
|
||||||
path: '/demos/table',
|
path: '/demos/table',
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user