diff --git a/yudao-ui-admin-vue3/package.json b/yudao-ui-admin-vue3/package.json index e2bdd1580..2e96c661a 100644 --- a/yudao-ui-admin-vue3/package.json +++ b/yudao-ui-admin-vue3/package.json @@ -38,7 +38,6 @@ "echarts-wordcloud": "^2.1.0", "element-plus": "2.2.25", "intro.js": "^6.0.0", - "js-cookie": "^3.0.1", "jsencrypt": "^3.3.1", "lodash-es": "^4.17.21", "mitt": "^3.0.0", diff --git a/yudao-ui-admin-vue3/pnpm-lock.yaml b/yudao-ui-admin-vue3/pnpm-lock.yaml index 57577bc78..5e65e649f 100644 --- a/yudao-ui-admin-vue3/pnpm-lock.yaml +++ b/yudao-ui-admin-vue3/pnpm-lock.yaml @@ -4,12 +4,12 @@ specifiers: '@commitlint/cli': ^17.3.0 '@commitlint/config-conventional': ^17.3.0 '@iconify/iconify': ^3.0.1 - '@iconify/json': ^2.1.145 + '@iconify/json': ^2.1.146 '@intlify/vite-plugin-vue-i18n': ^6.0.3 '@purge-icons/generated': ^0.9.0 '@types/intro.js': ^5.1.0 '@types/lodash-es': ^4.17.6 - '@types/node': ^18.11.9 + '@types/node': ^18.11.10 '@types/nprogress': ^0.2.0 '@types/qrcode': ^1.5.0 '@types/qs': ^6.9.7 @@ -35,7 +35,6 @@ specifiers: eslint-plugin-prettier: ^4.2.1 eslint-plugin-vue: ^9.8.0 intro.js: ^6.0.0 - js-cookie: ^3.0.1 jsencrypt: ^3.3.1 lint-staged: ^13.0.4 lodash-es: ^4.17.21 @@ -95,7 +94,6 @@ dependencies: echarts-wordcloud: 2.1.0_echarts@5.4.0 element-plus: 2.2.25_vue@3.2.45 intro.js: 6.0.0 - js-cookie: 3.0.1 jsencrypt: 3.3.1 lodash-es: 4.17.21 mitt: 3.0.0 @@ -116,12 +114,12 @@ dependencies: devDependencies: '@commitlint/cli': 17.3.0 '@commitlint/config-conventional': 17.3.0 - '@iconify/json': 2.1.145 + '@iconify/json': registry.npmmirror.com/@iconify/json/2.1.146 '@intlify/vite-plugin-vue-i18n': 6.0.3_vite@3.2.4+vue-i18n@9.2.2 '@purge-icons/generated': 0.9.0 '@types/intro.js': 5.1.0 '@types/lodash-es': 4.17.6 - '@types/node': 18.11.9 + '@types/node': registry.npmmirror.com/@types/node/18.11.10 '@types/nprogress': 0.2.0 '@types/qrcode': 1.5.0 '@types/qs': 6.9.7 @@ -151,7 +149,7 @@ devDependencies: stylelint-config-standard: 29.0.0_stylelint@14.15.0 stylelint-order: 5.0.0_stylelint@14.15.0 typescript: 4.9.3 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera vite-plugin-compression: 0.5.1_vite@3.2.4 vite-plugin-eslint: 1.8.1_eslint@8.28.0+vite@3.2.4 vite-plugin-html: 3.2.0_vite@3.2.4 @@ -544,7 +542,7 @@ packages: '@commitlint/execute-rule': 17.0.0 '@commitlint/resolve-extends': 17.3.0 '@commitlint/types': 17.0.0 - '@types/node': 14.18.33 + '@types/node': registry.npmmirror.com/@types/node/14.18.33 chalk: 4.1.2 cosmiconfig: 7.1.0 cosmiconfig-typescript-loader: 4.2.0_qoh33be55smklb2oyrgdyddh4a @@ -717,13 +715,6 @@ packages: dependencies: '@iconify/types': 2.0.0 - /@iconify/json/2.1.145: - resolution: {integrity: sha512-cYU5F2lOPTaUtq9Uulrv66Wrh4XQxWj50xk6d9LeMQZY8IMm2DqICONHVlhOeoYBbCwa0kOt9/W6pMWYB9BomQ==} - dependencies: - '@iconify/types': 2.0.0 - pathe: 0.3.9 - dev: true - /@iconify/types/2.0.0: resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} @@ -794,7 +785,7 @@ packages: debug: 4.3.4 fast-glob: 3.2.12 source-map: 0.6.1 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera vue-i18n: 9.2.2_vue@3.2.45 transitivePeerDependencies: - supports-color @@ -969,7 +960,7 @@ packages: resolution: {integrity: sha512-Ny/PJkO6nxWAQnaet8q/oWz15lrfwvdvBpuY4treB0CSsBO1CG0fVuNLngR3m3bepQLd+E4c3Y3DlC2okpUvPw==} dependencies: '@types/fined': 1.1.3 - '@types/node': 18.11.9 + '@types/node': registry.npmmirror.com/@types/node/18.11.10 dev: true /@types/lodash-es/4.17.6: @@ -984,18 +975,6 @@ packages: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} dev: true - /@types/node/10.17.60: - resolution: {integrity: sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==} - dev: true - - /@types/node/14.18.33: - resolution: {integrity: sha512-qelS/Ra6sacc4loe/3MSjXNL1dNQ/GjxNHVzuChwMfmk7HuycRLVQN2qNY3XahK+fZc5E2szqQSKUyAF0E+2bg==} - dev: true - - /@types/node/18.11.9: - resolution: {integrity: sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==} - dev: true - /@types/normalize-package-data/2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} dev: true @@ -1011,7 +990,7 @@ packages: /@types/qrcode/1.5.0: resolution: {integrity: sha512-x5ilHXRxUPIMfjtM+1vf/GPTRWZ81nqscursm5gMznJeK9M0YnZ1c3bEvRLQ0zSSgedLx1J6MGL231ObQGGhaA==} dependencies: - '@types/node': 18.11.9 + '@types/node': registry.npmmirror.com/@types/node/18.11.10 dev: true /@types/qs/6.9.7: @@ -1025,13 +1004,13 @@ packages: /@types/svgo/2.6.4: resolution: {integrity: sha512-l4cmyPEckf8moNYHdJ+4wkHvFxjyW6ulm9l4YGaOxeyBWPhBOT0gvni1InpFPdzx1dKf/2s62qGITwxNWnPQng==} dependencies: - '@types/node': 18.11.9 + '@types/node': registry.npmmirror.com/@types/node/18.11.10 dev: true /@types/through/0.0.30: resolution: {integrity: sha512-FvnCJljyxhPM3gkRgWmxmDZyAQSiBQQWLI0A0VFL0K7W1oRUrPJSqNO0NvTnLkBcotdlp3lKvaT0JrnyRDkzOg==} dependencies: - '@types/node': 18.11.9 + '@types/node': registry.npmmirror.com/@types/node/18.11.10 dev: true /@types/web-bluetooth/0.0.16: @@ -1218,7 +1197,7 @@ packages: '@babel/core': 7.20.2 '@babel/plugin-transform-typescript': 7.20.2_@babel+core@7.20.2 '@vue/babel-plugin-jsx': 1.1.1_@babel+core@7.20.2 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera vue: 3.2.45 transitivePeerDependencies: - supports-color @@ -1231,7 +1210,7 @@ packages: vite: ^3.0.0 vue: ^3.2.25 dependencies: - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera vue: 3.2.45 dev: true @@ -2297,7 +2276,7 @@ packages: ts-node: '>=10' typescript: '>=3' dependencies: - '@types/node': 14.18.33 + '@types/node': registry.npmmirror.com/@types/node/14.18.33 cosmiconfig: 7.1.0 ts-node: 10.9.1_kluoused5zacjtflizwvdqgpom typescript: 4.9.3 @@ -3968,11 +3947,6 @@ packages: resolution: {integrity: sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ==} dev: true - /js-cookie/3.0.1: - resolution: {integrity: sha512-+0rgsUXZu4ncpPxRL+lNEptWMOWl9etvPHc/koSRp6MPwpRYAhmk0dUG00J4bxVV3r9uUzfo24wW0knS07SKSw==} - engines: {node: '>=12'} - dev: false - /js-sdsl/4.1.5: resolution: {integrity: sha512-08bOAKweV2NUC1wqTtf3qZlnpOX/R2DU9ikpjOHs0H+ibQv3zpncVQg6um4uYtRtrwIX8M4Nh3ytK4HGlYAq7Q==} dev: true @@ -4934,10 +4908,6 @@ packages: resolution: {integrity: sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==} dev: true - /pathe/0.3.9: - resolution: {integrity: sha512-6Y6s0vT112P3jD8dGfuS6r+lpa0qqNrLyHPOwvXMnyNTQaYiwgau2DP3aNDsR13xqtGj7rrPo+jFUATpU6/s+g==} - dev: true - /picocolors/1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} @@ -5206,7 +5176,7 @@ packages: /rd/2.0.1: resolution: {integrity: sha512-/XdKU4UazUZTXFmI0dpABt8jSXPWcEyaGdk340KdHnsEOdkTctlX23aAK7ChQDn39YGNlAJr1M5uvaKt4QnpNw==} dependencies: - '@types/node': 10.17.60 + '@types/node': registry.npmmirror.com/@types/node/10.17.60 dev: true /read-pkg-up/7.0.1: @@ -6082,7 +6052,7 @@ packages: '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.3 - '@types/node': 14.18.33 + '@types/node': registry.npmmirror.com/@types/node/14.18.33 acorn: 8.8.1 acorn-walk: 8.2.0 arg: 4.1.3 @@ -6272,7 +6242,7 @@ packages: chalk: 4.1.2 debug: 4.3.4 fs-extra: 10.1.0 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera transitivePeerDependencies: - supports-color dev: true @@ -6287,7 +6257,7 @@ packages: '@types/eslint': 8.4.10 eslint: 8.28.0 rollup: 2.79.1 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera dev: true /vite-plugin-html/3.2.0_vite@3.2.4: @@ -6307,7 +6277,7 @@ packages: html-minifier-terser: 6.1.0 node-html-parser: 5.4.2 pathe: 0.2.0 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera dev: true /vite-plugin-progress/0.0.6_vite@3.2.4: @@ -6319,7 +6289,7 @@ packages: picocolors: 1.0.0 progress: 2.0.3 rd: 2.0.1 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera dev: true /vite-plugin-purge-icons/0.9.1_vite@3.2.4: @@ -6331,7 +6301,7 @@ packages: '@purge-icons/core': 0.9.1 '@purge-icons/generated': 0.9.0 rollup-plugin-purge-icons: 0.9.1 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera transitivePeerDependencies: - encoding - supports-color @@ -6349,7 +6319,7 @@ packages: fs-extra: 10.1.0 magic-string: 0.25.9 pathe: 0.2.0 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera dev: true /vite-plugin-svg-icons/2.0.1_vite@3.2.4: @@ -6365,7 +6335,7 @@ packages: pathe: 0.2.0 svg-baker: 1.7.0 svgo: 2.8.0 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera transitivePeerDependencies: - supports-color dev: true @@ -6377,7 +6347,7 @@ packages: dependencies: '@vue/compiler-sfc': 3.2.45 magic-string: 0.25.9 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera dev: true /vite-plugin-windicss/1.8.8_vite@3.2.4: @@ -6388,13 +6358,13 @@ packages: '@windicss/plugin-utils': 1.8.8 debug: 4.3.4 kolorist: 1.6.0 - vite: 3.2.4_ajklay5k626t46b6fyghkbup3i + vite: 3.2.4_clvymlzunojxjbv3h6i2warera windicss: 3.5.6 transitivePeerDependencies: - supports-color dev: true - /vite/3.2.4_ajklay5k626t46b6fyghkbup3i: + /vite/3.2.4_clvymlzunojxjbv3h6i2warera: resolution: {integrity: sha512-Z2X6SRAffOUYTa+sLy3NQ7nlHFU100xwanq1WDwqaiFiCe+25zdxP1TfCS5ojPV2oDDcXudHIoPnI1Z/66B7Yw==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -6419,7 +6389,7 @@ packages: terser: optional: true dependencies: - '@types/node': 18.11.9 + '@types/node': registry.npmmirror.com/@types/node/18.11.10 esbuild: 0.15.14 postcss: 8.4.19 resolve: 1.22.1 @@ -6764,6 +6734,21 @@ packages: dev: true optional: true + registry.npmmirror.com/@iconify/json/2.1.146: + resolution: {integrity: sha512-wIGCtWvxNjWbHPOuJK1e7VaRn0EVrcpzTyC1TaSDRJFsBoGki9Z2NEPEPOS4VaEukh8MLHzLor1IMGgiLhfohg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@iconify/json/-/json-2.1.146.tgz} + name: '@iconify/json' + version: 2.1.146 + dependencies: + '@iconify/types': registry.npmmirror.com/@iconify/types/2.0.0 + pathe: registry.npmmirror.com/pathe/0.3.9 + dev: true + + registry.npmmirror.com/@iconify/types/2.0.0: + resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@iconify/types/-/types-2.0.0.tgz} + name: '@iconify/types' + version: 2.0.0 + dev: true + registry.npmmirror.com/@intlify/message-compiler/9.3.0-beta.10: resolution: {integrity: sha512-RoOC6yceOykLRhN0NlbkNOBUx1el6iphx3W8NfOx3jHVNtfT1FYokx14/5sU3F1F0uxeG4sp6q+ppKvaF8o+ww==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@intlify/message-compiler/-/message-compiler-9.3.0-beta.10.tgz} name: '@intlify/message-compiler' @@ -6793,6 +6778,24 @@ packages: version: 2.11.7 dev: false + registry.npmmirror.com/@types/node/10.17.60: + resolution: {integrity: sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@types/node/-/node-10.17.60.tgz} + name: '@types/node' + version: 10.17.60 + dev: true + + registry.npmmirror.com/@types/node/14.18.33: + resolution: {integrity: sha512-qelS/Ra6sacc4loe/3MSjXNL1dNQ/GjxNHVzuChwMfmk7HuycRLVQN2qNY3XahK+fZc5E2szqQSKUyAF0E+2bg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@types/node/-/node-14.18.33.tgz} + name: '@types/node' + version: 14.18.33 + dev: true + + registry.npmmirror.com/@types/node/18.11.10: + resolution: {integrity: sha512-juG3RWMBOqcOuXC643OAdSA525V44cVgGV6dUDuiFtss+8Fk5x1hI93Rsld43VeJVIeqlP9I7Fn9/qaVqoEAuQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@types/node/-/node-18.11.10.tgz} + name: '@types/node' + version: 18.11.10 + dev: true + registry.npmmirror.com/@volar/language-core/1.0.10: resolution: {integrity: sha512-7WNzjvdUXjggEZvYu9EInABl4mvXtyiiaJDOJM+plHJT7xW5voLja0BrYYji6TUn8Q4HakLvTPpQddPLq134mg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@volar/language-core/-/language-core-1.0.10.tgz} name: '@volar/language-core' @@ -7227,6 +7230,12 @@ packages: hasBin: true dev: true + registry.npmmirror.com/pathe/0.3.9: + resolution: {integrity: sha512-6Y6s0vT112P3jD8dGfuS6r+lpa0qqNrLyHPOwvXMnyNTQaYiwgau2DP3aNDsR13xqtGj7rrPo+jFUATpU6/s+g==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/pathe/-/pathe-0.3.9.tgz} + name: pathe + version: 0.3.9 + dev: true + registry.npmmirror.com/picocolors/1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/picocolors/-/picocolors-1.0.0.tgz} name: picocolors diff --git a/yudao-ui-admin-vue3/src/utils/auth.ts b/yudao-ui-admin-vue3/src/utils/auth.ts index 47cfa7321..9d8c10156 100644 --- a/yudao-ui-admin-vue3/src/utils/auth.ts +++ b/yudao-ui-admin-vue3/src/utils/auth.ts @@ -1,31 +1,33 @@ -import Cookies from 'js-cookie' +import { useCache } from '@/hooks/web/useCache' import { TokenType } from '@/api/login/types' import { decrypt, encrypt } from '@/utils/jsencrypt' +const { wsCache } = useCache() + const AccessTokenKey = 'ACCESS_TOKEN' const RefreshTokenKey = 'REFRESH_TOKEN' // 获取token export const getAccessToken = () => { // 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错 - return Cookies.get(AccessTokenKey) ? Cookies.get(AccessTokenKey) : Cookies.get('ACCESS_TOKEN') + return wsCache.get(AccessTokenKey) ? wsCache.get(AccessTokenKey) : wsCache.get('ACCESS_TOKEN') } // 刷新token export const getRefreshToken = () => { - return Cookies.get(RefreshTokenKey) + return wsCache.get(RefreshTokenKey) } // 设置token export const setToken = (token: TokenType) => { - Cookies.set(RefreshTokenKey, token.refreshToken, token.expiresTime) - Cookies.set(AccessTokenKey, token.accessToken) + wsCache.set(RefreshTokenKey, token.refreshToken, { exp: token.expiresTime }) + wsCache.set(AccessTokenKey, token.accessToken) } // 删除token export const removeToken = () => { - Cookies.remove(AccessTokenKey) - Cookies.remove(RefreshTokenKey) + wsCache.delete(AccessTokenKey) + wsCache.delete(RefreshTokenKey) } /** 格式化token(jwt格式) */ @@ -39,40 +41,40 @@ const PasswordKey = 'PASSWORD' const RememberMeKey = 'REMEMBER_ME' export const getUsername = () => { - return Cookies.get(UsernameKey) + return wsCache.get(UsernameKey) } export const setUsername = (username: string) => { - Cookies.set(UsernameKey, username) + wsCache.set(UsernameKey, username) } export const removeUsername = () => { - Cookies.remove(UsernameKey) + wsCache.delete(UsernameKey) } export const getPassword = () => { - const password = Cookies.get(PasswordKey) + const password = wsCache.get(PasswordKey) return password ? decrypt(password) : undefined } export const setPassword = (password: string) => { - Cookies.set(PasswordKey, encrypt(password)) + wsCache.set(PasswordKey, encrypt(password)) } export const removePassword = () => { - Cookies.remove(PasswordKey) + wsCache.delete(PasswordKey) } export const getRememberMe = () => { - return Cookies.get(RememberMeKey) === 'true' + return wsCache.get(RememberMeKey) === 'true' } export const setRememberMe = (rememberMe: string) => { - Cookies.set(RememberMeKey, rememberMe) + wsCache.set(RememberMeKey, rememberMe) } export const removeRememberMe = () => { - Cookies.remove(RememberMeKey) + wsCache.delete(RememberMeKey) } // ========== 租户相关 ========== @@ -81,25 +83,25 @@ const TenantIdKey = 'TENANT_ID' const TenantNameKey = 'TENANT_NAME' export const getTenantName = () => { - return Cookies.get(TenantNameKey) + return wsCache.get(TenantNameKey) } export const setTenantName = (username: string) => { - Cookies.set(TenantNameKey, username) + wsCache.set(TenantNameKey, username) } export const removeTenantName = () => { - Cookies.remove(TenantNameKey) + wsCache.delete(TenantNameKey) } export const getTenantId = () => { - return Cookies.get(TenantIdKey) + return wsCache.get(TenantIdKey) } export const setTenantId = (username: string) => { - Cookies.set(TenantIdKey, username) + wsCache.set(TenantIdKey, username) } export const removeTenantId = () => { - Cookies.remove(TenantIdKey) + wsCache.delete(TenantIdKey) } diff --git a/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue b/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue index eae3ef475..005e83605 100644 --- a/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue +++ b/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue @@ -150,11 +150,11 @@ import { ElDivider, ElLoading } from 'element-plus' -import Cookies from 'js-cookie' import { useRouter } from 'vue-router' import type { RouteLocationNormalizedLoaded } from 'vue-router' import { useI18n } from '@/hooks/web/useI18n' import { useIcon } from '@/hooks/web/useIcon' +import { useCache } from '@/hooks/web/useCache' import { required } from '@/utils/formRules' import { setToken, setTenantId } from '@/utils/auth' import { decrypt, encrypt } from '@/utils/jsencrypt' @@ -166,6 +166,7 @@ import { LoginStateEnum, useLoginState, useFormValid } from './useLogin' const { t } = useI18n() const formLogin = ref() +const { wsCache } = useCache() const { validForm } = useFormValid(formLogin) const { setLoginState, getLoginState } = useLoginState() const { currentRoute, push } = useRouter() @@ -194,10 +195,10 @@ const loginData = reactive({ signIn: false }, loginForm: { - tenantName: Cookies.get('tenantName') ? Cookies.get('tenantName') : '芋道源码', - username: Cookies.get('username') ? Cookies.get('username') : 'admin', - password: Cookies.get('password') - ? (decrypt(Cookies.get('password')) as unknown as string) + tenantName: wsCache.get('tenantName') ? wsCache.get('tenantName') : '芋道源码', + username: wsCache.get('username') ? wsCache.get('username') : 'admin', + password: wsCache.get('password') + ? (decrypt(wsCache.get('password')) as unknown as string) : 'admin123', captchaVerification: '', rememberMe: false @@ -222,12 +223,12 @@ const getTenantId = async () => { } // 记住我 const getCookie = () => { - const username = Cookies.get('username') - const password = Cookies.get('password') - ? (decrypt(Cookies.get('password')) as unknown as string) + const username = wsCache.get('username') + const password = wsCache.get('password') + ? (decrypt(wsCache.get('password')) as unknown as string) : undefined - const rememberMe = Cookies.get('rememberMe') - const tenantName = Cookies.get('tenantName') + const rememberMe = wsCache.get('rememberMe') + const tenantName = wsCache.get('tenantName') loginData.loginForm = { ...loginData.loginForm, username: username ? username : loginData.loginForm.username, @@ -256,17 +257,17 @@ const handleLogin = async (params) => { background: 'rgba(0, 0, 0, 0.7)' }) if (loginData.loginForm.rememberMe) { - Cookies.set('username', loginData.loginForm.username, { expires: 30 }) - Cookies.set('password', encrypt(loginData.loginForm.password as unknown as string), { - expires: 30 + wsCache.set('username', loginData.loginForm.username, { exp: 30 * 24 * 60 * 60 }) + wsCache.set('password', encrypt(loginData.loginForm.password as unknown as string), { + exp: 30 }) - Cookies.set('rememberMe', loginData.loginForm.rememberMe, { expires: 30 }) - Cookies.set('tenantName', loginData.loginForm.tenantName, { expires: 30 }) + wsCache.set('rememberMe', loginData.loginForm.rememberMe, { exp: 30 * 24 * 60 * 60 }) + wsCache.set('tenantName', loginData.loginForm.tenantName, { exp: 30 * 24 * 60 * 60 }) } else { - Cookies.remove('username') - Cookies.remove('password') - Cookies.remove('rememberMe') - Cookies.remove('tenantName') + wsCache.delete('username') + wsCache.delete('password') + wsCache.delete('rememberMe') + wsCache.delete('tenantName') } setToken(res) if (!redirect.value) { diff --git a/yudao-ui-admin-vue3/vite.config.ts b/yudao-ui-admin-vue3/vite.config.ts index 5ac7c7d61..b6c53fedc 100644 --- a/yudao-ui-admin-vue3/vite.config.ts +++ b/yudao-ui-admin-vue3/vite.config.ts @@ -142,25 +142,30 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { optimizeDeps: { include: [ 'vue', + 'sass', 'vue-router', 'vue-types', 'vue-i18n', 'vxe-table', + 'vxe-table/es/style', 'xe-utils', 'lodash-es', - 'element-plus/es', + 'element-plus', 'element-plus/es/locale/lang/zh-cn', 'element-plus/es/locale/lang/en', '@iconify/iconify', '@vueuse/core', - 'axios', 'qs', + 'axios', + 'pinia', 'dayjs', - 'echarts', + 'qrcode', + 'echarts/core', + 'echarts/charts', + 'echarts/components', + 'echarts/renderers', 'echarts-wordcloud', 'intro.js', - 'qrcode', - 'pinia', 'crypto-js', '@wangeditor/editor', '@wangeditor/editor-for-vue'