diff --git a/yudao-ui-admin-vue3/package.json b/yudao-ui-admin-vue3/package.json index c2be68b1f..e90ef4070 100644 --- a/yudao-ui-admin-vue3/package.json +++ b/yudao-ui-admin-vue3/package.json @@ -31,7 +31,7 @@ "@wangeditor/editor-for-vue": "^5.1.10", "@zxcvbn-ts/core": "^2.1.0", "animate.css": "^4.1.1", - "axios": "^1.1.3", + "axios": "^0.27.2", "crypto-js": "^4.1.1", "dayjs": "^1.11.6", "echarts": "^5.4.0", diff --git a/yudao-ui-admin-vue3/pnpm-lock.yaml b/yudao-ui-admin-vue3/pnpm-lock.yaml index fc003f14c..8e9d2f482 100644 --- a/yudao-ui-admin-vue3/pnpm-lock.yaml +++ b/yudao-ui-admin-vue3/pnpm-lock.yaml @@ -23,7 +23,7 @@ specifiers: '@zxcvbn-ts/core': ^2.1.0 animate.css: ^4.1.1 autoprefixer: ^10.4.13 - axios: ^1.1.3 + axios: ^0.27.2 crypto-js: ^4.1.1 dayjs: ^1.11.6 echarts: ^5.4.0 @@ -87,7 +87,7 @@ dependencies: '@wangeditor/editor-for-vue': 5.1.12_95363b7c2c964a937bf2a01c911df30e '@zxcvbn-ts/core': 2.1.0 animate.css: 4.1.1 - axios: 1.1.3 + axios: 0.27.2 crypto-js: 4.1.1 dayjs: 1.11.6 echarts: 5.4.0 @@ -2175,12 +2175,11 @@ packages: - debug dev: true - /axios/1.1.3: - resolution: {integrity: sha512-00tXVRwKx/FZr/IDVFt4C+f9FYairX517WoGCL6dpOntqLkZofjhu43F/Xl44UOpqa+9sLFDrG/XAnFsUYgkDA==} + /axios/0.27.2: + resolution: {integrity: sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==} dependencies: follow-redirects: 1.15.2 form-data: 4.0.0 - proxy-from-env: 1.1.0 transitivePeerDependencies: - debug dev: false @@ -5790,10 +5789,6 @@ packages: engines: {node: '>=6'} dev: false - /proxy-from-env/1.1.0: - resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} - dev: false - /prr/1.0.1: resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==} dev: true diff --git a/yudao-ui-admin-vue3/src/config/axios/service.ts b/yudao-ui-admin-vue3/src/config/axios/service.ts index 52f5a8acd..cd1235e58 100644 --- a/yudao-ui-admin-vue3/src/config/axios/service.ts +++ b/yudao-ui-admin-vue3/src/config/axios/service.ts @@ -5,7 +5,7 @@ import axios, { AxiosResponse, AxiosError } from 'axios' -import { ElMessage, ElMessageBox, ElNotification } from 'element-plus' +import { useMessage } from '@/hooks/web/useMessage' import qs from 'qs' import { config } from '@/config/axios/config' import { getAccessToken, getRefreshToken, getTenantId, removeToken, setToken } from '@/utils/auth' @@ -17,6 +17,7 @@ import { useCache } from '@/hooks/web/useCache' const tenantEnable = import.meta.env.VITE_APP_TENANT_ENABLE const { result_code, base_url, request_timeout } = config +const message = useMessage() // 需要忽略的提示。忽略后,自动 Promise.reject('error') const ignoreMsgs = [ '无效的刷新令牌', // 刷新令牌被删除时,不用提示 @@ -46,9 +47,9 @@ service.interceptors.request.use( ;(config as Recordable).headers.Authorization = 'Bearer ' + getAccessToken() // 让每个请求携带自定义token } // 设置租户 - if (tenantEnable) { + if (tenantEnable && tenantEnable === 'true') { const tenantId = getTenantId() - if (tenantId) service.defaults.headers.common['tenant-id'] = tenantId + if (tenantId) (config as Recordable).headers.common['tenant-id'] = tenantId } const params = config.params || {} const data = config.data || false @@ -129,7 +130,6 @@ service.interceptors.response.use( // 2.1 刷新成功,则回放队列的请求 + 当前请求 setToken((await refreshTokenRes).data.data) config.headers!.Authorization = 'Bearer ' + getAccessToken() - service.defaults.headers.Authorization = 'Bearer ' + getAccessToken() requestList.forEach((cb: any) => { cb() }) @@ -157,10 +157,10 @@ service.interceptors.response.use( }) } } else if (code === 500) { - ElMessage.error(t('sys.api.errMsg500')) + message.error(t('sys.api.errMsg500')) return Promise.reject(new Error(msg)) } else if (code === 901) { - ElMessage.error( + message.error( '
' + t('sys.api.errMsg901') + '
' + @@ -175,9 +175,7 @@ service.interceptors.response.use( // hard coding:忽略这个提示,直接登出 console.log(msg) } else { - ElNotification.error({ - title: msg - }) + message.notifyError(msg) } return Promise.reject('error') } else { @@ -186,16 +184,16 @@ service.interceptors.response.use( }, (error: AxiosError) => { console.log('err' + error) // for debug - let { message } = error + let { message: msg } = error const { t } = useI18n() - if (message === 'Network Error') { - message = t('sys.api.errorMessage') - } else if (message.includes('timeout')) { - message = t('sys.api.apiTimeoutMessage') - } else if (message.includes('Request failed with status code')) { - message = t('sys.api.apiRequestFailed') + message.substr(message.length - 3) + if (msg === 'Network Error') { + msg = t('sys.api.errorMessage') + } else if (msg.includes('timeout')) { + msg = t('sys.api.apiTimeoutMessage') + } else if (msg.includes('Request failed with status code')) { + msg = t('sys.api.apiRequestFailed') + msg.substr(msg.length - 3) } - ElMessage.error(message) + message.error(msg) return Promise.reject(error) } ) @@ -207,11 +205,8 @@ const handleAuthorized = () => { const { t } = useI18n() if (!isRelogin.show) { isRelogin.show = true - ElMessageBox.confirm(t('sys.api.timeoutMessage'), t('common.confirmTitle'), { - confirmButtonText: t('login.relogin'), - cancelButtonText: t('common.cancel'), - type: 'warning' - }) + message + .confirm(t('sys.api.timeoutMessage')) .then(() => { const { wsCache } = useCache() resetRouter() // 重置静态路由表 diff --git a/yudao-ui-admin-vue3/src/hooks/web/useCache.ts b/yudao-ui-admin-vue3/src/hooks/web/useCache.ts index b405ef3cd..97a7df68a 100644 --- a/yudao-ui-admin-vue3/src/hooks/web/useCache.ts +++ b/yudao-ui-admin-vue3/src/hooks/web/useCache.ts @@ -4,9 +4,9 @@ import WebStorageCache from 'web-storage-cache' -type CacheType = 'sessionStorage' | 'localStorage' +type CacheType = 'localStorage' | 'sessionStorage' -export const useCache = (type: CacheType = 'sessionStorage') => { +export const useCache = (type: CacheType = 'localStorage') => { const wsCache: WebStorageCache = new WebStorageCache({ storage: type }) diff --git a/yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts b/yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts index 57db7578f..4eafbcbdb 100644 --- a/yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts +++ b/yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts @@ -121,10 +121,10 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema[]): VxeFormItemProps[] => props: { placeholder: t('common.selectText') } } } - const searchSchemaItem = { // 默认为 input - span: 6, + span: 8, + folding: searchSchema.length > 2, itemRender: itemRender, ...schemaItem.search, field: schemaItem.field, @@ -140,7 +140,7 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema[]): VxeFormItemProps[] => const buttons: VxeFormItemProps = { span: 24, align: 'center', - collapseNode: true, + collapseNode: searchSchema.length > 3, itemRender: { name: '$buttons', children: [ diff --git a/yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts b/yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts index 04b0df0b8..c13f0ffbb 100644 --- a/yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts +++ b/yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts @@ -1,5 +1,5 @@ import { computed, reactive } from 'vue' -import { VxeGridProps } from 'vxe-table' +import { SizeType, VxeGridProps } from 'vxe-table' import { useAppStore } from '@/store/modules/app' import { VxeAllSchemas } from './useVxeCrudSchemas' import { useI18n } from '@/hooks/web/useI18n' @@ -18,20 +18,27 @@ interface UseVxeGridConfig { const appStore = useAppStore() const currentSize = computed(() => { - if (appStore.getCurrentSize === 'small') { - return 'small' - } else if (appStore.getCurrentSize === 'large') { - return 'mini' - } else { - return 'medium' + let resSize: SizeType = 'small' + const appsize = appStore.getCurrentSize + switch (appsize) { + case 'large': + resSize = 'medium' + break + case 'default': + resSize = 'small' + break + case 'small': + resSize = 'mini' + break } + return resSize }) export const useVxeGrid = (config?: UseVxeGridConfig) => { const gridOptions = reactive({ loading: true, - size: currentSize.value, - height: 800, + size: currentSize as any, + height: 700, rowConfig: { isCurrent: true, // 当鼠标点击行时,是否要高亮当前行 isHover: true // 当鼠标移到行时,是否要高亮当前行 @@ -90,9 +97,11 @@ export const useVxeGrid = (config?: UseVxeGridConfig) => { } }) const delList = (ids: string | number | string[] | number[]) => { - message.delConfirm().then(() => { - config?.delListApi && config?.delListApi(ids) - message.success(t('common.delSuccess')) + return new Promise(async () => { + message.delConfirm().then(() => { + config?.delListApi && config?.delListApi(ids) + message.success(t('common.delSuccess')) + }) }) } return { diff --git a/yudao-ui-admin-vue3/src/plugins/vxeTable/index.ts b/yudao-ui-admin-vue3/src/plugins/vxeTable/index.ts index 2b5157635..1da528f70 100644 --- a/yudao-ui-admin-vue3/src/plugins/vxeTable/index.ts +++ b/yudao-ui-admin-vue3/src/plugins/vxeTable/index.ts @@ -7,7 +7,6 @@ import enUS from 'vxe-table/lib/locale/lang/en-US' import { // 全局对象 VXETable, - // 表格功能 Filter, Edit, @@ -15,7 +14,6 @@ import { Export, Keyboard, Validator, - // 可选组件 Icon, Column, @@ -42,7 +40,6 @@ import { Modal, List, Pulldown, - // 表格 Table } from 'vxe-table' diff --git a/yudao-ui-admin-vue3/src/views/system/dict/index.vue b/yudao-ui-admin-vue3/src/views/system/dict/index.vue index 26cc911a3..b9b1ad807 100644 --- a/yudao-ui-admin-vue3/src/views/system/dict/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/dict/index.vue @@ -1,3 +1,154 @@ + - - diff --git a/yudao-ui-admin-vue3/src/views/system/post/index.vue b/yudao-ui-admin-vue3/src/views/system/post/index.vue index 0f447cbf9..8a768611c 100644 --- a/yudao-ui-admin-vue3/src/views/system/post/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/post/index.vue @@ -60,9 +60,9 @@