diff --git a/src/api/bpm/processExpression/index.ts b/src/api/bpm/processExpression/index.ts index af6a7372..59c8c73e 100644 --- a/src/api/bpm/processExpression/index.ts +++ b/src/api/bpm/processExpression/index.ts @@ -1,4 +1,4 @@ -import request from '@/config/axios' +import { requestData, requestDownload } from '@/utils/request' // BPM 流程表达式 VO export interface ProcessExpressionVO { @@ -12,31 +12,36 @@ export interface ProcessExpressionVO { export const ProcessExpressionApi = { // 查询BPM 流程表达式分页 getProcessExpressionPage: async (params: any) => { - return await request.get({ url: `/bpm/process-expression/page`, params }) + return await requestData({ url: '/bpm/process-expression/page', method: 'GET', params }) }, // 查询BPM 流程表达式详情 getProcessExpression: async (id: number) => { - return await request.get({ url: `/bpm/process-expression/get?id=` + id }) + return await requestData({ url: '/bpm/process-expression/get?id=' + id, method: 'GET' }) }, // 新增BPM 流程表达式 createProcessExpression: async (data: ProcessExpressionVO) => { - return await request.post({ url: `/bpm/process-expression/create`, data }) + return await requestData({ url: '/bpm/process-expression/create', method: 'POST', data }) }, // 修改BPM 流程表达式 updateProcessExpression: async (data: ProcessExpressionVO) => { - return await request.put({ url: `/bpm/process-expression/update`, data }) + return await requestData({ url: '/bpm/process-expression/update', method: 'PUT', data }) }, // 删除BPM 流程表达式 deleteProcessExpression: async (id: number) => { - return await request.delete({ url: `/bpm/process-expression/delete?id=` + id }) + return await requestData({ url: '/bpm/process-expression/delete?id=' + id, method: 'DELETE' }) }, // 导出BPM 流程表达式 Excel exportProcessExpression: async (params) => { - return await request.download({ url: `/bpm/process-expression/export-excel`, params }) + return await requestDownload({ + url: '/bpm/process-expression/export-excel', + method: 'GET', + params, + responseType: 'blob' + }) } -} \ No newline at end of file +} diff --git a/src/api/bpm/processListener/index.ts b/src/api/bpm/processListener/index.ts index dabaa476..694397a8 100644 --- a/src/api/bpm/processListener/index.ts +++ b/src/api/bpm/processListener/index.ts @@ -1,4 +1,4 @@ -import request from '@/config/axios' +import { requestData } from '@/utils/request' // BPM 流程监听器 VO export interface ProcessListenerVO { @@ -15,26 +15,26 @@ export interface ProcessListenerVO { export const ProcessListenerApi = { // 查询流程监听器分页 getProcessListenerPage: async (params: any) => { - return await request.get({ url: `/bpm/process-listener/page`, params }) + return await requestData({ url: '/bpm/process-listener/page', method: 'GET', params }) }, // 查询流程监听器详情 getProcessListener: async (id: number) => { - return await request.get({ url: `/bpm/process-listener/get?id=` + id }) + return await requestData({ url: '/bpm/process-listener/get?id=' + id, method: 'GET' }) }, // 新增流程监听器 createProcessListener: async (data: ProcessListenerVO) => { - return await request.post({ url: `/bpm/process-listener/create`, data }) + return await requestData({ url: '/bpm/process-listener/create', method: 'POST', data }) }, // 修改流程监听器 updateProcessListener: async (data: ProcessListenerVO) => { - return await request.put({ url: `/bpm/process-listener/update`, data }) + return await requestData({ url: '/bpm/process-listener/update', method: 'PUT', data }) }, // 删除流程监听器 deleteProcessListener: async (id: number) => { - return await request.delete({ url: `/bpm/process-listener/delete?id=` + id }) + return await requestData({ url: '/bpm/process-listener/delete?id=' + id, method: 'DELETE' }) } } diff --git a/src/api/bpm/userGroup/index.ts b/src/api/bpm/userGroup/index.ts index 7d12755e..97037f80 100644 --- a/src/api/bpm/userGroup/index.ts +++ b/src/api/bpm/userGroup/index.ts @@ -1,47 +1,41 @@ -import request from '@/config/axios' - -export type UserGroupVO = { - id: number - name: string - description: string - userIds: number[] - status: number - remark: string - createTime: string -} - -// 创建用户组 -export const createUserGroup = async (data: UserGroupVO) => { - return await request.post({ - url: '/bpm/user-group/create', - data: data - }) -} - -// 更新用户组 -export const updateUserGroup = async (data: UserGroupVO) => { - return await request.put({ - url: '/bpm/user-group/update', - data: data - }) -} - -// 删除用户组 -export const deleteUserGroup = async (id: number) => { - return await request.delete({ url: '/bpm/user-group/delete?id=' + id }) -} - -// 获得用户组 -export const getUserGroup = async (id: number) => { - return await request.get({ url: '/bpm/user-group/get?id=' + id }) -} - -// 获得用户组分页 -export const getUserGroupPage = async (params) => { - return await request.get({ url: '/bpm/user-group/page', params }) -} - -// 获取用户组精简信息列表 -export const getUserGroupSimpleList = async (): Promise => { - return await request.get({ url: '/bpm/user-group/simple-list' }) -} +import { requestData } from '@/utils/request' + +export type UserGroupVO = { + id: number + name: string + description: string + userIds: number[] + status: number + remark: string + createTime: string +} + +// 创建用户组 +export const createUserGroup = async (data: UserGroupVO) => { + return await requestData({ url: '/bpm/user-group/create', method: 'POST', data }) +} + +// 更新用户组 +export const updateUserGroup = async (data: UserGroupVO) => { + return await requestData({ url: '/bpm/user-group/update', method: 'PUT', data }) +} + +// 删除用户组 +export const deleteUserGroup = async (id: number) => { + return await requestData({ url: '/bpm/user-group/delete?id=' + id, method: 'DELETE' }) +} + +// 获得用户组 +export const getUserGroup = async (id: number) => { + return await requestData({ url: '/bpm/user-group/get?id=' + id, method: 'GET' }) +} + +// 获得用户组分页 +export const getUserGroupPage = async (params) => { + return await requestData({ url: '/bpm/user-group/page', method: 'GET', params }) +} + +// 获取用户组精简信息列表 +export const getUserGroupSimpleList = async (): Promise => { + return await requestData({ url: '/bpm/user-group/simple-list', method: 'GET' }) +} diff --git a/src/api/system/dict/dict.data.ts b/src/api/system/dict/dict.data.ts index f4286481..4d05a5b9 100644 --- a/src/api/system/dict/dict.data.ts +++ b/src/api/system/dict/dict.data.ts @@ -1,49 +1,49 @@ -import request from '@/config/axios' - -export type DictDataVO = { - id: number | undefined - sort: number | undefined - label: string - value: string - dictType: string - status: number - colorType: string - cssClass: string - remark: string - createTime: Date -} - -// 查询字典数据(精简)列表 -export const getSimpleDictDataList = () => { - return request.get({ url: '/system/dict-data/simple-list' }) -} - -// 查询字典数据列表 -export const getDictDataPage = (params: PageParam) => { - return request.get({ url: '/system/dict-data/page', params }) -} - -// 查询字典数据详情 -export const getDictData = (id: number) => { - return request.get({ url: '/system/dict-data/get?id=' + id }) -} - -// 新增字典数据 -export const createDictData = (data: DictDataVO) => { - return request.post({ url: '/system/dict-data/create', data }) -} - -// 修改字典数据 -export const updateDictData = (data: DictDataVO) => { - return request.put({ url: '/system/dict-data/update', data }) -} - -// 删除字典数据 -export const deleteDictData = (id: number) => { - return request.delete({ url: '/system/dict-data/delete?id=' + id }) -} - -// 导出字典类型数据 -export const exportDictData = (params) => { - return request.download({ url: '/system/dict-data/export', params }) -} +import { requestData, requestDownload } from '@/utils/request' + +export type DictDataVO = { + id: number | undefined + sort: number | undefined + label: string + value: string + dictType: string + status: number + colorType: string + cssClass: string + remark: string + createTime: Date +} + +// 查询字典数据(精简)列表 +export const getSimpleDictDataList = () => { + return requestData({ url: '/system/dict-data/simple-list', method: 'GET' }) +} + +// 查询字典数据列表 +export const getDictDataPage = (params: PageParam) => { + return requestData({ url: '/system/dict-data/page', method: 'GET', params }) +} + +// 查询字典数据详情 +export const getDictData = (id: number) => { + return requestData({ url: '/system/dict-data/get?id=' + id, method: 'GET' }) +} + +// 新增字典数据 +export const createDictData = (data: DictDataVO) => { + return requestData({ url: '/system/dict-data/create', method: 'POST', data }) +} + +// 修改字典数据 +export const updateDictData = (data: DictDataVO) => { + return requestData({ url: '/system/dict-data/update', method: 'PUT', data }) +} + +// 删除字典数据 +export const deleteDictData = (id: number) => { + return requestData({ url: '/system/dict-data/delete?id=' + id, method: 'DELETE' }) +} + +// 导出字典类型数据 +export const exportDictData = (params) => { + return requestDownload({ url: '/system/dict-data/export', method: 'GET', params, responseType: 'blob' }) +} diff --git a/src/api/system/dict/dict.type.ts b/src/api/system/dict/dict.type.ts index eaa5fb6d..ee0db78c 100644 --- a/src/api/system/dict/dict.type.ts +++ b/src/api/system/dict/dict.type.ts @@ -1,44 +1,45 @@ -import request from '@/config/axios' - -export type DictTypeVO = { - id: number | undefined - name: string - type: string - status: number - remark: string - createTime: Date -} - -// 查询字典(精简)列表 -export const getSimpleDictTypeList = () => { - return request.get({ url: '/system/dict-type/list-all-simple' }) -} - -// 查询字典列表 -export const getDictTypePage = (params: PageParam) => { - return request.get({ url: '/system/dict-type/page', params }) -} - -// 查询字典详情 -export const getDictType = (id: number) => { - return request.get({ url: '/system/dict-type/get?id=' + id }) -} - -// 新增字典 -export const createDictType = (data: DictTypeVO) => { - return request.post({ url: '/system/dict-type/create', data }) -} - -// 修改字典 -export const updateDictType = (data: DictTypeVO) => { - return request.put({ url: '/system/dict-type/update', data }) -} - -// 删除字典 -export const deleteDictType = (id: number) => { - return request.delete({ url: '/system/dict-type/delete?id=' + id }) -} -// 导出字典类型 -export const exportDictType = (params) => { - return request.download({ url: '/system/dict-type/export', params }) -} +import { requestData, requestDownload } from '@/utils/request' + +export type DictTypeVO = { + id: number | undefined + name: string + type: string + status: number + remark: string + createTime: Date +} + +// 查询字典(精简)列表 +export const getSimpleDictTypeList = () => { + return requestData({ url: '/system/dict-type/list-all-simple', method: 'GET' }) +} + +// 查询字典列表 +export const getDictTypePage = (params: PageParam) => { + return requestData({ url: '/system/dict-type/page', method: 'GET', params }) +} + +// 查询字典详情 +export const getDictType = (id: number) => { + return requestData({ url: '/system/dict-type/get?id=' + id, method: 'GET' }) +} + +// 新增字典 +export const createDictType = (data: DictTypeVO) => { + return requestData({ url: '/system/dict-type/create', method: 'POST', data }) +} + +// 修改字典 +export const updateDictType = (data: DictTypeVO) => { + return requestData({ url: '/system/dict-type/update', method: 'PUT', data }) +} + +// 删除字典 +export const deleteDictType = (id: number) => { + return requestData({ url: '/system/dict-type/delete?id=' + id, method: 'DELETE' }) +} + +// 导出字典类型 +export const exportDictType = (params) => { + return requestDownload({ url: '/system/dict-type/export', method: 'GET', params, responseType: 'blob' }) +} diff --git a/src/api/system/notify/message/index.ts b/src/api/system/notify/message/index.ts index e407c77d..341c3b96 100644 --- a/src/api/system/notify/message/index.ts +++ b/src/api/system/notify/message/index.ts @@ -1,49 +1,50 @@ -import request from '@/config/axios' -import qs from 'qs' - -export interface NotifyMessageVO { - id: number - userId: number - userType: number - templateId: number - templateCode: string - templateNickname: string - templateContent: string - templateType: number - templateParams: string - readStatus: boolean - readTime: Date - createTime: Date -} - -// 查询站内信消息列表 -export const getNotifyMessagePage = async (params: PageParam) => { - return await request.get({ url: '/system/notify-message/page', params }) -} - -// 获得我的站内信分页 -export const getMyNotifyMessagePage = async (params: PageParam) => { - return await request.get({ url: '/system/notify-message/my-page', params }) -} - -// 批量标记已读 -export const updateNotifyMessageRead = async (ids) => { - return await request.put({ - url: '/system/notify-message/update-read?' + qs.stringify({ ids: ids }, { indices: false }) - }) -} - -// 标记所有站内信为已读 -export const updateAllNotifyMessageRead = async () => { - return await request.put({ url: '/system/notify-message/update-all-read' }) -} - -// 获取当前用户的最新站内信列表 -export const getUnreadNotifyMessageList = async () => { - return await request.get({ url: '/system/notify-message/get-unread-list' }) -} - -// 获得当前用户的未读站内信数量 -export const getUnreadNotifyMessageCount = async () => { - return await request.get({ url: '/system/notify-message/get-unread-count' }) -} +import { requestData } from '@/utils/request' +import qs from 'qs' + +export interface NotifyMessageVO { + id: number + userId: number + userType: number + templateId: number + templateCode: string + templateNickname: string + templateContent: string + templateType: number + templateParams: string + readStatus: boolean + readTime: Date + createTime: Date +} + +// 查询站内信消息列表 +export const getNotifyMessagePage = async (params: any) => { + return await requestData({ url: '/system/notify-message/page', method: 'GET', params }) +} + +// 获得我的站内信分页 +export const getMyNotifyMessagePage = async (params: any) => { + return await requestData({ url: '/system/notify-message/my-page', method: 'GET', params }) +} + +// 批量标记已读 +export const updateNotifyMessageRead = async (ids: any) => { + return await requestData({ + url: '/system/notify-message/update-read?' + qs.stringify({ ids: ids }, { indices: false }), + method: 'PUT' + }) +} + +// 标记所有站内信为已读 +export const updateAllNotifyMessageRead = async () => { + return await requestData({ url: '/system/notify-message/update-all-read', method: 'PUT' }) +} + +// 获取当前用户的最新站内信列表 +export const getUnreadNotifyMessageList = async () => { + return await requestData({ url: '/system/notify-message/get-unread-list', method: 'GET' }) +} + +// 获得当前用户的未读站内信数量 +export const getUnreadNotifyMessageCount = async () => { + return await requestData({ url: '/system/notify-message/get-unread-count', method: 'GET' }) +} diff --git a/src/api/system/notify/template/index.ts b/src/api/system/notify/template/index.ts index 44355dff..da576e1e 100644 --- a/src/api/system/notify/template/index.ts +++ b/src/api/system/notify/template/index.ts @@ -1,49 +1,49 @@ -import request from '@/config/axios' - -export interface NotifyTemplateVO { - id?: number - name: string - nickname: string - code: string - content: string - type?: number - params: string - status: number - remark: string -} - -export interface NotifySendReqVO { - userId: number | null - templateCode: string - templateParams: Map -} - -// 查询站内信模板列表 -export const getNotifyTemplatePage = async (params: PageParam) => { - return await request.get({ url: '/system/notify-template/page', params }) -} - -// 查询站内信模板详情 -export const getNotifyTemplate = async (id: number) => { - return await request.get({ url: '/system/notify-template/get?id=' + id }) -} - -// 新增站内信模板 -export const createNotifyTemplate = async (data: NotifyTemplateVO) => { - return await request.post({ url: '/system/notify-template/create', data }) -} - -// 修改站内信模板 -export const updateNotifyTemplate = async (data: NotifyTemplateVO) => { - return await request.put({ url: '/system/notify-template/update', data }) -} - -// 删除站内信模板 -export const deleteNotifyTemplate = async (id: number) => { - return await request.delete({ url: '/system/notify-template/delete?id=' + id }) -} - -// 发送站内信 -export const sendNotify = (data: NotifySendReqVO) => { - return request.post({ url: '/system/notify-template/send-notify', data }) -} +import { requestData } from '@/utils/request' + +export interface NotifyTemplateVO { + id?: number + name: string + nickname: string + code: string + content: string + type?: number + params: string + status: number + remark: string +} + +export interface NotifySendReqVO { + userId: number | null + templateCode: string + templateParams: Map +} + +// 查询站内信模板列表 +export const getNotifyTemplatePage = async (params: PageParam) => { + return await requestData({ url: '/system/notify-template/page', method: 'GET', params }) +} + +// 查询站内信模板详情 +export const getNotifyTemplate = async (id: number) => { + return await requestData({ url: '/system/notify-template/get?id=' + id, method: 'GET' }) +} + +// 新增站内信模板 +export const createNotifyTemplate = async (data: NotifyTemplateVO) => { + return await requestData({ url: '/system/notify-template/create', method: 'POST', data }) +} + +// 修改站内信模板 +export const updateNotifyTemplate = async (data: NotifyTemplateVO) => { + return await requestData({ url: '/system/notify-template/update', method: 'PUT', data }) +} + +// 删除站内信模板 +export const deleteNotifyTemplate = async (id: number) => { + return await requestData({ url: '/system/notify-template/delete?id=' + id, method: 'DELETE' }) +} + +// 发送站内信 +export const sendNotify = (data: NotifySendReqVO) => { + return requestData({ url: '/system/notify-template/send-notify', method: 'POST', data }) +} diff --git a/src/components/table/defaultAttribute.ts b/src/components/table/defaultAttribute.ts index a1d30a9c..a03ab97c 100644 --- a/src/components/table/defaultAttribute.ts +++ b/src/components/table/defaultAttribute.ts @@ -6,7 +6,7 @@ export const defaultAttribute: VxeTableProps = { border: true, stripe: true, size: 'small', - columnConfig: { resizable: true }, + columnConfig: { resizable: true, useKey: true }, rowConfig: { isCurrent: true, isHover: true }, scrollX: { scrollToLeftOnChange: true }, scrollY: { scrollToTopOnChange: true, enabled: true, gt: 100 }, diff --git a/src/config/axios/config.ts b/src/config/axios/config.ts deleted file mode 100644 index 81165087..00000000 --- a/src/config/axios/config.ts +++ /dev/null @@ -1,28 +0,0 @@ -const config: { - base_url: string - result_code: number | string - default_headers: AxiosHeaders - request_timeout: number -} = { - /** - * api请求基础路径 - */ - base_url: import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL, - /** - * 接口成功返回状态码 - */ - result_code: 200, - - /** - * 接口请求超时时间 - */ - request_timeout: 30000, - - /** - * 默认接口请求类型 - * 可选值:application/x-www-form-urlencoded multipart/form-data - */ - default_headers: 'application/json' -} - -export { config } diff --git a/src/config/axios/errorCode.ts b/src/config/axios/errorCode.ts deleted file mode 100644 index 94d719f8..00000000 --- a/src/config/axios/errorCode.ts +++ /dev/null @@ -1,6 +0,0 @@ -export default { - '401': '认证失败,无法访问系统资源', - '403': '当前操作没有权限', - '404': '访问资源不存在', - default: '系统未知错误,请反馈给管理员' -} diff --git a/src/config/axios/index.ts b/src/config/axios/index.ts deleted file mode 100644 index 79e558da..00000000 --- a/src/config/axios/index.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { service } from './service' - -import { config } from './config' - -const { default_headers } = config - -const request = (option: any) => { - const { url, method, params, data, headersType, responseType, ...config } = option - return service({ - url: url, - method, - params, - data, - ...config, - responseType: responseType, - headers: { - 'Content-Type': headersType || default_headers - } - }) -} -export default { - get: async (option: any) => { - const res = await request({ method: 'GET', ...option }) - return res.data as unknown as T - }, - post: async (option: any) => { - const res = await request({ method: 'POST', ...option }) - return res.data as unknown as T - }, - postOriginal: async (option: any) => { - const res = await request({ method: 'POST', ...option }) - return res - }, - delete: async (option: any) => { - const res = await request({ method: 'DELETE', ...option }) - return res.data as unknown as T - }, - put: async (option: any) => { - const res = await request({ method: 'PUT', ...option }) - return res.data as unknown as T - }, - download: async (option: any) => { - const res = await request({ method: 'GET', responseType: 'blob', ...option }) - return res as unknown as Promise - }, - upload: async (option: any) => { - option.headersType = 'multipart/form-data' - const res = await request({ method: 'POST', ...option }) - return res as unknown as Promise - } -} diff --git a/src/config/axios/service.ts b/src/config/axios/service.ts deleted file mode 100644 index 1d038aff..00000000 --- a/src/config/axios/service.ts +++ /dev/null @@ -1,228 +0,0 @@ -import axios, { - AxiosError, - AxiosInstance, - AxiosRequestHeaders, - AxiosResponse, - InternalAxiosRequestConfig -} from 'axios' - -import { ElMessage, ElMessageBox, ElNotification } from 'element-plus' -import qs from 'qs' -import { config } from '@/config/axios/config' -import { getAccessToken, getRefreshToken, getTenantId, removeToken, setToken } from '@/utils/auth' -import errorCode from './errorCode' - -import { deleteUserCache } from '@/hooks/web/useCache' - -const tenantEnable = import.meta.env.VITE_APP_TENANT_ENABLE -const { result_code, base_url, request_timeout } = config - -// 需要忽略的提示。忽略后,自动 Promise.reject('error') -const ignoreMsgs = [ - '无效的刷新令牌', // 刷新令牌被删除时,不用提示 - '刷新令牌已过期' // 使用刷新令牌,刷新获取新的访问令牌时,结果因为过期失败,此时需要忽略。否则,会导致继续 401,无法跳转到登出界面 -] -// 是否显示重新登录 -export const isRelogin = { show: false } -// Axios 无感知刷新令牌,参考 https://www.dashingdog.cn/article/11 与 https://segmentfault.com/a/1190000020210980 实现 -// 请求队列 -let requestList: any[] = [] -// 是否正在刷新中 -let isRefreshToken = false -// 请求白名单,无须token的接口 -const whiteList: string[] = ['/login', '/refresh-token'] - -// 创建axios实例 -const service: AxiosInstance = axios.create({ - baseURL: base_url, // api 的 base_url - timeout: request_timeout, // 请求超时时间 - withCredentials: false // 禁用 Cookie 等信息 -}) - -// request拦截器 -service.interceptors.request.use( - (config: InternalAxiosRequestConfig) => { - // 是否需要设置 token - let isToken = (config!.headers || {}).isToken === false - whiteList.some((v) => { - if (config.url) { - config.url.indexOf(v) > -1 - return (isToken = false) - } - }) - if (getAccessToken() && !isToken) { - ;(config as Recordable).headers.Authorization = 'Bearer ' + getAccessToken() // 让每个请求携带自定义token - } - // 设置租户 - if (tenantEnable && tenantEnable === 'true') { - const tenantId = getTenantId() - if (tenantId) (config as Recordable).headers['tenant-id'] = tenantId - } - const params = config.params || {} - const data = config.data || false - if ( - config.method?.toUpperCase() === 'POST' && - (config.headers as AxiosRequestHeaders)['Content-Type'] === - 'application/x-www-form-urlencoded' - ) { - config.data = qs.stringify(data) - } - // get参数编码 - if (config.method?.toUpperCase() === 'GET' && params) { - config.params = {} - const paramsStr = qs.stringify(params, { allowDots: true }) - if (paramsStr) { - config.url = config.url + '?' + paramsStr - } - } - return config - }, - (error: AxiosError) => { - // Do something with request error - console.log(error) // for debug - Promise.reject(error) - } -) - -// response 拦截器 -service.interceptors.response.use( - async (response: AxiosResponse) => { - let { data } = response - const config = response.config - if (!data) { - // 返回“[HTTP]请求没有返回值”; - throw new Error() - } - const { t } = useI18n() - // 未设置状态码则默认成功状态 - // 二进制数据则直接返回,例如说 Excel 导出 - if ( - response.request.responseType === 'blob' || - response.request.responseType === 'arraybuffer' - ) { - // 注意:如果导出的响应为 json,说明可能失败了,不直接返回进行下载 - if (response.data.type !== 'application/json') { - return response.data - } - data = await new Response(response.data).json() - } - const code = data.code || result_code - // 获取错误信息 - const msg = data.msg || errorCode[code] || errorCode['default'] - if (ignoreMsgs.indexOf(msg) !== -1) { - // 如果是忽略的错误码,直接返回 msg 异常 - return Promise.reject(msg) - } else if (code === 401) { - // 如果未认证,并且未进行刷新令牌,说明可能是访问令牌过期了 - if (!isRefreshToken) { - isRefreshToken = true - // 1. 如果获取不到刷新令牌,则只能执行登出操作 - if (!getRefreshToken()) { - return handleAuthorized() - } - // 2. 进行刷新访问令牌 - try { - const refreshTokenRes = await refreshToken() - // 2.1 刷新成功,则回放队列的请求 + 当前请求 - setToken((await refreshTokenRes).data.data) - config.headers!.Authorization = 'Bearer ' + getAccessToken() - requestList.forEach((cb: any) => { - cb() - }) - requestList = [] - return service(config) - } catch (e) { - // 为什么需要 catch 异常呢?刷新失败时,请求因为 Promise.reject 触发异常。 - // 2.2 刷新失败,只回放队列的请求 - requestList.forEach((cb: any) => { - cb() - }) - // 提示是否要登出。即不回放当前请求!不然会形成递归 - return handleAuthorized() - } finally { - requestList = [] - isRefreshToken = false - } - } else { - // 添加到队列,等待刷新获取到新的令牌 - return new Promise((resolve) => { - requestList.push(() => { - config.headers!.Authorization = 'Bearer ' + getAccessToken() // 让每个请求携带自定义token 请根据实际情况自行修改 - resolve(service(config)) - }) - }) - } - } else if (code === 500) { - ElMessage.error(t('sys.api.errMsg500')) - return Promise.reject(new Error(msg)) - } else if (code === 901) { - ElMessage.error({ - offset: 300, - dangerouslyUseHTMLString: true, - message: - '
' + - t('sys.api.errMsg901') + - '
' + - '
 
' + - '
参考 https://doc.iocoder.cn/ 教程
' + - '
 
' + - '
5 分钟搭建本地环境
' - }) - return Promise.reject(new Error(msg)) - } else if (code !== 200) { - if (msg === '无效的刷新令牌') { - // hard coding:忽略这个提示,直接登出 - console.log(msg) - } else { - ElNotification.error({ title: msg }) - } - return Promise.reject('error') - } else { - return data - } - }, - (error: AxiosError) => { - console.log('err' + error) // for debug - let { message } = 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) - } - ElMessage.error(message) - return Promise.reject(error) - } -) - -const refreshToken = async () => { - axios.defaults.headers.common['tenant-id'] = getTenantId() - return await axios.post(base_url + '/system/auth/refresh-token?refreshToken=' + getRefreshToken()) -} -const handleAuthorized = () => { - const { t } = useI18n() - if (!isRelogin.show) { - // 如果已经到重新登录页面则不进行弹窗提示 - if (window.location.href.includes('login?redirect=')) { - return - } - isRelogin.show = true - ElMessageBox.confirm(t('sys.api.timeoutMessage'), t('common.confirmTitle'), { - showCancelButton: false, - closeOnClickModal: false, - showClose: false, - confirmButtonText: t('login.relogin'), - type: 'warning' - }).then(() => { - deleteUserCache() // 删除用户缓存 - removeToken() - isRelogin.show = false - // 干掉token后再走一次路由让它过router.beforeEach的校验 - window.location.href = window.location.href - }) - } - return Promise.reject(t('sys.api.timeoutMessage')) -} -export { service } diff --git a/src/hooks/web/useLocale.ts b/src/hooks/web/useLocale.ts index 0565bf46..4de4a361 100644 --- a/src/hooks/web/useLocale.ts +++ b/src/hooks/web/useLocale.ts @@ -1,35 +1,36 @@ -import { i18n } from '@/plugins/vueI18n' -import { useLocaleStoreWithOut } from '@/stores/modules/locale' -import { setHtmlPageLang } from '@/plugins/vueI18n/helper' - -const setI18nLanguage = (locale: LocaleType) => { - const localeStore = useLocaleStoreWithOut() - - if (i18n.mode === 'legacy') { - i18n.global.locale = locale - } else { - ;(i18n.global.locale as any).value = locale - } - localeStore.setCurrentLocale({ - lang: locale - }) - setHtmlPageLang(locale) -} - -export const useLocale = () => { - // Switching the language will change the locale of useI18n - // And submit to configuration modification - const changeLocale = async (locale: LocaleType) => { - const globalI18n = i18n.global - - const langModule = await import(`../../locales/${locale}.ts`) - - globalI18n.setLocaleMessage(locale, langModule.default) - - setI18nLanguage(locale) - } - - return { - changeLocale - } -} +import { i18n } from '@/plugins/vueI18n' +import { useLocaleStoreWithOut } from '@/stores/modules/locale' +import { setHtmlPageLang } from '@/plugins/vueI18n/helper' +import { loadLocaleMessages } from '@/locales' + +const setI18nLanguage = (locale: LocaleType) => { + const localeStore = useLocaleStoreWithOut() + + if (i18n.mode === 'legacy') { + i18n.global.locale = locale + } else { + ;(i18n.global.locale as any).value = locale + } + localeStore.setCurrentLocale({ + lang: locale + }) + setHtmlPageLang(locale) +} + +export const useLocale = () => { + // Switching the language will change the locale of useI18n + // And submit to configuration modification + const changeLocale = async (locale: LocaleType) => { + const globalI18n = i18n.global + + const message = await loadLocaleMessages(locale) + + globalI18n.setLocaleMessage(locale, message) + + setI18nLanguage(locale) + } + + return { + changeLocale + } +} diff --git a/src/layouts/Layout.vue b/src/layouts/Layout.vue deleted file mode 100644 index a8b27c70..00000000 --- a/src/layouts/Layout.vue +++ /dev/null @@ -1,78 +0,0 @@ - - - diff --git a/src/layouts/components/AppView.vue b/src/layouts/components/AppView.vue deleted file mode 100644 index b3b00b31..00000000 --- a/src/layouts/components/AppView.vue +++ /dev/null @@ -1,72 +0,0 @@ - - - diff --git a/src/layouts/components/Breadcrumb/index.ts b/src/layouts/components/Breadcrumb/index.ts deleted file mode 100644 index 93ffe705..00000000 --- a/src/layouts/components/Breadcrumb/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Breadcrumb from './src/Breadcrumb.vue' - -export { Breadcrumb } diff --git a/src/layouts/components/Breadcrumb/src/Breadcrumb.vue b/src/layouts/components/Breadcrumb/src/Breadcrumb.vue deleted file mode 100644 index 7c36ffde..00000000 --- a/src/layouts/components/Breadcrumb/src/Breadcrumb.vue +++ /dev/null @@ -1,130 +0,0 @@ - - - diff --git a/src/layouts/components/Breadcrumb/src/helper.ts b/src/layouts/components/Breadcrumb/src/helper.ts deleted file mode 100644 index fb3ec197..00000000 --- a/src/layouts/components/Breadcrumb/src/helper.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { pathResolve } from '@/utils/routerHelper' -import type { RouteMeta } from 'vue-router' - -export const filterBreadcrumb = ( - routes: AppRouteRecordRaw[], - parentPath = '' -): AppRouteRecordRaw[] => { - const res: AppRouteRecordRaw[] = [] - - for (const route of routes) { - const meta = route?.meta as RouteMeta - if (meta.hidden && !meta.canTo) { - continue - } - - const data: AppRouteRecordRaw = - !meta.alwaysShow && route.children?.length === 1 - ? { ...route.children[0], path: pathResolve(route.path, route.children[0].path) } - : { ...route } - - data.path = pathResolve(parentPath, data.path) - - if (data.children) { - data.children = filterBreadcrumb(data.children, data.path) - } - if (data) { - res.push(data) - } - } - return res -} diff --git a/src/layouts/components/Collapse/index.ts b/src/layouts/components/Collapse/index.ts deleted file mode 100644 index 73f65a3a..00000000 --- a/src/layouts/components/Collapse/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Collapse from './src/Collapse.vue' - -export { Collapse } diff --git a/src/layouts/components/Collapse/src/Collapse.vue b/src/layouts/components/Collapse/src/Collapse.vue deleted file mode 100644 index addf5a54..00000000 --- a/src/layouts/components/Collapse/src/Collapse.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/src/layouts/components/ContextMenu/index.ts b/src/layouts/components/ContextMenu/index.ts deleted file mode 100644 index 2a7c1f0d..00000000 --- a/src/layouts/components/ContextMenu/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import ContextMenu from './src/ContextMenu.vue' -import { ElDropdown } from 'element-plus' -import type { RouteLocationNormalizedLoaded } from 'vue-router' - -export interface ContextMenuExpose { - elDropdownMenuRef: ComponentRef - tagItem: RouteLocationNormalizedLoaded -} - -export { ContextMenu } diff --git a/src/layouts/components/ContextMenu/src/ContextMenu.vue b/src/layouts/components/ContextMenu/src/ContextMenu.vue deleted file mode 100644 index 90eea4c2..00000000 --- a/src/layouts/components/ContextMenu/src/ContextMenu.vue +++ /dev/null @@ -1,76 +0,0 @@ - - - diff --git a/src/layouts/components/Footer/index.ts b/src/layouts/components/Footer/index.ts deleted file mode 100644 index bd052e0c..00000000 --- a/src/layouts/components/Footer/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Footer from './src/Footer.vue' - -export { Footer } diff --git a/src/layouts/components/Footer/src/Footer.vue b/src/layouts/components/Footer/src/Footer.vue deleted file mode 100644 index 4923330a..00000000 --- a/src/layouts/components/Footer/src/Footer.vue +++ /dev/null @@ -1,24 +0,0 @@ - - - diff --git a/src/layouts/components/LocaleDropdown/index.ts b/src/layouts/components/LocaleDropdown/index.ts deleted file mode 100644 index d02e640f..00000000 --- a/src/layouts/components/LocaleDropdown/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import LocaleDropdown from './src/LocaleDropdown.vue' - -export { LocaleDropdown } diff --git a/src/layouts/components/LocaleDropdown/src/LocaleDropdown.vue b/src/layouts/components/LocaleDropdown/src/LocaleDropdown.vue deleted file mode 100644 index 10c3bead..00000000 --- a/src/layouts/components/LocaleDropdown/src/LocaleDropdown.vue +++ /dev/null @@ -1,52 +0,0 @@ - - - diff --git a/src/layouts/components/Logo/index.ts b/src/layouts/components/Logo/index.ts deleted file mode 100644 index 1c4224c9..00000000 --- a/src/layouts/components/Logo/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Logo from './src/Logo.vue' - -export { Logo } diff --git a/src/layouts/components/Logo/src/Logo.vue b/src/layouts/components/Logo/src/Logo.vue deleted file mode 100644 index 092bfd3d..00000000 --- a/src/layouts/components/Logo/src/Logo.vue +++ /dev/null @@ -1,88 +0,0 @@ - - - diff --git a/src/layouts/components/Menu/index.ts b/src/layouts/components/Menu/index.ts deleted file mode 100644 index a6ec6965..00000000 --- a/src/layouts/components/Menu/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Menu from './src/Menu.vue' - -export { Menu } diff --git a/src/layouts/components/Menu/src/Menu.vue b/src/layouts/components/Menu/src/Menu.vue deleted file mode 100644 index 05f799be..00000000 --- a/src/layouts/components/Menu/src/Menu.vue +++ /dev/null @@ -1,257 +0,0 @@ - - - - - diff --git a/src/layouts/components/Menu/src/components/useRenderMenuItem.tsx b/src/layouts/components/Menu/src/components/useRenderMenuItem.tsx deleted file mode 100644 index 301313fe..00000000 --- a/src/layouts/components/Menu/src/components/useRenderMenuItem.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { ElSubMenu, ElMenuItem } from 'element-plus' -import { hasOneShowingChild } from '../helper' -import { isUrl } from '@/utils/is' -import { useRenderMenuTitle } from './useRenderMenuTitle' -import { pathResolve } from '@/utils/routerHelper' - -const { renderMenuTitle } = useRenderMenuTitle() - -export const useRenderMenuItem = () => - // allRouters: AppRouteRecordRaw[] = [], - { - const renderMenuItem = (routers: AppRouteRecordRaw[], parentPath = '/') => { - return routers - .filter((v) => !v.meta?.hidden) - .map((v) => { - const meta = v.meta ?? {} - const { oneShowingChild, onlyOneChild } = hasOneShowingChild(v.children, v) - const fullPath = isUrl(v.path) ? v.path : pathResolve(parentPath, v.path) // getAllParentPath(allRouters, v.path).join('/') - - if ( - oneShowingChild && - (!onlyOneChild?.children || onlyOneChild?.noShowingChildren) && - !meta?.alwaysShow - ) { - return ( - - {{ - default: () => renderMenuTitle(onlyOneChild ? onlyOneChild?.meta : meta) - }} - - ) - } else { - return ( - - {{ - title: () => renderMenuTitle(meta), - default: () => renderMenuItem(v.children!, fullPath) - }} - - ) - } - }) - } - - return { - renderMenuItem - } - } diff --git a/src/layouts/components/Menu/src/components/useRenderMenuTitle.tsx b/src/layouts/components/Menu/src/components/useRenderMenuTitle.tsx deleted file mode 100644 index 8941d9d7..00000000 --- a/src/layouts/components/Menu/src/components/useRenderMenuTitle.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import type { RouteMeta } from 'vue-router' -import { Icon } from '@/components/Icon' -import { useI18n } from '@/hooks/web/useI18n' - -export const useRenderMenuTitle = () => { - const renderMenuTitle = (meta: RouteMeta) => { - const { t } = useI18n() - const { title = 'Please set title', icon } = meta - - return icon ? ( - <> - - - {t(title as string)} - - - ) : ( - - {t(title as string)} - - ) - } - - return { - renderMenuTitle - } -} diff --git a/src/layouts/components/Menu/src/helper.ts b/src/layouts/components/Menu/src/helper.ts deleted file mode 100644 index c26f5f4b..00000000 --- a/src/layouts/components/Menu/src/helper.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { RouteMeta } from 'vue-router' -import { findPath } from '@/utils/tree' - -type OnlyOneChildType = AppRouteRecordRaw & { noShowingChildren?: boolean } - -interface HasOneShowingChild { - oneShowingChild?: boolean - onlyOneChild?: OnlyOneChildType -} - -export const getAllParentPath = (treeData: T[], path: string) => { - const menuList = findPath(treeData, (n) => n.path === path) as AppRouteRecordRaw[] - return (menuList || []).map((item) => item.path) -} - -export const hasOneShowingChild = ( - children: AppRouteRecordRaw[] = [], - parent: AppRouteRecordRaw -): HasOneShowingChild => { - const onlyOneChild = ref() - - const showingChildren = children.filter((v) => { - const meta = (v.meta ?? {}) as RouteMeta - if (meta.hidden) { - return false - } else { - // Temp set(will be used if only has one showing child) - onlyOneChild.value = v - return true - } - }) - - // When there is only one child router, the child router is displayed by default - if (showingChildren.length === 1) { - return { - oneShowingChild: true, - onlyOneChild: unref(onlyOneChild) - } - } - - // Show parent if there are no child router to display - if (!showingChildren.length) { - onlyOneChild.value = { ...parent, path: '', noShowingChildren: true } - return { - oneShowingChild: true, - onlyOneChild: unref(onlyOneChild) - } - } - - return { - oneShowingChild: false, - onlyOneChild: unref(onlyOneChild) - } -} diff --git a/src/layouts/components/Screenfull/index.ts b/src/layouts/components/Screenfull/index.ts deleted file mode 100644 index faec2d8e..00000000 --- a/src/layouts/components/Screenfull/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Screenfull from './src/Screenfull.vue' - -export { Screenfull } diff --git a/src/layouts/components/Screenfull/src/Screenfull.vue b/src/layouts/components/Screenfull/src/Screenfull.vue deleted file mode 100644 index 4c045f25..00000000 --- a/src/layouts/components/Screenfull/src/Screenfull.vue +++ /dev/null @@ -1,32 +0,0 @@ - - - diff --git a/src/layouts/components/Setting/index.ts b/src/layouts/components/Setting/index.ts deleted file mode 100644 index b64c9add..00000000 --- a/src/layouts/components/Setting/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Setting from './src/Setting.vue' - -export { Setting } diff --git a/src/layouts/components/Setting/src/Setting.vue b/src/layouts/components/Setting/src/Setting.vue deleted file mode 100644 index da3cbd28..00000000 --- a/src/layouts/components/Setting/src/Setting.vue +++ /dev/null @@ -1,299 +0,0 @@ - - - - - diff --git a/src/layouts/components/Setting/src/components/ColorRadioPicker.vue b/src/layouts/components/Setting/src/components/ColorRadioPicker.vue deleted file mode 100644 index 942ec6a4..00000000 --- a/src/layouts/components/Setting/src/components/ColorRadioPicker.vue +++ /dev/null @@ -1,67 +0,0 @@ - - - - - diff --git a/src/layouts/components/Setting/src/components/InterfaceDisplay.vue b/src/layouts/components/Setting/src/components/InterfaceDisplay.vue deleted file mode 100644 index b221f549..00000000 --- a/src/layouts/components/Setting/src/components/InterfaceDisplay.vue +++ /dev/null @@ -1,224 +0,0 @@ - - - diff --git a/src/layouts/components/Setting/src/components/LayoutRadioPicker.vue b/src/layouts/components/Setting/src/components/LayoutRadioPicker.vue deleted file mode 100644 index 950f3aa0..00000000 --- a/src/layouts/components/Setting/src/components/LayoutRadioPicker.vue +++ /dev/null @@ -1,172 +0,0 @@ - - - - - diff --git a/src/layouts/components/SizeDropdown/index.ts b/src/layouts/components/SizeDropdown/index.ts deleted file mode 100644 index 516488d6..00000000 --- a/src/layouts/components/SizeDropdown/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import SizeDropdown from './src/SizeDropdown.vue' - -export { SizeDropdown } diff --git a/src/layouts/components/SizeDropdown/src/SizeDropdown.vue b/src/layouts/components/SizeDropdown/src/SizeDropdown.vue deleted file mode 100644 index 1d7e9678..00000000 --- a/src/layouts/components/SizeDropdown/src/SizeDropdown.vue +++ /dev/null @@ -1,40 +0,0 @@ - - - diff --git a/src/layouts/components/TabMenu/index.ts b/src/layouts/components/TabMenu/index.ts deleted file mode 100644 index b5fd71cd..00000000 --- a/src/layouts/components/TabMenu/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import TabMenu from './src/TabMenu.vue' - -export { TabMenu } diff --git a/src/layouts/components/TabMenu/src/TabMenu.vue b/src/layouts/components/TabMenu/src/TabMenu.vue deleted file mode 100644 index b93f8166..00000000 --- a/src/layouts/components/TabMenu/src/TabMenu.vue +++ /dev/null @@ -1,237 +0,0 @@ - - - diff --git a/src/layouts/components/TabMenu/src/helper.ts b/src/layouts/components/TabMenu/src/helper.ts deleted file mode 100644 index 0871372a..00000000 --- a/src/layouts/components/TabMenu/src/helper.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { getAllParentPath } from '@/layouts/components/Menu/src/helper' -import type { RouteMeta } from 'vue-router' -import { isUrl } from '@/utils/is' -import { cloneDeep } from 'lodash-es' - -export type TabMapTypes = { - [key: string]: string[] -} - -export const tabPathMap = reactive({}) - -export const initTabMap = (routes: AppRouteRecordRaw[]) => { - for (const v of routes) { - const meta = (v.meta ?? {}) as RouteMeta - if (!meta?.hidden) { - tabPathMap[v.path] = [] - } - } -} - -export const filterMenusPath = ( - routes: AppRouteRecordRaw[], - allRoutes: AppRouteRecordRaw[] -): AppRouteRecordRaw[] => { - const res: AppRouteRecordRaw[] = [] - for (const v of routes) { - let data: Nullable = null - const meta = (v.meta ?? {}) as RouteMeta - if (!meta.hidden || meta.canTo) { - const allParentPath = getAllParentPath(allRoutes, v.path) - - const fullPath = isUrl(v.path) ? v.path : allParentPath.join('/') - - data = cloneDeep(v) - data.path = fullPath - if (v.children && data) { - data.children = filterMenusPath(v.children, allRoutes) - } - - if (data) { - res.push(data) - } - - if (allParentPath.length && Reflect.has(tabPathMap, allParentPath[0])) { - tabPathMap[allParentPath[0]].push(fullPath) - } - } - } - - return res -} diff --git a/src/layouts/components/TagsView/index.ts b/src/layouts/components/TagsView/index.ts deleted file mode 100644 index 30e604a8..00000000 --- a/src/layouts/components/TagsView/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import TagsView from './src/TagsView.vue' - -export { TagsView } diff --git a/src/layouts/components/TagsView/src/TagsView.vue b/src/layouts/components/TagsView/src/TagsView.vue deleted file mode 100644 index f24b177c..00000000 --- a/src/layouts/components/TagsView/src/TagsView.vue +++ /dev/null @@ -1,585 +0,0 @@ - - - - - diff --git a/src/layouts/components/TagsView/src/helper.ts b/src/layouts/components/TagsView/src/helper.ts deleted file mode 100644 index 22f6a507..00000000 --- a/src/layouts/components/TagsView/src/helper.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { RouteMeta, RouteLocationNormalizedLoaded } from 'vue-router' -import { pathResolve } from '@/utils/routerHelper' - -export const filterAffixTags = (routes: AppRouteRecordRaw[], parentPath = '') => { - let tags: RouteLocationNormalizedLoaded[] = [] - routes.forEach((route) => { - const meta = route.meta as RouteMeta - const tagPath = pathResolve(parentPath, route.path) - if (meta?.affix) { - tags.push({ ...route, path: tagPath, fullPath: tagPath } as RouteLocationNormalizedLoaded) - } - if (route.children) { - const tempTags: RouteLocationNormalizedLoaded[] = filterAffixTags(route.children, tagPath) - if (tempTags.length >= 1) { - tags = [...tags, ...tempTags] - } - } - }) - - return tags -} diff --git a/src/layouts/components/ThemeSwitch/index.ts b/src/layouts/components/ThemeSwitch/index.ts deleted file mode 100644 index 823a2765..00000000 --- a/src/layouts/components/ThemeSwitch/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import ThemeSwitch from './src/ThemeSwitch.vue' - -export { ThemeSwitch } diff --git a/src/layouts/components/ThemeSwitch/src/ThemeSwitch.vue b/src/layouts/components/ThemeSwitch/src/ThemeSwitch.vue deleted file mode 100644 index 97b355cf..00000000 --- a/src/layouts/components/ThemeSwitch/src/ThemeSwitch.vue +++ /dev/null @@ -1,46 +0,0 @@ - - - - diff --git a/src/layouts/components/ToolHeader.vue b/src/layouts/components/ToolHeader.vue deleted file mode 100644 index ec509df5..00000000 --- a/src/layouts/components/ToolHeader.vue +++ /dev/null @@ -1,95 +0,0 @@ - - - diff --git a/src/layouts/components/UserInfo/index.ts b/src/layouts/components/UserInfo/index.ts deleted file mode 100644 index c3a34aba..00000000 --- a/src/layouts/components/UserInfo/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import UserInfo from './src/UserInfo.vue' - -export { UserInfo } diff --git a/src/layouts/components/UserInfo/src/UserInfo.vue b/src/layouts/components/UserInfo/src/UserInfo.vue deleted file mode 100644 index bb8c2e9a..00000000 --- a/src/layouts/components/UserInfo/src/UserInfo.vue +++ /dev/null @@ -1,113 +0,0 @@ - - - - - diff --git a/src/layouts/components/UserInfo/src/components/LockDialog.vue b/src/layouts/components/UserInfo/src/components/LockDialog.vue deleted file mode 100644 index 0ba6322c..00000000 --- a/src/layouts/components/UserInfo/src/components/LockDialog.vue +++ /dev/null @@ -1,98 +0,0 @@ - - - - - diff --git a/src/layouts/components/UserInfo/src/components/LockPage.vue b/src/layouts/components/UserInfo/src/components/LockPage.vue deleted file mode 100644 index c288d01d..00000000 --- a/src/layouts/components/UserInfo/src/components/LockPage.vue +++ /dev/null @@ -1,269 +0,0 @@ - - - - - diff --git a/src/layouts/components/useRenderLayout.tsx b/src/layouts/components/useRenderLayout.tsx deleted file mode 100644 index 668de51d..00000000 --- a/src/layouts/components/useRenderLayout.tsx +++ /dev/null @@ -1,306 +0,0 @@ -import { computed } from 'vue' -import { useAppStore } from '@/stores/modules/app' -import { Menu } from '@/layouts/components/Menu' -import { TabMenu } from '@/layouts/components/TabMenu' -import { TagsView } from '@/layouts/components/TagsView' -import { Logo } from '@/layouts/components/Logo' -import AppView from './AppView.vue' -import ToolHeader from './ToolHeader.vue' -import { ElScrollbar } from 'element-plus' -import { useDesign } from '@/hooks/web/useDesign' - -const { getPrefixCls } = useDesign() - -const prefixCls = getPrefixCls('layout') - -const appStore = useAppStore() - -const pageLoading = computed(() => appStore.getPageLoading) - -// 标签页 -const tagsView = computed(() => appStore.getTagsView) - -// 菜单折叠 -const collapse = computed(() => appStore.getCollapse) - -// logo -const logo = computed(() => appStore.logo) - -// 固定头部 -const fixedHeader = computed(() => appStore.getFixedHeader) - -// 是否是移动端 -const mobile = computed(() => appStore.getMobile) - -// 固定菜单 -const fixedMenu = computed(() => appStore.getFixedMenu) - -export const useRenderLayout = () => { - const renderClassic = () => { - return ( - <> -
- {logo.value ? ( - - ) : undefined} - -
-
- -
- - - {tagsView.value ? ( - - ) : undefined} -
- - -
-
- - ) - } - - const renderTopLeft = () => { - return ( - <> -
- {logo.value ? : undefined} - - -
-
- -
- - {tagsView.value ? ( - - ) : undefined} - - - -
-
- - ) - } - - const renderTop = () => { - return ( - <> -
- {logo.value ? : undefined} - - -
-
- - {tagsView.value ? ( - - ) : undefined} - - - -
- - ) - } - - const renderCutMenu = () => { - return ( - <> -
- {logo.value ? : undefined} - - -
-
- -
- - {tagsView.value ? ( - - ) : undefined} - - - -
-
- - ) - } - - return { - renderClassic, - renderTopLeft, - renderTop, - renderCutMenu - } -} diff --git a/src/locales/index.ts b/src/locales/index.ts new file mode 100644 index 00000000..1d341cc2 --- /dev/null +++ b/src/locales/index.ts @@ -0,0 +1,11 @@ +const localeModules = import.meta.glob<{ default: Record }>('./*.ts') + +export async function loadLocaleMessages(locale: string) { + const path = `./${locale}.ts` + const loader = localeModules[path] + if (!loader) { + throw new Error(`Locale not found: ${locale}`) + } + const mod = await loader() + return mod.default ?? {} +} diff --git a/src/main.ts b/src/main.ts index 8af5fa27..d84bdb62 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,7 @@ import { createApp, reactive } from 'vue' import App from './App.vue' import router from './router' -import pinia from '@/stores/index' +import { setupStore } from '@/stores/index' import { registerIcons } from '@/utils/common' import mitt from 'mitt' import VxeUI from 'vxe-pc-ui' @@ -25,6 +25,13 @@ import VXETablePluginExportXLSX from 'vxe-table-plugin-export-xlsx' VXETable.use(VXETablePluginExportXLSX, { ExcelJS }) +VxeUI.setConfig({ + table: { + columnConfig: { + useKey: true + } + } +}) // 全局注册 tooltip 组件 window.XEUtils = XEUtils @@ -62,7 +69,7 @@ const setupAll = async () => { await setupI18n(app) app.use(router) - app.use(pinia) + setupStore(app) app.use(VxeUI) app.use(ElementPlus) app.use(VXETable) diff --git a/src/plugins/vueI18n/index.ts b/src/plugins/vueI18n/index.ts index 806f4002..e3c1a325 100644 --- a/src/plugins/vueI18n/index.ts +++ b/src/plugins/vueI18n/index.ts @@ -1,42 +1,42 @@ -import type { App } from 'vue' -import { createI18n } from 'vue-i18n' -import { useLocaleStoreWithOut } from '@/stores/modules/locale' -import type { I18n, I18nOptions } from 'vue-i18n' -import { setHtmlPageLang } from './helper' - -export let i18n: ReturnType - -const createI18nOptions = async (): Promise => { - const localeStore = useLocaleStoreWithOut() - const locale = localeStore.getCurrentLocale - const localeMap = localeStore.getLocaleMap - const defaultLocal = await import(`../../locales/${locale.lang}.ts`) - const message = defaultLocal.default ?? {} - - setHtmlPageLang(locale.lang) - - localeStore.setCurrentLocale({ - lang: locale.lang - // elLocale: elLocal - }) - - return { - legacy: false, - locale: locale.lang, - fallbackLocale: locale.lang, - messages: { - [locale.lang]: message - }, - availableLocales: localeMap.map((v) => v.lang), - sync: true, - silentTranslationWarn: true, - missingWarn: false, - silentFallbackWarn: true - } -} - -export const setupI18n = async (app: App) => { - const options = await createI18nOptions() - i18n = createI18n(options) as I18n - app.use(i18n) -} +import type { App } from 'vue' +import { createI18n } from 'vue-i18n' +import { useLocaleStoreWithOut } from '@/stores/modules/locale' +import type { I18n, I18nOptions } from 'vue-i18n' +import { setHtmlPageLang } from './helper' +import { loadLocaleMessages } from '@/locales' + +export let i18n: ReturnType + +const createI18nOptions = async (): Promise => { + const localeStore = useLocaleStoreWithOut() + const locale = localeStore.getCurrentLocale + const localeMap = localeStore.getLocaleMap + const message = await loadLocaleMessages(locale.lang) + + setHtmlPageLang(locale.lang) + + localeStore.setCurrentLocale({ + lang: locale.lang + // elLocale: elLocal + }) + + return { + legacy: false, + locale: locale.lang, + fallbackLocale: locale.lang, + messages: { + [locale.lang]: message + }, + availableLocales: localeMap.map((v) => v.lang), + sync: true, + silentTranslationWarn: true, + missingWarn: false, + silentFallbackWarn: true + } +} + +export const setupI18n = async (app: App) => { + const options = await createI18nOptions() + i18n = createI18n(options) as I18n + app.use(i18n) +} diff --git a/src/stores/index.ts b/src/stores/index.ts index e952ed84..827ef5a9 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -1,7 +1,15 @@ +import type { App } from 'vue' import { createPinia } from 'pinia' import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' const pinia = createPinia() pinia.use(piniaPluginPersistedstate) +/** 供 setup 外(WithOut)使用的同一 Pinia 实例 */ +export const store = pinia + +export const setupStore = (app: App) => { + app.use(pinia) +} + export default pinia diff --git a/src/stores/indexs.ts b/src/stores/indexs.ts deleted file mode 100644 index 63f00452..00000000 --- a/src/stores/indexs.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { App } from 'vue' -import { createPinia } from 'pinia' -import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' - -const store = createPinia() -store.use(piniaPluginPersistedstate) - -export const setupStore = (app: App) => { - app.use(store) -} - -export { store } diff --git a/src/stores/modules/app.ts b/src/stores/modules/app.ts deleted file mode 100644 index ea53adc4..00000000 --- a/src/stores/modules/app.ts +++ /dev/null @@ -1,277 +0,0 @@ -import { defineStore } from 'pinia' -import { store } from '../indexs' -import { setCssVar, humpToUnderline } from '@/utils' -import { ElMessage } from 'element-plus' -import { CACHE_KEY, useCache } from '@/hooks/web/useCache' -import { ElementPlusSize } from '@/types/elementPlus' -import { LayoutType } from '@/types/layout' -import { ThemeTypes } from '@/types/theme' - -const { wsCache } = useCache() - -interface AppState { - breadcrumb: boolean - breadcrumbIcon: boolean - collapse: boolean - uniqueOpened: boolean - hamburger: boolean - screenfull: boolean - search: boolean - size: boolean - locale: boolean - message: boolean - tagsView: boolean - tagsViewIcon: boolean - logo: boolean - fixedHeader: boolean - greyMode: boolean - pageLoading: boolean - layout: LayoutType - title: string - userInfo: string - isDark: boolean - currentSize: ElementPlusSize - sizeMap: ElementPlusSize[] - mobile: boolean - footer: boolean - theme: ThemeTypes - fixedMenu: boolean -} - -export const useAppStore = defineStore('app', { - state: (): AppState => { - return { - userInfo: 'userInfo', // 登录信息存储字段-建议每个项目换一个字段,避免与其他项目冲突 - sizeMap: ['default', 'large', 'small'], - mobile: false, // 是否是移动端 - title: import.meta.env.VITE_APP_TITLE, // 标题 - pageLoading: false, // 路由跳转loading - - breadcrumb: true, // 面包屑 - breadcrumbIcon: true, // 面包屑图标 - collapse: false, // 折叠菜单 - uniqueOpened: true, // 是否只保持一个子菜单的展开 - hamburger: true, // 折叠图标 - screenfull: true, // 全屏图标 - search: true, // 搜索图标 - size: true, // 尺寸图标 - locale: true, // 多语言图标 - message: true, // 消息图标 - tagsView: true, // 标签页 - tagsViewIcon: true, // 是否显示标签图标 - logo: true, // logo - fixedHeader: true, // 固定toolheader - footer: true, // 显示页脚 - greyMode: false, // 是否开始灰色模式,用于特殊悼念日 - fixedMenu: wsCache.get('fixedMenu') || false, // 是否固定菜单 - - layout: wsCache.get(CACHE_KEY.LAYOUT) || 'classic', // layout布局 - isDark: wsCache.get(CACHE_KEY.IS_DARK) || false, // 是否是暗黑模式 - currentSize: wsCache.get('default') || 'default', // 组件尺寸 - theme: wsCache.get(CACHE_KEY.THEME) || { - // 主题色 - elColorPrimary: '#409eff', - // 左侧菜单边框颜色 - leftMenuBorderColor: 'inherit', - // 左侧菜单背景颜色 - leftMenuBgColor: '#001529', - // 左侧菜单浅色背景颜色 - leftMenuBgLightColor: '#0f2438', - // 左侧菜单选中背景颜色 - leftMenuBgActiveColor: 'var(--el-color-primary)', - // 左侧菜单收起选中背景颜色 - leftMenuCollapseBgActiveColor: 'var(--el-color-primary)', - // 左侧菜单字体颜色 - leftMenuTextColor: '#bfcbd9', - // 左侧菜单选中字体颜色 - leftMenuTextActiveColor: '#fff', - // logo字体颜色 - logoTitleTextColor: '#fff', - // logo边框颜色 - logoBorderColor: 'inherit', - // 头部背景颜色 - topHeaderBgColor: '#fff', - // 头部字体颜色 - topHeaderTextColor: 'inherit', - // 头部悬停颜色 - topHeaderHoverColor: '#f6f6f6', - // 头部边框颜色 - topToolBorderColor: '#eee' - } - } - }, - getters: { - getBreadcrumb(): boolean { - return this.breadcrumb - }, - getBreadcrumbIcon(): boolean { - return this.breadcrumbIcon - }, - getCollapse(): boolean { - return this.collapse - }, - getUniqueOpened(): boolean { - return this.uniqueOpened - }, - getHamburger(): boolean { - return this.hamburger - }, - getScreenfull(): boolean { - return this.screenfull - }, - getSize(): boolean { - return this.size - }, - getLocale(): boolean { - return this.locale - }, - getMessage(): boolean { - return this.message - }, - getTagsView(): boolean { - return this.tagsView - }, - getTagsViewIcon(): boolean { - return this.tagsViewIcon - }, - getLogo(): boolean { - return this.logo - }, - getFixedHeader(): boolean { - return this.fixedHeader - }, - getGreyMode(): boolean { - return this.greyMode - }, - getFixedMenu(): boolean { - return this.fixedMenu - }, - getPageLoading(): boolean { - return this.pageLoading - }, - getLayout(): LayoutType { - return this.layout - }, - getTitle(): string { - return this.title - }, - getUserInfo(): string { - return this.userInfo - }, - getIsDark(): boolean { - return this.isDark - }, - getCurrentSize(): ElementPlusSize { - return this.currentSize - }, - getSizeMap(): ElementPlusSize[] { - return this.sizeMap - }, - getMobile(): boolean { - return this.mobile - }, - getTheme(): ThemeTypes { - return this.theme - }, - getFooter(): boolean { - return this.footer - } - }, - actions: { - setBreadcrumb(breadcrumb: boolean) { - this.breadcrumb = breadcrumb - }, - setBreadcrumbIcon(breadcrumbIcon: boolean) { - this.breadcrumbIcon = breadcrumbIcon - }, - setCollapse(collapse: boolean) { - this.collapse = collapse - }, - setUniqueOpened(uniqueOpened: boolean) { - this.uniqueOpened = uniqueOpened - }, - setHamburger(hamburger: boolean) { - this.hamburger = hamburger - }, - setScreenfull(screenfull: boolean) { - this.screenfull = screenfull - }, - setSize(size: boolean) { - this.size = size - }, - setLocale(locale: boolean) { - this.locale = locale - }, - setMessage(message: boolean) { - this.message = message - }, - setTagsView(tagsView: boolean) { - this.tagsView = tagsView - }, - setTagsViewIcon(tagsViewIcon: boolean) { - this.tagsViewIcon = tagsViewIcon - }, - setLogo(logo: boolean) { - this.logo = logo - }, - setFixedHeader(fixedHeader: boolean) { - this.fixedHeader = fixedHeader - }, - setGreyMode(greyMode: boolean) { - this.greyMode = greyMode - }, - setFixedMenu(fixedMenu: boolean) { - wsCache.set('fixedMenu', fixedMenu) - this.fixedMenu = fixedMenu - }, - setPageLoading(pageLoading: boolean) { - this.pageLoading = pageLoading - }, - setLayout(layout: LayoutType) { - if (this.mobile && layout !== 'classic') { - ElMessage.warning('移动端模式下不支持切换其他布局') - return - } - this.layout = layout - wsCache.set(CACHE_KEY.LAYOUT, this.layout) - }, - setTitle(title: string) { - this.title = title - }, - setIsDark(isDark: boolean) { - this.isDark = isDark - if (this.isDark) { - document.documentElement.classList.add('dark') - document.documentElement.classList.remove('light') - } else { - document.documentElement.classList.add('light') - document.documentElement.classList.remove('dark') - } - wsCache.set(CACHE_KEY.IS_DARK, this.isDark) - }, - setCurrentSize(currentSize: ElementPlusSize) { - this.currentSize = currentSize - wsCache.set('currentSize', this.currentSize) - }, - setMobile(mobile: boolean) { - this.mobile = mobile - }, - setTheme(theme: ThemeTypes) { - this.theme = Object.assign(this.theme, theme) - wsCache.set(CACHE_KEY.THEME, this.theme) - }, - setCssVarTheme() { - for (const key in this.theme) { - setCssVar(`--${humpToUnderline(key)}`, this.theme[key]) - } - }, - setFooter(footer: boolean) { - this.footer = footer - } - }, - persist: false -}) - -export const useAppStoreWithOut = () => { - return useAppStore(store) -} diff --git a/src/stores/modules/dict.ts b/src/stores/modules/dict.ts deleted file mode 100644 index 4547615d..00000000 --- a/src/stores/modules/dict.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { defineStore } from 'pinia' -import { store } from '../indexs' -// @ts-ignore -import { DictDataVO } from '@/api/system/dict/types' -import { CACHE_KEY, useCache } from '@/hooks/web/useCache' -const { wsCache } = useCache('sessionStorage') -// import { getSimpleDictDataList } from '@/api/system/dict/dict.data' - -export interface DictValueType { - value: any - label: string - clorType?: string - cssClass?: string -} -export interface DictTypeType { - dictType: string - dictValue: DictValueType[] -} -export interface DictState { - dictMap: Map - isSetDict: boolean -} - -export const useDictStore = defineStore('dict', { - state: (): DictState => ({ - dictMap: new Map(), - isSetDict: false - }), - getters: { - getDictMap(): Recordable { - const dictMap = wsCache.get(CACHE_KEY.DICT_CACHE) - if (dictMap) { - this.dictMap = dictMap - } - return this.dictMap - }, - getIsSetDict(): boolean { - return this.isSetDict - } - }, - actions: { - async setDictMap() { - const dictMap = wsCache.get(CACHE_KEY.DICT_CACHE) - if (dictMap) { - this.dictMap = dictMap - this.isSetDict = true - } else { - // const res = await getSimpleDictDataList() - // 设置数据 - const dictDataMap = new Map() - // res.forEach((dictData: DictDataVO) => { - // // 获得 dictType 层级 - // const enumValueObj = dictDataMap[dictData.dictType] - // if (!enumValueObj) { - // dictDataMap[dictData.dictType] = [] - // } - // // 处理 dictValue 层级 - // dictDataMap[dictData.dictType].push({ - // value: dictData.value, - // label: dictData.label, - // colorType: dictData.colorType, - // cssClass: dictData.cssClass - // }) - // }) - this.dictMap = dictDataMap - this.isSetDict = true - wsCache.set(CACHE_KEY.DICT_CACHE, dictDataMap, { exp: 60 }) // 60 秒 过期 - } - }, - getDictByType(type: string) { - console.log("🚀 ~ type:", type) - if (!this.isSetDict) { - this.setDictMap() - } - return this.dictMap[type] - }, - async resetDict() { - wsCache.delete(CACHE_KEY.DICT_CACHE) - // const res = await getSimpleDictDataList() - // 设置数据 - const dictDataMap = new Map() - // res.forEach((dictData: DictDataVO) => { - // // 获得 dictType 层级 - // const enumValueObj = dictDataMap[dictData.dictType] - // if (!enumValueObj) { - // dictDataMap[dictData.dictType] = [] - // } - // // 处理 dictValue 层级 - // dictDataMap[dictData.dictType].push({ - // value: dictData.value, - // label: dictData.label, - // colorType: dictData.colorType, - // cssClass: dictData.cssClass - // }) - // }) - this.dictMap = dictDataMap - this.isSetDict = true - wsCache.set(CACHE_KEY.DICT_CACHE, dictDataMap, { exp: 60 }) // 60 秒 过期 - } - } -}) - -export const useDictStoreWithOut = () => { - return useDictStore(store) -} diff --git a/src/stores/modules/locale.ts b/src/stores/modules/locale.ts index 5ddf1fad..ae686aaf 100644 --- a/src/stores/modules/locale.ts +++ b/src/stores/modules/locale.ts @@ -1,59 +1,59 @@ -import { defineStore } from 'pinia' -import { store } from '../indexs' -import zhCn from 'element-plus/es/locale/lang/zh-cn' -import en from 'element-plus/es/locale/lang/en' -import { CACHE_KEY, useCache } from '@/hooks/web/useCache' -import { LocaleDropdownType } from '@/types/localeDropdown' - -const { wsCache } = useCache() - -const elLocaleMap = { - 'zh-CN': zhCn, - en: en -} -interface LocaleState { - currentLocale: LocaleDropdownType - localeMap: LocaleDropdownType[] -} - -export const useLocaleStore = defineStore('locales', { - state: (): LocaleState => { - return { - currentLocale: { - lang: wsCache.get(CACHE_KEY.LANG) || 'zh-CN', - elLocale: elLocaleMap[wsCache.get(CACHE_KEY.LANG) || 'zh-CN'] - }, - // 多语言 - localeMap: [ - { - lang: 'zh-CN', - name: '简体中文' - }, - { - lang: 'en', - name: 'English' - } - ] - } - }, - getters: { - getCurrentLocale(): LocaleDropdownType { - return this.currentLocale - }, - getLocaleMap(): LocaleDropdownType[] { - return this.localeMap - } - }, - actions: { - setCurrentLocale(localeMap: LocaleDropdownType) { - // this.locale = Object.assign(this.locale, localeMap) - this.currentLocale.lang = localeMap?.lang - this.currentLocale.elLocale = elLocaleMap[localeMap?.lang] - wsCache.set(CACHE_KEY.LANG, localeMap?.lang) - } - } -}) - -export const useLocaleStoreWithOut = () => { - return useLocaleStore(store) -} +import { defineStore } from 'pinia' +import { store } from '@/stores/index' +import zhCn from 'element-plus/es/locale/lang/zh-cn' +import en from 'element-plus/es/locale/lang/en' +import { CACHE_KEY, useCache } from '@/hooks/web/useCache' +import { LocaleDropdownType } from '@/types/localeDropdown' + +const { wsCache } = useCache() + +const elLocaleMap = { + 'zh-CN': zhCn, + en: en +} +interface LocaleState { + currentLocale: LocaleDropdownType + localeMap: LocaleDropdownType[] +} + +export const useLocaleStore = defineStore('locales', { + state: (): LocaleState => { + return { + currentLocale: { + lang: wsCache.get(CACHE_KEY.LANG) || 'zh-CN', + elLocale: elLocaleMap[wsCache.get(CACHE_KEY.LANG) || 'zh-CN'] + }, + // 多语言 + localeMap: [ + { + lang: 'zh-CN', + name: '简体中文' + }, + { + lang: 'en', + name: 'English' + } + ] + } + }, + getters: { + getCurrentLocale(): LocaleDropdownType { + return this.currentLocale + }, + getLocaleMap(): LocaleDropdownType[] { + return this.localeMap + } + }, + actions: { + setCurrentLocale(localeMap: LocaleDropdownType) { + // this.locale = Object.assign(this.locale, localeMap) + this.currentLocale.lang = localeMap?.lang + this.currentLocale.elLocale = elLocaleMap[localeMap?.lang] + wsCache.set(CACHE_KEY.LANG, localeMap?.lang) + } + } +}) + +export const useLocaleStoreWithOut = () => { + return useLocaleStore(store) +} diff --git a/src/stores/modules/lock.ts b/src/stores/modules/lock.ts deleted file mode 100644 index ad0d63bd..00000000 --- a/src/stores/modules/lock.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { defineStore } from 'pinia' -import { store } from '@/stores/indexs' - -interface lockInfo { - isLock?: boolean - password?: string -} - -interface LockState { - lockInfo: lockInfo -} - -export const useLockStore = defineStore('lock', { - state: (): LockState => { - return { - lockInfo: { - // isLock: false, // 是否锁定屏幕 - // password: '' // 锁屏密码 - } - } - }, - getters: { - getLockInfo(): lockInfo { - return this.lockInfo - } - }, - actions: { - setLockInfo(lockInfo: lockInfo) { - this.lockInfo = lockInfo - }, - resetLockInfo() { - this.lockInfo = {} - }, - unLock(password: string) { - if (this.lockInfo?.password === password) { - this.resetLockInfo() - return true - } else { - return false - } - } - }, - persist: true -}) - -export const useLockStoreWithOut = () => { - return useLockStore(store) -} diff --git a/src/stores/modules/permission.ts b/src/stores/modules/permission.ts deleted file mode 100644 index 93c56c92..00000000 --- a/src/stores/modules/permission.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { defineStore } from 'pinia' -import { store } from '@/stores/indexs' -import { cloneDeep } from 'lodash-es' -import { flatMultiLevelRoutes, generateRoute } from '@/utils/routerHelper' -import { CACHE_KEY, useCache } from '@/hooks/web/useCache' - -const { wsCache } = useCache() - -export interface PermissionState { - routers: AppRouteRecordRaw[] - addRouters: AppRouteRecordRaw[] - menuTabRouters: AppRouteRecordRaw[] -} - -export const usePermissionStore = defineStore('permission', { - state: (): PermissionState => ({ - routers: [], - addRouters: [], - menuTabRouters: [] - }), - getters: { - getRouters(): AppRouteRecordRaw[] { - return this.routers - }, - getAddRouters(): AppRouteRecordRaw[] { - return flatMultiLevelRoutes(cloneDeep(this.addRouters)) - }, - getMenuTabRouters(): AppRouteRecordRaw[] { - return this.menuTabRouters - } - }, - actions: { - async generateRoutes(): Promise { - return new Promise(async (resolve) => { - // 获得菜单列表,它在登录的时候,setUserInfoAction 方法中已经进行获取 - let res: AppCustomRouteRecordRaw[] = [] - if (wsCache.get(CACHE_KEY.ROLE_ROUTERS)) { - res = wsCache.get(CACHE_KEY.ROLE_ROUTERS) as AppCustomRouteRecordRaw[] - } - const routerMap: AppRouteRecordRaw[] = generateRoute(res) - // 动态路由,404一定要放到最后面 - this.addRouters = routerMap.concat([ - { - path: '/:path(.*)*', - redirect: '/404', - name: '404Page', - meta: { - hidden: true, - breadcrumb: false - } - } - ]) - // 渲染菜单的所有路由 - resolve() - }) - }, - setMenuTabRouters(routers: AppRouteRecordRaw[]): void { - this.menuTabRouters = routers - } - }, - persist: false -}) - -export const usePermissionStoreWithOut = () => { - return usePermissionStore(store) -} diff --git a/src/stores/modules/simpleWorkflow.ts b/src/stores/modules/simpleWorkflow.ts deleted file mode 100644 index cf98538d..00000000 --- a/src/stores/modules/simpleWorkflow.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { store } from '../index' -import { defineStore } from 'pinia' - -export const useWorkFlowStore = defineStore('simpleWorkflow', { - state: () => ({ - tableId: '', - isTried: false, - promoterDrawer: false, - flowPermission1: {}, - approverDrawer: false, - approverConfig1: {}, - copyerDrawer: false, - copyerConfig1: {}, - conditionDrawer: false, - conditionsConfig1: { - conditionNodes: [] - } - }), - actions: { - setTableId(payload) { - this.tableId = payload - }, - setIsTried(payload) { - this.isTried = payload - }, - setPromoter(payload) { - this.promoterDrawer = payload - }, - setFlowPermission(payload) { - this.flowPermission1 = payload - }, - setApprover(payload) { - this.approverDrawer = payload - }, - setApproverConfig(payload) { - this.approverConfig1 = payload - }, - setCopyer(payload) { - this.copyerDrawer = payload - }, - setCopyerConfig(payload) { - this.copyerConfig1 = payload - }, - setCondition(payload) { - this.conditionDrawer = payload - }, - setConditionsConfig(payload) { - this.conditionsConfig1 = payload - } - } -}) - -export const useWorkFlowStoreWithOut = () => { - return useWorkFlowStore(store) -} diff --git a/src/stores/modules/tagsView.ts b/src/stores/modules/tagsView.ts deleted file mode 100644 index 87620dcf..00000000 --- a/src/stores/modules/tagsView.ts +++ /dev/null @@ -1,141 +0,0 @@ -import router from '@/router' -import type { RouteLocationNormalizedLoaded } from 'vue-router' -import { getRawRoute } from '@/utils/routerHelper' -import { defineStore } from 'pinia' -import { store } from '../indexs' -import { findIndex } from '@/utils' - -export interface TagsViewState { - visitedViews: RouteLocationNormalizedLoaded[] - cachedViews: Set -} - -export const useTagsViewStore = defineStore('tagsView', { - state: (): TagsViewState => ({ - visitedViews: [], - cachedViews: new Set() - }), - getters: { - getVisitedViews(): RouteLocationNormalizedLoaded[] { - return this.visitedViews - }, - getCachedViews(): string[] { - return Array.from(this.cachedViews) - } - }, - actions: { - // 新增缓存和tag - addView(view: RouteLocationNormalizedLoaded): void { - this.addVisitedView(view) - this.addCachedView() - }, - // 新增tag - addVisitedView(view: RouteLocationNormalizedLoaded) { - if (this.visitedViews.some((v) => v.path === view.path)) return - if (view.meta?.noTagsView) return - this.visitedViews.push( - Object.assign({}, view, { - title: view.meta?.title || 'no-name' - }) - ) - }, - // 新增缓存 - addCachedView() { - const cacheMap: Set = new Set() - for (const v of this.visitedViews) { - const item = getRawRoute(v) - const needCache = !item.meta?.noCache - if (!needCache) { - continue - } - const name = item.name as string - cacheMap.add(name) - } - if (Array.from(this.cachedViews).sort().toString() === Array.from(cacheMap).sort().toString()) - return - this.cachedViews = cacheMap - }, - // 删除某个 - delView(view: RouteLocationNormalizedLoaded) { - this.delVisitedView(view) - this.delCachedView() - }, - // 删除tag - delVisitedView(view: RouteLocationNormalizedLoaded) { - for (const [i, v] of this.visitedViews.entries()) { - if (v.path === view.path) { - this.visitedViews.splice(i, 1) - break - } - } - }, - // 删除缓存 - delCachedView() { - const route = router.currentRoute.value - const index = findIndex(this.getCachedViews, (v) => v === route.name) - if (index > -1) { - this.cachedViews.delete(this.getCachedViews[index]) - } - }, - // 删除所有缓存和tag - delAllViews() { - this.delAllVisitedViews() - this.delCachedView() - }, - // 删除所有tag - delAllVisitedViews() { - // const affixTags = this.visitedViews.filter((tag) => tag.meta.affix) - this.visitedViews = [] - }, - // 删除其他 - delOthersViews(view: RouteLocationNormalizedLoaded) { - this.delOthersVisitedViews(view) - this.addCachedView() - }, - // 删除其他tag - delOthersVisitedViews(view: RouteLocationNormalizedLoaded) { - this.visitedViews = this.visitedViews.filter((v) => { - return v?.meta?.affix || v.path === view.path - }) - }, - // 删除左侧 - delLeftViews(view: RouteLocationNormalizedLoaded) { - const index = findIndex( - this.visitedViews, - (v) => v.path === view.path - ) - if (index > -1) { - this.visitedViews = this.visitedViews.filter((v, i) => { - return v?.meta?.affix || v.path === view.path || i > index - }) - this.addCachedView() - } - }, - // 删除右侧 - delRightViews(view: RouteLocationNormalizedLoaded) { - const index = findIndex( - this.visitedViews, - (v) => v.path === view.path - ) - if (index > -1) { - this.visitedViews = this.visitedViews.filter((v, i) => { - return v?.meta?.affix || v.path === view.path || i < index - }) - this.addCachedView() - } - }, - updateVisitedView(view: RouteLocationNormalizedLoaded) { - for (let v of this.visitedViews) { - if (v.path === view.path) { - v = Object.assign(v, view) - break - } - } - } - }, - persist: false -}) - -export const useTagsViewStoreWithOut = () => { - return useTagsViewStore(store) -} diff --git a/src/stores/modules/user.ts b/src/stores/modules/user.ts deleted file mode 100644 index 6117fb7a..00000000 --- a/src/stores/modules/user.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { store } from '@/stores/indexs' -import { defineStore } from 'pinia' -import { getAccessToken, removeToken } from '@/utils/auth' -import { CACHE_KEY, useCache, deleteUserCache } from '@/hooks/web/useCache' -// import { getInfo, loginOut } from '@/api/login' - -const { wsCache } = useCache() - -interface UserVO { - id: number - avatar: string - nickname: string - deptId: number -} - -interface UserInfoVO { - // USER 缓存 - permissions: string[] - roles: string[] - isSetUser: boolean - user: UserVO -} - -export const useUserStore = defineStore('admin-user', { - state: (): UserInfoVO => ({ - permissions: [], - roles: [], - isSetUser: false, - user: { - id: 0, - avatar: '', - nickname: '', - deptId: 0 - } - }), - getters: { - getPermissions(): string[] { - return this.permissions - }, - getRoles(): string[] { - return this.roles - }, - getIsSetUser(): boolean { - return this.isSetUser - }, - getUser(): UserVO { - return this.user - } - }, - actions: { - async setUserInfoAction() { - if (!getAccessToken()) { - this.resetState() - return null - } - let userInfo = wsCache.get(CACHE_KEY.USER) - if (!userInfo) { - // userInfo = await getInfo() - } - this.permissions = userInfo.permissions - this.roles = userInfo.roles - this.user = userInfo.user - this.isSetUser = true - wsCache.set(CACHE_KEY.USER, userInfo) - wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus) - }, - async setUserAvatarAction(avatar: string) { - const userInfo = wsCache.get(CACHE_KEY.USER) - // NOTE: 是否需要像`setUserInfoAction`一样判断`userInfo != null` - this.user.avatar = avatar - userInfo.user.avatar = avatar - wsCache.set(CACHE_KEY.USER, userInfo) - }, - async setUserNicknameAction(nickname: string) { - const userInfo = wsCache.get(CACHE_KEY.USER) - // NOTE: 是否需要像`setUserInfoAction`一样判断`userInfo != null` - this.user.nickname = nickname - userInfo.user.nickname = nickname - wsCache.set(CACHE_KEY.USER, userInfo) - }, - async loginOut() { - // await loginOut() - removeToken() - deleteUserCache() // 删除用户缓存 - this.resetState() - }, - resetState() { - this.permissions = [] - this.roles = [] - this.isSetUser = false - this.user = { - id: 0, - avatar: '', - nickname: '', - deptId: 0 - } - } - } -}) - -export const useUserStoreWithOut = () => { - return useUserStore(store) -} diff --git a/src/utils/dict.ts b/src/utils/dict.ts index 5a9fa5dd..ba6c6f76 100644 --- a/src/utils/dict.ts +++ b/src/utils/dict.ts @@ -1,16 +1,39 @@ /** - * 数据字典工具类 + * 数据字典工具类(统一读取 dictData store) */ -import {useDictStoreWithOut} from '@/stores/modules/dict' -import {ElementPlusInfoType} from '@/types/elementPlus' +import { useDictData } from '@/stores/dictData' +import { store } from '@/stores/index' +import type { BasicDictData } from '@/stores/interface' +import { ElementPlusInfoType } from '@/types/elementPlus' -const dictStore = useDictStoreWithOut() +const getDictDataStore = () => useDictData(store) + +function toDictCodeVariants(dictType: string): string[] { + const variants = new Set([dictType]) + if (dictType.includes('_')) { + variants.add( + dictType + .split('_') + .map((part) => part.charAt(0).toUpperCase() + part.slice(1)) + .join('_') + ) + } + return [...variants] +} + +function findBasicDict(dictType: string): BasicDictData | undefined { + const basic = getDictDataStore().state.basic + for (const variant of toDictCodeVariants(dictType)) { + const found = basic.find( + (item) => item.code === variant || item.code.toLowerCase() === variant.toLowerCase() + ) + if (found) return found + } + return undefined +} /** * 获取 dictType 对应的数据字典数组 - * - * @param dictType 数据类型 - * @returns {*|Array} 数据字典数组 */ export interface DictDataType { dictType: string @@ -24,15 +47,20 @@ export interface NumberDictDataType extends DictDataType { value: number } -export const getDictOptions = (dictType: string) => { - return dictStore.getDictByType(dictType) || [] +export const getDictOptions = (dictType: string): DictDataType[] => { + const basic = findBasicDict(dictType) + if (!basic?.children?.length) return [] + return basic.children.map((item) => ({ + dictType, + label: item.name, + value: item.code || item.id, + colorType: '' as ElementPlusInfoType | '', + cssClass: '' + })) } export const getIntDictOptions = (dictType: string): NumberDictDataType[] => { - // 获得通用的 DictDataType 列表 const dictOptions: DictDataType[] = getDictOptions(dictType) - // 转换成 number 类型的 NumberDictDataType 类型 - // why 需要特殊转换:避免 IDEA 在 v-for="dict in getIntDictOptions(...)" 时,el-option 的 key 会告警 const dictOption: NumberDictDataType[] = [] dictOptions.forEach((dict: DictDataType) => { dictOption.push({ @@ -40,7 +68,6 @@ export const getIntDictOptions = (dictType: string): NumberDictDataType[] => { value: parseInt(dict.value + '') }) }) - console.log("🚀 ~ getIntDictOptions ~ dictOption:", dictOption) return dictOption } @@ -70,9 +97,6 @@ export const getBoolDictOptions = (dictType: string) => { /** * 获取指定字典类型的指定值对应的字典对象 - * @param dictType 字典类型 - * @param value 字典值 - * @return DictDataType 字典对象 */ export const getDictObj = (dictType: string, value: any): DictDataType | undefined => { const dictOptions: DictDataType[] = getDictOptions(dictType) @@ -85,10 +109,6 @@ export const getDictObj = (dictType: string, value: any): DictDataType | undefin /** * 获得字典数据的文本展示 - * - * @param dictType 字典类型 - * @param value 字典数据的值 - * @return 字典名称 */ export const getDictLabel = (dictType: string, value: any): string => { const dictOptions: DictDataType[] = getDictOptions(dictType) diff --git a/src/utils/request.ts b/src/utils/request.ts index 8b1e9c58..6ef6c9ca 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -242,6 +242,25 @@ function createAxios>( return Axios(axiosConfig) as T } +/** 发起请求并直接返回业务 data 字段 */ +export async function requestData( + axiosConfig: AxiosRequestConfig, + options?: Options, + loading?: LoadingOptions +): Promise { + const res = await createAxios>(axiosConfig, options, loading) + return (res as ApiResponse)?.data as T +} + +/** 下载文件,返回原始 axios 响应 */ +export function requestDownload( + axiosConfig: AxiosRequestConfig, + options?: Options, + loading?: LoadingOptions +) { + return createAxios(axiosConfig, { ...options, reductDataFormat: false }, loading) +} + export default createAxios /** diff --git a/src/utils/routerHelper.ts b/src/utils/routerHelper.ts index 08942384..f8b04fe6 100644 --- a/src/utils/routerHelper.ts +++ b/src/utils/routerHelper.ts @@ -1,253 +1,14 @@ -import type { RouteLocationNormalized, Router, RouteRecordNormalized } from 'vue-router' -import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router' -import { isUrl } from '@/utils/is' -import { cloneDeep, omit } from 'lodash-es' -import qs from 'qs' - -const modules = import.meta.glob('../views/**/*.{vue,tsx}') -/** - * 注册一个异步组件 - * @param componentPath 例:/bpm/oa/leave/detail - */ -export const registerComponent = (componentPath: string) => { - for (const item in modules) { - if (item.includes(componentPath)) { - // 使用异步组件的方式来动态加载组件 - // @ts-ignore - return defineAsyncComponent(modules[item]) - } - } -} -/* Layout */ -export const Layout = () => import('@/layouts/Layout.vue') - -export const getParentLayout = () => { - return () => - new Promise((resolve) => { - resolve({ - name: 'ParentLayout' - }) - }) -} - -// 按照路由中meta下的rank等级升序来排序路由 -export const ascending = (arr: any[]) => { - arr.forEach((v) => { - if (v?.meta?.rank === null) v.meta.rank = undefined - if (v?.meta?.rank === 0) { - if (v.name !== 'home' && v.path !== '/') { - console.warn('rank only the home page can be 0') - } - } - }) - return arr.sort((a: { meta: { rank: number } }, b: { meta: { rank: number } }) => { - return a?.meta?.rank - b?.meta?.rank - }) -} - -export const getRawRoute = (route: RouteLocationNormalized): RouteLocationNormalized => { - if (!route) return route - const { matched, ...opt } = route - return { - ...opt, - matched: (matched - ? matched.map((item) => ({ - meta: item.meta, - name: item.name, - path: item.path - })) - : undefined) as RouteRecordNormalized[] - } -} - -// 后端控制路由生成 -export const generateRoute = (routes: AppCustomRouteRecordRaw[]): AppRouteRecordRaw[] => { - const res: AppRouteRecordRaw[] = [] - const modulesRoutesKeys = Object.keys(modules) - for (const route of routes) { - // 1. 生成 meta 菜单元数据 - const meta = { - title: route.name, - icon: route.icon, - hidden: !route.visible, - noCache: !route.keepAlive, - alwaysShow: - route.children && - route.children.length === 1 && - (route.alwaysShow !== undefined ? route.alwaysShow : true) - } as any - // 特殊逻辑:如果后端配置的 MenuDO.component 包含 ?,则表示需要传递参数 - // 此时,我们需要解析参数,并且将参数放到 meta.query 中 - // 这样,后续在 Vue 文件中,可以通过 const { currentRoute } = useRouter() 中,通过 meta.query 获取到参数 - if (route.component && route.component.indexOf('?') > -1) { - const query = route.component.split('?')[1] - route.component = route.component.split('?')[0] - meta.query = qs.parse(query) - } - - // 2. 生成 data(AppRouteRecordRaw) - // 路由地址转首字母大写驼峰,作为路由名称,适配keepAlive - let data: AppRouteRecordRaw = { - path: route.path.indexOf('?') > -1 ? route.path.split('?')[0] : route.path, - name: - route.componentName && route.componentName.length > 0 - ? route.componentName - : toCamelCase(route.path, true), - redirect: route.redirect, - meta: meta - } - //处理顶级非目录路由 - if (!route.children && route.parentId == 0 && route.component) { - data.component = Layout - data.meta = {} - data.name = toCamelCase(route.path, true) + 'Parent' - data.redirect = '' - meta.alwaysShow = true - const childrenData: AppRouteRecordRaw = { - path: '', - name: - route.componentName && route.componentName.length > 0 - ? route.componentName - : toCamelCase(route.path, true), - redirect: route.redirect, - meta: meta - } - const index = route?.component - ? modulesRoutesKeys.findIndex((ev) => ev.includes(route.component)) - : modulesRoutesKeys.findIndex((ev) => ev.includes(route.path)) - childrenData.component = modules[modulesRoutesKeys[index]] - data.children = [childrenData] - } else { - // 目录 - if (route.children) { - data.component = Layout - data.redirect = getRedirect(route.path, route.children) - // 外链 - } else if (isUrl(route.path)) { - data = { - path: '/external-link', - component: Layout, - meta: { - name: route.name - }, - children: [data] - } as AppRouteRecordRaw - // 菜单 - } else { - // 对后端传component组件路径和不传做兼容(如果后端传component组件路径,那么path可以随便写,如果不传,component组件路径会根path保持一致) - const index = route?.component - ? modulesRoutesKeys.findIndex((ev) => ev.includes(route.component)) - : modulesRoutesKeys.findIndex((ev) => ev.includes(route.path)) - data.component = modules[modulesRoutesKeys[index]] - } - if (route.children) { - data.children = generateRoute(route.children) - } - } - res.push(data as AppRouteRecordRaw) - } - return res -} -export const getRedirect = (parentPath: string, children: AppCustomRouteRecordRaw[]) => { - if (!children || children.length == 0) { - return parentPath - } - const path = generateRoutePath(parentPath, children[0].path) - // 递归子节点 - if (children[0].children) return getRedirect(path, children[0].children) -} -const generateRoutePath = (parentPath: string, path: string) => { - if (parentPath.endsWith('/')) { - parentPath = parentPath.slice(0, -1) // 移除默认的 / - } - if (!path.startsWith('/')) { - path = '/' + path - } - return parentPath + path -} -export const pathResolve = (parentPath: string, path: string) => { - if (isUrl(path)) return path - const childPath = path.startsWith('/') || !path ? path : `/${path}` - return `${parentPath}${childPath}`.replace(/\/\//g, '/') -} - -// 路由降级 -export const flatMultiLevelRoutes = (routes: AppRouteRecordRaw[]) => { - const modules: AppRouteRecordRaw[] = cloneDeep(routes) - for (let index = 0; index < modules.length; index++) { - const route = modules[index] - if (!isMultipleRoute(route)) { - continue - } - promoteRouteLevel(route) - } - return modules -} - -// 层级是否大于2 -const isMultipleRoute = (route: AppRouteRecordRaw) => { - if (!route || !Reflect.has(route, 'children') || !route.children?.length) { - return false - } - - const children = route.children - - let flag = false - for (let index = 0; index < children.length; index++) { - const child = children[index] - if (child.children?.length) { - flag = true - break - } - } - return flag -} - -// 生成二级路由 -const promoteRouteLevel = (route: AppRouteRecordRaw) => { - let router: Router | null = createRouter({ - routes: [route as RouteRecordRaw], - history: createWebHashHistory() - }) - - const routes = router.getRoutes() - addToChildren(routes, route.children || [], route) - router = null - - route.children = route.children?.map((item) => omit(item, 'children')) -} - -// 添加所有子菜单 -const addToChildren = ( - routes: RouteRecordNormalized[], - children: AppRouteRecordRaw[], - routeModule: AppRouteRecordRaw -) => { - for (let index = 0; index < children.length; index++) { - const child = children[index] - const route = routes.find((item) => item.name === child.name) - if (!route) { - continue - } - routeModule.children = routeModule.children || [] - if (!routeModule.children.find((item) => item.name === route.name)) { - routeModule.children?.push(route as unknown as AppRouteRecordRaw) - } - if (child.children?.length) { - addToChildren(routes, child.children, routeModule) - } - } -} -const toCamelCase = (str: string, upperCaseFirst: boolean) => { - str = (str || '') - .replace(/-(.)/g, function (group1: string) { - return group1.toUpperCase() - }) - .replaceAll('-', '') - - if (upperCaseFirst && str) { - str = str.charAt(0).toUpperCase() + str.slice(1) - } - - return str -} +const modules = import.meta.glob('../views/**/*.{vue,tsx}') + +/** + * 注册一个异步组件 + * @param componentPath 例:/bpm/oa/leave/detail + */ +export const registerComponent = (componentPath: string) => { + for (const item in modules) { + if (item.includes(componentPath)) { + // @ts-ignore + return defineAsyncComponent(modules[item]) + } + } +} diff --git a/src/views/pqs/harmonicMonitoring/reportForms/word/index.vue b/src/views/pqs/harmonicMonitoring/reportForms/word/index.vue index 38c4466f..f0c85882 100644 --- a/src/views/pqs/harmonicMonitoring/reportForms/word/index.vue +++ b/src/views/pqs/harmonicMonitoring/reportForms/word/index.vue @@ -10,51 +10,63 @@ -
-
+ + + + + + + + + + + + + + + +
+
+ 接线图预览 + 删除 +
+ 接线图
@@ -63,7 +75,7 @@ diff --git a/src/views/pqs/qualityInspeection/panorama/components/details/propInfo.vue b/src/views/pqs/qualityInspeection/panorama/components/details/propInfo.vue index 102e039a..ba4a4135 100644 --- a/src/views/pqs/qualityInspeection/panorama/components/details/propInfo.vue +++ b/src/views/pqs/qualityInspeection/panorama/components/details/propInfo.vue @@ -25,7 +25,7 @@ showOverflow v-loading="loading" :row-config="{ isCurrent: true, isHover: true }" - :columnConfig="{ resizable: true }" + :columnConfig="{ resizable: true, useKey: true }" @cell-click="currentChangeEvent" style="z-index: 0" > diff --git a/src/views/pqs/qualityInspeection/panorama/components/line/info.vue b/src/views/pqs/qualityInspeection/panorama/components/line/info.vue index 18b1020a..1e664306 100644 --- a/src/views/pqs/qualityInspeection/panorama/components/line/info.vue +++ b/src/views/pqs/qualityInspeection/panorama/components/line/info.vue @@ -100,7 +100,7 @@ border align="center" showOverflow - :columnConfig="{ resizable: true }" + :columnConfig="{ resizable: true, useKey: true }" > diff --git a/src/views/system/bpm/form/editor/index.vue b/src/views/system/bpm/form/editor/index.vue index 49a5e077..75a3b0da 100644 --- a/src/views/system/bpm/form/editor/index.vue +++ b/src/views/system/bpm/form/editor/index.vue @@ -52,7 +52,7 @@ import { onMounted, ref, reactive } from 'vue' import { useRouter, useRoute } from 'vue-router' import FcDesigner from '@form-create/designer' import { encodeConf, encodeFields, setConfAndFields } from '@/utils/formCreate' -import { useTagsViewStore } from '@/stores/modules/tagsView' +import { useNavTabs } from '@/stores/navTabs' import { useFormCreateDesigner } from '@/components/FormCreate' import { Plus, Back } from '@element-plus/icons-vue' import ContentWrap from '@/components/ContentWrap/src/ContentWrap.vue' @@ -75,7 +75,7 @@ import { addForm, getById, updateForm } from '@/api/bpm-boot/form' const { push, currentRoute, go } = useRouter() // 路由 const { query } = useRoute() // 路由信息 -const { delView } = useTagsViewStore() // 视图操作 +const navTabs = useNavTabs() const designer = ref() // 表单设计器 useFormCreateDesigner(designer) // 表单设计器增强 @@ -135,8 +135,8 @@ const submitForm = async () => { } /** 关闭按钮 */ const close = () => { - delView(unref(currentRoute)) - go(-1) + navTabs.closeTab(unref(currentRoute)) + go(-1) } /** 初始化 **/