mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 00:26:20 +08:00
Compare commits
376 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5d8d9786e3 | ||
![]() |
2cca7e8bfb | ||
![]() |
74ded8aed7 | ||
![]() |
d620758c2f | ||
![]() |
f2ec2ca273 | ||
![]() |
b66a83c10f | ||
![]() |
7bbb86249b | ||
![]() |
b0a45d4739 | ||
![]() |
1095d44110 | ||
![]() |
e938e8e9a8 | ||
![]() |
3b0077dc73 | ||
![]() |
3de5b53bcd | ||
![]() |
d7f5dfeb9f | ||
![]() |
85bc1f2340 | ||
![]() |
edede25c8f | ||
![]() |
6da30edef5 | ||
![]() |
d9286b5345 | ||
![]() |
8d218ec8d5 | ||
![]() |
72dbe574d3 | ||
![]() |
4c91ac11e2 | ||
![]() |
ce480c5d66 | ||
![]() |
7f5e415da9 | ||
![]() |
714a351036 | ||
![]() |
a78c3a305b | ||
![]() |
bb8c2dea40 | ||
![]() |
dce3aba20d | ||
![]() |
256e0275fe | ||
![]() |
c70cf3cace | ||
![]() |
4f4bec0c22 | ||
![]() |
491941e4c5 | ||
![]() |
f1678a7cc0 | ||
![]() |
ed8cffb2a1 | ||
![]() |
8284d106e2 | ||
![]() |
de305ecd47 | ||
![]() |
a222404220 | ||
![]() |
5335ae7578 | ||
![]() |
f32d2715ef | ||
![]() |
fb73be0928 | ||
![]() |
c2a159155c | ||
![]() |
70ee1c8403 | ||
![]() |
7346988622 | ||
![]() |
d6fdfd9f93 | ||
![]() |
d88915bac3 | ||
![]() |
a1b9bbc2ce | ||
![]() |
64d6fece08 | ||
![]() |
be3d98fa3d | ||
![]() |
ce0f528ba8 | ||
![]() |
085929a9c0 | ||
![]() |
de4eaddffd | ||
![]() |
e1804bd866 | ||
![]() |
334a0ea8e5 | ||
![]() |
bce6cee53a | ||
![]() |
32daad6198 | ||
![]() |
a4a5a44009 | ||
![]() |
c5b39f2c16 | ||
![]() |
4c0f2038af | ||
![]() |
d25dfcc7c0 | ||
![]() |
8992ef472e | ||
![]() |
f7a1b02236 | ||
![]() |
0dc2f1496b | ||
![]() |
dab977ffbc | ||
![]() |
92cc603680 | ||
![]() |
d3ec7a58ad | ||
![]() |
83e529681a | ||
![]() |
4d6f24d053 | ||
![]() |
45b0be7f7e | ||
![]() |
c999abb236 | ||
![]() |
816fffe960 | ||
![]() |
0ad30503a7 | ||
![]() |
d02ab2d220 | ||
![]() |
6753e24b3d | ||
![]() |
b90d3572a9 | ||
![]() |
1657439569 | ||
![]() |
8dd8a5ed01 | ||
![]() |
f1717973c4 | ||
![]() |
0cc53558fb | ||
![]() |
7e77177ed8 | ||
![]() |
bb1fee5885 | ||
![]() |
53b2b23620 | ||
![]() |
4c67d8c388 | ||
![]() |
0ab2a541cb | ||
![]() |
4dc5385104 | ||
![]() |
26bd4aeba6 | ||
![]() |
61d6057fa4 | ||
![]() |
9090cee184 | ||
![]() |
31042de6bc | ||
![]() |
aabafe8610 | ||
![]() |
098621892d | ||
![]() |
582d7e7351 | ||
![]() |
ca487426a1 | ||
![]() |
2387dcdc6d | ||
![]() |
9435b480ab | ||
![]() |
8c2ba755c1 | ||
![]() |
c7639c4909 | ||
![]() |
6af828260e | ||
![]() |
5a9a8644d6 | ||
![]() |
0bb3b7f90d | ||
![]() |
87ee7cd27a | ||
![]() |
ce030d2d1d | ||
![]() |
43c8bf0d0b | ||
![]() |
bc099041ce | ||
![]() |
0629cc7b14 | ||
![]() |
4e16438494 | ||
![]() |
c5713c75ec | ||
![]() |
e7ac09cf39 | ||
![]() |
be4c98b980 | ||
![]() |
e013f04151 | ||
![]() |
3948ba1b01 | ||
![]() |
e74a9ed337 | ||
![]() |
750a50ebfd | ||
![]() |
6d1adce462 | ||
![]() |
d01c1b4d05 | ||
![]() |
6844f69c20 | ||
![]() |
057b82632b | ||
![]() |
908a2fbb3a | ||
![]() |
2d2a265418 | ||
![]() |
e05a009989 | ||
![]() |
7fad00cb77 | ||
![]() |
93d4655285 | ||
![]() |
448d21287c | ||
![]() |
31f489fa90 | ||
![]() |
640ac6217f | ||
![]() |
37c25a42f5 | ||
![]() |
cdb460897b | ||
![]() |
84df7a4bb2 | ||
![]() |
476b2b8acc | ||
![]() |
4041284345 | ||
![]() |
a12c5706e8 | ||
![]() |
6fa35521b7 | ||
![]() |
00c446efff | ||
![]() |
5539190c39 | ||
![]() |
384f929443 | ||
![]() |
9ba15705b5 | ||
![]() |
d16f6f8e44 | ||
![]() |
fc2e2c8789 | ||
![]() |
df0e0cbe69 | ||
![]() |
7dcb38cac6 | ||
![]() |
eda251a426 | ||
![]() |
17d16ae545 | ||
![]() |
9ae67bf9ca | ||
![]() |
8ba4fb2449 | ||
![]() |
1bafeb6638 | ||
![]() |
fd57b83db6 | ||
![]() |
513ccb9543 | ||
![]() |
e962fa039a | ||
![]() |
58b30aae9a | ||
![]() |
4f9cdc5634 | ||
![]() |
5292838fcd | ||
![]() |
fd9450304d | ||
![]() |
bc499744c0 | ||
![]() |
c8b169494f | ||
![]() |
c1d3a94371 | ||
![]() |
0eb1275c34 | ||
![]() |
e08a155c40 | ||
![]() |
c37a15fefb | ||
![]() |
7e4312ec1e | ||
![]() |
839271d70a | ||
![]() |
768fadbffb | ||
![]() |
9aa2cf3ebf | ||
![]() |
b1f78c6696 | ||
![]() |
dda27477af | ||
![]() |
1a8cdeb374 | ||
![]() |
5f0bf59a8b | ||
![]() |
1b7896c435 | ||
![]() |
d39e13270c | ||
![]() |
5cabd4a6eb | ||
![]() |
451371a812 | ||
![]() |
6faacd2d85 | ||
![]() |
61aefcaa65 | ||
![]() |
acfba7cccc | ||
![]() |
cb28986683 | ||
![]() |
a89ba204eb | ||
![]() |
a45208673a | ||
![]() |
39188780ea | ||
![]() |
99326342bc | ||
![]() |
dfe560a542 | ||
![]() |
692df33fd8 | ||
![]() |
9316d950b1 | ||
![]() |
5abb0f2b37 | ||
![]() |
e47c618b18 | ||
![]() |
2abc8275c6 | ||
![]() |
f1d42769ea | ||
![]() |
dac9301af4 | ||
![]() |
20c10df846 | ||
![]() |
b11df08aa4 | ||
![]() |
6e391af3fe | ||
![]() |
7925c1ea28 | ||
![]() |
442bd440ba | ||
![]() |
4a4321a77d | ||
![]() |
aee08b14fa | ||
![]() |
b9dee8595f | ||
![]() |
a753eb35cb | ||
![]() |
c001535b56 | ||
![]() |
9afb4318fd | ||
![]() |
baa42a57fd | ||
![]() |
6981b73ef6 | ||
![]() |
266c33819f | ||
![]() |
9c26ee1b9c | ||
![]() |
f305637366 | ||
![]() |
40071529d2 | ||
![]() |
6f5711b088 | ||
![]() |
bc55b92c9b | ||
![]() |
f1e8e241b1 | ||
![]() |
5833043d14 | ||
![]() |
35f2d074ae | ||
![]() |
c0e40fa01e | ||
![]() |
ddb678ddfa | ||
![]() |
91e13c4287 | ||
![]() |
de7279399d | ||
![]() |
a89e497e82 | ||
![]() |
0f50e0458e | ||
![]() |
4730b3af31 | ||
![]() |
740d160198 | ||
![]() |
aefde45ad5 | ||
![]() |
3cc72d6791 | ||
![]() |
fbcba766ae | ||
![]() |
1455eb48db | ||
![]() |
ba97f80d33 | ||
![]() |
0902de7504 | ||
![]() |
da8e0bdf91 | ||
![]() |
06236c9fe0 | ||
![]() |
2c536976e8 | ||
![]() |
c2e2ca9bed | ||
![]() |
02c469b17a | ||
![]() |
deff31bc5d | ||
![]() |
e09a797d05 | ||
![]() |
8a7d9bcd4d | ||
![]() |
934ccd34ea | ||
![]() |
85f1e58bcc | ||
![]() |
e073b4c944 | ||
![]() |
554f4615a1 | ||
![]() |
d21578ab33 | ||
![]() |
857af11ced | ||
![]() |
50468e9581 | ||
![]() |
19dc88b4e0 | ||
![]() |
cfbd52bbe7 | ||
![]() |
c0edd7b70e | ||
![]() |
fe5848cf21 | ||
![]() |
c3b5abc392 | ||
![]() |
a40332cbfe | ||
![]() |
42908a4535 | ||
![]() |
a0920d284d | ||
![]() |
419b7aea07 | ||
![]() |
e807539b80 | ||
![]() |
0634f2ca9e | ||
![]() |
d09e998ae7 | ||
![]() |
e097600003 | ||
![]() |
3ee7051950 | ||
![]() |
5ad93c6004 | ||
![]() |
ce7f382b9b | ||
![]() |
1832d0c07a | ||
![]() |
e05a40f680 | ||
![]() |
ee85839ba3 | ||
![]() |
d6a3eecbc2 | ||
![]() |
8932bf9a2d | ||
![]() |
9d4d78d2c9 | ||
![]() |
2d553f204a | ||
![]() |
3b86435766 | ||
![]() |
e3637e7af4 | ||
![]() |
b41e3939ac | ||
![]() |
23e0932883 | ||
![]() |
8f2008ac74 | ||
![]() |
2bf48e0f23 | ||
![]() |
c0441cf5c3 | ||
![]() |
b3f6b04981 | ||
![]() |
8d93e047d0 | ||
![]() |
fb43e54847 | ||
![]() |
1e0ede09a2 | ||
![]() |
823f7b3226 | ||
![]() |
28d73f95bd | ||
![]() |
418ca2405e | ||
![]() |
7c21eb9b3a | ||
![]() |
923ecdab3c | ||
![]() |
eb231120e1 | ||
![]() |
a343b49014 | ||
![]() |
28078d4263 | ||
![]() |
de266e538d | ||
![]() |
b85a11d0f0 | ||
![]() |
770574c9b0 | ||
![]() |
0c633ff67d | ||
![]() |
d31cb904db | ||
![]() |
a542317dc3 | ||
![]() |
e4305daf98 | ||
![]() |
10b59395b2 | ||
![]() |
1dca636521 | ||
![]() |
5db1250a8d | ||
![]() |
136cbb1e3b | ||
![]() |
78535bdd86 | ||
![]() |
aaa30fbf10 | ||
![]() |
9092c34cd5 | ||
![]() |
3d55b0d45b | ||
![]() |
573a443007 | ||
![]() |
79eb909c66 | ||
![]() |
927220933e | ||
![]() |
5a3a7633ac | ||
![]() |
414101613e | ||
![]() |
21bae3ad49 | ||
![]() |
b303f1bea3 | ||
![]() |
8f1bd4ae76 | ||
![]() |
5c24a1c4c4 | ||
![]() |
e91d757169 | ||
![]() |
4cda7c6fc1 | ||
![]() |
a23020b76d | ||
![]() |
af6ab98945 | ||
![]() |
ecc2135b5e | ||
![]() |
4e4ce944bc | ||
![]() |
b63f7d17de | ||
![]() |
67d514ad0e | ||
![]() |
929141be96 | ||
![]() |
e82bafa43e | ||
![]() |
5fc28f92d5 | ||
![]() |
5ac055be2f | ||
![]() |
266b566850 | ||
![]() |
a281631ae3 | ||
![]() |
f964533701 | ||
![]() |
dd158a17fe | ||
![]() |
c8d59a0bbc | ||
![]() |
2423aeab64 | ||
![]() |
1a43142252 | ||
![]() |
52e295f1d5 | ||
![]() |
de8ea59177 | ||
![]() |
1dc6faf3e6 | ||
![]() |
598ce5a1bf | ||
![]() |
8c607b38f1 | ||
![]() |
b84cc5eb06 | ||
![]() |
f015a874e2 | ||
![]() |
4f35b95b6b | ||
![]() |
46e28f0203 | ||
![]() |
aab6b4f393 | ||
![]() |
54ea44cdad | ||
![]() |
a462be0a5e | ||
![]() |
b639650397 | ||
![]() |
9217a12bcc | ||
![]() |
6b594aec53 | ||
![]() |
fa33c6b0d7 | ||
![]() |
a2b594c962 | ||
![]() |
0dafaa5972 | ||
![]() |
b0a0cbcd6a | ||
![]() |
f6e27aee16 | ||
![]() |
23b5538eae | ||
![]() |
ab62739fd1 | ||
![]() |
b70fade587 | ||
![]() |
05bad7b9dc | ||
![]() |
13d660bede | ||
![]() |
8523afd512 | ||
![]() |
8480454b73 | ||
![]() |
e024f6a6e7 | ||
![]() |
cb1759b257 | ||
![]() |
81560fd3c6 | ||
![]() |
170a4bceb1 | ||
![]() |
cfda62ef9c | ||
![]() |
16cd2438dd | ||
![]() |
2a667c9e7f | ||
![]() |
52257f061d | ||
![]() |
50cf2d0b8f | ||
![]() |
2aabbc788a | ||
![]() |
bc18ecb277 | ||
![]() |
413df9f5e1 | ||
![]() |
3fcfac1f37 | ||
![]() |
5fca9ce2c5 | ||
![]() |
dc4b05272f | ||
![]() |
b8411c9311 | ||
![]() |
4806aced85 | ||
![]() |
3b3f6c903a | ||
![]() |
b3c4002b69 | ||
![]() |
7e00488635 | ||
![]() |
090d844014 | ||
![]() |
013cb7f16b | ||
![]() |
c2b207dd51 | ||
![]() |
83921284a6 | ||
![]() |
59b309aa7e | ||
![]() |
49c890ebec | ||
![]() |
c8dd3b6c14 | ||
![]() |
9999650a9a | ||
![]() |
b5364fe546 | ||
![]() |
74b0dfd54f |
10
.eslintrc.js
10
.eslintrc.js
@@ -1,6 +1,4 @@
|
||||
// @ts-check
|
||||
const { defineConfig } = require('eslint-define-config');
|
||||
module.exports = defineConfig({
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
browser: true,
|
||||
@@ -20,9 +18,7 @@ module.exports = defineConfig({
|
||||
extends: [
|
||||
'plugin:vue/vue3-recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'prettier',
|
||||
'plugin:prettier/recommended',
|
||||
'plugin:jest/recommended',
|
||||
],
|
||||
rules: {
|
||||
'vue/script-setup-uses-vars': 'error',
|
||||
@@ -62,6 +58,7 @@ module.exports = defineConfig({
|
||||
'vue/singleline-html-element-content-newline': 'off',
|
||||
'vue/attribute-hyphenation': 'off',
|
||||
'vue/require-default-prop': 'off',
|
||||
'vue/require-explicit-emits': 'off',
|
||||
'vue/html-self-closing': [
|
||||
'error',
|
||||
{
|
||||
@@ -74,5 +71,6 @@ module.exports = defineConfig({
|
||||
math: 'always',
|
||||
},
|
||||
],
|
||||
'vue/multi-word-component-names': 'off',
|
||||
},
|
||||
});
|
||||
};
|
||||
|
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# https://docs.github.com/cn/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
|
||||
|
||||
# Automatically normalize line endings (to LF) for all text-based files.
|
||||
* text=auto eol=lf
|
||||
|
||||
# Declare files that will always have CRLF line endings on checkout.
|
||||
*.{cmd,[cC][mM][dD]} text eol=crlf
|
||||
*.{bat,[bB][aA][tT]} text eol=crlf
|
||||
|
||||
# Denote all files that are truly binary and should not be modified.
|
||||
*.{ico,png,jpg,jpeg,gif,webp,svg,woff,woff2} binary
|
45
.github/workflows/deploy.yml
vendored
45
.github/workflows/deploy.yml
vendored
@@ -55,32 +55,31 @@ jobs:
|
||||
# ARGS: --delete --verbose --parallel=80
|
||||
|
||||
push-to-gh-pages:
|
||||
if: "contains(github.event.head_commit.message, '[release]')"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Sed Config Base
|
||||
shell: bash
|
||||
run: |
|
||||
sed -i 's#VITE_PUBLIC_PATH\s*=.*#VITE_PUBLIC_PATH = /vue-vben-admin/#g' ./.env.production
|
||||
sed -i "s#VITE_BUILD_COMPRESS\s*=.*#VITE_BUILD_COMPRESS = 'gzip'#g" ./.env.production
|
||||
sed -i "s#VITE_DROP_CONSOLE\s*=.*#VITE_DROP_CONSOLE = true#g" ./.env.production
|
||||
cat ./.env.production
|
||||
|
||||
- name: use Node.js 16
|
||||
uses: actions/setup-node@v2.1.2
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16.x'
|
||||
|
||||
- name: Get yarn cache
|
||||
id: yarn-cache
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.yarn-cache.outputs.dir }}
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
@@ -94,25 +93,31 @@ jobs:
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan github.com > ~/.ssh/known_hosts
|
||||
chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
|
||||
git config --local user.email "vbenadmin@163.com"
|
||||
git config --local user.name "vbenAdmin"
|
||||
|
||||
- name: Delete gh-pages branch
|
||||
run: |
|
||||
git push origin --delete gh-pages
|
||||
git config --global user.email "vbenadmin@163.com"
|
||||
git config --global user.name "vbenAdmin"
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||
run: |
|
||||
yarn install
|
||||
yarn run build
|
||||
touch dist/.nojekyll
|
||||
cp dist/index.html dist/404.html
|
||||
|
||||
- name: Delete gh-pages branch
|
||||
run: |
|
||||
git push origin --delete gh-pages
|
||||
|
||||
- name: Deploy
|
||||
uses: peaceiris/actions-gh-pages@v2.5.0
|
||||
env:
|
||||
ACTIONS_DEPLOY_KEY: ${{secrets.ACTIONS_DEPLOY_KEY}}
|
||||
uses: peaceiris/actions-gh-pages@v3.9.0
|
||||
with:
|
||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||
PUBLISH_BRANCH: gh-pages
|
||||
PUBLISH_DIR: ./dist
|
||||
with:
|
||||
forceOrphan: true
|
||||
CNAME: vben.vvbin.cn
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
56
.github/workflows/ftp-schedule.yml
vendored
56
.github/workflows/ftp-schedule.yml
vendored
@@ -1,56 +0,0 @@
|
||||
name: schedule-push-to-ftp
|
||||
|
||||
# Timed deployment project
|
||||
on:
|
||||
push:
|
||||
schedule:
|
||||
- cron: '0 20 * * *'
|
||||
|
||||
jobs:
|
||||
schedule-push-to-ftp:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Sed Config Base
|
||||
shell: bash
|
||||
run: |
|
||||
sed -i 's#VITE_PUBLIC_PATH\s*=.*#VITE_PUBLIC_PATH = /next/#g' ./.env.production
|
||||
sed -i "s#VITE_BUILD_COMPRESS\s*=.*#VITE_BUILD_COMPRESS = 'gzip'#g" ./.env.production
|
||||
sed -i "s#VITE_DROP_CONSOLE\s*=.*#VITE_DROP_CONSOLE = true#g" ./.env.production
|
||||
cat ./.env.production
|
||||
|
||||
- name: use Node.js 16
|
||||
uses: actions/setup-node@v2.1.2
|
||||
with:
|
||||
node-version: '16.x'
|
||||
|
||||
- name: Get yarn cache
|
||||
id: yarn-cache
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.yarn-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
yarn install
|
||||
yarn run build
|
||||
|
||||
- name: Deploy
|
||||
uses: SamKirkland/FTP-Deploy-Action@2.0.0
|
||||
env:
|
||||
FTP_SERVER: ${{ secrets.FTP_SERVER }}
|
||||
FTP_USERNAME: ${{ secrets.FTP_USERNAME }}
|
||||
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
|
||||
METHOD: sftp
|
||||
PORT: ${{ secrets.FTP_PORT }}
|
||||
LOCAL_DIR: dist
|
||||
REMOTE_DIR: /srv/www/vben-admin
|
||||
ARGS: --delete --verbose --parallel=80
|
5
.gitignore
vendored
5
.gitignore
vendored
@@ -27,3 +27,8 @@ pnpm-debug.log*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
|
||||
.history
|
||||
|
@@ -2,5 +2,5 @@ ports:
|
||||
- port: 3344
|
||||
onOpen: open-preview
|
||||
tasks:
|
||||
- init: yarn
|
||||
command: yarn dev
|
||||
- init: pnpm install
|
||||
command: pnpm run dev
|
||||
|
@@ -3,4 +3,6 @@
|
||||
# shellcheck source=./_/husky.sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
PATH="/usr/local/bin:$PATH"
|
||||
|
||||
npx --no-install commitlint --edit "$1"
|
||||
|
@@ -1,8 +0,0 @@
|
||||
module.exports = {
|
||||
'*.{js,jsx,ts,tsx}': ['eslint --fix', 'prettier --write'],
|
||||
'{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': ['prettier --write--parser json'],
|
||||
'package.json': ['prettier --write'],
|
||||
'*.vue': ['eslint --fix', 'prettier --write', 'stylelint --fix'],
|
||||
'*.{scss,less,styl,html}': ['stylelint --fix', 'prettier --write'],
|
||||
'*.md': ['prettier --write'],
|
||||
};
|
@@ -4,5 +4,7 @@
|
||||
|
||||
[ -n "$CI" ] && exit 0
|
||||
|
||||
PATH="/usr/local/bin:$PATH"
|
||||
|
||||
# Format and submit code according to lintstagedrc.js configuration
|
||||
npm run lint:lint-staged
|
||||
|
2
.vscode/extensions.json
vendored
2
.vscode/extensions.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"octref.vetur",
|
||||
"vue.volar",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"stylelint.vscode-stylelint",
|
||||
"esbenp.prettier-vscode",
|
||||
|
50
.vscode/settings.json
vendored
50
.vscode/settings.json
vendored
@@ -1,16 +1,10 @@
|
||||
{
|
||||
"typescript.tsdk": "./node_modules/typescript/lib",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true,
|
||||
"volar.tsPlugin": true,
|
||||
"volar.tsPluginStatus": false,
|
||||
//===========================================
|
||||
//============= Editor ======================
|
||||
//===========================================
|
||||
"npm.packageManager": "pnpm",
|
||||
"editor.tabSize": 2,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
//===========================================
|
||||
//============= files =======================
|
||||
//===========================================
|
||||
"files.eol": "\n",
|
||||
"search.exclude": {
|
||||
"**/node_modules": true,
|
||||
@@ -61,7 +55,7 @@
|
||||
"**/yarn.lock": true
|
||||
},
|
||||
"stylelint.enable": true,
|
||||
"stylelint.packageManager": "yarn",
|
||||
"stylelint.validate": ["css", "less", "postcss", "scss", "vue", "sass"],
|
||||
"path-intellisense.mappings": {
|
||||
"/@/": "${workspaceRoot}/src"
|
||||
},
|
||||
@@ -94,7 +88,8 @@
|
||||
},
|
||||
"[vue]": {
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": false
|
||||
"source.fixAll.eslint": true,
|
||||
"source.fixAll.stylelint": true
|
||||
}
|
||||
},
|
||||
"i18n-ally.localesPaths": ["src/locales/lang"],
|
||||
@@ -137,6 +132,39 @@
|
||||
"lintstagedrc",
|
||||
"brotli",
|
||||
"tailwindcss",
|
||||
"sider"
|
||||
]
|
||||
"sider",
|
||||
"pnpm",
|
||||
"antd"
|
||||
],
|
||||
"vetur.format.scriptInitialIndent": true,
|
||||
"vetur.format.styleInitialIndent": true,
|
||||
"vetur.validation.script": false,
|
||||
"MicroPython.executeButton": [
|
||||
{
|
||||
"text": "▶",
|
||||
"tooltip": "运行",
|
||||
"alignment": "left",
|
||||
"command": "extension.executeFile",
|
||||
"priority": 3.5
|
||||
}
|
||||
],
|
||||
"MicroPython.syncButton": [
|
||||
{
|
||||
"text": "$(sync)",
|
||||
"tooltip": "同步",
|
||||
"alignment": "left",
|
||||
"command": "extension.execute",
|
||||
"priority": 4
|
||||
}
|
||||
],
|
||||
// 控制相关文件嵌套展示
|
||||
"explorer.fileNesting.enabled": true,
|
||||
"explorer.fileNesting.expand": false,
|
||||
"explorer.fileNesting.patterns": {
|
||||
"*.ts": "$(capture).test.ts, $(capture).test.tsx",
|
||||
"*.tsx": "$(capture).test.ts, $(capture).test.tsx",
|
||||
"*.env": "$(capture).env.*",
|
||||
"package.json": "pnpm-lock.yaml,yarn.lock,LICENSE,README*,CHANGELOG*,CNAME,.gitattributes,.gitignore,prettier.config.js,stylelint.config.js,commitlint.config.js,.stylelintignore,.prettierignore,.gitpod.yml,.eslintrc.js,.eslintignore"
|
||||
},
|
||||
"terminal.integrated.scrollback": 10000
|
||||
}
|
||||
|
48
.yarnclean
48
.yarnclean
@@ -1,48 +0,0 @@
|
||||
# test directories
|
||||
__tests__
|
||||
test
|
||||
tests
|
||||
powered-test
|
||||
|
||||
# asset directories
|
||||
docs
|
||||
doc
|
||||
website
|
||||
images
|
||||
assets
|
||||
|
||||
# examples
|
||||
example
|
||||
examples
|
||||
|
||||
# code coverage directories
|
||||
coverage
|
||||
.nyc_output
|
||||
|
||||
# build scripts
|
||||
Makefile
|
||||
Gulpfile.js
|
||||
Gruntfile.js
|
||||
|
||||
# configs
|
||||
appveyor.yml
|
||||
circle.yml
|
||||
codeship-services.yml
|
||||
codeship-steps.yml
|
||||
wercker.yml
|
||||
.tern-project
|
||||
.gitattributes
|
||||
.editorconfig
|
||||
.*ignore
|
||||
.eslintrc
|
||||
.jshintrc
|
||||
.flowconfig
|
||||
.documentup.json
|
||||
.yarn-metadata.json
|
||||
.travis.yml
|
||||
|
||||
# misc
|
||||
*.md
|
||||
|
||||
!istanbul-reports/lib/html/assets
|
||||
!istanbul-api/node_modules/istanbul-reports/lib/html/assets
|
@@ -1,4 +1,4 @@
|
||||
## [2.7.2](https://github.com/anncwb/vue-vben-admin/compare/v2.7.1...v2.7.2) (2021-09-13)
|
||||
## [2.8.0](https://github.com/anncwb/vue-vben-admin/compare/v2.7.2...v2.8.0) (2021-11-03)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
14
README.md
14
README.md
@@ -21,11 +21,11 @@ Vue Vben Admin is a free and open source middle and back-end template. Using the
|
||||
- **Authority** Built-in complete dynamic routing permission generation scheme.
|
||||
- **Component** Multiple commonly used components are encapsulated twice
|
||||
|
||||
## 预览
|
||||
## Preview
|
||||
|
||||
- [vue-vben-admin](https://vvbin.cn/next/) - Full version Chinese site
|
||||
- [vue-vben-admin](https://vben.vvbin.cn/) - Full version Chinese site
|
||||
- [vue-vben-admin-gh-pages](https://anncwb.github.io/vue-vben-admin/) - Full version of the github site
|
||||
- [vben-admin-thin-next](https://vvbin.cn/thin/next/) - Simplified Chinese site
|
||||
- [vben-admin-thin-next](https://vben.vvbin.cn/thin/next/) - Simplified Chinese site
|
||||
- [vben-admin-thin-gh-pages](https://anncwb.github.io/vben-admin-thin-next/) -Simplified github site
|
||||
|
||||
Test account: vben/123456
|
||||
@@ -44,7 +44,7 @@ Open the project in Gitpod (free online dev environment for GitHub) and start co
|
||||
|
||||
## Documentation
|
||||
|
||||
[Document](https://vvbin.cn/doc-next/)
|
||||
[Document](https://doc.vvbin.cn/)
|
||||
|
||||
## Preparation
|
||||
|
||||
@@ -70,20 +70,20 @@ git clone https://github.com/anncwb/vue-vben-admin.git
|
||||
```bash
|
||||
cd vue-vben-admin
|
||||
|
||||
yarn install
|
||||
pnpm install
|
||||
|
||||
```
|
||||
|
||||
- run
|
||||
|
||||
```bash
|
||||
yarn serve
|
||||
pnpm serve
|
||||
```
|
||||
|
||||
- build
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
pnpm build
|
||||
```
|
||||
|
||||
## Change Log
|
||||
|
@@ -23,9 +23,9 @@ Vue Vben Admin 是一个免费开源的中后台模版。使用了最新的`vue3
|
||||
|
||||
## 预览
|
||||
|
||||
- [vue-vben-admin](https://vvbin.cn/next/) - 完整版中文站点
|
||||
- [vue-vben-admin](https://vben.vvbin.cn/) - 完整版中文站点
|
||||
- [vue-vben-admin-gh-pages](https://anncwb.github.io/vue-vben-admin/) - 完整版 github 站点
|
||||
- [vben-admin-thin-next](https://vvbin.cn/thin/next/) - 简化版中文站点
|
||||
- [vben-admin-thin-next](https://vben.vvbin.cn/thin/next/) - 简化版中文站点
|
||||
- [vben-admin-thin-gh-pages](https://anncwb.github.io/vben-admin-thin-next/) - 简化版 github 站点
|
||||
|
||||
测试账号: vben/123456
|
||||
@@ -44,7 +44,7 @@ Vue Vben Admin 是一个免费开源的中后台模版。使用了最新的`vue3
|
||||
|
||||
## 文档
|
||||
|
||||
[文档地址](https://vvbin.cn/doc-next/)
|
||||
[文档地址](https://doc.vvbin.cn/)
|
||||
|
||||
## 准备
|
||||
|
||||
@@ -70,20 +70,20 @@ git clone https://github.com/anncwb/vue-vben-admin.git
|
||||
```bash
|
||||
cd vue-vben-admin
|
||||
|
||||
yarn install
|
||||
pnpm install
|
||||
|
||||
```
|
||||
|
||||
- 运行
|
||||
|
||||
```bash
|
||||
yarn serve
|
||||
pnpm serve
|
||||
```
|
||||
|
||||
- 打包
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
pnpm build
|
||||
```
|
||||
|
||||
## 更新日志
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import inquirer from 'inquirer';
|
||||
import chalk from 'chalk';
|
||||
import colors from 'picocolors';
|
||||
import pkg from '../../../package.json';
|
||||
|
||||
async function generateIcon() {
|
||||
@@ -64,7 +64,7 @@ async function generateIcon() {
|
||||
}
|
||||
fs.emptyDir(path.join(process.cwd(), 'node_modules/.vite'));
|
||||
console.log(
|
||||
`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]`,
|
||||
`✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]`,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import { GLOB_CONFIG_FILE_NAME, OUTPUT_DIR } from '../constant';
|
||||
import fs, { writeFileSync } from 'fs-extra';
|
||||
import chalk from 'chalk';
|
||||
import colors from 'picocolors';
|
||||
|
||||
import { getEnvConfig, getRootPath } from '../utils';
|
||||
import { getConfigFileName } from '../getConfigFileName';
|
||||
@@ -21,20 +21,22 @@ function createConfig(params: CreateConfigParams) {
|
||||
try {
|
||||
const windowConf = `window.${configName}`;
|
||||
// Ensure that the variable will not be modified
|
||||
const configStr = `${windowConf}=${JSON.stringify(config)};
|
||||
let configStr = `${windowConf}=${JSON.stringify(config)};`;
|
||||
configStr += `
|
||||
Object.freeze(${windowConf});
|
||||
Object.defineProperty(window, "${configName}", {
|
||||
configurable: false,
|
||||
writable: false,
|
||||
});
|
||||
`.replace(/\s/g, '');
|
||||
|
||||
fs.mkdirp(getRootPath(OUTPUT_DIR));
|
||||
writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr);
|
||||
|
||||
console.log(chalk.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`);
|
||||
console.log(chalk.gray(OUTPUT_DIR + '/' + chalk.green(configFileName)) + '\n');
|
||||
console.log(colors.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`);
|
||||
console.log(colors.gray(OUTPUT_DIR + '/' + colors.green(configFileName)) + '\n');
|
||||
} catch (error) {
|
||||
console.log(chalk.red('configuration file configuration file failed to package:\n' + error));
|
||||
console.log(colors.red('configuration file configuration file failed to package:\n' + error));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// #!/usr/bin/env node
|
||||
|
||||
import { runBuildConfig } from './buildConf';
|
||||
import chalk from 'chalk';
|
||||
import colors from 'picocolors';
|
||||
|
||||
import pkg from '../../package.json';
|
||||
|
||||
@@ -14,9 +14,9 @@ export const runBuild = async () => {
|
||||
runBuildConfig();
|
||||
}
|
||||
|
||||
console.log(`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - build successfully!');
|
||||
console.log(`✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - build successfully!');
|
||||
} catch (error) {
|
||||
console.log(chalk.red('vite build error:\n' + error));
|
||||
console.log(colors.red('vite build error:\n' + error));
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
@@ -36,11 +36,11 @@ export function wrapperEnv(envConf: Recordable): ViteEnv {
|
||||
}
|
||||
}
|
||||
ret[envName] = realName;
|
||||
if (typeof realName === 'string') {
|
||||
process.env[envName] = realName;
|
||||
} else if (typeof realName === 'object') {
|
||||
process.env[envName] = JSON.stringify(realName);
|
||||
}
|
||||
// if (typeof realName === 'string') {
|
||||
// process.env[envName] = realName;
|
||||
// } else if (typeof realName === 'object') {
|
||||
// process.env[envName] = JSON.stringify(realName);
|
||||
// }
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@@ -1,21 +0,0 @@
|
||||
// TODO
|
||||
import type { GetManualChunk } from 'rollup';
|
||||
|
||||
//
|
||||
const vendorLibs: { match: string[]; output: string }[] = [
|
||||
// {
|
||||
// match: ['xlsx'],
|
||||
// output: 'xlsx',
|
||||
// },
|
||||
];
|
||||
|
||||
// @ts-ignore
|
||||
export const configManualChunk: GetManualChunk = (id: string) => {
|
||||
if (/[\\/]node_modules[\\/]/.test(id)) {
|
||||
const matchItem = vendorLibs.find((item) => {
|
||||
const reg = new RegExp(`[\\/]node_modules[\\/]_?(${item.match.join('|')})(.*)`, 'ig');
|
||||
return reg.test(id);
|
||||
});
|
||||
return matchItem ? matchItem.output : null;
|
||||
}
|
||||
};
|
@@ -2,16 +2,16 @@
|
||||
* Used to package and output gzip. Note that this does not work properly in Vite, the specific reason is still being investigated
|
||||
* https://github.com/anncwb/vite-plugin-compression
|
||||
*/
|
||||
import type { Plugin } from 'vite';
|
||||
import type { PluginOption } from 'vite';
|
||||
import compressPlugin from 'vite-plugin-compression';
|
||||
|
||||
export function configCompressPlugin(
|
||||
compress: 'gzip' | 'brotli' | 'none',
|
||||
deleteOriginFile = false,
|
||||
): Plugin | Plugin[] {
|
||||
): PluginOption | PluginOption[] {
|
||||
const compressList = compress.split(',');
|
||||
|
||||
const plugins: Plugin[] = [];
|
||||
const plugins: PluginOption[] = [];
|
||||
|
||||
if (compressList.includes('gzip')) {
|
||||
plugins.push(
|
||||
|
@@ -1,25 +0,0 @@
|
||||
import type { Plugin } from 'vite';
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* Temporarily solve the Vite circular dependency problem, and wait for a better solution to fix it later. I don't know what problems this writing will bring.
|
||||
* @returns
|
||||
*/
|
||||
|
||||
export function configHmrPlugin(): Plugin {
|
||||
return {
|
||||
name: 'singleHMR',
|
||||
handleHotUpdate({ modules, file }) {
|
||||
if (file.match(/xml$/)) return [];
|
||||
|
||||
modules.forEach((m) => {
|
||||
if (!m.url.match(/\.(css|less)/)) {
|
||||
m.importedModules = new Set();
|
||||
m.importers = new Set();
|
||||
}
|
||||
});
|
||||
|
||||
return modules;
|
||||
},
|
||||
};
|
||||
}
|
@@ -2,8 +2,8 @@
|
||||
* Plugin to minimize and use ejs template syntax in index.html.
|
||||
* https://github.com/anncwb/vite-plugin-html
|
||||
*/
|
||||
import type { Plugin } from 'vite';
|
||||
import html from 'vite-plugin-html';
|
||||
import type { PluginOption } from 'vite';
|
||||
import { createHtmlPlugin } from 'vite-plugin-html';
|
||||
import pkg from '../../../package.json';
|
||||
import { GLOB_CONFIG_FILE_NAME } from '../../constant';
|
||||
|
||||
@@ -16,7 +16,7 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) {
|
||||
return `${path || '/'}${GLOB_CONFIG_FILE_NAME}?v=${pkg.version}-${new Date().getTime()}`;
|
||||
};
|
||||
|
||||
const htmlPlugin: Plugin[] = html({
|
||||
const htmlPlugin: PluginOption[] = createHtmlPlugin({
|
||||
minify: isBuild,
|
||||
inject: {
|
||||
// Inject data into ejs template
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import type { Plugin } from 'vite';
|
||||
import { PluginOption } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||
import legacy from '@vitejs/plugin-legacy';
|
||||
import purgeIcons from 'vite-plugin-purge-icons';
|
||||
import windiCSS from 'vite-plugin-windicss';
|
||||
import vueSetupExtend from 'vite-plugin-vue-setup-extend';
|
||||
import VitePluginCertificate from 'vite-plugin-mkcert';
|
||||
//import vueSetupExtend from 'vite-plugin-vue-setup-extend';
|
||||
import { configHtmlPlugin } from './html';
|
||||
import { configPwaConfig } from './pwa';
|
||||
import { configMockPlugin } from './mock';
|
||||
@@ -14,7 +15,6 @@ import { configVisualizerConfig } from './visualizer';
|
||||
import { configThemePlugin } from './theme';
|
||||
import { configImageminPlugin } from './imagemin';
|
||||
import { configSvgIconsPlugin } from './svgSprite';
|
||||
import { configHmrPlugin } from './hmr';
|
||||
|
||||
export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
||||
const {
|
||||
@@ -25,21 +25,21 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
||||
VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE,
|
||||
} = viteEnv;
|
||||
|
||||
const vitePlugins: (Plugin | Plugin[])[] = [
|
||||
const vitePlugins: (PluginOption | PluginOption[])[] = [
|
||||
// have to
|
||||
vue(),
|
||||
// have to
|
||||
vueJsx(),
|
||||
// support name
|
||||
vueSetupExtend(),
|
||||
//vueSetupExtend(),
|
||||
VitePluginCertificate({
|
||||
source: 'coding',
|
||||
}),
|
||||
];
|
||||
|
||||
// vite-plugin-windicss
|
||||
vitePlugins.push(windiCSS());
|
||||
|
||||
// TODO
|
||||
!isBuild && vitePlugins.push(configHmrPlugin());
|
||||
|
||||
// @vitejs/plugin-legacy
|
||||
VITE_LEGACY && isBuild && vitePlugins.push(legacy());
|
||||
|
||||
@@ -61,12 +61,12 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
||||
// rollup-plugin-visualizer
|
||||
vitePlugins.push(configVisualizerConfig());
|
||||
|
||||
//vite-plugin-theme
|
||||
// vite-plugin-theme
|
||||
vitePlugins.push(configThemePlugin(isBuild));
|
||||
|
||||
// The following plugins only work in the production environment
|
||||
if (isBuild) {
|
||||
//vite-plugin-imagemin
|
||||
// vite-plugin-imagemin
|
||||
VITE_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin());
|
||||
|
||||
// rollup-plugin-gzip
|
||||
|
@@ -2,13 +2,13 @@
|
||||
* Introduces component library styles on demand.
|
||||
* https://github.com/anncwb/vite-plugin-style-import
|
||||
*/
|
||||
import styleImport from 'vite-plugin-style-import';
|
||||
import { createStyleImportPlugin, VxeTableResolve } from 'vite-plugin-style-import';
|
||||
|
||||
export function configStyleImportPlugin(isBuild: boolean) {
|
||||
if (!isBuild) {
|
||||
export function configStyleImportPlugin(_isBuild: boolean) {
|
||||
if (!_isBuild) {
|
||||
return [];
|
||||
}
|
||||
const styleImportPlugin = styleImport({
|
||||
const styleImportPlugin = createStyleImportPlugin({
|
||||
libs: [
|
||||
{
|
||||
libraryName: 'ant-design-vue',
|
||||
@@ -19,6 +19,7 @@ export function configStyleImportPlugin(isBuild: boolean) {
|
||||
'anchor-link',
|
||||
'sub-menu',
|
||||
'menu-item',
|
||||
'menu-divider',
|
||||
'menu-item-group',
|
||||
'breadcrumb-item',
|
||||
'breadcrumb-separator',
|
||||
@@ -48,6 +49,7 @@ export function configStyleImportPlugin(isBuild: boolean) {
|
||||
// 这里是需要额外引入样式的子组件列表
|
||||
// 单独引入子组件时需引入组件样式,否则会在打包后导致子组件样式丢失
|
||||
const replaceList = {
|
||||
textarea: 'input',
|
||||
'typography-text': 'typography',
|
||||
'typography-title': 'typography',
|
||||
'typography-paragraph': 'typography',
|
||||
@@ -63,6 +65,8 @@ export function configStyleImportPlugin(isBuild: boolean) {
|
||||
'layout-footer': 'layout',
|
||||
'layout-header': 'layout',
|
||||
'month-picker': 'date-picker',
|
||||
'range-picker': 'date-picker',
|
||||
'image-preview-group': 'image',
|
||||
};
|
||||
|
||||
return ignoreList.includes(name)
|
||||
@@ -73,6 +77,7 @@ export function configStyleImportPlugin(isBuild: boolean) {
|
||||
},
|
||||
},
|
||||
],
|
||||
resolves: [VxeTableResolve()],
|
||||
});
|
||||
return styleImportPlugin;
|
||||
}
|
||||
|
@@ -3,11 +3,11 @@
|
||||
* https://github.com/anncwb/vite-plugin-svg-icons
|
||||
*/
|
||||
|
||||
import SvgIconsPlugin from 'vite-plugin-svg-icons';
|
||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
|
||||
import path from 'path';
|
||||
|
||||
export function configSvgIconsPlugin(isBuild: boolean) {
|
||||
const svgIconsPlugin = SvgIconsPlugin({
|
||||
const svgIconsPlugin = createSvgIconsPlugin({
|
||||
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
|
||||
svgoOptions: isBuild,
|
||||
// default
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* Vite plugin for website theme color switching
|
||||
* https://github.com/anncwb/vite-plugin-theme
|
||||
*/
|
||||
import type { Plugin } from 'vite';
|
||||
import type { PluginOption } from 'vite';
|
||||
import path from 'path';
|
||||
import {
|
||||
viteThemePlugin,
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
import { getThemeColors, generateColors } from '../../config/themeConfig';
|
||||
import { generateModifyVars } from '../../generate/generateModifyVars';
|
||||
|
||||
export function configThemePlugin(isBuild: boolean): Plugin[] {
|
||||
export function configThemePlugin(isBuild: boolean): PluginOption[] {
|
||||
const colors = generateColors({
|
||||
mixDarken,
|
||||
mixLighten,
|
||||
@@ -85,5 +85,5 @@ export function configThemePlugin(isBuild: boolean): Plugin[] {
|
||||
}),
|
||||
];
|
||||
|
||||
return plugin as unknown as Plugin[];
|
||||
return plugin as unknown as PluginOption[];
|
||||
}
|
||||
|
@@ -1,3 +1,23 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
const scopes = fs
|
||||
.readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true })
|
||||
.filter((dirent) => dirent.isDirectory())
|
||||
.map((dirent) => dirent.name.replace(/s$/, ''));
|
||||
|
||||
// precomputed scope
|
||||
const scopeComplete = execSync('git status --porcelain || true')
|
||||
.toString()
|
||||
.trim()
|
||||
.split('\n')
|
||||
.find((r) => ~r.indexOf('M src'))
|
||||
?.replace(/(\/)/g, '%%')
|
||||
?.match(/src%%((\w|-)*)/)?.[1]
|
||||
?.replace(/s$/, '');
|
||||
|
||||
/** @type {import('cz-git').UserConfig} */
|
||||
module.exports = {
|
||||
ignores: [(commit) => commit.includes('init')],
|
||||
extends: ['@commitlint/config-conventional'],
|
||||
@@ -30,4 +50,58 @@ module.exports = {
|
||||
],
|
||||
],
|
||||
},
|
||||
prompt: {
|
||||
/** @use `yarn commit :f` */
|
||||
alias: {
|
||||
f: 'docs: fix typos',
|
||||
r: 'docs: update README',
|
||||
s: 'style: update code format',
|
||||
b: 'build: bump dependencies',
|
||||
c: 'chore: update config',
|
||||
},
|
||||
customScopesAlign: !scopeComplete ? 'top' : 'bottom',
|
||||
defaultScope: scopeComplete,
|
||||
scopes: [...scopes, 'mock'],
|
||||
allowEmptyIssuePrefixs: false,
|
||||
allowCustomIssuePrefixs: false,
|
||||
|
||||
// English
|
||||
typesAppend: [
|
||||
{ value: 'wip', name: 'wip: work in process' },
|
||||
{ value: 'workflow', name: 'workflow: workflow improvements' },
|
||||
{ value: 'types', name: 'types: type definition file changes' },
|
||||
],
|
||||
|
||||
// 中英文对照版
|
||||
// messages: {
|
||||
// type: '选择你要提交的类型 :',
|
||||
// scope: '选择一个提交范围 (可选):',
|
||||
// customScope: '请输入自定义的提交范围 :',
|
||||
// subject: '填写简短精炼的变更描述 :\n',
|
||||
// body: '填写更加详细的变更描述 (可选)。使用 "|" 换行 :\n',
|
||||
// breaking: '列举非兼容性重大的变更 (可选)。使用 "|" 换行 :\n',
|
||||
// footerPrefixsSelect: '选择关联issue前缀 (可选):',
|
||||
// customFooterPrefixs: '输入自定义issue前缀 :',
|
||||
// footer: '列举关联issue (可选) 例如: #31, #I3244 :\n',
|
||||
// confirmCommit: '是否提交或修改commit ?',
|
||||
// },
|
||||
// types: [
|
||||
// { value: 'feat', name: 'feat: 新增功能' },
|
||||
// { value: 'fix', name: 'fix: 修复缺陷' },
|
||||
// { value: 'docs', name: 'docs: 文档变更' },
|
||||
// { value: 'style', name: 'style: 代码格式' },
|
||||
// { value: 'refactor', name: 'refactor: 代码重构' },
|
||||
// { value: 'perf', name: 'perf: 性能优化' },
|
||||
// { value: 'test', name: 'test: 添加疏漏测试或已有测试改动' },
|
||||
// { value: 'build', name: 'build: 构建流程、外部依赖变更 (如升级 npm 包、修改打包配置等)' },
|
||||
// { value: 'ci', name: 'ci: 修改 CI 配置、脚本' },
|
||||
// { value: 'revert', name: 'revert: 回滚 commit' },
|
||||
// { value: 'chore', name: 'chore: 对构建过程或辅助工具和库的更改 (不影响源文件、测试用例)' },
|
||||
// { value: 'wip', name: 'wip: 正在开发中' },
|
||||
// { value: 'workflow', name: 'workflow: 工作流程改进' },
|
||||
// { value: 'types', name: 'types: 类型定义文件修改' },
|
||||
// ],
|
||||
// emptyScopesAlias: 'empty: 不填写',
|
||||
// customScopesAlias: 'custom: 自定义',
|
||||
},
|
||||
};
|
||||
|
21
index.html
21
index.html
@@ -8,7 +8,6 @@
|
||||
name="viewport"
|
||||
content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
|
||||
/>
|
||||
|
||||
<title><%= title %></title>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</head>
|
||||
@@ -30,7 +29,7 @@
|
||||
}
|
||||
|
||||
html[data-theme='dark'] .app-loading .app-loading-title {
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
color: rgb(255 255 255 / 85%);
|
||||
}
|
||||
|
||||
.app-loading {
|
||||
@@ -48,7 +47,6 @@
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
display: flex;
|
||||
-webkit-transform: translate3d(-50%, -50%, 0);
|
||||
transform: translate3d(-50%, -50%, 0);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
@@ -66,7 +64,7 @@
|
||||
display: flex;
|
||||
margin-top: 30px;
|
||||
font-size: 30px;
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
color: rgb(0 0 0 / 85%);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -97,7 +95,7 @@
|
||||
height: 20px;
|
||||
background-color: #0065cc;
|
||||
border-radius: 100%;
|
||||
opacity: 0.3;
|
||||
opacity: 30%;
|
||||
transform: scale(0.75);
|
||||
animation: antSpinMove 1s infinite linear alternate;
|
||||
transform-origin: 50% 50%;
|
||||
@@ -111,43 +109,38 @@
|
||||
.dot i:nth-child(2) {
|
||||
top: 0;
|
||||
right: 0;
|
||||
-webkit-animation-delay: 0.4s;
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
|
||||
.dot i:nth-child(3) {
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
-webkit-animation-delay: 0.8s;
|
||||
animation-delay: 0.8s;
|
||||
}
|
||||
|
||||
.dot i:nth-child(4) {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
-webkit-animation-delay: 1.2s;
|
||||
animation-delay: 1.2s;
|
||||
}
|
||||
@keyframes antRotate {
|
||||
to {
|
||||
-webkit-transform: rotate(405deg);
|
||||
transform: rotate(405deg);
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes antRotate {
|
||||
@keyframes antRotate {
|
||||
to {
|
||||
-webkit-transform: rotate(405deg);
|
||||
transform: rotate(405deg);
|
||||
}
|
||||
}
|
||||
@keyframes antSpinMove {
|
||||
to {
|
||||
opacity: 1;
|
||||
opacity: 100%;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes antSpinMove {
|
||||
@keyframes antSpinMove {
|
||||
to {
|
||||
opacity: 1;
|
||||
opacity: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -1,36 +0,0 @@
|
||||
export default {
|
||||
preset: 'ts-jest',
|
||||
roots: ['<rootDir>/tests/'],
|
||||
clearMocks: true,
|
||||
moduleDirectories: ['node_modules', 'src'],
|
||||
moduleFileExtensions: ['js', 'ts', 'vue', 'tsx', 'jsx', 'json', 'node'],
|
||||
modulePaths: ['<rootDir>/src', '<rootDir>/node_modules'],
|
||||
testMatch: [
|
||||
'**/tests/**/*.[jt]s?(x)',
|
||||
'**/?(*.)+(spec|test).[tj]s?(x)',
|
||||
'(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$',
|
||||
],
|
||||
testPathIgnorePatterns: [
|
||||
'<rootDir>/tests/server/',
|
||||
'<rootDir>/tests/__mocks__/',
|
||||
'/node_modules/',
|
||||
],
|
||||
transform: {
|
||||
'^.+\\.tsx?$': 'ts-jest',
|
||||
},
|
||||
transformIgnorePatterns: ['<rootDir>/tests/__mocks__/', '/node_modules/'],
|
||||
// A map from regular expressions to module names that allow to stub out resources with a single module
|
||||
moduleNameMapper: {
|
||||
'\\.(vs|fs|vert|frag|glsl|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
||||
'<rootDir>/tests/__mocks__/fileMock.ts',
|
||||
'\\.(sass|s?css|less)$': '<rootDir>/tests/__mocks__/styleMock.ts',
|
||||
'\\?worker$': '<rootDir>/tests/__mocks__/workerMock.ts',
|
||||
'^/@/(.*)$': '<rootDir>/src/$1',
|
||||
},
|
||||
testEnvironment: 'jsdom',
|
||||
verbose: true,
|
||||
collectCoverage: false,
|
||||
coverageDirectory: 'coverage',
|
||||
collectCoverageFrom: ['src/**/*.{js,ts,vue}'],
|
||||
coveragePathIgnorePatterns: ['^.+\\.d\\.ts$'],
|
||||
};
|
@@ -1,5 +1,21 @@
|
||||
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';
|
||||
|
||||
// 问题描述
|
||||
// 1. `import.meta.globEager` 已被弃用, 需要升级vite版本,有兼容问题
|
||||
// 2. `vite-plugin-mock` 插件问题 https://github.com/vbenjs/vite-plugin-mock/issues/56
|
||||
|
||||
// const modules: Record<string, any> = import.meta.glob("./**/*.ts", {
|
||||
// import: "default",
|
||||
// eager: true,
|
||||
// });
|
||||
|
||||
// const mockModules = Object.keys(modules).reduce((pre, key) => {
|
||||
// if (!key.includes("/_")) {
|
||||
// pre.push(...modules[key]);
|
||||
// }
|
||||
// return pre;
|
||||
// }, [] as any[]);
|
||||
|
||||
const modules = import.meta.globEager('./**/*.ts');
|
||||
|
||||
const mockModules: any[] = [];
|
||||
|
@@ -1,8 +1,9 @@
|
||||
// Interface data format used to return a unified format
|
||||
import { ResultEnum } from '/@/enums/httpEnum';
|
||||
|
||||
export function resultSuccess<T = Recordable>(result: T, { message = 'ok' } = {}) {
|
||||
return {
|
||||
code: 0,
|
||||
code: ResultEnum.SUCCESS,
|
||||
result,
|
||||
message,
|
||||
type: 'success',
|
||||
@@ -26,7 +27,10 @@ export function resultPageSuccess<T = any>(
|
||||
};
|
||||
}
|
||||
|
||||
export function resultError(message = 'Request failed', { code = -1, result = null } = {}) {
|
||||
export function resultError(
|
||||
message = 'Request failed',
|
||||
{ code = ResultEnum.ERROR, result = null } = {},
|
||||
) {
|
||||
return {
|
||||
code,
|
||||
result,
|
||||
@@ -37,11 +41,9 @@ export function resultError(message = 'Request failed', { code = -1, result = nu
|
||||
|
||||
export function pagination<T = any>(pageNo: number, pageSize: number, array: T[]): T[] {
|
||||
const offset = (pageNo - 1) * Number(pageSize);
|
||||
const ret =
|
||||
offset + Number(pageSize) >= array.length
|
||||
? array.slice(offset, array.length)
|
||||
: array.slice(offset, offset + Number(pageSize));
|
||||
return ret;
|
||||
return offset + Number(pageSize) >= array.length
|
||||
? array.slice(offset, array.length)
|
||||
: array.slice(offset, offset + Number(pageSize));
|
||||
}
|
||||
|
||||
export interface requestParams {
|
||||
|
@@ -27,6 +27,9 @@ const demoList = (() => {
|
||||
name6: '@cname()',
|
||||
name7: '@cname()',
|
||||
name8: '@cname()',
|
||||
radio1: `选项${index + 1}`,
|
||||
radio2: `选项${index + 1}`,
|
||||
radio3: `选项${index + 1}`,
|
||||
avatar: Random.image('400x400', Random.color(), Random.color(), Random.first()),
|
||||
imgArr: getRandomPics(Math.ceil(Math.random() * 3) + 1),
|
||||
imgs: getRandomPics(Math.ceil(Math.random() * 3) + 1),
|
||||
|
@@ -221,11 +221,11 @@ const linkRoute = {
|
||||
name: 'Doc',
|
||||
meta: {
|
||||
title: 'routes.demo.iframe.doc',
|
||||
frameSrc: 'https://vvbin.cn/doc-next/',
|
||||
frameSrc: 'https://doc.vvbin.cn/',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'https://vvbin.cn/doc-next/',
|
||||
path: 'https://doc.vvbin.cn/',
|
||||
name: 'DocExternal',
|
||||
component: 'LAYOUT',
|
||||
meta: {
|
||||
|
@@ -7,7 +7,7 @@ export function createFakeUserList() {
|
||||
userId: '1',
|
||||
username: 'vben',
|
||||
realName: 'Vben Admin',
|
||||
avatar: 'https://q1.qlogo.cn/g?b=qq&nk=190848757&s=640',
|
||||
avatar: '',
|
||||
desc: 'manager',
|
||||
password: '123456',
|
||||
token: 'fakeToken1',
|
||||
@@ -24,7 +24,7 @@ export function createFakeUserList() {
|
||||
username: 'test',
|
||||
password: '123456',
|
||||
realName: 'test user',
|
||||
avatar: 'https://q1.qlogo.cn/g?b=qq&nk=339449197&s=640',
|
||||
avatar: '',
|
||||
desc: 'tester',
|
||||
token: 'fakeToken2',
|
||||
homePath: '/dashboard/workbench',
|
||||
@@ -111,4 +111,12 @@ export default [
|
||||
return resultSuccess(undefined, { message: 'Token has been destroyed' });
|
||||
},
|
||||
},
|
||||
{
|
||||
url: '/basic-api/testRetry',
|
||||
statusCode: 405,
|
||||
method: 'get',
|
||||
response: () => {
|
||||
return resultError('Error!');
|
||||
},
|
||||
},
|
||||
] as MockMethod[];
|
||||
|
213
package.json
213
package.json
@@ -1,18 +1,19 @@
|
||||
{
|
||||
"name": "vben-admin",
|
||||
"version": "2.7.2",
|
||||
"version": "2.9.0",
|
||||
"author": {
|
||||
"name": "vben",
|
||||
"email": "anncwb@126.com",
|
||||
"url": "https://github.com/anncwb"
|
||||
},
|
||||
"scripts": {
|
||||
"bootstrap": "yarn install",
|
||||
"commit": "czg",
|
||||
"bootstrap": "pnpm install",
|
||||
"serve": "npm run dev",
|
||||
"dev": "vite",
|
||||
"build": "cross-env NODE_ENV=production vite build && esno ./build/script/postBuild.ts",
|
||||
"build:test": "cross-env vite build --mode test && esno ./build/script/postBuild.ts",
|
||||
"build:no-cache": "yarn clean:cache && npm run build",
|
||||
"build:no-cache": "pnpm clean:cache && npm run build",
|
||||
"report": "cross-env REPORT=true npm run build",
|
||||
"type:check": "vue-tsc --noEmit --skipLibCheck",
|
||||
"preview": "npm run build && vite preview",
|
||||
@@ -23,130 +24,137 @@
|
||||
"lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,tsx}\" --fix",
|
||||
"lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"",
|
||||
"lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
|
||||
"lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js",
|
||||
"lint:lint-staged": "lint-staged",
|
||||
"test:unit": "jest",
|
||||
"test:unit-coverage": "jest --coverage",
|
||||
"test:gzip": "npx http-server dist --cors --gzip -c-1",
|
||||
"test:br": "npx http-server dist --cors --brotli -c-1",
|
||||
"reinstall": "rimraf yarn.lock && rimraf package.lock.json && rimraf node_modules && npm run bootstrap",
|
||||
"reinstall": "rimraf pnpm-lock.yaml && rimraf package.lock.json && rimraf node_modules && npm run bootstrap",
|
||||
"prepare": "husky install",
|
||||
"gen:icon": "esno ./build/generate/icon/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/colors": "^6.0.0",
|
||||
"@ant-design/icons-vue": "^6.0.1",
|
||||
"@iconify/iconify": "^2.0.4",
|
||||
"@logicflow/core": "^0.7.2",
|
||||
"@logicflow/extension": "^0.7.2",
|
||||
"@vueuse/core": "^6.7.4",
|
||||
"@vueuse/shared": "^6.7.4",
|
||||
"@zxcvbn-ts/core": "^1.0.0-beta.0",
|
||||
"ant-design-vue": "2.2.8",
|
||||
"axios": "^0.24.0",
|
||||
"codemirror": "^5.63.3",
|
||||
"@ant-design/icons-vue": "^6.1.0",
|
||||
"@iconify/iconify": "^2.2.1",
|
||||
"@logicflow/core": "^1.1.13",
|
||||
"@logicflow/extension": "^1.1.13",
|
||||
"@vue/runtime-core": "^3.2.33",
|
||||
"@vue/shared": "^3.2.33",
|
||||
"@vueuse/core": "^8.3.0",
|
||||
"@vueuse/shared": "^8.3.0",
|
||||
"@zxcvbn-ts/core": "^2.0.1",
|
||||
"ant-design-vue": "^3.2.0",
|
||||
"axios": "^0.26.1",
|
||||
"codemirror": "^5.65.3",
|
||||
"cropperjs": "^1.5.12",
|
||||
"crypto-js": "^4.1.1",
|
||||
"echarts": "^5.2.2",
|
||||
"intro.js": "^4.2.2",
|
||||
"dayjs": "^1.11.1",
|
||||
"echarts": "^5.3.2",
|
||||
"exceljs": "^4.3.0",
|
||||
"intro.js": "^5.1.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"mockjs": "^1.1.0",
|
||||
"moment": "^2.29.1",
|
||||
"nprogress": "^0.2.0",
|
||||
"path-to-regexp": "^6.2.0",
|
||||
"pinia": "2.0.0",
|
||||
"pinia": "2.0.12",
|
||||
"print-js": "^1.6.0",
|
||||
"qrcode": "^1.4.4",
|
||||
"qs": "^6.10.1",
|
||||
"qrcode": "^1.5.0",
|
||||
"qs": "^6.10.3",
|
||||
"resize-observer-polyfill": "^1.5.1",
|
||||
"showdown": "^1.9.1",
|
||||
"sortablejs": "^1.14.0",
|
||||
"tinymce": "^5.10.0",
|
||||
"vditor": "^3.8.7",
|
||||
"vue": "^3.2.21",
|
||||
"showdown": "^2.1.0",
|
||||
"sortablejs": "^1.15.0",
|
||||
"tinymce": "^5.10.7",
|
||||
"vditor": "^3.8.13",
|
||||
"vue": "^3.2.45",
|
||||
"vue-i18n": "^9.1.9",
|
||||
"vue-json-pretty": "^2.0.4",
|
||||
"vue-router": "^4.0.12",
|
||||
"vue-json-pretty": "^2.0.6",
|
||||
"vue-router": "^4.0.14",
|
||||
"vue-types": "^4.1.1",
|
||||
"xlsx": "^0.17.3"
|
||||
"vxe-table": "^4.3.9",
|
||||
"vxe-table-plugin-export-xlsx": "^3.0.4",
|
||||
"xe-utils": "^3.5.7",
|
||||
"xlsx": "^0.18.5",
|
||||
"vuedraggable": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^14.1.0",
|
||||
"@commitlint/config-conventional": "^14.1.0",
|
||||
"@iconify/json": "^1.1.422",
|
||||
"@purge-icons/generated": "^0.7.0",
|
||||
"@commitlint/cli": "^16.2.3",
|
||||
"@commitlint/config-conventional": "^16.2.1",
|
||||
"@iconify/json": "^2.1.30",
|
||||
"@purge-icons/generated": "^0.8.1",
|
||||
"@types/codemirror": "^5.60.5",
|
||||
"@types/crypto-js": "^4.0.2",
|
||||
"@types/crypto-js": "^4.1.1",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/inquirer": "^8.1.3",
|
||||
"@types/inquirer": "^8.2.1",
|
||||
"@types/intro.js": "^3.0.2",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/lodash-es": "^4.17.5",
|
||||
"@types/mockjs": "^1.0.4",
|
||||
"@types/node": "^16.11.6",
|
||||
"@types/lodash-es": "^4.17.6",
|
||||
"@types/mockjs": "^1.0.6",
|
||||
"@types/node": "^17.0.25",
|
||||
"@types/nprogress": "^0.2.0",
|
||||
"@types/qrcode": "^1.4.1",
|
||||
"@types/qrcode": "^1.4.2",
|
||||
"@types/qs": "^6.9.7",
|
||||
"@types/showdown": "^1.9.4",
|
||||
"@types/sortablejs": "^1.10.7",
|
||||
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
||||
"@typescript-eslint/parser": "^5.3.0",
|
||||
"@vitejs/plugin-legacy": "^1.6.2",
|
||||
"@vitejs/plugin-vue": "^1.9.4",
|
||||
"@vitejs/plugin-vue-jsx": "^1.2.0",
|
||||
"@vue/compiler-sfc": "3.2.21",
|
||||
"@vue/test-utils": "^2.0.0-rc.16",
|
||||
"autoprefixer": "^10.4.0",
|
||||
"commitizen": "^4.2.4",
|
||||
"conventional-changelog-cli": "^2.1.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
||||
"@typescript-eslint/parser": "^5.20.0",
|
||||
"@vitejs/plugin-legacy": "^1.8.1",
|
||||
"@vitejs/plugin-vue": "^2.3.1",
|
||||
"@vitejs/plugin-vue-jsx": "^1.3.10",
|
||||
"@vue/compiler-sfc": "^3.2.33",
|
||||
"@vue/test-utils": "^2.0.0-rc.21",
|
||||
"autoprefixer": "^10.4.4",
|
||||
"conventional-changelog-cli": "^2.2.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"dotenv": "^10.0.0",
|
||||
"eslint": "^8.1.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-define-config": "^1.1.2",
|
||||
"eslint-plugin-jest": "^25.2.2",
|
||||
"cz-git": "^1.3.9",
|
||||
"czg": "^1.3.9",
|
||||
"dotenv": "^16.0.0",
|
||||
"eslint": "^8.13.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"eslint-plugin-vue": "^8.0.3",
|
||||
"esno": "^0.10.1",
|
||||
"fs-extra": "^10.0.0",
|
||||
"eslint-plugin-vue": "^8.6.0",
|
||||
"esno": "^0.14.1",
|
||||
"fs-extra": "^10.1.0",
|
||||
"husky": "^7.0.4",
|
||||
"inquirer": "^8.2.0",
|
||||
"jest": "^27.3.1",
|
||||
"inquirer": "^8.2.2",
|
||||
"less": "^4.1.2",
|
||||
"lint-staged": "11.2.6",
|
||||
"lint-staged": "12.3.7",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"postcss": "^8.3.11",
|
||||
"postcss-html": "^1.2.0",
|
||||
"postcss-less": "^5.0.0",
|
||||
"prettier": "^2.4.1",
|
||||
"picocolors": "^1.0.0",
|
||||
"postcss": "^8.4.12",
|
||||
"postcss-html": "^1.4.1",
|
||||
"postcss-less": "^6.0.0",
|
||||
"prettier": "^2.6.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup-plugin-visualizer": "^5.5.2",
|
||||
"stylelint": "^14.0.1",
|
||||
"stylelint-config-html": "^1.0.0",
|
||||
"rollup": "^2.70.2",
|
||||
"rollup-plugin-visualizer": "^5.6.0",
|
||||
"sass": "^1.57.1",
|
||||
"stylelint": "^14.7.1",
|
||||
"stylelint-config-prettier": "^9.0.3",
|
||||
"stylelint-config-standard": "^23.0.0",
|
||||
"stylelint-config-recommended": "^7.0.0",
|
||||
"stylelint-config-recommended-vue": "^1.4.0",
|
||||
"stylelint-config-standard": "^25.0.0",
|
||||
"stylelint-order": "^5.0.0",
|
||||
"ts-jest": "^27.0.7",
|
||||
"ts-node": "^10.4.0",
|
||||
"typescript": "^4.4.4",
|
||||
"vite": "^2.6.13",
|
||||
"vite-plugin-compression": "^0.3.5",
|
||||
"vite-plugin-html": "^2.1.1",
|
||||
"vite-plugin-imagemin": "^0.4.6",
|
||||
"ts-node": "^10.7.0",
|
||||
"typescript": "^4.6.3",
|
||||
"vite": "^2.9.5",
|
||||
"vite-plugin-compression": "^0.5.1",
|
||||
"vite-plugin-html": "^3.2.0",
|
||||
"vite-plugin-imagemin": "^0.6.1",
|
||||
"vite-plugin-mkcert": "^1.6.0",
|
||||
"vite-plugin-mock": "^2.9.6",
|
||||
"vite-plugin-purge-icons": "^0.7.0",
|
||||
"vite-plugin-pwa": "^0.11.3",
|
||||
"vite-plugin-style-import": "^1.3.0",
|
||||
"vite-plugin-svg-icons": "^1.0.5",
|
||||
"vite-plugin-theme": "^0.8.1",
|
||||
"vite-plugin-vue-setup-extend": "^0.1.0",
|
||||
"vite-plugin-windicss": "^1.4.12",
|
||||
"vue-eslint-parser": "^8.0.1",
|
||||
"vue-tsc": "^0.28.10"
|
||||
"vite-plugin-purge-icons": "^0.8.1",
|
||||
"vite-plugin-pwa": "^0.11.13",
|
||||
"vite-plugin-style-import": "^2.0.0",
|
||||
"vite-plugin-svg-icons": "^2.0.1",
|
||||
"vite-plugin-theme": "^0.8.6",
|
||||
"vite-plugin-vue-setup-extend": "^0.4.0",
|
||||
"vite-plugin-windicss": "^1.8.4",
|
||||
"vue-eslint-parser": "^8.3.0",
|
||||
"vue-tsc": "^1.0.9"
|
||||
},
|
||||
"resolutions": {
|
||||
"//": "Used to install imagemin dependencies, because imagemin may not be installed in China. If it is abroad, you can delete it",
|
||||
"bin-wrapper": "npm:bin-wrapper-china",
|
||||
"rollup": "^2.56.3"
|
||||
"rollup": "^2.56.3",
|
||||
"gifsicle": "5.2.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -159,5 +167,34 @@
|
||||
"homepage": "https://github.com/anncwb/vue-vben-admin",
|
||||
"engines": {
|
||||
"node": "^12 || >=14"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,jsx,ts,tsx}": [
|
||||
"eslint --fix",
|
||||
"prettier --write"
|
||||
],
|
||||
"{!(package)*.json,*.code-snippets,.!(browserslist)*rc}": [
|
||||
"prettier --write--parser json"
|
||||
],
|
||||
"package.json": [
|
||||
"prettier --write"
|
||||
],
|
||||
"*.vue": [
|
||||
"eslint --fix",
|
||||
"prettier --write",
|
||||
"stylelint --fix"
|
||||
],
|
||||
"*.{scss,less,styl,html}": [
|
||||
"stylelint --fix",
|
||||
"prettier --write"
|
||||
],
|
||||
"*.md": [
|
||||
"prettier --write"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "node_modules/cz-git"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
8812
pnpm-lock.yaml
generated
8812
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -4,14 +4,4 @@
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*/
|
||||
.tinymce-mobile-unfocused-selections .tinymce-mobile-unfocused-selection{position: absolute;display: inline-block;background-color: green;opacity: .5;}
|
||||
|
||||
body{-webkit-text-size-adjust: none;}
|
||||
|
||||
body img{max-width: 96vw;}
|
||||
|
||||
body table img{max-width: 95%;}
|
||||
|
||||
body{font-family: sans-serif;}
|
||||
|
||||
table{border-collapse: collapse;}
|
||||
.tinymce-mobile-unfocused-selections .tinymce-mobile-unfocused-selection{background-color:green;display:inline-block;opacity:.5;position:absolute}body{-webkit-text-size-adjust:none}body img{max-width:96vw}body table img{max-width:95%}body{font-family:sans-serif}table{border-collapse:collapse}
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
7
public/resource/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css
vendored
Normal file
7
public/resource/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||||
* Licensed under the LGPL or a commercial license.
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*/
|
||||
body.tox-dialog__disable-scroll{overflow:hidden}.tox-fullscreen{border:0;height:100%;margin:0;overflow:hidden;-ms-scroll-chaining:none;overscroll-behavior:none;padding:0;touch-action:pinch-zoom;width:100%}.tox.tox-tinymce.tox-fullscreen .tox-statusbar__resize-handle{display:none}.tox-shadowhost.tox-fullscreen,.tox.tox-tinymce.tox-fullscreen{left:0;position:fixed;top:0;z-index:1200}.tox.tox-tinymce.tox-fullscreen{background-color:transparent}.tox-fullscreen .tox.tox-tinymce-aux,.tox-fullscreen~.tox.tox-tinymce-aux{z-index:1201}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -4,14 +4,4 @@
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*/
|
||||
.tinymce-mobile-unfocused-selections .tinymce-mobile-unfocused-selection{position: absolute;display: inline-block;background-color: green;opacity: .5;}
|
||||
|
||||
body{-webkit-text-size-adjust: none;}
|
||||
|
||||
body img{max-width: 96vw;}
|
||||
|
||||
body table img{max-width: 95%;}
|
||||
|
||||
body{font-family: sans-serif;}
|
||||
|
||||
table{border-collapse: collapse;}
|
||||
.tinymce-mobile-unfocused-selections .tinymce-mobile-unfocused-selection{background-color:green;display:inline-block;opacity:.5;position:absolute}body{-webkit-text-size-adjust:none}body img{max-width:96vw}body table img{max-width:95%}body{font-family:sans-serif}table{border-collapse:collapse}
|
||||
|
870
public/resource/tinymce/skins/ui/oxide/skin.min.css
vendored
870
public/resource/tinymce/skins/ui/oxide/skin.min.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
7
public/resource/tinymce/skins/ui/oxide/skin.shadowdom.min.css
vendored
Normal file
7
public/resource/tinymce/skins/ui/oxide/skin.shadowdom.min.css
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||||
* Licensed under the LGPL or a commercial license.
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*/
|
||||
body.tox-dialog__disable-scroll{overflow:hidden}.tox-fullscreen{border:0;height:100%;margin:0;overflow:hidden;-ms-scroll-chaining:none;overscroll-behavior:none;padding:0;touch-action:pinch-zoom;width:100%}.tox.tox-tinymce.tox-fullscreen .tox-statusbar__resize-handle{display:none}.tox-shadowhost.tox-fullscreen,.tox.tox-tinymce.tox-fullscreen{left:0;position:fixed;top:0;z-index:1200}.tox.tox-tinymce.tox-fullscreen{background-color:transparent}.tox-fullscreen .tox.tox-tinymce-aux,.tox-fullscreen~.tox.tox-tinymce-aux{z-index:1201}
|
@@ -12,6 +12,7 @@
|
||||
import { useTitle } from '/@/hooks/web/useTitle';
|
||||
import { useLocale } from '/@/locales/useLocale';
|
||||
|
||||
import 'dayjs/locale/zh-cn';
|
||||
// support Multi-language
|
||||
const { getAntdLocale } = useLocale();
|
||||
|
||||
|
@@ -14,6 +14,7 @@ export const demoListApi = (params: DemoParams) =>
|
||||
url: Api.DEMO_LIST,
|
||||
params,
|
||||
headers: {
|
||||
// @ts-ignore
|
||||
ignoreCancelToken: true,
|
||||
},
|
||||
});
|
||||
|
@@ -8,6 +8,7 @@ enum Api {
|
||||
Logout = '/logout',
|
||||
GetUserInfo = '/getUserInfo',
|
||||
GetPermCode = '/getPermCode',
|
||||
TestRetry = '/testRetry',
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,3 +40,16 @@ export function getPermCode() {
|
||||
export function doLogout() {
|
||||
return defHttp.get({ url: Api.Logout });
|
||||
}
|
||||
|
||||
export function testRetry() {
|
||||
return defHttp.get(
|
||||
{ url: Api.TestRetry },
|
||||
{
|
||||
retryRequest: {
|
||||
isOpenRetry: true,
|
||||
count: 5,
|
||||
waitTime: 1000,
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@@ -4,11 +4,11 @@
|
||||
-->
|
||||
<template>
|
||||
<Dropdown
|
||||
placement="bottomCenter"
|
||||
placement="bottom"
|
||||
:trigger="['click']"
|
||||
:dropMenuList="localeList"
|
||||
:selectedKeys="selectedKeys"
|
||||
@menuEvent="handleMenuEvent"
|
||||
@menu-event="handleMenuEvent"
|
||||
overlayClassName="app-locale-picker-overlay"
|
||||
>
|
||||
<span class="cursor-pointer flex items-center">
|
||||
|
@@ -10,14 +10,15 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { Button } from 'ant-design-vue';
|
||||
export default defineComponent({
|
||||
name: 'AButton',
|
||||
extends: Button,
|
||||
inheritAttrs: false,
|
||||
});
|
||||
</script>
|
||||
<script lang="ts" setup>
|
||||
import { computed, unref } from 'vue';
|
||||
import { Button } from 'ant-design-vue';
|
||||
import Icon from '/@/components/Icon/src/Icon.vue';
|
||||
import { buttonProps } from './props';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
|
@@ -1,5 +1,12 @@
|
||||
const validColors = ['primary', 'error', 'warning', 'success', ''] as const;
|
||||
type ButtonColorType = typeof validColors[number];
|
||||
|
||||
export const buttonProps = {
|
||||
color: { type: String, validator: (v) => ['error', 'warning', 'success', ''].includes(v) },
|
||||
color: {
|
||||
type: String as PropType<ButtonColorType>,
|
||||
validator: (v) => validColors.includes(v),
|
||||
default: '',
|
||||
},
|
||||
loading: { type: Boolean },
|
||||
disabled: { type: Boolean },
|
||||
/**
|
||||
|
@@ -3,7 +3,6 @@
|
||||
<div class="p-4 mb-2 bg-white">
|
||||
<BasicForm @register="registerForm" />
|
||||
</div>
|
||||
{{ sliderProp.width }}
|
||||
<div class="p-2 bg-white">
|
||||
<List
|
||||
:grid="{ gutter: 5, xs: 1, sm: 2, md: 4, lg: 4, xl: 6, xxl: grid }"
|
||||
@@ -39,7 +38,7 @@
|
||||
<Image :src="item.imgs[0]" />
|
||||
</div>
|
||||
</template>
|
||||
<template class="ant-card-actions" #actions>
|
||||
<template #actions>
|
||||
<!-- <SettingOutlined key="setting" />-->
|
||||
<EditOutlined key="edit" />
|
||||
<Dropdown
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { ref } from 'vue';
|
||||
//每行个数
|
||||
// 每行个数
|
||||
export const grid = ref(12);
|
||||
// slider属性
|
||||
export const useSlider = (min = 6, max = 12) => {
|
||||
|
@@ -53,7 +53,7 @@
|
||||
color: var(--comment);
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
opacity: 60%;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.CodeMirror-guttermarker {
|
||||
@@ -90,7 +90,7 @@
|
||||
display: inline-block;
|
||||
font-size: 0.8em;
|
||||
content: '>';
|
||||
opacity: 80%;
|
||||
opacity: 0.8;
|
||||
transform: rotate(90deg);
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
@@ -1,40 +1,14 @@
|
||||
<template>
|
||||
<div :class="prefixCls">
|
||||
<CollapseHeader v-bind="$props" :prefixCls="prefixCls" :show="show" @expand="handleExpand">
|
||||
<template #title>
|
||||
<slot name="title"></slot>
|
||||
</template>
|
||||
<template #action>
|
||||
<slot name="action"></slot>
|
||||
</template>
|
||||
</CollapseHeader>
|
||||
|
||||
<div class="p-2">
|
||||
<CollapseTransition :enable="canExpan">
|
||||
<Skeleton v-if="loading" :active="loading" />
|
||||
<div :class="`${prefixCls}__body`" v-else v-show="show">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</CollapseTransition>
|
||||
</div>
|
||||
<div :class="`${prefixCls}__footer`" v-if="$slots.footer">
|
||||
<slot name="footer"></slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type { PropType } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
// component
|
||||
<script lang="tsx">
|
||||
import { ref, unref, defineComponent, type PropType, type ExtractPropTypes } from 'vue';
|
||||
import { isNil } from 'lodash-es';
|
||||
import { Skeleton } from 'ant-design-vue';
|
||||
import { CollapseTransition } from '/@/components/Transition';
|
||||
import CollapseHeader from './CollapseHeader.vue';
|
||||
import { triggerWindowResize } from '/@/utils/event';
|
||||
// hook
|
||||
import { useTimeoutFn } from '/@/hooks/core/useTimeout';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
|
||||
const props = defineProps({
|
||||
const collapseContainerProps = {
|
||||
title: { type: String, default: '' },
|
||||
loading: { type: Boolean },
|
||||
/**
|
||||
@@ -57,23 +31,60 @@
|
||||
* Delayed loading time
|
||||
*/
|
||||
lazyTime: { type: Number, default: 0 },
|
||||
};
|
||||
|
||||
export type CollapseContainerProps = ExtractPropTypes<typeof collapseContainerProps>;
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CollapseContainer',
|
||||
|
||||
props: collapseContainerProps,
|
||||
|
||||
setup(props, { expose, slots }) {
|
||||
const { prefixCls } = useDesign('collapse-container');
|
||||
|
||||
const show = ref(true);
|
||||
|
||||
const handleExpand = (val: boolean) => {
|
||||
show.value = isNil(val) ? !show.value : val;
|
||||
if (props.triggerWindowResize) {
|
||||
// 200 milliseconds here is because the expansion has animation,
|
||||
useTimeoutFn(triggerWindowResize, 200);
|
||||
}
|
||||
};
|
||||
|
||||
expose({ handleExpand });
|
||||
|
||||
return () => (
|
||||
<div class={unref(prefixCls)}>
|
||||
<CollapseHeader
|
||||
{...props}
|
||||
prefixCls={unref(prefixCls)}
|
||||
onExpand={handleExpand}
|
||||
show={show.value}
|
||||
v-slots={{
|
||||
title: slots.title,
|
||||
action: slots.action,
|
||||
}}
|
||||
/>
|
||||
|
||||
<div class="p-2">
|
||||
<CollapseTransition enable={props.canExpan}>
|
||||
{props.loading ? (
|
||||
<Skeleton active={props.loading} />
|
||||
) : (
|
||||
<div class={`${prefixCls}__body`} v-show={show.value}>{slots.default?.()}</div>
|
||||
)}
|
||||
</CollapseTransition>
|
||||
</div>
|
||||
|
||||
{slots.footer && <div class={`${prefixCls}__footer`}>{slots.footer()}</div>}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
const show = ref(true);
|
||||
|
||||
const { prefixCls } = useDesign('collapse-container');
|
||||
|
||||
/**
|
||||
* @description: Handling development events
|
||||
*/
|
||||
function handleExpand() {
|
||||
show.value = !show.value;
|
||||
if (props.triggerWindowResize) {
|
||||
// 200 milliseconds here is because the expansion has animation,
|
||||
useTimeoutFn(triggerWindowResize, 200);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@prefix-cls: ~'@{namespace}-collapse-container';
|
||||
|
||||
|
@@ -1,38 +1,44 @@
|
||||
<template>
|
||||
<div :class="[`${prefixCls}__header px-2 py-5`, $attrs.class]">
|
||||
<BasicTitle :helpMessage="helpMessage" normal>
|
||||
<template v-if="title">
|
||||
{{ title }}
|
||||
</template>
|
||||
<template v-else>
|
||||
<slot name="title"></slot>
|
||||
</template>
|
||||
</BasicTitle>
|
||||
<div :class="`${prefixCls}__action`">
|
||||
<slot name="action"></slot>
|
||||
<BasicArrow v-if="canExpan" up :expand="show" @click="$emit('expand')" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
<script lang="tsx">
|
||||
import { defineComponent, computed, unref, type ExtractPropTypes } from 'vue';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { BasicArrow, BasicTitle } from '/@/components/Basic';
|
||||
|
||||
const props = {
|
||||
prefixCls: { type: String },
|
||||
const collapseHeaderProps = {
|
||||
prefixCls: String,
|
||||
title: String,
|
||||
show: Boolean,
|
||||
canExpan: Boolean,
|
||||
helpMessage: {
|
||||
type: [Array, String] as PropType<string[] | string>,
|
||||
default: '',
|
||||
},
|
||||
title: { type: String },
|
||||
show: { type: Boolean },
|
||||
canExpan: { type: Boolean },
|
||||
};
|
||||
|
||||
export type CollapseHeaderProps = ExtractPropTypes<typeof collapseHeaderProps>;
|
||||
|
||||
export default defineComponent({
|
||||
components: { BasicArrow, BasicTitle },
|
||||
name: 'CollapseHeader',
|
||||
inheritAttrs: false,
|
||||
props,
|
||||
props: collapseHeaderProps,
|
||||
emits: ['expand'],
|
||||
setup(props, { slots, attrs, emit }) {
|
||||
const { prefixCls } = useDesign('collapse-container');
|
||||
const _prefixCls = computed(() => props.prefixCls || unref(prefixCls));
|
||||
return () => (
|
||||
<div class={[`${unref(_prefixCls)}__header px-2 py-5`, attrs.class]}>
|
||||
<BasicTitle helpMessage={props.helpMessage} normal>
|
||||
{slots.title?.() || props.title}
|
||||
</BasicTitle>
|
||||
|
||||
<div class={`${unref(_prefixCls)}__action`}>
|
||||
{slots.action
|
||||
? slots.action({ expand: props.show, onClick: () => emit('expand') })
|
||||
: props.canExpan && (
|
||||
<BasicArrow up expand={props.show} onClick={() => emit('expand')} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<script lang="tsx">
|
||||
import type { ContextMenuItem, ItemContentProps, Axis } from './typing';
|
||||
import type { FunctionalComponent, CSSProperties } from 'vue';
|
||||
import type { FunctionalComponent, CSSProperties, PropType } from 'vue';
|
||||
import { defineComponent, nextTick, onMounted, computed, ref, unref, onUnmounted } from 'vue';
|
||||
import Icon from '/@/components/Icon';
|
||||
import { Menu, Divider } from 'ant-design-vue';
|
||||
@@ -60,9 +60,11 @@
|
||||
const top = body.clientHeight < y + menuHeight ? y - menuHeight : y;
|
||||
return {
|
||||
...styles,
|
||||
position: 'absolute',
|
||||
width: `${width}px`,
|
||||
left: `${left + 1}px`,
|
||||
top: `${top + 1}px`,
|
||||
zIndex: 9999,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -87,7 +89,8 @@
|
||||
}
|
||||
|
||||
function renderMenuItem(items: ContextMenuItem[]) {
|
||||
return items.map((item) => {
|
||||
const visibleItems = items.filter((item) => !item.hidden);
|
||||
return visibleItems.map((item) => {
|
||||
const { disabled, label, children, divider = false } = item;
|
||||
|
||||
const contentProps = {
|
||||
@@ -124,15 +127,11 @@
|
||||
}
|
||||
const { items } = props;
|
||||
return (
|
||||
<Menu
|
||||
inlineIndent={12}
|
||||
mode="vertical"
|
||||
class={prefixCls}
|
||||
ref={wrapRef}
|
||||
style={unref(getStyle)}
|
||||
>
|
||||
{renderMenuItem(items)}
|
||||
</Menu>
|
||||
<div class={prefixCls}>
|
||||
<Menu inlineIndent={12} mode="vertical" ref={wrapRef} style={unref(getStyle)}>
|
||||
{renderMenuItem(items)}
|
||||
</Menu>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
},
|
||||
@@ -185,6 +184,9 @@
|
||||
background-clip: padding-box;
|
||||
user-select: none;
|
||||
|
||||
&__item {
|
||||
margin: 0 !important;
|
||||
}
|
||||
.item-style();
|
||||
|
||||
.ant-divider {
|
||||
|
@@ -6,6 +6,7 @@ export interface Axis {
|
||||
export interface ContextMenuItem {
|
||||
label: string;
|
||||
icon?: string;
|
||||
hidden?: boolean;
|
||||
disabled?: boolean;
|
||||
handler?: Fn;
|
||||
divider?: boolean;
|
||||
|
@@ -129,6 +129,7 @@
|
||||
uploadApi: {
|
||||
type: Function as PropType<(params: apiFunParams) => Promise<any>>,
|
||||
},
|
||||
src: { type: String },
|
||||
};
|
||||
|
||||
export default defineComponent({
|
||||
@@ -138,7 +139,7 @@
|
||||
emits: ['uploadSuccess', 'register'],
|
||||
setup(props, { emit }) {
|
||||
let filename = '';
|
||||
const src = ref('');
|
||||
const src = ref(props.src || '');
|
||||
const previewSource = ref('');
|
||||
const cropper = ref<Cropper>();
|
||||
let scaleX = 1;
|
||||
@@ -186,7 +187,7 @@
|
||||
try {
|
||||
setModalProps({ confirmLoading: true });
|
||||
const result = await uploadApi({ name: 'file', file: blob, filename });
|
||||
emit('uploadSuccess', { source: previewSource.value, data: result.data });
|
||||
emit('uploadSuccess', { source: previewSource.value, data: result.url });
|
||||
closeModal();
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
<CopperModal
|
||||
@register="register"
|
||||
@uploadSuccess="handleUploadSuccess"
|
||||
@upload-success="handleUploadSuccess"
|
||||
:uploadApi="uploadApi"
|
||||
:src="sourceValue"
|
||||
/>
|
||||
@@ -91,9 +91,9 @@
|
||||
},
|
||||
);
|
||||
|
||||
function handleUploadSuccess({ source }) {
|
||||
function handleUploadSuccess({ source, data }) {
|
||||
sourceValue.value = source;
|
||||
emit('change', source);
|
||||
emit('change', { source, data });
|
||||
createMessage.success(t('component.cropper.uploadSuccess'));
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
import type { DescriptionsProps } from 'ant-design-vue/es/descriptions/index';
|
||||
import type { CSSProperties } from 'vue';
|
||||
import type { CollapseContainerOptions } from '/@/components/Container/index';
|
||||
import { defineComponent, computed, ref, unref } from 'vue';
|
||||
import { defineComponent, computed, ref, unref, toRefs } from 'vue';
|
||||
import { get } from 'lodash-es';
|
||||
import { Descriptions } from 'ant-design-vue';
|
||||
import { CollapseContainer } from '/@/components/Container/index';
|
||||
@@ -121,6 +121,9 @@
|
||||
return null;
|
||||
}
|
||||
const getField = get(_data, field);
|
||||
if (getField && !toRefs(_data).hasOwnProperty(field)) {
|
||||
return isFunction(render) ? render('', _data) : '';
|
||||
}
|
||||
return isFunction(render) ? render(getField, _data) : getField ?? '';
|
||||
};
|
||||
|
||||
|
@@ -94,7 +94,7 @@
|
||||
opt.width = '100%';
|
||||
}
|
||||
const detailCls = `${prefixCls}__detail`;
|
||||
opt.wrapClassName = wrapClassName ? `${wrapClassName} ${detailCls}` : detailCls;
|
||||
opt.class = wrapClassName ? `${wrapClassName} ${detailCls}` : detailCls;
|
||||
|
||||
if (!getContainer) {
|
||||
// TODO type error?
|
||||
|
@@ -47,7 +47,7 @@
|
||||
const heightStr = `${props.height}`;
|
||||
return {
|
||||
height: heightStr,
|
||||
lineHeight: heightStr,
|
||||
lineHeight: `calc(${heightStr} - 1px)`,
|
||||
};
|
||||
});
|
||||
|
||||
|
@@ -128,13 +128,12 @@ export interface DrawerProps extends DrawerFooterProps {
|
||||
* @type any (string | slot)
|
||||
*/
|
||||
title?: VNodeChild | JSX.Element;
|
||||
|
||||
/**
|
||||
* The class name of the container of the Drawer dialog.
|
||||
* @type string
|
||||
*/
|
||||
wrapClassName?: string;
|
||||
|
||||
class?: string;
|
||||
/**
|
||||
* Style of wrapper element which **contains mask** compare to `drawerStyle`
|
||||
* @type object
|
||||
|
@@ -57,7 +57,7 @@
|
||||
* @type string[]
|
||||
*/
|
||||
trigger: {
|
||||
type: [Array] as PropType<('contextmenu' | 'click' | 'hover')[]>,
|
||||
type: Array as PropType<('contextmenu' | 'click' | 'hover')[]>,
|
||||
default: () => {
|
||||
return ['contextmenu'];
|
||||
},
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import xlsx from 'xlsx';
|
||||
import * as xlsx from 'xlsx';
|
||||
import type { WorkBook } from 'xlsx';
|
||||
import type { JsonToSheet, AoAToSheet } from './typing';
|
||||
|
||||
@@ -6,6 +6,28 @@ const { utils, writeFile } = xlsx;
|
||||
|
||||
const DEF_FILE_NAME = 'excel-list.xlsx';
|
||||
|
||||
/**
|
||||
* @param data source data
|
||||
* @param worksheet worksheet object
|
||||
* @param min min width
|
||||
*/
|
||||
function setColumnWidth(data, worksheet, min = 3) {
|
||||
const obj = {};
|
||||
worksheet['!cols'] = [];
|
||||
data.forEach((item) => {
|
||||
Object.keys(item).forEach((key) => {
|
||||
const cur = item[key];
|
||||
const length = cur?.length ?? min;
|
||||
obj[key] = Math.max(length, obj[key] ?? min);
|
||||
});
|
||||
});
|
||||
Object.keys(obj).forEach((key) => {
|
||||
worksheet['!cols'].push({
|
||||
wch: obj[key],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function jsonToSheetXlsx<T = any>({
|
||||
data,
|
||||
header,
|
||||
@@ -20,7 +42,7 @@ export function jsonToSheetXlsx<T = any>({
|
||||
}
|
||||
|
||||
const worksheet = utils.json_to_sheet(arrData, json2sheetOpts);
|
||||
|
||||
setColumnWidth(arrData, worksheet);
|
||||
/* add worksheet to workbook */
|
||||
const workbook: WorkBook = {
|
||||
SheetNames: [filename],
|
||||
|
@@ -14,7 +14,7 @@
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, unref } from 'vue';
|
||||
import XLSX from 'xlsx';
|
||||
import * as XLSX from 'xlsx';
|
||||
import { dateUtil } from '/@/utils/dateUtil';
|
||||
|
||||
import type { ExcelData } from './typing';
|
||||
@@ -31,11 +31,51 @@
|
||||
type: Number,
|
||||
default: 8,
|
||||
},
|
||||
// 是否直接返回选中文件
|
||||
isReturnFile: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
emits: ['success', 'error'],
|
||||
emits: ['success', 'error', 'cancel'],
|
||||
setup(props, { emit }) {
|
||||
const inputRef = ref<HTMLInputElement | null>(null);
|
||||
const loadingRef = ref<Boolean>(false);
|
||||
const cancelRef = ref<Boolean>(true);
|
||||
|
||||
function shapeWorkSheel(sheet: XLSX.WorkSheet, range: XLSX.Range) {
|
||||
let str = ' ',
|
||||
char = 65,
|
||||
customWorkSheet = {
|
||||
t: 's',
|
||||
v: str,
|
||||
r: '<t> </t><phoneticPr fontId="1" type="noConversion"/>',
|
||||
h: str,
|
||||
w: str,
|
||||
};
|
||||
if (!sheet || !sheet['!ref']) return [];
|
||||
let c = 0,
|
||||
r = 1;
|
||||
while (c < range.e.c + 1) {
|
||||
while (r < range.e.r + 1) {
|
||||
if (!sheet[String.fromCharCode(char) + r]) {
|
||||
sheet[String.fromCharCode(char) + r] = customWorkSheet;
|
||||
}
|
||||
r++;
|
||||
}
|
||||
r = 1;
|
||||
str += ' ';
|
||||
customWorkSheet = {
|
||||
t: 's',
|
||||
v: str,
|
||||
r: '<t> </t><phoneticPr fontId="1" type="noConversion"/>',
|
||||
h: str,
|
||||
w: str,
|
||||
};
|
||||
c++;
|
||||
char++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 第一行作为头部
|
||||
@@ -44,8 +84,8 @@
|
||||
if (!sheet || !sheet['!ref']) return [];
|
||||
const headers: string[] = [];
|
||||
// A3:B7=>{s:{c:0, r:2}, e:{c:1, r:6}}
|
||||
const range = XLSX.utils.decode_range(sheet['!ref']);
|
||||
|
||||
const range: XLSX.Range = XLSX.utils.decode_range(sheet['!ref']);
|
||||
shapeWorkSheel(sheet, range);
|
||||
const R = range.s.r;
|
||||
/* start in the first row */
|
||||
for (let C = range.s.c; C <= range.e.c; ++C) {
|
||||
@@ -137,18 +177,45 @@
|
||||
* @description: 触发选择文件管理器
|
||||
*/
|
||||
function handleInputClick(e: Event) {
|
||||
const files = e && (e.target as HTMLInputElement).files;
|
||||
const target = e && (e.target as HTMLInputElement);
|
||||
const files = target?.files;
|
||||
const rawFile = files && files[0]; // only setting files[0]
|
||||
|
||||
target.value = '';
|
||||
|
||||
if (!rawFile) return;
|
||||
|
||||
cancelRef.value = false;
|
||||
if (props.isReturnFile) {
|
||||
emit('success', rawFile);
|
||||
return;
|
||||
}
|
||||
upload(rawFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 文件选择器关闭后,判断取消状态
|
||||
*/
|
||||
function handleFocusChange() {
|
||||
const timeId = setInterval(() => {
|
||||
if (cancelRef.value === true) {
|
||||
emit('cancel');
|
||||
}
|
||||
clearInterval(timeId);
|
||||
window.removeEventListener('focus', handleFocusChange);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 点击上传按钮
|
||||
*/
|
||||
function handleUpload() {
|
||||
const inputRefDom = unref(inputRef);
|
||||
inputRefDom && inputRefDom.click();
|
||||
if (inputRefDom) {
|
||||
cancelRef.value = true;
|
||||
inputRefDom.click();
|
||||
window.addEventListener('focus', handleFocusChange);
|
||||
}
|
||||
}
|
||||
|
||||
return { handleUpload, handleInputClick, inputRef };
|
||||
|
@@ -9,7 +9,9 @@ export { useForm } from './src/hooks/useForm';
|
||||
export { default as ApiSelect } from './src/components/ApiSelect.vue';
|
||||
export { default as RadioButtonGroup } from './src/components/RadioButtonGroup.vue';
|
||||
export { default as ApiTreeSelect } from './src/components/ApiTreeSelect.vue';
|
||||
export { default as ApiTree } from './src/components/ApiTree.vue';
|
||||
export { default as ApiRadioGroup } from './src/components/ApiRadioGroup.vue';
|
||||
export { default as ApiCascader } from './src/components/ApiCascader.vue';
|
||||
export { default as ApiTransfer } from './src/components/ApiTransfer.vue';
|
||||
|
||||
export { BasicForm };
|
||||
|
@@ -10,6 +10,7 @@
|
||||
<slot name="formHeader"></slot>
|
||||
<template v-for="schema in getSchema" :key="schema.field">
|
||||
<FormItem
|
||||
:isAdvanced="fieldsIsAdvancedMap[schema.field]"
|
||||
:tableAction="tableAction"
|
||||
:formActionType="formActionType"
|
||||
:schema="schema"
|
||||
@@ -58,15 +59,17 @@
|
||||
import { createFormContext } from './hooks/useFormContext';
|
||||
import { useAutoFocus } from './hooks/useAutoFocus';
|
||||
import { useModalContext } from '/@/components/Modal';
|
||||
import { useDebounceFn } from '@vueuse/core';
|
||||
|
||||
import { basicProps } from './props';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'BasicForm',
|
||||
components: { FormItem, Form, Row, FormAction },
|
||||
props: basicProps,
|
||||
emits: ['advanced-change', 'reset', 'submit', 'register'],
|
||||
emits: ['advanced-change', 'reset', 'submit', 'register', 'field-value-change'],
|
||||
setup(props, { emit, attrs }) {
|
||||
const formModel = reactive<Recordable>({});
|
||||
const modalFn = useModalContext();
|
||||
@@ -116,13 +119,13 @@
|
||||
const getSchema = computed((): FormSchema[] => {
|
||||
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any);
|
||||
for (const schema of schemas) {
|
||||
const { defaultValue, component } = schema;
|
||||
const { defaultValue, component, isHandleDateDefaultValue = true } = schema;
|
||||
// handle date type
|
||||
if (defaultValue && dateItemType.includes(component)) {
|
||||
if (isHandleDateDefaultValue && defaultValue && dateItemType.includes(component)) {
|
||||
if (!Array.isArray(defaultValue)) {
|
||||
schema.defaultValue = dateUtil(defaultValue);
|
||||
} else {
|
||||
const def: moment.Moment[] = [];
|
||||
const def: any[] = [];
|
||||
defaultValue.forEach((item) => {
|
||||
def.push(dateUtil(item));
|
||||
});
|
||||
@@ -131,13 +134,15 @@
|
||||
}
|
||||
}
|
||||
if (unref(getProps).showAdvancedButton) {
|
||||
return schemas.filter((schema) => schema.component !== 'Divider') as FormSchema[];
|
||||
return cloneDeep(
|
||||
schemas.filter((schema) => schema.component !== 'Divider') as FormSchema[],
|
||||
);
|
||||
} else {
|
||||
return schemas as FormSchema[];
|
||||
return cloneDeep(schemas as FormSchema[]);
|
||||
}
|
||||
});
|
||||
|
||||
const { handleToggleAdvanced } = useAdvanced({
|
||||
const { handleToggleAdvanced, fieldsIsAdvancedMap } = useAdvanced({
|
||||
advanceState,
|
||||
emit,
|
||||
getProps,
|
||||
@@ -170,7 +175,7 @@
|
||||
updateSchema,
|
||||
resetSchema,
|
||||
appendSchemaByField,
|
||||
removeSchemaByFiled,
|
||||
removeSchemaByField,
|
||||
resetFields,
|
||||
scrollToField,
|
||||
} = useFormEvents({
|
||||
@@ -225,14 +230,23 @@
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => formModel,
|
||||
useDebounceFn(() => {
|
||||
unref(getProps).submitOnChange && handleSubmit();
|
||||
}, 300),
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
async function setProps(formProps: Partial<FormProps>): Promise<void> {
|
||||
propsRef.value = deepMerge(unref(propsRef) || {}, formProps);
|
||||
}
|
||||
|
||||
function setFormModel(key: string, value: any) {
|
||||
function setFormModel(key: string, value: any, schema: FormSchema) {
|
||||
formModel[key] = value;
|
||||
const { validateTrigger } = unref(getBindValue);
|
||||
if (!validateTrigger || validateTrigger === 'change') {
|
||||
emit('field-value-change', key, value);
|
||||
// TODO 优化验证,这里如果是autoLink=false手动关联的情况下才会再次触发此函数
|
||||
if (schema && schema.itemProps && !schema.itemProps.autoLink) {
|
||||
validateFields([key]).catch((_) => {});
|
||||
}
|
||||
}
|
||||
@@ -255,7 +269,7 @@
|
||||
updateSchema,
|
||||
resetSchema,
|
||||
setProps,
|
||||
removeSchemaByFiled,
|
||||
removeSchemaByField,
|
||||
appendSchemaByField,
|
||||
clearValidate,
|
||||
validateFields,
|
||||
@@ -286,6 +300,7 @@
|
||||
getFormActionBindProps: computed(
|
||||
(): Recordable => ({ ...getProps.value, ...advanceState }),
|
||||
),
|
||||
fieldsIsAdvancedMap,
|
||||
...formActionType,
|
||||
};
|
||||
},
|
||||
|
@@ -24,8 +24,10 @@ import {
|
||||
import ApiRadioGroup from './components/ApiRadioGroup.vue';
|
||||
import RadioButtonGroup from './components/RadioButtonGroup.vue';
|
||||
import ApiSelect from './components/ApiSelect.vue';
|
||||
import ApiTree from './components/ApiTree.vue';
|
||||
import ApiTreeSelect from './components/ApiTreeSelect.vue';
|
||||
import ApiCascader from './components/ApiCascader.vue';
|
||||
import ApiTransfer from './components/ApiTransfer.vue';
|
||||
import { BasicUpload } from '/@/components/Upload';
|
||||
import { StrengthMeter } from '/@/components/StrengthMeter';
|
||||
import { IconPicker } from '/@/components/Icon';
|
||||
@@ -43,6 +45,7 @@ componentMap.set('AutoComplete', AutoComplete);
|
||||
|
||||
componentMap.set('Select', Select);
|
||||
componentMap.set('ApiSelect', ApiSelect);
|
||||
componentMap.set('ApiTree', ApiTree);
|
||||
componentMap.set('TreeSelect', TreeSelect);
|
||||
componentMap.set('ApiTreeSelect', ApiTreeSelect);
|
||||
componentMap.set('ApiRadioGroup', ApiRadioGroup);
|
||||
@@ -55,6 +58,7 @@ componentMap.set('ApiCascader', ApiCascader);
|
||||
componentMap.set('Cascader', Cascader);
|
||||
componentMap.set('Slider', Slider);
|
||||
componentMap.set('Rate', Rate);
|
||||
componentMap.set('ApiTransfer', ApiTransfer);
|
||||
|
||||
componentMap.set('DatePicker', DatePicker);
|
||||
componentMap.set('MonthPicker', DatePicker.MonthPicker);
|
||||
|
@@ -26,7 +26,7 @@
|
||||
import { get, omit } from 'lodash-es';
|
||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue';
|
||||
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
interface Option {
|
||||
value: string;
|
||||
label: string;
|
||||
@@ -76,7 +76,7 @@
|
||||
const loading = ref<boolean>(false);
|
||||
const emitData = ref<any[]>([]);
|
||||
const isFirstLoad = ref(true);
|
||||
|
||||
const { t } = useI18n();
|
||||
// Embedded in the form, just use the hook binding to perform form verification
|
||||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||
|
||||
@@ -170,7 +170,7 @@
|
||||
);
|
||||
|
||||
function handleChange(keys, args) {
|
||||
emitData.value = keys;
|
||||
emitData.value = args;
|
||||
emit('defaultChange', keys, args);
|
||||
}
|
||||
|
||||
@@ -188,6 +188,7 @@
|
||||
state,
|
||||
options,
|
||||
loading,
|
||||
t,
|
||||
handleChange,
|
||||
loadData,
|
||||
handleRenderDisplay,
|
||||
|
@@ -2,12 +2,17 @@
|
||||
* @Description:It is troublesome to implement radio button group in the form. So it is extracted independently as a separate component
|
||||
-->
|
||||
<template>
|
||||
<RadioGroup v-bind="attrs" v-model:value="state" button-style="solid" @change="handleChange">
|
||||
<RadioGroup v-bind="attrs" v-model:value="state" button-style="solid">
|
||||
<template v-for="item in getOptions" :key="`${item.value}`">
|
||||
<RadioButton v-if="props.isBtn" :value="item.value" :disabled="item.disabled">
|
||||
<RadioButton
|
||||
v-if="props.isBtn"
|
||||
:value="item.value"
|
||||
:disabled="item.disabled"
|
||||
@click="handleClick(item)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</RadioButton>
|
||||
<Radio v-else :value="item.value" :disabled="item.disabled">
|
||||
<Radio v-else :value="item.value" :disabled="item.disabled" @click="handleClick(item)">
|
||||
{{ item.label }}
|
||||
</Radio>
|
||||
</template>
|
||||
@@ -62,7 +67,7 @@
|
||||
const attrs = useAttrs();
|
||||
const { t } = useI18n();
|
||||
// Embedded in the form, just use the hook binding to perform form verification
|
||||
const [state] = useRuleFormItem(props);
|
||||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||
|
||||
// Processing options value
|
||||
const getOptions = computed(() => {
|
||||
@@ -120,11 +125,11 @@
|
||||
emit('options-change', unref(getOptions));
|
||||
}
|
||||
|
||||
function handleChange(_, ...args) {
|
||||
function handleClick(...args) {
|
||||
emitData.value = args;
|
||||
}
|
||||
|
||||
return { state, getOptions, attrs, loading, t, handleChange, props };
|
||||
return { state, getOptions, attrs, loading, t, handleClick, props };
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<Select
|
||||
@dropdownVisibleChange="handleFetch"
|
||||
@dropdown-visible-change="handleFetch"
|
||||
v-bind="$attrs"
|
||||
@change="handleChange"
|
||||
:options="getOptions"
|
||||
@@ -48,17 +48,15 @@
|
||||
default: null,
|
||||
},
|
||||
// api params
|
||||
params: {
|
||||
type: Object as PropType<Recordable>,
|
||||
default: () => ({}),
|
||||
},
|
||||
params: propTypes.any.def({}),
|
||||
// support xxx.xxx.xx
|
||||
resultField: propTypes.string.def(''),
|
||||
labelField: propTypes.string.def('label'),
|
||||
valueField: propTypes.string.def('value'),
|
||||
immediate: propTypes.bool.def(true),
|
||||
alwaysLoad: propTypes.bool.def(false),
|
||||
},
|
||||
emits: ['options-change', 'change'],
|
||||
emits: ['options-change', 'change', 'update:value'],
|
||||
setup(props, { emit }) {
|
||||
const options = ref<OptionsItem[]>([]);
|
||||
const loading = ref(false);
|
||||
@@ -75,10 +73,10 @@
|
||||
|
||||
return unref(options).reduce((prev, next: Recordable) => {
|
||||
if (next) {
|
||||
const value = next[valueField];
|
||||
const value = get(next, valueField);
|
||||
prev.push({
|
||||
...omit(next, [labelField, valueField]),
|
||||
label: next[labelField],
|
||||
label: get(next, labelField),
|
||||
value: numberToString ? `${value}` : value,
|
||||
});
|
||||
}
|
||||
@@ -87,9 +85,16 @@
|
||||
});
|
||||
|
||||
watchEffect(() => {
|
||||
props.immediate && fetch();
|
||||
props.immediate && !props.alwaysLoad && fetch();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => state.value,
|
||||
(v) => {
|
||||
emit('update:value', v);
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.params,
|
||||
() => {
|
||||
@@ -121,10 +126,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleFetch() {
|
||||
if (!props.immediate && unref(isFirstLoad)) {
|
||||
await fetch();
|
||||
isFirstLoad.value = false;
|
||||
async function handleFetch(visible) {
|
||||
if (visible) {
|
||||
if (props.alwaysLoad) {
|
||||
await fetch();
|
||||
} else if (!props.immediate && unref(isFirstLoad)) {
|
||||
await fetch();
|
||||
isFirstLoad.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
137
src/components/Form/src/components/ApiTransfer.vue
Normal file
137
src/components/Form/src/components/ApiTransfer.vue
Normal file
@@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<Transfer
|
||||
:data-source="getdataSource"
|
||||
:filter-option="filterOption"
|
||||
:render="(item) => item.title"
|
||||
:showSelectAll="showSelectAll"
|
||||
:selectedKeys="selectedKeys"
|
||||
:targetKeys="getTargetKeys"
|
||||
:showSearch="showSearch"
|
||||
@change="handleChange"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, watch, ref, unref, watchEffect } from 'vue';
|
||||
import { Transfer } from 'ant-design-vue';
|
||||
import { isFunction } from '/@/utils/is';
|
||||
import { get, omit } from 'lodash-es';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { TransferDirection, TransferItem } from 'ant-design-vue/lib/transfer';
|
||||
export default defineComponent({
|
||||
name: 'ApiTransfer',
|
||||
components: { Transfer },
|
||||
props: {
|
||||
value: { type: Array as PropType<Array<string>> },
|
||||
api: {
|
||||
type: Function as PropType<(arg?: Recordable) => Promise<TransferItem[]>>,
|
||||
default: null,
|
||||
},
|
||||
params: { type: Object },
|
||||
dataSource: { type: Array as PropType<Array<TransferItem>> },
|
||||
immediate: propTypes.bool.def(true),
|
||||
alwaysLoad: propTypes.bool.def(false),
|
||||
afterFetch: { type: Function as PropType<Fn> },
|
||||
resultField: propTypes.string.def(''),
|
||||
labelField: propTypes.string.def('title'),
|
||||
valueField: propTypes.string.def('key'),
|
||||
showSearch: { type: Boolean, default: false },
|
||||
disabled: { type: Boolean, default: false },
|
||||
filterOption: {
|
||||
type: Function as PropType<(inputValue: string, item: TransferItem) => boolean>,
|
||||
},
|
||||
selectedKeys: { type: Array as PropType<Array<string>> },
|
||||
showSelectAll: { type: Boolean, default: false },
|
||||
targetKeys: { type: Array as PropType<Array<string>> },
|
||||
},
|
||||
emits: ['options-change', 'change'],
|
||||
setup(props, { attrs, emit }) {
|
||||
const _dataSource = ref<TransferItem[]>([]);
|
||||
const _targetKeys = ref<string[]>([]);
|
||||
const { t } = useI18n();
|
||||
|
||||
const getAttrs = computed(() => {
|
||||
return {
|
||||
...(!props.api ? { dataSource: unref(_dataSource) } : {}),
|
||||
...attrs,
|
||||
};
|
||||
});
|
||||
const getdataSource = computed(() => {
|
||||
const { labelField, valueField } = props;
|
||||
|
||||
return unref(_dataSource).reduce((prev, next: Recordable) => {
|
||||
if (next) {
|
||||
prev.push({
|
||||
...omit(next, [labelField, valueField]),
|
||||
title: next[labelField],
|
||||
key: next[valueField],
|
||||
});
|
||||
}
|
||||
return prev;
|
||||
}, [] as TransferItem[]);
|
||||
});
|
||||
const getTargetKeys = computed<string[]>(() => {
|
||||
if (unref(_targetKeys).length > 0) {
|
||||
return unref(_targetKeys);
|
||||
}
|
||||
if (Array.isArray(props.value)) {
|
||||
return props.value;
|
||||
}
|
||||
if (Array.isArray(props.targetKeys)){
|
||||
return props.targetKeys;
|
||||
}
|
||||
return [];
|
||||
});
|
||||
|
||||
function handleChange(keys: string[], direction: TransferDirection, moveKeys: string[]) {
|
||||
_targetKeys.value = keys;
|
||||
console.log(direction);
|
||||
console.log(moveKeys);
|
||||
emit('change', keys);
|
||||
}
|
||||
|
||||
watchEffect(() => {
|
||||
props.immediate && !props.alwaysLoad && fetch();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.params,
|
||||
() => {
|
||||
fetch();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
async function fetch() {
|
||||
const api = props.api;
|
||||
if (!api || !isFunction(api)) {
|
||||
if (Array.isArray(props.dataSource)) {
|
||||
_dataSource.value = props.dataSource;
|
||||
}
|
||||
return;
|
||||
}
|
||||
_dataSource.value = [];
|
||||
try {
|
||||
const res = await api(props.params);
|
||||
if (Array.isArray(res)) {
|
||||
_dataSource.value = res;
|
||||
emitChange();
|
||||
return;
|
||||
}
|
||||
if (props.resultField) {
|
||||
_dataSource.value = get(res, props.resultField) || [];
|
||||
}
|
||||
emitChange();
|
||||
} catch (error) {
|
||||
console.warn(error);
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
function emitChange() {
|
||||
emit('options-change', unref(getdataSource));
|
||||
}
|
||||
return { getTargetKeys, getdataSource, t, getAttrs, handleChange };
|
||||
},
|
||||
});
|
||||
</script>
|
90
src/components/Form/src/components/ApiTree.vue
Normal file
90
src/components/Form/src/components/ApiTree.vue
Normal file
@@ -0,0 +1,90 @@
|
||||
<template>
|
||||
<a-tree v-bind="getAttrs" @change="handleChange">
|
||||
<template #[item]="data" v-for="item in Object.keys($slots)">
|
||||
<slot :name="item" v-bind="data || {}"></slot>
|
||||
</template>
|
||||
<template #suffixIcon v-if="loading">
|
||||
<LoadingOutlined spin />
|
||||
</template>
|
||||
</a-tree>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, watch, ref, onMounted, unref } from 'vue';
|
||||
import { Tree } from 'ant-design-vue';
|
||||
import { isArray, isFunction } from '/@/utils/is';
|
||||
import { get } from 'lodash-es';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue';
|
||||
export default defineComponent({
|
||||
name: 'ApiTree',
|
||||
components: { ATree: Tree, LoadingOutlined },
|
||||
props: {
|
||||
api: { type: Function as PropType<(arg?: Recordable) => Promise<Recordable>> },
|
||||
params: { type: Object },
|
||||
immediate: { type: Boolean, default: true },
|
||||
resultField: propTypes.string.def(''),
|
||||
afterFetch: { type: Function as PropType<Fn> },
|
||||
},
|
||||
emits: ['options-change', 'change'],
|
||||
setup(props, { attrs, emit }) {
|
||||
const treeData = ref<Recordable[]>([]);
|
||||
const isFirstLoaded = ref<Boolean>(false);
|
||||
const loading = ref(false);
|
||||
const getAttrs = computed(() => {
|
||||
return {
|
||||
...(props.api ? { treeData: unref(treeData) } : {}),
|
||||
...attrs,
|
||||
};
|
||||
});
|
||||
|
||||
function handleChange(...args) {
|
||||
emit('change', ...args);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.params,
|
||||
() => {
|
||||
!unref(isFirstLoaded) && fetch();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.immediate,
|
||||
(v) => {
|
||||
v && !isFirstLoaded.value && fetch();
|
||||
},
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
props.immediate && fetch();
|
||||
});
|
||||
|
||||
async function fetch() {
|
||||
const { api, afterFetch } = props;
|
||||
if (!api || !isFunction(api)) return;
|
||||
loading.value = true;
|
||||
treeData.value = [];
|
||||
let result;
|
||||
try {
|
||||
result = await api(props.params);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (afterFetch && isFunction(afterFetch)) {
|
||||
result = afterFetch(result);
|
||||
}
|
||||
loading.value = false;
|
||||
if (!result) return;
|
||||
if (!isArray(result)) {
|
||||
result = get(result, props.resultField);
|
||||
}
|
||||
treeData.value = (result as Recordable[]) || [];
|
||||
isFirstLoaded.value = true;
|
||||
emit('options-change', treeData.value);
|
||||
}
|
||||
return { getAttrs, loading, handleChange };
|
||||
},
|
||||
});
|
||||
</script>
|
@@ -1,17 +1,20 @@
|
||||
<script lang="tsx">
|
||||
import type { PropType, Ref } from 'vue';
|
||||
import type { FormActionType, FormProps } from '../types/form';
|
||||
import type { FormSchema } from '../types/form';
|
||||
import { computed, defineComponent, toRefs, unref } from 'vue';
|
||||
import type { FormActionType, FormProps, FormSchema } from '../types/form';
|
||||
import type { ValidationRule } from 'ant-design-vue/lib/form/Form';
|
||||
import type { TableActionType } from '/@/components/Table';
|
||||
import { defineComponent, computed, unref, toRefs } from 'vue';
|
||||
import { Form, Col, Divider } from 'ant-design-vue';
|
||||
import { Col, Divider, Form } from 'ant-design-vue';
|
||||
import { componentMap } from '../componentMap';
|
||||
import { BasicHelp } from '/@/components/Basic';
|
||||
import { isBoolean, isFunction, isNull } from '/@/utils/is';
|
||||
import { getSlot } from '/@/utils/helper/tsxHelper';
|
||||
import { createPlaceholderMessage, setComponentRuleType } from '../helper';
|
||||
import { upperFirst, cloneDeep } from 'lodash-es';
|
||||
import {
|
||||
createPlaceholderMessage,
|
||||
NO_AUTO_LINK_COMPONENTS,
|
||||
setComponentRuleType,
|
||||
} from '../helper';
|
||||
import { cloneDeep, upperFirst } from 'lodash-es';
|
||||
import { useItemLabelWidth } from '../hooks/useLabelWidth';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
|
||||
@@ -36,7 +39,7 @@
|
||||
default: () => ({}),
|
||||
},
|
||||
setFormModel: {
|
||||
type: Function as PropType<(key: string, value: any) => void>,
|
||||
type: Function as PropType<(key: string, value: any, schema: FormSchema) => void>,
|
||||
default: null,
|
||||
},
|
||||
tableAction: {
|
||||
@@ -45,6 +48,9 @@
|
||||
formActionType: {
|
||||
type: Object as PropType<FormActionType>,
|
||||
},
|
||||
isAdvanced: {
|
||||
type: Boolean,
|
||||
},
|
||||
},
|
||||
setup(props, { slots }) {
|
||||
const { t } = useI18n();
|
||||
@@ -78,10 +84,14 @@
|
||||
componentProps = componentProps({ schema, tableAction, formModel, formActionType }) ?? {};
|
||||
}
|
||||
if (schema.component === 'Divider') {
|
||||
componentProps = Object.assign({ type: 'horizontal' }, componentProps, {
|
||||
orientation: 'left',
|
||||
plain: true,
|
||||
});
|
||||
componentProps = Object.assign(
|
||||
{ type: 'horizontal' },
|
||||
{
|
||||
orientation: 'left',
|
||||
plain: true,
|
||||
},
|
||||
componentProps,
|
||||
);
|
||||
}
|
||||
return componentProps as Recordable;
|
||||
});
|
||||
@@ -104,8 +114,8 @@
|
||||
const { show, ifShow } = props.schema;
|
||||
const { showAdvancedButton } = props.formProps;
|
||||
const itemIsAdvanced = showAdvancedButton
|
||||
? isBoolean(props.schema.isAdvanced)
|
||||
? props.schema.isAdvanced
|
||||
? isBoolean(props.isAdvanced)
|
||||
? props.isAdvanced
|
||||
: true
|
||||
: true;
|
||||
|
||||
@@ -178,8 +188,21 @@
|
||||
|
||||
const getRequired = isFunction(required) ? required(unref(getValues)) : required;
|
||||
|
||||
if ((!rules || rules.length === 0) && getRequired) {
|
||||
rules = [{ required: getRequired, validator }];
|
||||
/*
|
||||
* 1、若设置了required属性,又没有其他的rules,就创建一个验证规则;
|
||||
* 2、若设置了required属性,又存在其他的rules,则只rules中不存在required属性时,才添加验证required的规则
|
||||
* 也就是说rules中的required,优先级大于required
|
||||
*/
|
||||
if (getRequired) {
|
||||
if (!rules || rules.length === 0) {
|
||||
rules = [{ required: getRequired, validator }];
|
||||
} else {
|
||||
const requiredIndex: number = rules.findIndex((rule) => Reflect.has(rule, 'required'));
|
||||
|
||||
if (requiredIndex === -1) {
|
||||
rules.push({ required: getRequired, validator });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const requiredRuleIndex: number = rules.findIndex(
|
||||
@@ -238,7 +261,7 @@
|
||||
}
|
||||
const target = e ? e.target : null;
|
||||
const value = target ? (isCheck ? target.checked : target.value) : e;
|
||||
props.setFormModel(field, value);
|
||||
props.setFormModel(field, value, props.schema);
|
||||
},
|
||||
};
|
||||
const Comp = componentMap.get(component) as ReturnType<typeof defineComponent>;
|
||||
@@ -328,6 +351,15 @@
|
||||
const showSuffix = !!suffix;
|
||||
const getSuffix = isFunction(suffix) ? suffix(unref(getValues)) : suffix;
|
||||
|
||||
// TODO 自定义组件验证会出现问题,因此这里框架默认将自定义组件设置手动触发验证,如果其他组件还有此问题请手动设置autoLink=false
|
||||
if (NO_AUTO_LINK_COMPONENTS.includes(component)) {
|
||||
props.schema &&
|
||||
(props.schema.itemProps! = {
|
||||
autoLink: false,
|
||||
...props.schema.itemProps,
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<Form.Item
|
||||
name={field}
|
||||
|
@@ -4,14 +4,14 @@
|
||||
<template>
|
||||
<RadioGroup v-bind="attrs" v-model:value="state" button-style="solid">
|
||||
<template v-for="item in getOptions" :key="`${item.value}`">
|
||||
<RadioButton :value="item.value" :disabled="item.disabled">
|
||||
<RadioButton :value="item.value" :disabled="item.disabled" @click="handleClick(item)">
|
||||
{{ item.label }}
|
||||
</RadioButton>
|
||||
</template>
|
||||
</RadioGroup>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
import { defineComponent, PropType, computed, ref } from 'vue';
|
||||
import { Radio } from 'ant-design-vue';
|
||||
import { isString } from '/@/utils/is';
|
||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||
@@ -35,10 +35,12 @@
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
emits: ['change'],
|
||||
setup(props) {
|
||||
const attrs = useAttrs();
|
||||
const emitData = ref<any[]>([]);
|
||||
// Embedded in the form, just use the hook binding to perform form verification
|
||||
const [state] = useRuleFormItem(props);
|
||||
const [state] = useRuleFormItem(props, 'value', 'change', emitData);
|
||||
|
||||
// Processing options value
|
||||
const getOptions = computed((): OptionsItem[] => {
|
||||
@@ -51,7 +53,11 @@
|
||||
return options.map((item) => ({ label: item, value: item })) as OptionsItem[];
|
||||
});
|
||||
|
||||
return { state, getOptions, attrs };
|
||||
function handleClick(...args) {
|
||||
emitData.value = args;
|
||||
}
|
||||
|
||||
return { state, getOptions, attrs, handleClick };
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
@@ -70,3 +70,18 @@ export function handleInputNumberValue(component?: ComponentType, val?: any) {
|
||||
* 时间字段
|
||||
*/
|
||||
export const dateItemType = genType();
|
||||
|
||||
export const defaultValueComponents = ['Input', 'InputPassword', 'InputSearch', 'InputTextArea'];
|
||||
|
||||
// TODO 自定义组件封装会出现验证问题,因此这里目前改成手动触发验证
|
||||
export const NO_AUTO_LINK_COMPONENTS: ComponentType[] = [
|
||||
'Upload',
|
||||
'ApiTransfer',
|
||||
'ApiTree',
|
||||
'ApiSelect',
|
||||
'ApiTreeSelect',
|
||||
'ApiRadioGroup',
|
||||
'ApiCascader',
|
||||
'AutoComplete',
|
||||
'RadioButtonGroup',
|
||||
];
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import type { ColEx } from '../types';
|
||||
import type { AdvanceState } from '../types/hooks';
|
||||
import type { ComputedRef, Ref } from 'vue';
|
||||
import { ComputedRef, getCurrentInstance, Ref, shallowReactive } from 'vue';
|
||||
import type { FormProps, FormSchema } from '../types/form';
|
||||
import { computed, unref, watch } from 'vue';
|
||||
import { isBoolean, isFunction, isNumber, isObject } from '/@/utils/is';
|
||||
@@ -26,6 +26,8 @@ export default function ({
|
||||
formModel,
|
||||
defaultValueRef,
|
||||
}: UseAdvancedContext) {
|
||||
const vm = getCurrentInstance();
|
||||
|
||||
const { realWidthRef, screenEnum, screenRef } = useBreakpoint();
|
||||
|
||||
const getEmptySpan = computed((): number => {
|
||||
@@ -111,6 +113,8 @@ export default function ({
|
||||
}
|
||||
}
|
||||
|
||||
const fieldsIsAdvancedMap = shallowReactive({});
|
||||
|
||||
function updateAdvanced() {
|
||||
let itemColSum = 0;
|
||||
let realItemColSum = 0;
|
||||
@@ -146,10 +150,13 @@ export default function ({
|
||||
if (isAdvanced) {
|
||||
realItemColSum = itemColSum;
|
||||
}
|
||||
schema.isAdvanced = isAdvanced;
|
||||
fieldsIsAdvancedMap[schema.field] = isAdvanced;
|
||||
}
|
||||
}
|
||||
|
||||
// 确保页面发送更新
|
||||
vm?.proxy?.$forceUpdate();
|
||||
|
||||
advanceState.actionSpan = (realItemColSum % BASIC_COL_LEN) + unref(getEmptySpan);
|
||||
|
||||
getAdvanced(unref(getProps).actionColOptions || { span: BASIC_COL_LEN }, itemColSum, true);
|
||||
@@ -161,5 +168,5 @@ export default function ({
|
||||
advanceState.isAdvanced = !advanceState.isAdvanced;
|
||||
}
|
||||
|
||||
return { handleToggleAdvanced };
|
||||
return { handleToggleAdvanced, fieldsIsAdvancedMap };
|
||||
}
|
||||
|
@@ -79,8 +79,8 @@ export function useForm(props?: Props): UseFormReturnType {
|
||||
});
|
||||
},
|
||||
|
||||
removeSchemaByFiled: async (field: string | string[]) => {
|
||||
unref(formRef)?.removeSchemaByFiled(field);
|
||||
removeSchemaByField: async (field: string | string[]) => {
|
||||
unref(formRef)?.removeSchemaByField(field);
|
||||
},
|
||||
|
||||
// TODO promisify
|
||||
@@ -94,7 +94,7 @@ export function useForm(props?: Props): UseFormReturnType {
|
||||
},
|
||||
|
||||
appendSchemaByField: async (
|
||||
schema: FormSchema,
|
||||
schema: FormSchema | FormSchema[],
|
||||
prefixField: string | undefined,
|
||||
first: boolean,
|
||||
) => {
|
||||
|
@@ -1,10 +1,18 @@
|
||||
import type { ComputedRef, Ref } from 'vue';
|
||||
import type { FormProps, FormSchema, FormActionType } from '../types/form';
|
||||
import type { NamePath } from 'ant-design-vue/lib/form/interface';
|
||||
import { unref, toRaw } from 'vue';
|
||||
import { isArray, isFunction, isObject, isString } from '/@/utils/is';
|
||||
import { unref, toRaw, nextTick } from 'vue';
|
||||
import {
|
||||
isArray,
|
||||
isFunction,
|
||||
isObject,
|
||||
isString,
|
||||
isDef,
|
||||
isNullOrUnDef,
|
||||
isEmpty,
|
||||
} from '/@/utils/is';
|
||||
import { deepMerge } from '/@/utils';
|
||||
import { dateItemType, handleInputNumberValue } from '../helper';
|
||||
import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper';
|
||||
import { dateUtil } from '/@/utils/dateUtil';
|
||||
import { cloneDeep, uniqBy } from 'lodash-es';
|
||||
import { error } from '/@/utils/log';
|
||||
@@ -37,9 +45,13 @@ export function useFormEvents({
|
||||
if (!formEl) return;
|
||||
|
||||
Object.keys(formModel).forEach((key) => {
|
||||
formModel[key] = defaultValueRef.value[key];
|
||||
const schema = unref(getSchema).find((item) => item.field === key);
|
||||
const isInput = schema?.component && defaultValueComponents.includes(schema.component);
|
||||
const defaultValue = cloneDeep(defaultValueRef.value[key]);
|
||||
formModel[key] = isInput ? defaultValue || '' : defaultValue;
|
||||
});
|
||||
clearValidate();
|
||||
nextTick(() => clearValidate());
|
||||
|
||||
emit('reset', toRaw(formModel));
|
||||
submitOnReset && handleSubmit();
|
||||
}
|
||||
@@ -52,6 +64,10 @@ export function useFormEvents({
|
||||
.map((item) => item.field)
|
||||
.filter(Boolean);
|
||||
|
||||
// key 支持 a.b.c 的嵌套写法
|
||||
const delimiter = '.';
|
||||
const nestKeyArray = fields.filter((item) => String(item).indexOf(delimiter) >= 0);
|
||||
|
||||
const validKeys: string[] = [];
|
||||
Object.keys(values).forEach((key) => {
|
||||
const schema = unref(getSchema).find((item) => item.field === key);
|
||||
@@ -60,6 +76,11 @@ export function useFormEvents({
|
||||
const hasKey = Reflect.has(values, key);
|
||||
|
||||
value = handleInputNumberValue(schema?.component, value);
|
||||
const { componentProps } = schema || {};
|
||||
let _props = componentProps as any;
|
||||
if (typeof componentProps === 'function') {
|
||||
_props = _props({ formModel: unref(formModel) });
|
||||
}
|
||||
// 0| '' is allow
|
||||
if (hasKey && fields.includes(key)) {
|
||||
// time type
|
||||
@@ -69,19 +90,32 @@ export function useFormEvents({
|
||||
for (const ele of value) {
|
||||
arr.push(ele ? dateUtil(ele) : null);
|
||||
}
|
||||
formModel[key] = arr;
|
||||
unref(formModel)[key] = arr;
|
||||
} else {
|
||||
const { componentProps } = schema || {};
|
||||
let _props = componentProps as any;
|
||||
if (typeof componentProps === 'function') {
|
||||
_props = _props({ formModel });
|
||||
}
|
||||
formModel[key] = value ? (_props?.valueFormat ? value : dateUtil(value)) : null;
|
||||
unref(formModel)[key] = value ? (_props?.valueFormat ? value : dateUtil(value)) : null;
|
||||
}
|
||||
} else {
|
||||
formModel[key] = value;
|
||||
unref(formModel)[key] = value;
|
||||
}
|
||||
if (_props?.onChange) {
|
||||
_props?.onChange(value);
|
||||
}
|
||||
validKeys.push(key);
|
||||
} else {
|
||||
nestKeyArray.forEach((nestKey: string) => {
|
||||
try {
|
||||
const value = nestKey.split('.').reduce((out, item) => out[item], values);
|
||||
if (isDef(value)) {
|
||||
unref(formModel)[nestKey] = unref(value);
|
||||
validKeys.push(nestKey);
|
||||
}
|
||||
} catch (e) {
|
||||
// key not exist
|
||||
if (isDef(defaultValueRef.value[nestKey])) {
|
||||
unref(formModel)[nestKey] = cloneDeep(unref(defaultValueRef.value[nestKey]));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
validateFields(validKeys).catch((_) => {});
|
||||
@@ -89,7 +123,7 @@ export function useFormEvents({
|
||||
/**
|
||||
* @description: Delete based on field name
|
||||
*/
|
||||
async function removeSchemaByFiled(fields: string | string[]): Promise<void> {
|
||||
async function removeSchemaByField(fields: string | string[]): Promise<void> {
|
||||
const schemaList: FormSchema[] = cloneDeep(unref(getSchema));
|
||||
if (!fields) {
|
||||
return;
|
||||
@@ -100,7 +134,7 @@ export function useFormEvents({
|
||||
fieldList = [fields];
|
||||
}
|
||||
for (const field of fieldList) {
|
||||
_removeSchemaByFiled(field, schemaList);
|
||||
_removeSchemaByFeild(field, schemaList);
|
||||
}
|
||||
schemaRef.value = schemaList;
|
||||
}
|
||||
@@ -108,7 +142,7 @@ export function useFormEvents({
|
||||
/**
|
||||
* @description: Delete based on field name
|
||||
*/
|
||||
function _removeSchemaByFiled(field: string, schemaList: FormSchema[]): void {
|
||||
function _removeSchemaByFeild(field: string, schemaList: FormSchema[]): void {
|
||||
if (isString(field)) {
|
||||
const index = schemaList.findIndex((schema) => schema.field === field);
|
||||
if (index !== -1) {
|
||||
@@ -121,22 +155,26 @@ export function useFormEvents({
|
||||
/**
|
||||
* @description: Insert after a certain field, if not insert the last
|
||||
*/
|
||||
async function appendSchemaByField(schema: FormSchema, prefixField?: string, first = false) {
|
||||
async function appendSchemaByField(
|
||||
schema: FormSchema | FormSchema[],
|
||||
prefixField?: string,
|
||||
first = false,
|
||||
) {
|
||||
const schemaList: FormSchema[] = cloneDeep(unref(getSchema));
|
||||
|
||||
const index = schemaList.findIndex((schema) => schema.field === prefixField);
|
||||
const hasInList = schemaList.some((item) => item.field === prefixField || schema.field);
|
||||
|
||||
if (!hasInList) return;
|
||||
|
||||
const _schemaList = isObject(schema) ? [schema as FormSchema] : (schema as FormSchema[]);
|
||||
if (!prefixField || index === -1 || first) {
|
||||
first ? schemaList.unshift(schema) : schemaList.push(schema);
|
||||
first ? schemaList.unshift(..._schemaList) : schemaList.push(..._schemaList);
|
||||
schemaRef.value = schemaList;
|
||||
_setDefaultValue(schema);
|
||||
return;
|
||||
}
|
||||
if (index !== -1) {
|
||||
schemaList.splice(index + 1, 0, schema);
|
||||
schemaList.splice(index + 1, 0, ..._schemaList);
|
||||
}
|
||||
_setDefaultValue(schema);
|
||||
|
||||
schemaRef.value = schemaList;
|
||||
}
|
||||
|
||||
@@ -182,19 +220,52 @@ export function useFormEvents({
|
||||
return;
|
||||
}
|
||||
const schema: FormSchema[] = [];
|
||||
updateData.forEach((item) => {
|
||||
unref(getSchema).forEach((val) => {
|
||||
unref(getSchema).forEach((val) => {
|
||||
let _val;
|
||||
updateData.forEach((item) => {
|
||||
if (val.field === item.field) {
|
||||
const newSchema = deepMerge(val, item);
|
||||
schema.push(newSchema as FormSchema);
|
||||
} else {
|
||||
schema.push(val);
|
||||
_val = item;
|
||||
}
|
||||
});
|
||||
if (_val !== undefined && val.field === _val.field) {
|
||||
const newSchema = deepMerge(val, _val);
|
||||
schema.push(newSchema as FormSchema);
|
||||
} else {
|
||||
schema.push(val);
|
||||
}
|
||||
});
|
||||
_setDefaultValue(schema);
|
||||
|
||||
schemaRef.value = uniqBy(schema, 'field');
|
||||
}
|
||||
|
||||
function _setDefaultValue(data: FormSchema | FormSchema[]) {
|
||||
let schemas: FormSchema[] = [];
|
||||
if (isObject(data)) {
|
||||
schemas.push(data as FormSchema);
|
||||
}
|
||||
if (isArray(data)) {
|
||||
schemas = [...data];
|
||||
}
|
||||
|
||||
const obj: Recordable = {};
|
||||
const currentFieldsValue = getFieldsValue();
|
||||
schemas.forEach((item) => {
|
||||
if (
|
||||
item.component != 'Divider' &&
|
||||
Reflect.has(item, 'field') &&
|
||||
item.field &&
|
||||
!isNullOrUnDef(item.defaultValue) &&
|
||||
(!(item.field in currentFieldsValue) ||
|
||||
isNullOrUnDef(currentFieldsValue[item.field]) ||
|
||||
isEmpty(currentFieldsValue[item.field]))
|
||||
) {
|
||||
obj[item.field] = item.defaultValue;
|
||||
}
|
||||
});
|
||||
setFieldsValue(obj);
|
||||
}
|
||||
|
||||
function getFieldsValue(): Recordable {
|
||||
const formEl = unref(formElRef);
|
||||
if (!formEl) return {};
|
||||
@@ -243,6 +314,9 @@ export function useFormEvents({
|
||||
const res = handleFormValues(values);
|
||||
emit('submit', res);
|
||||
} catch (error: any) {
|
||||
if (error?.outOfDate === false && error?.errorFields) {
|
||||
return;
|
||||
}
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
@@ -256,7 +330,7 @@ export function useFormEvents({
|
||||
updateSchema,
|
||||
resetSchema,
|
||||
appendSchemaByField,
|
||||
removeSchemaByFiled,
|
||||
removeSchemaByField,
|
||||
resetFields,
|
||||
setFieldsValue,
|
||||
scrollToField,
|
||||
|
@@ -3,7 +3,7 @@ import { dateUtil } from '/@/utils/dateUtil';
|
||||
import { unref } from 'vue';
|
||||
import type { Ref, ComputedRef } from 'vue';
|
||||
import type { FormProps, FormSchema } from '../types/form';
|
||||
import { set } from 'lodash-es';
|
||||
import { cloneDeep, set } from 'lodash-es';
|
||||
|
||||
interface UseFormValuesContext {
|
||||
defaultValueRef: Ref<any>;
|
||||
@@ -11,6 +11,43 @@ interface UseFormValuesContext {
|
||||
getProps: ComputedRef<FormProps>;
|
||||
formModel: Recordable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desription deconstruct array-link key. This method will mutate the target.
|
||||
*/
|
||||
function tryDeconstructArray(key: string, value: any, target: Recordable) {
|
||||
const pattern = /^\[(.+)\]$/;
|
||||
if (pattern.test(key)) {
|
||||
const match = key.match(pattern);
|
||||
if (match && match[1]) {
|
||||
const keys = match[1].split(',');
|
||||
value = Array.isArray(value) ? value : [value];
|
||||
keys.forEach((k, index) => {
|
||||
set(target, k.trim(), value[index]);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desription deconstruct object-link key. This method will mutate the target.
|
||||
*/
|
||||
function tryDeconstructObject(key: string, value: any, target: Recordable) {
|
||||
const pattern = /^\{(.+)\}$/;
|
||||
if (pattern.test(key)) {
|
||||
const match = key.match(pattern);
|
||||
if (match && match[1]) {
|
||||
const keys = match[1].split(',');
|
||||
value = isObject(value) ? value : {};
|
||||
keys.forEach((k) => {
|
||||
set(target, k.trim(), value[k.trim()]);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function useFormValues({
|
||||
defaultValueRef,
|
||||
getSchema,
|
||||
@@ -33,14 +70,23 @@ export function useFormValues({
|
||||
if (isObject(value)) {
|
||||
value = transformDateFunc?.(value);
|
||||
}
|
||||
if (isArray(value) && value[0]?._isAMomentObject && value[1]?._isAMomentObject) {
|
||||
|
||||
if (isArray(value) && value[0]?.format && value[1]?.format) {
|
||||
value = value.map((item) => transformDateFunc?.(item));
|
||||
}
|
||||
// Remove spaces
|
||||
if (isString(value)) {
|
||||
value = value.trim();
|
||||
// remove params from URL
|
||||
if(value === '') {
|
||||
value = undefined;
|
||||
}else {
|
||||
value = value.trim();
|
||||
}
|
||||
}
|
||||
if (!tryDeconstructArray(key, value, res) && !tryDeconstructObject(key, value, res)) {
|
||||
// 没有解构成功的,按原样赋值
|
||||
set(res, key, value);
|
||||
}
|
||||
set(res, key, value);
|
||||
}
|
||||
return handleRangeTimeValue(res);
|
||||
}
|
||||
@@ -56,14 +102,21 @@ export function useFormValues({
|
||||
}
|
||||
|
||||
for (const [field, [startTimeKey, endTimeKey], format = 'YYYY-MM-DD'] of fieldMapToTime) {
|
||||
if (!field || !startTimeKey || !endTimeKey || !values[field]) {
|
||||
if (!field || !startTimeKey || !endTimeKey) {
|
||||
continue;
|
||||
}
|
||||
// If the value to be converted is empty, remove the field
|
||||
if (!values[field]) {
|
||||
Reflect.deleteProperty(values, field);
|
||||
continue;
|
||||
}
|
||||
|
||||
const [startTime, endTime]: string[] = values[field];
|
||||
|
||||
values[startTimeKey] = dateUtil(startTime).format(format);
|
||||
values[endTimeKey] = dateUtil(endTime).format(format);
|
||||
const [startTimeFormat, endTimeFormat] = Array.isArray(format) ? format : [format, format];
|
||||
|
||||
values[startTimeKey] = dateUtil(startTime).format(startTimeFormat);
|
||||
values[endTimeKey] = dateUtil(endTime).format(endTimeFormat);
|
||||
Reflect.deleteProperty(values, field);
|
||||
}
|
||||
|
||||
@@ -77,10 +130,13 @@ export function useFormValues({
|
||||
const { defaultValue } = item;
|
||||
if (!isNullOrUnDef(defaultValue)) {
|
||||
obj[item.field] = defaultValue;
|
||||
formModel[item.field] = defaultValue;
|
||||
|
||||
if (formModel[item.field] === undefined) {
|
||||
formModel[item.field] = defaultValue;
|
||||
}
|
||||
}
|
||||
});
|
||||
defaultValueRef.value = obj;
|
||||
defaultValueRef.value = cloneDeep(obj);
|
||||
}
|
||||
|
||||
return { handleFormValues, initDefault };
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import type { Ref } from 'vue';
|
||||
import type { FormProps, FormSchema } from '../types/form';
|
||||
|
||||
import { computed, unref } from 'vue';
|
||||
import type { FormProps, FormSchema } from '../types/form';
|
||||
import { isNumber } from '/@/utils/is';
|
||||
|
||||
export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<FormProps>) {
|
||||
@@ -14,6 +13,7 @@ export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<
|
||||
labelWidth: globalLabelWidth,
|
||||
labelCol: globalLabelCol,
|
||||
wrapperCol: globWrapperCol,
|
||||
layout,
|
||||
} = unref(propsRef);
|
||||
|
||||
// If labelWidth is set globally, all items setting
|
||||
@@ -33,7 +33,10 @@ export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<
|
||||
|
||||
return {
|
||||
labelCol: { style: { width }, ...col },
|
||||
wrapperCol: { style: { width: `calc(100% - ${width})` }, ...wrapCol },
|
||||
wrapperCol: {
|
||||
style: { width: layout === 'vertical' ? '100%' : `calc(100% - ${width})` },
|
||||
...wrapCol,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ import { propTypes } from '/@/utils/propTypes';
|
||||
export const basicProps = {
|
||||
model: {
|
||||
type: Object as PropType<Recordable>,
|
||||
default: {},
|
||||
default: () => ({}),
|
||||
},
|
||||
// 标签宽度 固定宽度
|
||||
labelWidth: {
|
||||
@@ -23,7 +23,7 @@ export const basicProps = {
|
||||
compact: propTypes.bool,
|
||||
// 表单配置规则
|
||||
schemas: {
|
||||
type: [Array] as PropType<FormSchema[]>,
|
||||
type: Array as PropType<FormSchema[]>,
|
||||
default: () => [],
|
||||
},
|
||||
mergeDynamicData: {
|
||||
@@ -40,11 +40,12 @@ export const basicProps = {
|
||||
// 在INPUT组件上单击回车时,是否自动提交
|
||||
autoSubmitOnEnter: propTypes.bool.def(false),
|
||||
submitOnReset: propTypes.bool,
|
||||
submitOnChange: propTypes.bool,
|
||||
size: propTypes.oneOf(['default', 'small', 'large']).def('default'),
|
||||
// 禁用表单
|
||||
disabled: propTypes.bool,
|
||||
emptySpan: {
|
||||
type: [Number, Object] as PropType<number>,
|
||||
type: [Number, Object] as PropType<number | Recordable>,
|
||||
default: 0,
|
||||
},
|
||||
// 是否显示收起展开按钮
|
||||
@@ -53,7 +54,7 @@ export const basicProps = {
|
||||
transformDateFunc: {
|
||||
type: Function as PropType<Fn>,
|
||||
default: (date: any) => {
|
||||
return date._isAMomentObject ? date?.format('YYYY-MM-DD HH:mm:ss') : date;
|
||||
return date?.format?.('YYYY-MM-DD HH:mm:ss') ?? date;
|
||||
},
|
||||
},
|
||||
rulesMessageJoinLabel: propTypes.bool.def(true),
|
||||
|
@@ -7,7 +7,7 @@ import type { TableActionType } from '/@/components/Table/src/types/table';
|
||||
import type { CSSProperties } from 'vue';
|
||||
import type { RowProps } from 'ant-design-vue/lib/grid/Row';
|
||||
|
||||
export type FieldMapToTime = [string, [string, string], string?][];
|
||||
export type FieldMapToTime = [string, [string, string], (string | [string, string])?][];
|
||||
|
||||
export type Rule = RuleObject & {
|
||||
trigger?: 'blur' | 'change' | ['change', 'blur'];
|
||||
@@ -26,16 +26,16 @@ export interface ButtonProps extends AntdButtonProps {
|
||||
|
||||
export interface FormActionType {
|
||||
submit: () => Promise<void>;
|
||||
setFieldsValue: <T>(values: T) => Promise<void>;
|
||||
setFieldsValue: (values: Recordable) => Promise<void>;
|
||||
resetFields: () => Promise<void>;
|
||||
getFieldsValue: () => Recordable;
|
||||
clearValidate: (name?: string | string[]) => Promise<void>;
|
||||
updateSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>;
|
||||
resetSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>;
|
||||
setProps: (formProps: Partial<FormProps>) => Promise<void>;
|
||||
removeSchemaByFiled: (field: string | string[]) => Promise<void>;
|
||||
removeSchemaByField: (field: string | string[]) => Promise<void>;
|
||||
appendSchemaByField: (
|
||||
schema: FormSchema,
|
||||
schema: FormSchema | FormSchema[],
|
||||
prefixField: string | undefined,
|
||||
first?: boolean | undefined,
|
||||
) => Promise<void>;
|
||||
@@ -49,17 +49,20 @@ export type RegisterFn = (formInstance: FormActionType) => void;
|
||||
export type UseFormReturnType = [RegisterFn, FormActionType];
|
||||
|
||||
export interface FormProps {
|
||||
name?: string;
|
||||
layout?: 'vertical' | 'inline' | 'horizontal';
|
||||
// Form value
|
||||
model?: Recordable;
|
||||
// The width of all items in the entire form
|
||||
labelWidth?: number | string;
|
||||
//alignment
|
||||
// alignment
|
||||
labelAlign?: 'left' | 'right';
|
||||
//Row configuration for the entire form
|
||||
// Row configuration for the entire form
|
||||
rowProps?: RowProps;
|
||||
// Submit form on reset
|
||||
submitOnReset?: boolean;
|
||||
// Submit form on form changing
|
||||
submitOnChange?: boolean;
|
||||
// Col configuration for the entire form
|
||||
labelCol?: Partial<ColEx>;
|
||||
// Col configuration for the entire form
|
||||
@@ -172,6 +175,10 @@ export interface FormSchema {
|
||||
|
||||
// 默认值
|
||||
defaultValue?: any;
|
||||
|
||||
// 是否自动处理与时间相关组件的默认值
|
||||
isHandleDateDefaultValue?: boolean;
|
||||
|
||||
isAdvanced?: boolean;
|
||||
|
||||
// Matching details components
|
||||
|
@@ -91,6 +91,7 @@ export type ComponentType =
|
||||
| 'Select'
|
||||
| 'ApiSelect'
|
||||
| 'TreeSelect'
|
||||
| 'ApiTree'
|
||||
| 'ApiTreeSelect'
|
||||
| 'ApiRadioGroup'
|
||||
| 'RadioButtonGroup'
|
||||
@@ -112,4 +113,5 @@ export type ComponentType =
|
||||
| 'Render'
|
||||
| 'Slider'
|
||||
| 'Rate'
|
||||
| 'Divider';
|
||||
| 'Divider'
|
||||
| 'ApiTransfer';
|
||||
|
@@ -31,18 +31,7 @@
|
||||
v-for="icon in getPaginationList"
|
||||
:key="icon"
|
||||
:class="currentSelect === icon ? 'border border-primary' : ''"
|
||||
class="
|
||||
p-2
|
||||
w-1/8
|
||||
cursor-pointer
|
||||
mr-1
|
||||
mt-1
|
||||
flex
|
||||
justify-center
|
||||
items-center
|
||||
border border-solid
|
||||
hover:border-primary
|
||||
"
|
||||
class="p-2 w-1/8 cursor-pointer mr-1 mt-1 flex justify-center items-center border border-solid hover:border-primary"
|
||||
@click="handleClick(icon)"
|
||||
:title="icon"
|
||||
>
|
||||
@@ -135,7 +124,16 @@
|
||||
const { prefixCls } = useDesign('icon-picker');
|
||||
|
||||
const debounceHandleSearchChange = useDebounceFn(handleSearchChange, 100);
|
||||
const { clipboardRef, isSuccessRef } = useCopyToClipboard(props.value);
|
||||
|
||||
let clipboardRef;
|
||||
let isSuccessRef;
|
||||
|
||||
if (props.copy) {
|
||||
const clipboard = useCopyToClipboard(props.value);
|
||||
clipboardRef = clipboard?.clipboardRef;
|
||||
isSuccessRef = clipboard?.isSuccessRef;
|
||||
}
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const { getPaginationList, getTotal, setCurrentPage } = usePagination(
|
||||
|
@@ -19,6 +19,7 @@
|
||||
import { useModalContext } from '../../Modal';
|
||||
import { useRootSetting } from '/@/hooks/setting/useRootSetting';
|
||||
import { onMountedOrActivated } from '/@/hooks/core/onMountedOrActivated';
|
||||
import { getTheme } from './getTheme';
|
||||
|
||||
type Lang = 'zh_CN' | 'en_US' | 'ja_JP' | 'ko_KR' | undefined;
|
||||
|
||||
@@ -46,8 +47,9 @@
|
||||
if (!inited) {
|
||||
return;
|
||||
}
|
||||
const theme = val === 'dark' ? 'dark' : 'classic';
|
||||
instance.getVditor()?.setTheme(theme);
|
||||
instance
|
||||
.getVditor()
|
||||
?.setTheme(getTheme(val) as any, getTheme(val, 'content'), getTheme(val, 'code'));
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
@@ -87,13 +89,22 @@
|
||||
if (!wrapEl) return;
|
||||
const bindValue = { ...attrs, ...props };
|
||||
const insEditor = new Vditor(wrapEl, {
|
||||
theme: getDarkMode.value === 'dark' ? 'dark' : 'classic',
|
||||
// 设置外观主题
|
||||
theme: getTheme(getDarkMode.value) as any,
|
||||
lang: unref(getCurrentLang),
|
||||
mode: 'sv',
|
||||
fullscreen: {
|
||||
index: 520,
|
||||
},
|
||||
preview: {
|
||||
theme: {
|
||||
// 设置内容主题
|
||||
current: getTheme(getDarkMode.value, 'content'),
|
||||
},
|
||||
hljs: {
|
||||
// 设置代码块主题
|
||||
style: getTheme(getDarkMode.value, 'code'),
|
||||
},
|
||||
actions: [],
|
||||
},
|
||||
input: (v) => {
|
||||
|
@@ -1,23 +1,62 @@
|
||||
<template>
|
||||
<!-- eslint-disable vue/no-v-html -->
|
||||
<div v-html="getHtmlData" :class="$props.class" class="markdown-viewer"></div>
|
||||
<div ref="viewerRef" id="markdownViewer" :class="$props.class"></div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import showdown from 'showdown';
|
||||
|
||||
const converter = new showdown.Converter();
|
||||
converter.setOption('tables', true);
|
||||
import { defineProps, onBeforeUnmount, onDeactivated, Ref, ref, unref, watch } from 'vue';
|
||||
import VditorPreview from 'vditor/dist/method.min';
|
||||
import { onMountedOrActivated } from '/@/hooks/core/onMountedOrActivated';
|
||||
import { useRootSetting } from '/@/hooks/setting/useRootSetting';
|
||||
import { getTheme } from './getTheme';
|
||||
const props = defineProps({
|
||||
value: { type: String },
|
||||
class: { type: String },
|
||||
});
|
||||
const getHtmlData = computed(() => converter.makeHtml(props.value || ''));
|
||||
</script>
|
||||
const viewerRef = ref<ElRef>(null);
|
||||
const vditorPreviewRef = ref(null) as Ref<Nullable<VditorPreview>>;
|
||||
const { getDarkMode } = useRootSetting();
|
||||
|
||||
<style scoped>
|
||||
.markdown-viewer {
|
||||
width: 100%;
|
||||
function init() {
|
||||
const viewerEl = unref(viewerRef) as HTMLElement;
|
||||
vditorPreviewRef.value = VditorPreview.preview(viewerEl, props.value, {
|
||||
mode: getTheme(getDarkMode.value, 'content'),
|
||||
theme: {
|
||||
// 设置内容主题
|
||||
current: getTheme(getDarkMode.value, 'content'),
|
||||
},
|
||||
hljs: {
|
||||
// 设置代码块主题
|
||||
style: getTheme(getDarkMode.value, 'code'),
|
||||
},
|
||||
});
|
||||
}
|
||||
</style>
|
||||
watch(
|
||||
() => getDarkMode.value,
|
||||
(val) => {
|
||||
VditorPreview.setContentTheme(getTheme(val, 'content'));
|
||||
VditorPreview.setCodeTheme(getTheme(val, 'code'));
|
||||
init();
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
(v, oldValue) => {
|
||||
v !== oldValue && init();
|
||||
},
|
||||
);
|
||||
|
||||
function destroy() {
|
||||
const vditorInstance = unref(vditorPreviewRef);
|
||||
if (!vditorInstance) return;
|
||||
try {
|
||||
vditorInstance?.destroy?.();
|
||||
} catch (error) {}
|
||||
vditorPreviewRef.value = null;
|
||||
}
|
||||
|
||||
onMountedOrActivated(init);
|
||||
|
||||
onBeforeUnmount(destroy);
|
||||
onDeactivated(destroy);
|
||||
</script>
|
||||
|
19
src/components/Markdown/src/getTheme.ts
Normal file
19
src/components/Markdown/src/getTheme.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 获取主题类型 深色浅色模式 对应的值
|
||||
* @param darkModeVal 深色模式值
|
||||
* @param themeMode 主题类型——外观(默认), 内容, 代码块
|
||||
*/
|
||||
export const getTheme = (
|
||||
darkModeVal: 'light' | 'dark' | string,
|
||||
themeMode: 'default' | 'content' | 'code' = 'default',
|
||||
) => {
|
||||
const isDark = darkModeVal === 'dark';
|
||||
switch (themeMode) {
|
||||
case 'default':
|
||||
return isDark ? 'dark' : 'classic';
|
||||
case 'content':
|
||||
return isDark ? 'dark' : 'light';
|
||||
case 'code':
|
||||
return isDark ? 'dracula' : 'github';
|
||||
}
|
||||
};
|
@@ -6,7 +6,7 @@
|
||||
:openKeys="getOpenKeys"
|
||||
:inlineIndent="inlineIndent"
|
||||
:theme="theme"
|
||||
@openChange="handleOpenChange"
|
||||
@open-change="handleOpenChange"
|
||||
:class="getMenuClass"
|
||||
@click="handleMenuClick"
|
||||
:subMenuOpenDelay="0.2"
|
||||
|
@@ -41,7 +41,7 @@ export const basicProps = {
|
||||
export const itemProps = {
|
||||
item: {
|
||||
type: Object as PropType<Menu>,
|
||||
default: {},
|
||||
default: () => ({}),
|
||||
},
|
||||
level: propTypes.number,
|
||||
theme: propTypes.oneOf(['dark', 'light']),
|
||||
|
@@ -139,8 +139,9 @@
|
||||
...attrs,
|
||||
...unref(getMergeProps),
|
||||
visible: unref(visibleRef),
|
||||
wrapClassName: unref(getWrapClassName),
|
||||
};
|
||||
attr['wrapClassName'] = `${attr?.['wrapClassName'] || ''} ${unref(getWrapClassName)}`;
|
||||
|
||||
if (unref(fullScreenRef)) {
|
||||
return omit(attr, ['height', 'title']);
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
props: basicProps,
|
||||
emits: ['cancel'],
|
||||
setup(props, { slots }) {
|
||||
setup(props, { slots, emit }) {
|
||||
const { visible, draggable, destroyOnClose } = toRefs(props);
|
||||
const attrs = useAttrs();
|
||||
useModalDragMove({
|
||||
@@ -19,8 +19,12 @@ export default defineComponent({
|
||||
draggable,
|
||||
});
|
||||
|
||||
const onCancel = (e: Event) => {
|
||||
emit('cancel', e);
|
||||
};
|
||||
|
||||
return () => {
|
||||
const propsData = { ...unref(attrs), ...props } as Recordable;
|
||||
const propsData = { ...unref(attrs), ...props, onCancel } as Recordable;
|
||||
return <Modal {...propsData}>{extendSlots(slots)}</Modal>;
|
||||
};
|
||||
},
|
||||
|
@@ -17,6 +17,5 @@
|
||||
},
|
||||
title: { type: String },
|
||||
},
|
||||
emits: ['dblclick'],
|
||||
});
|
||||
</script>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user