From 3a39b2afb7445124100d215fa3bcbc09365ec604 Mon Sep 17 00:00:00 2001 From: xingyuv Date: Sat, 18 Mar 2023 23:10:57 +0800 Subject: [PATCH] feat: axios --- .env | 13 +- .env.development | 9 +- .env.front | 24 + .env.production | 4 +- .env.test | 3 +- CNAME | 2 +- package.json | 11 +- pnpm-lock.yaml | 166 +------ src/components/FlowChart/index.ts | 4 - src/components/FlowChart/src/FlowChart.vue | 142 ------ .../FlowChart/src/FlowChartToolbar.vue | 153 ------ .../FlowChart/src/adpterForTurbo.ts | 75 --- src/components/FlowChart/src/config.ts | 96 ---- src/components/FlowChart/src/enum.ts | 11 - src/components/FlowChart/src/types.ts | 14 - .../FlowChart/src/useFlowContext.ts | 17 - src/components/Verifition/index.ts | 4 + src/components/Verifition/src/Verify.vue | 452 ++++++++++++++++++ .../Verifition/src/Verify/VerifyPoints.vue | 250 ++++++++++ .../Verifition/src/Verify/VerifySlide.vue | 357 ++++++++++++++ src/components/Verifition/src/Verify/index.ts | 4 + src/components/Verifition/src/utils/ase.ts | 14 + src/components/Verifition/src/utils/util.ts | 97 ++++ src/components/Verify/index.ts | 7 - src/components/Verify/src/DragVerify.vue | 365 -------------- src/components/Verify/src/ImgRotate.vue | 214 --------- src/components/Verify/src/props.ts | 86 ---- src/components/Verify/src/typing.ts | 14 - src/types/axios.d.ts | 6 +- src/types/config.d.ts | 8 + src/types/index.d.ts | 10 + src/types/store.d.ts | 8 +- src/types/vue-router.d.ts | 38 +- src/utils/http/axios/Axios.ts | 164 ++++++- src/utils/http/axios/axiosCancel.ts | 11 +- src/utils/http/axios/axiosTransform.ts | 3 +- src/utils/http/axios/checkStatus.ts | 2 +- src/utils/http/axios/helper.ts | 2 +- src/utils/http/axios/index.ts | 53 +- src/views/base/login/Login.vue | 2 +- src/views/base/login/LoginForm.vue | 71 ++- src/views/base/login/MobileForm.vue | 1 - src/views/base/login/QrCodeForm.vue | 2 +- src/views/base/login/RegisterForm.vue | 1 - src/views/base/login/SessionTimeoutLogin.vue | 5 +- 45 files changed, 1539 insertions(+), 1456 deletions(-) create mode 100644 .env.front delete mode 100644 src/components/FlowChart/index.ts delete mode 100644 src/components/FlowChart/src/FlowChart.vue delete mode 100644 src/components/FlowChart/src/FlowChartToolbar.vue delete mode 100644 src/components/FlowChart/src/adpterForTurbo.ts delete mode 100644 src/components/FlowChart/src/config.ts delete mode 100644 src/components/FlowChart/src/enum.ts delete mode 100644 src/components/FlowChart/src/types.ts delete mode 100644 src/components/FlowChart/src/useFlowContext.ts create mode 100644 src/components/Verifition/index.ts create mode 100644 src/components/Verifition/src/Verify.vue create mode 100644 src/components/Verifition/src/Verify/VerifyPoints.vue create mode 100644 src/components/Verifition/src/Verify/VerifySlide.vue create mode 100644 src/components/Verifition/src/Verify/index.ts create mode 100644 src/components/Verifition/src/utils/ase.ts create mode 100644 src/components/Verifition/src/utils/util.ts delete mode 100644 src/components/Verify/index.ts delete mode 100644 src/components/Verify/src/DragVerify.vue delete mode 100644 src/components/Verify/src/ImgRotate.vue delete mode 100644 src/components/Verify/src/props.ts delete mode 100644 src/components/Verify/src/typing.ts diff --git a/.env b/.env index fc3262c9..e94bec4f 100644 --- a/.env +++ b/.env @@ -1,8 +1,15 @@ # 端口号 -VITE_PORT = 3100 +VITE_PORT = 80 # 网站标题 -VITE_GLOB_APP_TITLE = Vben Admin +VITE_GLOB_APP_TITLE = 芋道管理系统 # 简称,用于配置文件名字 不要出现空格、数字开头等特殊字符 -VITE_GLOB_APP_SHORT_NAME = vue_vben_admin +VITE_GLOB_APP_SHORT_NAME = Vben + +# 租户开关 +VITE_GLOB_APP_TENANT_ENABLE = true + +# 验证码的开关 +VITE_GLOB_APP_CAPTCHA_ENABLE = true + diff --git a/.env.development b/.env.development index 9a788b27..176c28bb 100644 --- a/.env.development +++ b/.env.development @@ -1,18 +1,21 @@ +# 本地开发环境 +NODE_ENV=development + # 资源公共路径,需要以 /开头和结尾 VITE_PUBLIC_PATH = / # 本地开发代理,可以解决跨域及多地址代理 # 如果接口地址匹配到,则会转发到http://localhost:3000,防止本地出现跨域问题 # 可以有多个,注意多个不能换行,否则代理将会失效 -VITE_PROXY = [["/basic-api","http://localhost:3000"],["/upload","http://localhost:3300/upload"]] -# VITE_PROXY=[["/api","https://xingyuv.com/test"]] +VITE_PROXY = [["/dev-api","http://localhost:48080"],["/upload","http://localhost:48080/admin-api/infra/file/upload"]] +# VITE_PROXY=[["/api","http://vben.xingyuv.com/test"]] # 是否删除Console.log VITE_DROP_CONSOLE = false # 接口地址 # 如果没有跨域问题,直接在这里配置即可 -VITE_GLOB_API_URL = /basic-api +VITE_GLOB_API_URL = "http://localhost:48080/admin-api" # 文件上传接口 可选 VITE_GLOB_UPLOAD_URL = /upload diff --git a/.env.front b/.env.front new file mode 100644 index 00000000..daf9d788 --- /dev/null +++ b/.env.front @@ -0,0 +1,24 @@ +# 本地开发环境 +NODE_ENV=development + +# 资源公共路径,需要以 /开头和结尾 +VITE_PUBLIC_PATH = / + +# 本地开发代理,可以解决跨域及多地址代理 +# 如果接口地址匹配到,则会转发到http://localhost:3000,防止本地出现跨域问题 +# 可以有多个,注意多个不能换行,否则代理将会失效 +VITE_PROXY = [["/dev-api","http://api-dashboard.yudao.iocoder.cn"],["/upload","http://api-dashboard.yudao.iocoder.cn/admin-api/infra/file/upload"]] +# VITE_PROXY=[["/api","http://vben.xingyuv.com/test"]] + +# 是否删除Console.log +VITE_DROP_CONSOLE = false + +# 接口地址 +# 如果没有跨域问题,直接在这里配置即可 +VITE_GLOB_API_URL = "http://localhost:48080/admin-api" + +# 文件上传接口 可选 +VITE_GLOB_UPLOAD_URL = /upload + +# 接口地址前缀,有些系统所有接口地址都有前缀,可以在这里统一加,方便切换 +VITE_GLOB_API_URL_PREFIX = diff --git a/.env.production b/.env.production index b1211a7e..68729f74 100644 --- a/.env.production +++ b/.env.production @@ -13,13 +13,13 @@ VITE_BUILD_COMPRESS = 'gzip' VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false # 接口地址 可以由nginx做转发或者直接写实际地址 -VITE_GLOB_API_URL = /basic-api +VITE_GLOB_API_URL = /admin-api # 文件上传地址 可以由nginx做转发或者直接写实际地址 VITE_GLOB_UPLOAD_URL = /upload # 接口地址前缀,有些系统所有接口地址都有前缀,可以在这里统一加,方便切换 -VITE_GLOB_API_URL_PREFIX = +VITE_GLOB_API_URL_PREFIX = # 打包是否开启pwa功能 VITE_USE_PWA = false diff --git a/.env.test b/.env.test index adcf778d..de3ecb98 100644 --- a/.env.test +++ b/.env.test @@ -1,4 +1,5 @@ NODE_ENV=production + # 资源公共路径,需要以 / 开头和结尾 VITE_PUBLIC_PATH = / @@ -14,7 +15,7 @@ VITE_BUILD_COMPRESS = 'none' VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false # 接口地址 可以由nginx做转发或者直接写实际地址 -VITE_GLOB_API_URL = /basic-api +VITE_GLOB_API_URL = /admin-api # 文件上传地址 可以由nginx做转发或者直接写实际地址 VITE_GLOB_UPLOAD_URL = /upload diff --git a/CNAME b/CNAME index 3436928a..902f3995 100644 --- a/CNAME +++ b/CNAME @@ -1 +1 @@ -vben.vvbin.cn +vben.xingyuv.com diff --git a/package.json b/package.json index 7130fff5..694334e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "vben-admin", - "version": "1.0.2", + "name": "ruoyi-ui-admin-vben", + "version": "1.0.0", "author": { "name": "xingyu4j", "email": "xingyu4j@vip.qq.com", @@ -34,8 +34,6 @@ "@ant-design/colors": "^7.0.0", "@ant-design/icons-vue": "^6.1.0", "@iconify/iconify": "^3.1.0", - "@logicflow/core": "^1.2.1", - "@logicflow/extension": "^1.2.1", "@vue/runtime-core": "^3.2.47", "@vueuse/core": "^9.13.0", "@zxcvbn-ts/core": "^2.2.1", @@ -55,7 +53,6 @@ "qrcode": "^1.5.1", "qs": "^6.11.1", "resize-observer-polyfill": "^1.5.1", - "showdown": "^2.1.0", "sortablejs": "^1.15.0", "tinymce": "^5.10.7", "vditor": "^3.9.1", @@ -82,7 +79,6 @@ "@types/nprogress": "^0.2.0", "@types/qrcode": "^1.5.0", "@types/qs": "^6.9.7", - "@types/showdown": "^2.0.0", "@types/sortablejs": "^1.15.1", "@typescript-eslint/eslint-plugin": "^5.55.0", "@typescript-eslint/parser": "^5.55.0", @@ -91,6 +87,7 @@ "@vitejs/plugin-vue-jsx": "^3.0.1", "@vue/compiler-sfc": "^3.2.47", "autoprefixer": "^10.4.14", + "consola": "^2.15.3", "conventional-changelog-cli": "^2.2.2", "cross-env": "^7.0.3", "cz-git": "^1.6.0", @@ -106,7 +103,6 @@ "inquirer": "^9.1.4", "less": "^4.1.3", "lint-staged": "^13.2.0", - "npm-run-all": "^4.1.5", "picocolors": "^1.0.0", "postcss": "^8.4.21", "postcss-html": "^1.5.0", @@ -122,7 +118,6 @@ "stylelint-config-standard": "^29.0.0", "stylelint-order": "^6.0.2", "terser": "^5.16.6", - "ts-node": "^10.9.1", "typescript": "^5.0.2", "unplugin-vue-setup-extend-plus": "^0.4.9", "vite": "^4.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bab858dd..9e1c0d64 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,8 +8,6 @@ specifiers: '@iconify/iconify': ^3.1.0 '@iconify/json': ^2.2.36 '@kirklin/vite-plugin-vben-theme': ^0.1.1 - '@logicflow/core': ^1.2.1 - '@logicflow/extension': ^1.2.1 '@purge-icons/generated': ^0.9.0 '@types/codemirror': ^5.60.5 '@types/crypto-js': ^4.1.1 @@ -21,7 +19,6 @@ specifiers: '@types/nprogress': ^0.2.0 '@types/qrcode': ^1.5.0 '@types/qs': ^6.9.7 - '@types/showdown': ^2.0.0 '@types/sortablejs': ^1.15.1 '@typescript-eslint/eslint-plugin': ^5.55.0 '@typescript-eslint/parser': ^5.55.0 @@ -36,6 +33,7 @@ specifiers: autoprefixer: ^10.4.14 axios: ^1.3.4 codemirror: ^5.65.3 + consola: ^2.15.3 conventional-changelog-cli: ^2.2.2 cropperjs: ^1.5.13 cross-env: ^7.0.3 @@ -57,7 +55,6 @@ specifiers: less: ^4.1.3 lint-staged: ^13.2.0 lodash-es: ^4.17.21 - npm-run-all: ^4.1.5 nprogress: ^0.2.0 path-to-regexp: ^6.2.1 picocolors: ^1.0.0 @@ -73,7 +70,6 @@ specifiers: rimraf: ^4.4.0 rollup: ^3.19.1 rollup-plugin-visualizer: ^5.9.0 - showdown: ^2.1.0 sortablejs: ^1.15.0 stylelint: ^14.16.1 stylelint-config-prettier: ^9.0.5 @@ -83,7 +79,6 @@ specifiers: stylelint-order: ^6.0.2 terser: ^5.16.6 tinymce: ^5.10.7 - ts-node: ^10.9.1 typescript: ^5.0.2 unplugin-vue-setup-extend-plus: ^0.4.9 vditor: ^3.9.1 @@ -110,8 +105,6 @@ dependencies: '@ant-design/colors': 7.0.0 '@ant-design/icons-vue': 6.1.0_vue@3.2.47 '@iconify/iconify': 3.1.0 - '@logicflow/core': 1.2.1 - '@logicflow/extension': 1.2.1 '@vue/runtime-core': 3.2.47 '@vueuse/core': 9.13.0_vue@3.2.47 '@zxcvbn-ts/core': 2.2.1 @@ -131,7 +124,6 @@ dependencies: qrcode: 1.5.1 qs: 6.11.1 resize-observer-polyfill: 1.5.1 - showdown: 2.1.0 sortablejs: 1.15.0 tinymce: 5.10.7 vditor: 3.9.1 @@ -158,7 +150,6 @@ devDependencies: '@types/nprogress': 0.2.0 '@types/qrcode': 1.5.0 '@types/qs': 6.9.7 - '@types/showdown': 2.0.0 '@types/sortablejs': 1.15.1 '@typescript-eslint/eslint-plugin': 5.55.0_qsnvknysi52qtaxqdyqyohkcku '@typescript-eslint/parser': 5.55.0_j4766f7ecgqbon3u7zlxn5zszu @@ -167,6 +158,7 @@ devDependencies: '@vitejs/plugin-vue-jsx': 3.0.1_vite@4.2.0+vue@3.2.47 '@vue/compiler-sfc': 3.2.47 autoprefixer: 10.4.14_postcss@8.4.21 + consola: 2.15.3 conventional-changelog-cli: 2.2.2 cross-env: 7.0.3 cz-git: 1.6.0 @@ -182,7 +174,6 @@ devDependencies: inquirer: 9.1.4 less: 4.1.3 lint-staged: 13.2.0 - npm-run-all: 4.1.5 picocolors: 1.0.0 postcss: 8.4.21 postcss-html: 1.5.0 @@ -198,7 +189,6 @@ devDependencies: stylelint-config-standard: 29.0.0_stylelint@14.16.1 stylelint-order: 6.0.3_stylelint@14.16.1 terser: 5.16.6 - ts-node: 10.9.1_sxidjv3cojnrggmso45tj7hldi typescript: 5.0.2 unplugin-vue-setup-extend-plus: 0.4.9 vite: 4.2.0_kfn5zdpk76mco3hnivyqwkouli @@ -2062,23 +2052,6 @@ packages: - supports-color dev: true - /@logicflow/core/1.2.1: - resolution: {integrity: sha512-m6/K7I85jFfCWcrNEQQpchomUWM4ZUjcOhHjsVhejnfpoEx7jke3tSJlh41LyT9hIUEIy7nxnphp5L4YB+InCA==} - dependencies: - '@types/mousetrap': 1.6.11 - mousetrap: 1.6.5 - preact: 10.12.1 - dev: false - - /@logicflow/extension/1.2.1: - resolution: {integrity: sha512-C006Y73sqe0x5ArWzTWc2YglhDNs+Ck/eXJnnaZ89uYqyVDdLgr/6RBjL8JAV41Lg7EQMB1yqmfUW53tCPTRtw==} - dependencies: - '@logicflow/core': 1.2.1 - ids: 1.0.0 - lodash-es: 4.17.21 - preact: 10.12.1 - dev: false - /@nodelib/fs.scandir/2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -2423,10 +2396,6 @@ packages: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} dev: true - /@types/mousetrap/1.6.11: - resolution: {integrity: sha512-F0oAily9Q9QQpv9JKxKn0zMKfOo36KHCW7myYsmUyf2t0g+sBTbG3UleTPoguHdE1z3GLFr3p7/wiOio52QFjQ==} - dev: false - /@types/node/10.17.60: resolution: {integrity: sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==} dev: true @@ -2467,10 +2436,6 @@ packages: resolution: {integrity: sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==} dev: true - /@types/showdown/2.0.0: - resolution: {integrity: sha512-70xBJoLv+oXjB5PhtA8vo7erjLDp9/qqI63SRHm4REKrwuPOLs8HhXwlZJBJaB4kC18cCZ1UUZ6Fb/PLFW4TCA==} - dev: true - /@types/sortablejs/1.15.1: resolution: {integrity: sha512-g/JwBNToh6oCTAwNS8UGVmjO7NLDKsejVhvE4x1eWiPTC3uCuNsa/TD4ssvX3du+MLiM+SHPNDuijp8y76JzLQ==} dev: true @@ -3609,11 +3574,6 @@ packages: engines: {node: '>= 12'} dev: true - /commander/9.5.0: - resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} - engines: {node: ^12.20.0 || >=14} - dev: false - /common-tags/1.8.2: resolution: {integrity: sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==} engines: {node: '>=4.0.0'} @@ -3929,17 +3889,6 @@ packages: - encoding dev: true - /cross-spawn/6.0.5: - resolution: {integrity: sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==} - engines: {node: '>=4.8'} - dependencies: - nice-try: 1.0.5 - path-key: 2.0.1 - semver: 5.7.1 - shebang-command: 1.2.0 - which: 1.3.1 - dev: true - /cross-spawn/7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} @@ -5561,10 +5510,6 @@ packages: resolution: {integrity: sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ==} dev: true - /ids/1.0.0: - resolution: {integrity: sha512-Zvtq1xUto4LttpstyOlFum8lKx+i1OmRfg+6A9drFS9iSZsDPMHG4Sof/qwNR4kCU7jBeWFPrY2ocHxiz7cCRw==} - dev: false - /ieee754/1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} dev: true @@ -6424,11 +6369,6 @@ packages: resolution: {integrity: sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==} dev: true - /memorystream/0.3.1: - resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==} - engines: {node: '>= 0.10.0'} - dev: true - /meow/8.1.2: resolution: {integrity: sha512-r85E3NdZ+mpYk1C6RjPFEMSE+s1iZMuHtsHAqY0DT3jZczl0diWUZ8g6oU7h0M9cD2EL+PzaYghhCLzR0ZNn5Q==} engines: {node: '>=10'} @@ -6600,10 +6540,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /mousetrap/1.6.5: - resolution: {integrity: sha512-QNo4kEepaIBwiT8CDhP98umTetp+JNfQYBWvC1pc6/OAibuXtRcxZ58Qz8skvEHYvURne/7R8T5VoOI7rDsEUA==} - dev: false - /ms/2.0.0: resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} dev: true @@ -6679,10 +6615,6 @@ packages: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} dev: true - /nice-try/1.0.5: - resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} - dev: true - /no-case/3.0.4: resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==} dependencies: @@ -6754,22 +6686,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /npm-run-all/4.1.5: - resolution: {integrity: sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==} - engines: {node: '>= 4'} - hasBin: true - dependencies: - ansi-styles: 3.2.1 - chalk: 2.4.2 - cross-spawn: 6.0.5 - memorystream: 0.3.1 - minimatch: 3.1.2 - pidtree: 0.3.1 - read-pkg: 3.0.0 - shell-quote: 1.8.0 - string.prototype.padend: 3.1.4 - dev: true - /npm-run-path/4.0.1: resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} engines: {node: '>=8'} @@ -7027,11 +6943,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /path-key/2.0.1: - resolution: {integrity: sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==} - engines: {node: '>=4'} - dev: true - /path-key/3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} @@ -7086,12 +6997,6 @@ packages: engines: {node: '>=8.6'} dev: true - /pidtree/0.3.1: - resolution: {integrity: sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==} - engines: {node: '>=0.10'} - hasBin: true - dev: true - /pidtree/0.6.0: resolution: {integrity: sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==} engines: {node: '>=0.10'} @@ -7259,10 +7164,6 @@ packages: posthtml-render: 1.4.0 dev: true - /preact/10.12.1: - resolution: {integrity: sha512-l8386ixSsBdbreOAkqtrwqHwdvR35ID8c3rKPa8lCWuO86dBi32QWHV4vfsZK1utLLFMvw+Z5Ad4XLkZzchscg==} - dev: false - /prelude-ls/1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -7766,13 +7667,6 @@ packages: resolution: {integrity: sha512-S4vJDjHHMBaiZuT9NPb616CSmLf618jawtv3sufLl6ivK8WocjAo58cXwbRV1cgqxH0Qbv+iUt6m05eqEa2IRA==} dev: false - /shebang-command/1.2.0: - resolution: {integrity: sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==} - engines: {node: '>=0.10.0'} - dependencies: - shebang-regex: 1.0.0 - dev: true - /shebang-command/2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -7780,27 +7674,11 @@ packages: shebang-regex: 3.0.0 dev: true - /shebang-regex/1.0.0: - resolution: {integrity: sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==} - engines: {node: '>=0.10.0'} - dev: true - /shebang-regex/3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} dev: true - /shell-quote/1.8.0: - resolution: {integrity: sha512-QHsz8GgQIGKlRi24yFc6a6lN69Idnx634w49ay6+jA5yFh7a1UY+4Rp6HPx/L/1zcEDPEij8cIsiqR6bQsE5VQ==} - dev: true - - /showdown/2.1.0: - resolution: {integrity: sha512-/6NVYu4U819R2pUIk79n67SYgJHWCce0a5xTP979WbNp0FL9MN1I1QK662IDU1b6JzKTvmhgI7T7JYIxBi3kMQ==} - hasBin: true - dependencies: - commander: 9.5.0 - dev: false - /side-channel/1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: @@ -8039,15 +7917,6 @@ packages: side-channel: 1.0.4 dev: true - /string.prototype.padend/3.1.4: - resolution: {integrity: sha512-67otBXoksdjsnXXRUq+KMVTdlVRZ2af422Y0aTyTjVaoQkGr3mxl2Bc5emi7dOQ3OGVVQQskmLEWwFXwommpNw==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.21.1 - dev: true - /string.prototype.trimend/1.0.6: resolution: {integrity: sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==} dependencies: @@ -8503,37 +8372,6 @@ packages: yn: 3.1.1 dev: true - /ts-node/10.9.1_sxidjv3cojnrggmso45tj7hldi: - resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} - hasBin: true - peerDependencies: - '@swc/core': '>=1.2.50' - '@swc/wasm': '>=1.2.50' - '@types/node': '*' - typescript: '>=2.7' - peerDependenciesMeta: - '@swc/core': - optional: true - '@swc/wasm': - optional: true - dependencies: - '@cspotcode/source-map-support': 0.8.1 - '@tsconfig/node10': 1.0.9 - '@tsconfig/node12': 1.0.11 - '@tsconfig/node14': 1.0.3 - '@tsconfig/node16': 1.0.3 - '@types/node': 18.15.3 - acorn: 8.8.2 - acorn-walk: 8.2.0 - arg: 4.1.3 - create-require: 1.1.1 - diff: 4.0.2 - make-error: 1.3.6 - typescript: 5.0.2 - v8-compile-cache-lib: 3.0.1 - yn: 3.1.1 - dev: true - /tslib/1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true diff --git a/src/components/FlowChart/index.ts b/src/components/FlowChart/index.ts deleted file mode 100644 index 3a73b290..00000000 --- a/src/components/FlowChart/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { withInstall } from '@/utils' -import flowChart from './src/FlowChart.vue' - -export const FlowChart = withInstall(flowChart) diff --git a/src/components/FlowChart/src/FlowChart.vue b/src/components/FlowChart/src/FlowChart.vue deleted file mode 100644 index 7e5011af..00000000 --- a/src/components/FlowChart/src/FlowChart.vue +++ /dev/null @@ -1,142 +0,0 @@ - - diff --git a/src/components/FlowChart/src/FlowChartToolbar.vue b/src/components/FlowChart/src/FlowChartToolbar.vue deleted file mode 100644 index b2b060a9..00000000 --- a/src/components/FlowChart/src/FlowChartToolbar.vue +++ /dev/null @@ -1,153 +0,0 @@ - - - diff --git a/src/components/FlowChart/src/adpterForTurbo.ts b/src/components/FlowChart/src/adpterForTurbo.ts deleted file mode 100644 index 7deaad39..00000000 --- a/src/components/FlowChart/src/adpterForTurbo.ts +++ /dev/null @@ -1,75 +0,0 @@ -const TurboType = { - SEQUENCE_FLOW: 1, - START_EVENT: 2, - END_EVENT: 3, - USER_TASK: 4, - SERVICE_TASK: 5, - EXCLUSIVE_GATEWAY: 6 -} - -function convertFlowElementToEdge(element) { - const { incoming, outgoing, properties, key } = element - const { text, startPoint, endPoint, pointsList, logicFlowType } = properties - const edge = { - id: key, - type: logicFlowType, - sourceNodeId: incoming[0], - targetNodeId: outgoing[0], - text, - startPoint, - endPoint, - pointsList, - properties: {} - } - const excludeProperties = ['startPoint', 'endPoint', 'pointsList', 'text', 'logicFlowType'] - Object.keys(element.properties).forEach((property) => { - if (excludeProperties.indexOf(property) === -1) { - edge.properties[property] = element.properties[property] - } - }) - return edge -} - -function convertFlowElementToNode(element) { - const { properties, key } = element - const { x, y, text, logicFlowType } = properties - const node = { - id: key, - type: logicFlowType, - x, - y, - text, - properties: {} - } - const excludeProperties = ['x', 'y', 'text', 'logicFlowType'] - Object.keys(element.properties).forEach((property) => { - if (excludeProperties.indexOf(property) === -1) { - node.properties[property] = element.properties[property] - } - }) - return node -} - -export function toLogicFlowData(data) { - const lfData: { - // TODO type - nodes: any[] - edges: any[] - } = { - nodes: [], - edges: [] - } - const list = data.flowElementList - list && - list.length > 0 && - list.forEach((element) => { - if (element.type === TurboType.SEQUENCE_FLOW) { - const edge = convertFlowElementToEdge(element) - lfData.edges.push(edge) - } else { - const node = convertFlowElementToNode(element) - lfData.nodes.push(node) - } - }) - return lfData -} diff --git a/src/components/FlowChart/src/config.ts b/src/components/FlowChart/src/config.ts deleted file mode 100644 index 53be5ad3..00000000 --- a/src/components/FlowChart/src/config.ts +++ /dev/null @@ -1,96 +0,0 @@ -export const nodeList = [ - { - text: '开始', - type: 'start', - class: 'node-start' - }, - { - text: '矩形', - type: 'rect', - class: 'node-rect' - }, - { - type: 'user', - text: '用户', - class: 'node-user' - }, - { - type: 'push', - text: '推送', - class: 'node-push' - }, - { - type: 'download', - text: '位置', - class: 'node-download' - }, - { - type: 'end', - text: '结束', - class: 'node-end' - } -] - -export const BpmnNode = [ - { - type: 'bpmn:startEvent', - text: '开始', - class: 'bpmn-start' - }, - { - type: 'bpmn:endEvent', - text: '结束', - class: 'bpmn-end' - }, - { - type: 'bpmn:exclusiveGateway', - text: '网关', - class: 'bpmn-exclusiveGateway' - }, - { - type: 'bpmn:userTask', - text: '用户', - class: 'bpmn-user' - } -] - -export function configDefaultDndPanel(lf) { - return [ - { - text: '选区', - icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAAH6ji2bAAAABGdBTUEAALGPC/xhBQAAAOVJREFUOBGtVMENwzAIjKP++2026ETdpv10iy7WFbqFyyW6GBywLCv5gI+Dw2Bluj1znuSjhb99Gkn6QILDY2imo60p8nsnc9bEo3+QJ+AKHfMdZHnl78wyTnyHZD53Zzx73MRSgYvnqgCUHj6gwdck7Zsp1VOrz0Uz8NbKunzAW+Gu4fYW28bUYutYlzSa7B84Fh7d1kjLwhcSdYAYrdkMQVpsBr5XgDGuXwQfQr0y9zwLda+DUYXLaGKdd2ZTtvbolaO87pdo24hP7ov16N0zArH1ur3iwJpXxm+v7oAJNR4JEP8DoAuSFEkYH7cAAAAASUVORK5CYII=', - callback: () => { - lf.updateEditConfig({ - stopMoveGraph: true - }) - } - }, - { - type: 'circle', - text: '开始', - icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAAH6ji2bAAAABGdBTUEAALGPC/xhBQAAAnBJREFUOBGdVL1rU1EcPfdGBddmaZLiEhdx1MHZQXApraCzQ7GKLgoRBxMfcRELuihWKcXFRcEWF8HBf0DdDCKYRZpnl7p0svLe9Zzbd29eQhTbC8nv+9zf130AT63jvooOGS8Vf9Nt5zxba7sXQwODfkWpkbjTQfCGUd9gIp3uuPP8bZ946g56dYQvnBg+b1HB8VIQmMFrazKcKSvFW2dQTxJnJdQ77urmXWOMBCmXM2Rke4S7UAW+/8ywwFoewmBps2tu7mbTdp8VMOkIRAkKfrVawalJTtIliclFbaOBqa0M2xImHeVIfd/nKAfVq/LGnPss5Kh00VEdSzfwnBXPUpmykNss4lUI9C1ga+8PNrBD5YeqRY2Zz8PhjooIbfJXjowvQJBqkmEkVnktWhwu2SM7SMx7Cj0N9IC0oQXRo8xwAGzQms+xrB/nNSUWVveI48ayrFGyC2+E2C+aWrZHXvOuz+CiV6iycWe1Rd1Q6+QUG07nb5SbPrL4426d+9E1axKjY3AoRrlEeSQo2Eu0T6BWAAr6COhTcWjRaYfKG5csnvytvUr/WY4rrPMB53Uo7jZRjXaG6/CFfNMaXEu75nG47X+oepU7PKJvvzGDY1YLSKHJrK7vFUwXKkaxwhCW3u+sDFMVrIju54RYYbFKpALZAo7sB6wcKyyrd+aBMryMT2gPyD6GsQoRFkGHr14TthZni9ck0z+Pnmee460mHXbRAypKNy3nuMdrWgVKj8YVV8E7PSzp1BZ9SJnJAsXdryw/h5ctboUVi4AFiCd+lQaYMw5z3LGTBKjLQOeUF35k89f58Vv/tGh+l+PE/wG0rgfIUbZK5AAAAABJRU5ErkJggg==' - }, - { - type: 'rect', - text: '用户任务', - icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAEFVwZaAAAABGdBTUEAALGPC/xhBQAAAqlJREFUOBF9VM9rE0EUfrMJNUKLihGbpLGtaCOIR8VjQMGDePCgCCIiCNqzCAp2MyYUCXhUtF5E0D+g1t48qAd7CCLqQUQKEWkStcEfVGlLdp/fm3aW2QQdyLzf33zz5m2IsAZ9XhDpyaaIZkTS4ASzK41TFao88GuJ3hsr2pAbipHxuSYyKRugagICGANkfFnNh3HeE2N0b3nN2cgnpcictw5veJIzxmDamSlxxQZicq/mflxhbaH8BLRbuRwNtZp0JAhoplVRUdzmCe/vO27wFuuA3S5qXruGdboy5/PRGFsbFGKo/haRtQHIrM83bVeTrOgNhZReWaYGnE4aUQgTJNvijJFF4jQ8BxJE5xfKatZWmZcTQ+BVgh7s8SgPlCkcec4mGTmieTP4xd7PcpIEg1TX6gdeLW8rTVMVLVvb7ctXoH0Cydl2QOPJBG21STE5OsnbweVYzAnD3A7PVILuY0yiiyDwSm2g441r6rMSgp6iK42yqroI2QoXeJVeA+YeZSa47gZdXaZWQKTrG93rukk/l2Al6Kzh5AZEl7dDQy+JjgFahQjRopSxPbrbvK7GRe9ePWBo1wcU7sYrFZtavXALwGw/7Dnc50urrHJuTPSoO2IMV3gUQGNg87IbSOIY9BpiT9HV7FCZ94nPXb3MSnwHn/FFFE1vG6DTby+r31KAkUktB3Qf6ikUPWxW1BkXSPQeMHHiW0+HAd2GelJsZz1OJegCxqzl+CLVHa/IibuHeJ1HAKzhuDR+ymNaRFM+4jU6UWKXorRmbyqkq/D76FffevwdCp+jN3UAN/C9JRVTDuOxC/oh+EdMnqIOrlYteKSfadVRGLJFJPSB/ti/6K8f0CNymg/iH2gO/f0DwE0yjAFO6l8JaR5j0VPwPwfaYHqOqrCI319WzwhwzNW/aQAAAABJRU5ErkJggg==', - cls: 'important-node' - }, - { - type: 'rect', - text: '系统任务', - icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAEFVwZaAAAABGdBTUEAALGPC/xhBQAAAqlJREFUOBF9VM9rE0EUfrMJNUKLihGbpLGtaCOIR8VjQMGDePCgCCIiCNqzCAp2MyYUCXhUtF5E0D+g1t48qAd7CCLqQUQKEWkStcEfVGlLdp/fm3aW2QQdyLzf33zz5m2IsAZ9XhDpyaaIZkTS4ASzK41TFao88GuJ3hsr2pAbipHxuSYyKRugagICGANkfFnNh3HeE2N0b3nN2cgnpcictw5veJIzxmDamSlxxQZicq/mflxhbaH8BLRbuRwNtZp0JAhoplVRUdzmCe/vO27wFuuA3S5qXruGdboy5/PRGFsbFGKo/haRtQHIrM83bVeTrOgNhZReWaYGnE4aUQgTJNvijJFF4jQ8BxJE5xfKatZWmZcTQ+BVgh7s8SgPlCkcec4mGTmieTP4xd7PcpIEg1TX6gdeLW8rTVMVLVvb7ctXoH0Cydl2QOPJBG21STE5OsnbweVYzAnD3A7PVILuY0yiiyDwSm2g441r6rMSgp6iK42yqroI2QoXeJVeA+YeZSa47gZdXaZWQKTrG93rukk/l2Al6Kzh5AZEl7dDQy+JjgFahQjRopSxPbrbvK7GRe9ePWBo1wcU7sYrFZtavXALwGw/7Dnc50urrHJuTPSoO2IMV3gUQGNg87IbSOIY9BpiT9HV7FCZ94nPXb3MSnwHn/FFFE1vG6DTby+r31KAkUktB3Qf6ikUPWxW1BkXSPQeMHHiW0+HAd2GelJsZz1OJegCxqzl+CLVHa/IibuHeJ1HAKzhuDR+ymNaRFM+4jU6UWKXorRmbyqkq/D76FffevwdCp+jN3UAN/C9JRVTDuOxC/oh+EdMnqIOrlYteKSfadVRGLJFJPSB/ti/6K8f0CNymg/iH2gO/f0DwE0yjAFO6l8JaR5j0VPwPwfaYHqOqrCI319WzwhwzNW/aQAAAABJRU5ErkJggg==', - cls: 'import_icon' - }, - { - type: 'diamond', - text: '条件判断', - icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAAHeEJUAAAAABGdBTUEAALGPC/xhBQAAAvVJREFUOBGNVEFrE0EU/mY3bQoiFlOkaUJrQUQoWMGePLX24EH0IIoHKQiCV0G8iE1covgLiqA/QTzVm1JPogc9tIJYFaQtlhQxqYjSpunu+L7JvmUTU3AgmTfvffPNN++9WSA1DO182f6xwILzD5btfAoQmwL5KJEwiQyVbSVZ0IgRyV6PTpIJ81E5ZvqfHQR0HUOBHW4L5Et2kQ6Zf7iAOhTFAA8s0pEP7AXO1uAA52SbqGk6h/6J45LaLhO64ByfcUzM39V7ZiAdS2yCePPEIQYvTUHqM/n7dgQNfBKWPjpF4ISk8q3J4nB11qw6X8l+FsF3EhlkEMfrjIer3wJTLwS2aCNcj4DbGxXTw00JmAuO+Ni6bBxVUCvS5d9aa04+so4pHW5jLTywuXAL7jJ+D06sl82Sgl2JuVBQn498zkc2bGKxULHjCnSMadBKYDYYHAtsby1EQ5lNGrQd4Y3v4Zo0XdGEmDno46yCM9Tk+RiJmUYHS/aXHPNTcjxcbTFna000PFJHIVZ5lFRqRpJWk9/+QtlOUYJj9HG5pVFEU7zqIYDVsw2s+AJaD8wTd2umgSCCyUxgGsS1Y6TBwXQQTFuZaHcd8gAGioE90hlsY+wMcs30RduYtxanjMGal8H5dMW67dmT1JFtYUEe8LiQLRsPZ6IIc7A4J5tqco3T0pnv/4u0kyzrYUq7gASuEyI8VXKvB9Odytv6jS/PNaZBln0nioJG/AVQRZvApOdhjj3Jt8QC8Im09SafwdBdvIpztpxWxpeKCC+EsFdS8DCyuCn2munFpL7ctHKp+Xc5cMybeIyMAN33SPL3ZR9QV1XVwLyzHm6Iv0/yeUuUb7PPlZC4D4HZkeu6dpF4v9j9MreGtMbxMMRLIcjJic9yHi7WQ3yVKzZVWUr5UrViJvn1FfUlwe/KYVfYyWRLSGNu16hR01U9IacajXPei0wx/5BqgInvJN+MMNtNme7ReU9SBbgntovn0kKHpFg7UogZvaZiOue/q1SBo9ktHzQAAAAASUVORK5CYII=' - }, - { - type: 'circle', - text: '结束', - icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAAH6ji2bAAAABGdBTUEAALGPC/xhBQAAA1BJREFUOBFtVE1IVUEYPXOf+tq40Y3vPcmFIdSjIorWoRG0ERWUgnb5FwVhYQSl72oUoZAboxKNFtWiwKRN0M+jpfSzqJAQclHo001tKkjl3emc8V69igP3znzfnO/M9zcDcKT67azmjYWTwl9Vn7Vumeqzj1DVb6cleQY4oAVnIOPb+mKAGxQmKI5CWNJ2aLPatxWa3aB9K7/fB+/Z0jUF6TmMlFLQqrkECWQzOZxYGjTlOl8eeKaIY5yHnFn486xBustDjWT6dG7pmjHOJd+33t0iitTPkK6tEvjxq4h2MozQ6WFSX/LkDUGfFwfhEZj1Auz/U4pyAi5Sznd7uKzznXeVHlI/Aywmk6j7fsUsEuCGADrWARXXwjxWQsUbIupDHJI7kF5dRktg0eN81IbiZXiTESic50iwS+t1oJgL83jAiBupLDCQqwziaWSoAFSeIR3P5Xv5az00wyIn35QRYTwdSYbz8pH8fxUUAtxnFvYmEmgI0wYXUXcCCSpeEVpXlsRhBnCEATxWylL9+EKCAYhe1NGstUa6356kS9NVvt3DU2fd+Wtbm/+lSbylJqsqkSm9CRhvoJVlvKPvF1RKY/FcPn5j4UfIMLn8D4UYb54BNsilTDXKnF4CfTobA0FpoW/LSp306wkXM+XaOJhZaFkcNM82ASNAWMrhrUbRfmyeI1FvRBTpN06WKxa9BK0o2E4Pd3zfBBEwPsv9sQBnmLVbLEIZ/Xe9LYwJu/Er17W6HYVBc7vmuk0xUQ+pqxdom5Fnp55SiytXLPYoMXNM4u4SNSCFWnrVIzKG3EGyMXo6n/BQOe+bX3FClY4PwydVhthOZ9NnS+ntiLh0fxtlUJHAuGaFoVmttpVMeum0p3WEXbcll94l1wM/gZ0Ccczop77VvN2I7TlsZCsuXf1WHvWEhjO8DPtyOVg2/mvK9QqboEth+7pD6NUQC1HN/TwvydGBARi9MZSzLE4b8Ru3XhX2PBxf8E1er2A6516o0w4sIA+lwURhAON82Kwe2iDAC1Watq4XHaGQ7skLcFOtI5lDxuM2gZe6WFIotPAhbaeYlU4to5cuarF1QrcZ/lwrLaCJl66JBocYZnrNlvm2+MBCTmUymPrYZVbjdlr/BxlMjmNmNI3SAAAAAElFTkSuQmCC' - } - ] -} diff --git a/src/components/FlowChart/src/enum.ts b/src/components/FlowChart/src/enum.ts deleted file mode 100644 index 26e24960..00000000 --- a/src/components/FlowChart/src/enum.ts +++ /dev/null @@ -1,11 +0,0 @@ -export enum ToolbarTypeEnum { - ZOOM_IN = 'zoomIn', - ZOOM_OUT = 'zoomOut', - RESET_ZOOM = 'resetZoom', - - UNDO = 'undo', - REDO = 'redo', - - SNAPSHOT = 'snapshot', - VIEW_DATA = 'viewData' -} diff --git a/src/components/FlowChart/src/types.ts b/src/components/FlowChart/src/types.ts deleted file mode 100644 index 5e42aedb..00000000 --- a/src/components/FlowChart/src/types.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NodeConfig } from '@logicflow/core' -import { ToolbarTypeEnum } from './enum' - -export interface NodeItem extends NodeConfig { - icon: string -} - -export interface ToolbarConfig { - type?: string | ToolbarTypeEnum - tooltip?: string | boolean - icon?: string - disabled?: boolean - separate?: boolean -} diff --git a/src/components/FlowChart/src/useFlowContext.ts b/src/components/FlowChart/src/useFlowContext.ts deleted file mode 100644 index da348e5c..00000000 --- a/src/components/FlowChart/src/useFlowContext.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type LogicFlow from '@logicflow/core' - -import { provide, inject } from 'vue' - -const key = Symbol('flow-chart') - -type Instance = { - logicFlow: LogicFlow -} - -export function createFlowChartContext(instance: Instance) { - provide(key, instance) -} - -export function useFlowChartContext(): Instance { - return inject(key) as Instance -} diff --git a/src/components/Verifition/index.ts b/src/components/Verifition/index.ts new file mode 100644 index 00000000..ae0a248e --- /dev/null +++ b/src/components/Verifition/index.ts @@ -0,0 +1,4 @@ +import { withInstall } from '@/utils/index' +import verify from './src/Verify.vue' + +export const Verify = withInstall(verify) diff --git a/src/components/Verifition/src/Verify.vue b/src/components/Verifition/src/Verify.vue new file mode 100644 index 00000000..9b6014bf --- /dev/null +++ b/src/components/Verifition/src/Verify.vue @@ -0,0 +1,452 @@ + + + diff --git a/src/components/Verifition/src/Verify/VerifyPoints.vue b/src/components/Verifition/src/Verify/VerifyPoints.vue new file mode 100644 index 00000000..8e641aad --- /dev/null +++ b/src/components/Verifition/src/Verify/VerifyPoints.vue @@ -0,0 +1,250 @@ + + diff --git a/src/components/Verifition/src/Verify/VerifySlide.vue b/src/components/Verifition/src/Verify/VerifySlide.vue new file mode 100644 index 00000000..08da64bd --- /dev/null +++ b/src/components/Verifition/src/Verify/VerifySlide.vue @@ -0,0 +1,357 @@ + + diff --git a/src/components/Verifition/src/Verify/index.ts b/src/components/Verifition/src/Verify/index.ts new file mode 100644 index 00000000..0daa63a5 --- /dev/null +++ b/src/components/Verifition/src/Verify/index.ts @@ -0,0 +1,4 @@ +import VerifySlide from './VerifySlide.vue' +import VerifyPoints from './VerifyPoints.vue' + +export { VerifySlide, VerifyPoints } diff --git a/src/components/Verifition/src/utils/ase.ts b/src/components/Verifition/src/utils/ase.ts new file mode 100644 index 00000000..d2e6b988 --- /dev/null +++ b/src/components/Verifition/src/utils/ase.ts @@ -0,0 +1,14 @@ +import CryptoJS from 'crypto-js' +/** + * @word 要加密的内容 + * @keyWord String 服务器随机返回的关键字 + * */ +export function aesEncrypt(word, keyWord = 'XwKsGlMcdPMEhR1B') { + const key = CryptoJS.enc.Utf8.parse(keyWord) + const srcs = CryptoJS.enc.Utf8.parse(word) + const encrypted = CryptoJS.AES.encrypt(srcs, key, { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7 + }) + return encrypted.toString() +} diff --git a/src/components/Verifition/src/utils/util.ts b/src/components/Verifition/src/utils/util.ts new file mode 100644 index 00000000..15c16270 --- /dev/null +++ b/src/components/Verifition/src/utils/util.ts @@ -0,0 +1,97 @@ +export function resetSize(vm) { + let img_width, img_height, bar_width, bar_height //图片的宽度、高度,移动条的宽度、高度 + const EmployeeWindow = window as any + const parentWidth = vm.$el.parentNode.offsetWidth || EmployeeWindow.offsetWidth + const parentHeight = vm.$el.parentNode.offsetHeight || EmployeeWindow.offsetHeight + if (vm.imgSize.width.indexOf('%') != -1) { + img_width = (parseInt(vm.imgSize.width) / 100) * parentWidth + 'px' + } else { + img_width = vm.imgSize.width + } + + if (vm.imgSize.height.indexOf('%') != -1) { + img_height = (parseInt(vm.imgSize.height) / 100) * parentHeight + 'px' + } else { + img_height = vm.imgSize.height + } + + if (vm.barSize.width.indexOf('%') != -1) { + bar_width = (parseInt(vm.barSize.width) / 100) * parentWidth + 'px' + } else { + bar_width = vm.barSize.width + } + + if (vm.barSize.height.indexOf('%') != -1) { + bar_height = (parseInt(vm.barSize.height) / 100) * parentHeight + 'px' + } else { + bar_height = vm.barSize.height + } + + return { imgWidth: img_width, imgHeight: img_height, barWidth: bar_width, barHeight: bar_height } +} + +export const _code_chars = [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'o', + 'p', + 'q', + 'r', + 's', + 't', + 'u', + 'v', + 'w', + 'x', + 'y', + 'z', + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G', + 'H', + 'I', + 'J', + 'K', + 'L', + 'M', + 'N', + 'O', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'U', + 'V', + 'W', + 'X', + 'Y', + 'Z' +] +export const _code_color1 = ['#fffff0', '#f0ffff', '#f0fff0', '#fff0f0'] +export const _code_color2 = ['#FF0033', '#006699', '#993366', '#FF9900', '#66CC66', '#FF33CC'] diff --git a/src/components/Verify/index.ts b/src/components/Verify/index.ts deleted file mode 100644 index 98654f27..00000000 --- a/src/components/Verify/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { withInstall } from '@/utils' -import basicDragVerify from './src/DragVerify.vue' -import rotateDragVerify from './src/ImgRotate.vue' - -export const BasicDragVerify = withInstall(basicDragVerify) -export const RotateDragVerify = withInstall(rotateDragVerify) -export * from './src/typing' diff --git a/src/components/Verify/src/DragVerify.vue b/src/components/Verify/src/DragVerify.vue deleted file mode 100644 index f699930f..00000000 --- a/src/components/Verify/src/DragVerify.vue +++ /dev/null @@ -1,365 +0,0 @@ - - diff --git a/src/components/Verify/src/ImgRotate.vue b/src/components/Verify/src/ImgRotate.vue deleted file mode 100644 index fa24cc68..00000000 --- a/src/components/Verify/src/ImgRotate.vue +++ /dev/null @@ -1,214 +0,0 @@ - - diff --git a/src/components/Verify/src/props.ts b/src/components/Verify/src/props.ts deleted file mode 100644 index 9122e1f8..00000000 --- a/src/components/Verify/src/props.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { useI18n } from '@/hooks/web/useI18n' - -const { t } = useI18n() -export const basicProps = { - value: { - type: Boolean as PropType, - default: false - }, - - isSlot: { - type: Boolean as PropType, - default: false - }, - - text: { - type: [String] as PropType, - default: t('component.verify.dragText') - }, - successText: { - type: [String] as PropType, - default: t('component.verify.successText') - }, - height: { - type: [Number, String] as PropType, - default: 40 - }, - - width: { - type: [Number, String] as PropType, - default: 220 - }, - - circle: { - type: Boolean as PropType, - default: false - }, - - wrapStyle: { - type: Object as PropType, - default: () => ({}) - }, - contentStyle: { - type: Object as PropType, - default: () => ({}) - }, - barStyle: { - type: Object as PropType, - default: () => ({}) - }, - actionStyle: { - type: Object as PropType, - default: () => ({}) - } -} - -export const rotateProps = { - ...basicProps, - src: { - type: String as PropType - }, - - imgWidth: { - type: Number as PropType, - default: 260 - }, - - imgWrapStyle: { - type: Object as PropType, - default: () => ({}) - }, - - minDegree: { - type: Number as PropType, - default: 90 - }, - - maxDegree: { - type: Number as PropType, - default: 270 - }, - - diffDegree: { - type: Number as PropType, - default: 20 - } -} diff --git a/src/components/Verify/src/typing.ts b/src/components/Verify/src/typing.ts deleted file mode 100644 index 6ff148e4..00000000 --- a/src/components/Verify/src/typing.ts +++ /dev/null @@ -1,14 +0,0 @@ -export interface DragVerifyActionType { - resume: () => void -} - -export interface PassingData { - isPassing: boolean - time: number -} - -export interface MoveData { - event: MouseEvent | TouchEvent - moveDistance: number - moveX: number -} diff --git a/src/types/axios.d.ts b/src/types/axios.d.ts index 0d8ceb6a..5b5be707 100644 --- a/src/types/axios.d.ts +++ b/src/types/axios.d.ts @@ -35,11 +35,11 @@ export interface RetryRequest { count: number waitTime: number } + export interface Result { code: number - type: 'success' | 'error' | 'warning' - message: string - result: T + msg: string + data: T } // multipart/form-data: upload file diff --git a/src/types/config.d.ts b/src/types/config.d.ts index 5ba8bad3..58987f9a 100644 --- a/src/types/config.d.ts +++ b/src/types/config.d.ts @@ -159,6 +159,10 @@ export interface GlobConfig { urlPrefix?: string // Project abbreviation shortName: string + // 租户开关 + tenantEnable: string + // 验证码开关 + captchaEnable: string } export interface GlobEnvConfig { // Site title @@ -171,4 +175,8 @@ export interface GlobEnvConfig { VITE_GLOB_APP_SHORT_NAME: string // Upload url VITE_GLOB_UPLOAD_URL?: string + // 租户开关 + VITE_GLOB_APP_TENANT_ENABLE: string + // 验证码开关 + VITE_GLOB_APP_CAPTCHA_ENABLE: string } diff --git a/src/types/index.d.ts b/src/types/index.d.ts index d721cba0..7e4384fc 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -8,6 +8,16 @@ declare interface PromiseFn { declare type RefType = T | null +declare interface PageParam { + pageSize?: number + pageNo?: number +} + +declare interface PageResult { + list: T[] + total: number +} + declare type LabelValueOptions = { label: string value: any diff --git a/src/types/store.d.ts b/src/types/store.d.ts index f4e946d2..5b7f9624 100644 --- a/src/types/store.d.ts +++ b/src/types/store.d.ts @@ -1,6 +1,5 @@ import { ErrorTypeEnum } from '@/enums/exceptionEnum' import { MenuModeEnum, MenuTypeEnum } from '@/enums/menuEnum' -import { RoleInfo } from '@/api/sys/model/userModel' // Lock screen information export interface LockInfo { @@ -37,7 +36,7 @@ export interface UserInfo { avatar: string desc?: string homePath?: string - roles: RoleInfo[] + roles: string[] } export interface BeforeMiniState { @@ -46,3 +45,8 @@ export interface BeforeMiniState { menuMode?: MenuModeEnum menuType?: MenuTypeEnum } + +export interface DictState { + dictMap: Map + isSetDict: boolean +} diff --git a/src/types/vue-router.d.ts b/src/types/vue-router.d.ts index 92a890e0..1311e069 100644 --- a/src/types/vue-router.d.ts +++ b/src/types/vue-router.d.ts @@ -5,43 +5,47 @@ export {} declare module 'vue-router' { interface RouteMeta extends Record { orderNo?: number - // title + // 路由title 一般必填 title: string - // dynamic router level. + // 动态路由可打开Tab页数 dynamicLevel?: number - // dynamic router real route path (For performance). + // 动态路由的实际Path, 即去除路由的动态部分; realPath?: string - // Whether to ignore permissions + // 是否忽略权限,只在权限模式为Role的时候有效 ignoreAuth?: boolean - // role info + // 可以访问的角色,只在权限模式为Role的时候有效 roles?: RoleEnum[] - // Whether not to cache + // 是否忽略KeepAlive缓存 ignoreKeepAlive?: boolean - // Is it fixed on tab + // 是否固定标签 affix?: boolean - // icon on tab + // 图标,也是菜单图标 icon?: string + // 内嵌iframe的地址 frameSrc?: string - // current page transition + // 指定该路由切换的动画名 transitionName?: string - // Whether the route has been dynamically added + // 隐藏该路由在面包屑上面的显示 hideBreadcrumb?: boolean - // Hide submenu + // 如果该路由会携带参数,且需要在tab页上面显示。则需要设置为true + carryParam?: boolean + // 隐藏所有子菜单 hideChildrenInMenu?: boolean // Carrying parameters carryParam?: boolean // Used internally to mark single-level menus single?: boolean - // Currently active menu + // 当前激活的菜单。用于配置详情页时左侧激活的菜单路径 currentActiveMenu?: string - // Never show in tab + // 当前路由不再标签页显示 hideTab?: boolean - // Never show in menu + // 当前路由不再菜单显示 hideMenu?: boolean - isLink?: boolean - // only build for Menu + // 菜单排序,只对第一级有效 + orderNo?: number + // 忽略路由。用于在ROUTE_MAPPING以及BACK权限模式下,生成对应的菜单而忽略路由。2.5.3以上版本有效 ignoreRoute?: boolean - // Hide path for children + // 是否在子级菜单的完整path中忽略本级path。2.5.3以上版本有效 hidePathForChildren?: boolean } } diff --git a/src/utils/http/axios/Axios.ts b/src/utils/http/axios/Axios.ts index 041c110d..9d8d436f 100644 --- a/src/utils/http/axios/Axios.ts +++ b/src/utils/http/axios/Axios.ts @@ -8,11 +8,19 @@ import { isFunction } from '@/utils/is' import { cloneDeep } from 'lodash-es' import { ContentTypeEnum } from '@/enums/httpEnum' import { RequestEnum } from '@/enums/httpEnum' +import { downloadByData } from '@/utils/file/download' +import { useGlobSetting } from '@/hooks/setting' +import { setAccessToken, getRefreshToken, getTenantId, getAccessToken } from '@/utils/auth' export * from './axiosTransform' +const globSetting = useGlobSetting() +// 请求队列 +let requestList: any[] = [] +// 是否正在刷新中 +let isRefreshToken = false /** - * @description: axios module + * @description: axios 模块 */ export class VAxios { private axiosInstance: AxiosInstance @@ -25,7 +33,7 @@ export class VAxios { } /** - * @description: Create axios instance + * @description: 创建 axios 实例 */ private createAxios(config: CreateAxiosOptions): void { this.axiosInstance = axios.create(config) @@ -39,9 +47,13 @@ export class VAxios { getAxios(): AxiosInstance { return this.axiosInstance } + refreshToken() { + axios.defaults.headers.common['tenant-id'] = getTenantId() as number + return axios.post(globSetting.apiUrl + '/system/auth/refresh-token?refreshToken=' + getRefreshToken()) + } /** - * @description: Reconfigure axios + * @description: 重新配置 axios */ configAxios(config: CreateAxiosOptions) { if (!this.axiosInstance) { @@ -51,7 +63,7 @@ export class VAxios { } /** - * @description: Set general header + * @description: 设置通用标题 */ setHeader(headers: any): void { if (!this.axiosInstance) { @@ -86,13 +98,54 @@ export class VAxios { return config }, undefined) - // Request interceptor error capture + // 请求拦截器错误捕获 requestInterceptorsCatch && isFunction(requestInterceptorsCatch) && this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch) - // Response result interceptor processing - this.axiosInstance.interceptors.response.use((res: AxiosResponse) => { + // 响应结果拦截器处理 + this.axiosInstance.interceptors.response.use(async (res: AxiosResponse) => { + const config = res.config + if (res.data.code === 401) { + // 如果未认证,并且未进行刷新令牌,说明可能是访问令牌过期了 + if (!isRefreshToken) { + isRefreshToken = true + // 1. 获取到刷新token + if (getRefreshToken()) { + // 2. 进行刷新访问令牌 + console.info('进行刷新访问令牌') + try { + const refreshTokenRes = await this.refreshToken() + // 2.1 刷新成功,则回放队列的请求 + 当前请求 + setAccessToken(refreshTokenRes.data.data) + ;(config as Recordable).headers.Authorization = 'Bearer ' + getAccessToken() + requestList.forEach((cb: any) => { + cb() + }) + requestList = [] + // TODO + // res = await Promise.all([this.axiosInstance(config)])[0] + console.info('刷新令牌end', res) + } catch (e) { + console.info(e) + requestList.forEach((cb: any) => { + cb() + }) + } finally { + requestList = [] + isRefreshToken = false + } + } + } else { + // 添加到队列,等待刷新获取到新的令牌 + return new Promise((resolve) => { + requestList.push(() => { + ;(config as Recordable).headers.Authorization = 'Bearer ' + getAccessToken() // 让每个请求携带自定义token 请根据实际情况自行修改 + resolve(this.axiosInstance(config)) + }) + }) + } + } res && axiosCanceler.removePending(res.config) if (responseInterceptors && isFunction(responseInterceptors)) { res = responseInterceptors(res) @@ -100,7 +153,7 @@ export class VAxios { return res }, undefined) - // Response result interceptor error capture + // 响应结果拦截器错误捕获 responseInterceptorsCatch && isFunction(responseInterceptorsCatch) && this.axiosInstance.interceptors.response.use(undefined, (error) => { @@ -110,7 +163,7 @@ export class VAxios { } /** - * @description: File Upload + * @description: 文件上传 */ uploadFile(config: AxiosRequestConfig, params: UploadFileParams) { const formData = new window.FormData() @@ -142,12 +195,13 @@ export class VAxios { data: formData, headers: { 'Content-type': ContentTypeEnum.FORM_DATA, + // @ts-ignore ignoreCancelToken: true } }) } - // support form-data + // 支持表单数据 supportFormData(config: AxiosRequestConfig) { const headers = config.headers || this.options.headers const contentType = headers?.['Content-Type'] || headers?.['content-type'] @@ -182,6 +236,94 @@ export class VAxios { return this.request({ ...config, method: 'DELETE' }, options) } + download(config: AxiosRequestConfig, title: string, options?: RequestOptions): Promise { + let conf: CreateAxiosOptions = cloneDeep({ + ...config, + method: 'GET', + responseType: 'blob' + }) + const transform = this.getTransform() + + const { requestOptions } = this.options + + const opt: RequestOptions = Object.assign({}, requestOptions, options) + + const { beforeRequestHook, requestCatchHook } = transform || {} + + if (beforeRequestHook && isFunction(beforeRequestHook)) { + conf = beforeRequestHook(conf, opt) + } + conf.requestOptions = opt + + conf = this.supportFormData(conf) + + return new Promise((resolve, reject) => { + this.axiosInstance + .request>(conf) + .then((res: AxiosResponse) => { + resolve(res as unknown as Promise) + // download file + if (typeof res != undefined) { + downloadByData(res?.data as unknown as BlobPart, title) + } + }) + .catch((e: Error | AxiosError) => { + if (requestCatchHook && isFunction(requestCatchHook)) { + reject(requestCatchHook(e, opt)) + return + } + if (axios.isAxiosError(e)) { + // rewrite error message from axios in here + } + reject(e) + }) + }) + } + + export(config: AxiosRequestConfig, title: string, options?: RequestOptions): Promise { + let conf: CreateAxiosOptions = cloneDeep({ + ...config, + method: 'POST', + responseType: 'blob' + }) + const transform = this.getTransform() + + const { requestOptions } = this.options + + const opt: RequestOptions = Object.assign({}, requestOptions, options) + + const { beforeRequestHook, requestCatchHook } = transform || {} + + if (beforeRequestHook && isFunction(beforeRequestHook)) { + conf = beforeRequestHook(conf, opt) + } + conf.requestOptions = opt + + conf = this.supportFormData(conf) + + return new Promise((resolve, reject) => { + this.axiosInstance + .request>(conf) + .then((res: AxiosResponse) => { + resolve(res as unknown as Promise) + // download file + if (typeof res != undefined) { + downloadByData(res?.data as unknown as BlobPart, title) + } + }) + .catch((e: Error | AxiosError) => { + if (requestCatchHook && isFunction(requestCatchHook)) { + reject(requestCatchHook(e, opt)) + return + } + if (axios.isAxiosError(e)) { + // rewrite error message from axios in here + } + reject(e) + }) + }) + } + request(config: AxiosRequestConfig, options?: RequestOptions): Promise { let conf: CreateAxiosOptions = cloneDeep(config) // cancelToken 如果被深拷贝,会导致最外层无法使用cancel方法来取消请求 @@ -223,7 +365,7 @@ export class VAxios { return } if (axios.isAxiosError(e)) { - // rewrite error message from axios in here + // 在此处重写来自 axios 的错误消息 } reject(e) }) diff --git a/src/utils/http/axios/axiosCancel.ts b/src/utils/http/axios/axiosCancel.ts index e874af50..e472149b 100644 --- a/src/utils/http/axios/axiosCancel.ts +++ b/src/utils/http/axios/axiosCancel.ts @@ -9,7 +9,7 @@ export const getPendingUrl = (config: InternalAxiosRequestConfig) => [config.met export class AxiosCanceler { /** - * Add request + * 添加请求 * @param {Object} config */ addPending(config: InternalAxiosRequestConfig) { @@ -19,14 +19,14 @@ export class AxiosCanceler { config.cancelToken || new axios.CancelToken((cancel) => { if (!pendingMap.has(url)) { - // If there is no current request in pending, add it + // 如果当前没有待处理的请求,添加它 pendingMap.set(url, cancel) } }) } /** - * @description: Clear all pending + * @description: 清除所有待处理 */ removeAllPending() { pendingMap.forEach((cancel) => { @@ -36,15 +36,14 @@ export class AxiosCanceler { } /** - * Removal request + * 删除请求 * @param {Object} config */ removePending(config: InternalAxiosRequestConfig) { const url = getPendingUrl(config) if (pendingMap.has(url)) { - // If there is a current request identifier in pending, - // the current request needs to be cancelled and removed + // 如果有当前请求标识符处于pending状态,则需要取消当前请求并移除 const cancel = pendingMap.get(url) cancel && cancel(url) pendingMap.delete(url) diff --git a/src/utils/http/axios/axiosTransform.ts b/src/utils/http/axios/axiosTransform.ts index 453ed10d..dab10e61 100644 --- a/src/utils/http/axios/axiosTransform.ts +++ b/src/utils/http/axios/axiosTransform.ts @@ -12,8 +12,7 @@ export interface CreateAxiosOptions extends AxiosRequestConfig { export abstract class AxiosTransform { /** - * @description: Process configuration before request - * @description: Process configuration before request + * @description: 请求前的流程配置 */ beforeRequestHook?: (config: AxiosRequestConfig, options: RequestOptions) => AxiosRequestConfig diff --git a/src/utils/http/axios/checkStatus.ts b/src/utils/http/axios/checkStatus.ts index 99a40e02..730aa825 100644 --- a/src/utils/http/axios/checkStatus.ts +++ b/src/utils/http/axios/checkStatus.ts @@ -24,7 +24,7 @@ export function checkStatus(status: number, msg: string, errorMessageMode: Error // Jump to the login page if not logged in, and carry the path of the current page // Return to the current page after successful login. This step needs to be operated on the login page. case 401: - userStore.setToken(undefined) + userStore.setAccessToken(undefined) errMessage = msg || t('sys.api.errMsg401') if (stp === SessionTimeoutProcessingEnum.PAGE_COVERAGE) { userStore.setSessionTimeout(true) diff --git a/src/utils/http/axios/helper.ts b/src/utils/http/axios/helper.ts index fe25932c..902d3c05 100644 --- a/src/utils/http/axios/helper.ts +++ b/src/utils/http/axios/helper.ts @@ -16,7 +16,7 @@ export function joinTimestamp(join: boolean, restful = false): string | object { } /** - * @description: Format request parameter time + * @description: 请求参数时间格式 */ export function formatRequestDate(params: Recordable) { if (Object.prototype.toString.call(params) !== '[object Object]') { diff --git a/src/utils/http/axios/index.ts b/src/utils/http/axios/index.ts index 2b8d6f29..d3f9939f 100644 --- a/src/utils/http/axios/index.ts +++ b/src/utils/http/axios/index.ts @@ -10,8 +10,8 @@ import { checkStatus } from './checkStatus' import { useGlobSetting } from '@/hooks/setting' import { useMessage } from '@/hooks/web/useMessage' import { RequestEnum, ResultEnum, ContentTypeEnum } from '@/enums/httpEnum' -import { isString, isUnDef, isNull, isEmpty } from '@/utils/is' -import { getToken } from '@/utils/auth' +import { isEmpty, isNull, isString, isUnDef } from '@/utils/is' +import { getAccessToken, getTenantId } from '@/utils/auth' import { setObjToUrlParams, deepMerge } from '@/utils' import { useErrorLogStoreWithOut } from '@/store/modules/errorLog' import { useI18n } from '@/hooks/web/useI18n' @@ -22,8 +22,12 @@ import axios from 'axios' const globSetting = useGlobSetting() const urlPrefix = globSetting.urlPrefix +const tenantEnable = globSetting.tenantEnable const { createMessage, createErrorModal, createSuccessModal } = useMessage() +// 请求白名单,无须token的接口 +const whiteList: string[] = ['/login', '/refresh-token'] + /** * @description: 数据处理,方便区分多种处理方式 */ @@ -34,6 +38,10 @@ const transform: AxiosTransform = { transformResponseHook: (res: AxiosResponse, options: RequestOptions) => { const { t } = useI18n() const { isTransformResponse, isReturnNativeResponse } = options + // 二进制数据则直接返回 + if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') { + return res.data + } // 是否返回原生响应头 比如:需要获取响应头时使用该属性 if (isReturnNativeResponse) { return res @@ -50,18 +58,20 @@ const transform: AxiosTransform = { // return '[HTTP] Request has no return value'; throw new Error(t('sys.api.apiRequestFailed')) } + console.info(data) // 这里 code,result,message为 后台统一的字段,需要在 types.ts内修改为项目自己的接口返回格式 - const { code, result, message } = data - + const { code, data: result, msg } = data + console.info(result) // 这里逻辑可以根据项目进行修改 const hasSuccess = data && Reflect.has(data, 'code') && code === ResultEnum.SUCCESS if (hasSuccess) { - let successMsg = message - + let successMsg = msg + if (successMsg === null || successMsg === undefined || successMsg === '') { + successMsg = t('sys.api.operationSuccess') + } if (isNull(successMsg) || isUnDef(successMsg) || isEmpty(successMsg)) { successMsg = t(`sys.api.operationSuccess`) } - if (options.successMessageMode === 'modal') { createSuccessModal({ title: t('sys.api.successTip'), content: successMsg }) } else if (options.successMessageMode === 'message') { @@ -74,19 +84,19 @@ const transform: AxiosTransform = { // 如果不希望中断当前请求,请return数据,否则直接抛出异常即可 let timeoutMsg = '' switch (code) { - case ResultEnum.TIMEOUT: + case ResultEnum.UNAUTHORIZED: timeoutMsg = t('sys.api.timeoutMessage') const userStore = useUserStoreWithOut() - userStore.setToken(undefined) + userStore.setAccessToken(undefined) userStore.logout(true) break default: - if (message) { - timeoutMsg = message + if (msg) { + timeoutMsg = msg } } - // errorMessageMode='modal'的时候会显示modal错误弹窗,而不是消息提示,用于一些比较重要的错误 + // errorMessageMode='modal' 的时候会显示modal错误弹窗,而不是消息提示,用于一些比较重要的错误 // errorMessageMode='none' 一般是调用时明确表示不希望自动弹出错误提示 if (options.errorMessageMode === 'modal') { createErrorModal({ title: t('sys.api.errorTip'), content: timeoutMsg }) @@ -147,12 +157,25 @@ const transform: AxiosTransform = { * @description: 请求拦截器处理 */ requestInterceptors: (config, options) => { + // 是否需要设置 token + let isToken = (config as Recordable)?.requestOptions?.withToken == false + whiteList.some((v) => { + if (config.url) { + config.url.indexOf(v) > -1 + return (isToken = false) + } + }) // 请求之前处理config - const token = getToken() - if (token && (config as Recordable)?.requestOptions?.withToken !== false) { + const token = getAccessToken() + if (token && !isToken) { // jwt token ;(config as Recordable).headers.Authorization = options.authenticationScheme ? `${options.authenticationScheme} ${token}` : token } + // 设置租户 + if (tenantEnable && tenantEnable === 'true') { + const tenantId = getTenantId() + if (tenantId) (config as Recordable).headers['tenant-id'] = tenantId + } return config }, @@ -221,7 +244,7 @@ function createAxios(opt?: Partial) { // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#authentication_schemes // authentication schemes,e.g: Bearer // authenticationScheme: 'Bearer', - authenticationScheme: '', + authenticationScheme: 'Bearer', timeout: 10 * 1000, // 基础接口地址 // baseURL: globSetting.apiUrl, diff --git a/src/views/base/login/Login.vue b/src/views/base/login/Login.vue index 3fc2feab..59d42d5c 100644 --- a/src/views/base/login/Login.vue +++ b/src/views/base/login/Login.vue @@ -14,7 +14,7 @@