diff --git a/.eslintrc-auto-import.json b/.eslintrc-auto-import.json index d076c08..a6661b6 100644 --- a/.eslintrc-auto-import.json +++ b/.eslintrc-auto-import.json @@ -1,5 +1,36 @@ { "globals": { + "ComponentInternalInstance": true, + "TransferKey": true, + "ElFormRules": true, + "CheckboxValueType": true, + "PropType": true, + "DateModelType": true, + "UploadFile": true, + "ElFormInstance": true, + "ElTableInstance": true, + "ElTreeInstance": true, + "ElTreeSelectInstance": true, + "ElSelectInstance": true, + "ElUploadInstance": true, + "ElCardInstance": true, + "ElDialogInstance": true, + "ElInputInstance": true, + "ElInputNumberInstance": true, + "ElRadioInstance": true, + "ElRadioGroupInstance": true, + "ElRadioButtonInstance": true, + "ElCheckboxInstance": true, + "ElCheckboxGroupInstance": true, + "ElSwitchInstance": true, + "ElDatePickerInstance": true, + "ElTimePickerInstance": true, + "ElTimeSelectInstance": true, + "ElScrollbarInstance": true, + "ElCascaderInstance": true, + "ElColorPickerInstance": true, + "ElRateInstance": true, + "ElSliderInstance": true, "useRouter": true, "useRoute": true, "EffectScope": true, diff --git a/.eslintrc.js b/.eslintrc.js index 2b2e0d0..b6b10a6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -29,7 +29,8 @@ module.exports = { // 关闭空类型检查 {} extendDefaults: true, types: { - '{}': false + '{}': false, + 'Function': false } } ] diff --git a/package.json b/package.json index 98195b8..039083c 100644 --- a/package.json +++ b/package.json @@ -35,10 +35,12 @@ "path-to-regexp": "6.2.0", "pinia": "2.0.22", "screenfull": "6.0.0", + "vform3-builds": "3.0.8", "vue": "3.2.45", "vue-cropper": "1.0.3", "vue-i18n": "9.2.2", - "vue-router": "4.1.4" + "vue-router": "4.1.4", + "vue-types": "^5.0.3" }, "devDependencies": { "@iconify/json": "^2.2.40", @@ -71,11 +73,11 @@ "unplugin-auto-import": "0.13.0", "unplugin-icons": "0.15.1", "unplugin-vue-components": "0.23.0", + "vite": "4.3.1", "vite-plugin-compression": "0.5.1", "vite-plugin-svg-icons": "2.0.1", "vite-plugin-vue-setup-extend": "^0.4.0", "vitest": "^0.29.7", - "vite": "4.3.1", "vue-eslint-parser": "9.1.0", "vue-tsc": "0.35.0" } diff --git a/src/api/system/user/index.ts b/src/api/system/user/index.ts index d9fc1bd..21325c3 100644 --- a/src/api/system/user/index.ts +++ b/src/api/system/user/index.ts @@ -9,64 +9,64 @@ import { parseStrEmpty } from '@/utils/ruoyi'; * 查询用户列表 * @param query */ -export function listUser(query: UserQuery): AxiosPromise { +export const listUser = (query: UserQuery): AxiosPromise => { return request({ url: '/system/user/list', method: 'get', params: query }); -} +}; /** * 获取用户详情 * @param userId */ -export function getUser(userId?: string | number): AxiosPromise { +export const getUser = (userId?: string | number): AxiosPromise => { return request({ url: '/system/user/' + parseStrEmpty(userId), method: 'get' }); -} +}; /** * 新增用户 */ -export function addUser(data: UserForm) { +export const addUser = (data: UserForm) => { return request({ url: '/system/user', method: 'post', data: data }); -} +}; /** * 修改用户 */ -export function updateUser(data: UserForm) { +export const updateUser = (data: UserForm) => { return request({ url: '/system/user', method: 'put', data: data }); -} +}; /** * 删除用户 * @param userId 用户ID */ -export function delUser(userId: Array | string | number) { +export const delUser = (userId: Array | string | number) => { return request({ url: '/system/user/' + userId, method: 'delete' }); -} +}; /** * 用户密码重置 * @param userId 用户ID * @param password 密码 */ -export function resetUserPwd(userId: string | number, password: string) { +export const resetUserPwd = (userId: string | number, password: string) => { const data = { userId, password @@ -76,14 +76,14 @@ export function resetUserPwd(userId: string | number, password: string) { method: 'put', data: data }); -} +}; /** * 用户状态修改 * @param userId 用户ID * @param status 用户状态 */ -export function changeUserStatus(userId: number | string, status: string) { +export const changeUserStatus = (userId: number | string, status: string) => { const data = { userId, status @@ -93,36 +93,36 @@ export function changeUserStatus(userId: number | string, status: string) { method: 'put', data: data }); -} +}; /** * 查询用户个人信息 */ -export function getUserProfile(): AxiosPromise { +export const getUserProfile = (): AxiosPromise => { return request({ url: '/system/user/profile', method: 'get' }); -} +}; /** * 修改用户个人信息 * @param data 用户信息 */ -export function updateUserProfile(data: UserForm) { +export const updateUserProfile = (data: UserForm) => { return request({ url: '/system/user/profile', method: 'put', data: data }); -} +}; /** * 用户密码重置 * @param oldPassword 旧密码 * @param newPassword 新密码 */ -export function updateUserPwd(oldPassword: string, newPassword: string) { +export const updateUserPwd = (oldPassword: string, newPassword: string) => { const data = { oldPassword, newPassword @@ -132,49 +132,66 @@ export function updateUserPwd(oldPassword: string, newPassword: string) { method: 'put', params: data }); -} +}; /** * 用户头像上传 * @param data 头像文件 */ -export function uploadAvatar(data: FormData) { +export const uploadAvatar = (data: FormData) => { return request({ url: '/system/user/profile/avatar', method: 'post', data: data }); -} +}; /** * 查询授权角色 * @param userId 用户ID */ -export function getAuthRole(userId: string | number): AxiosPromise<{ user: UserVO; roles: RoleVO[] }> { +export const getAuthRole = (userId: string | number): AxiosPromise<{ user: UserVO; roles: RoleVO[] }> => { return request({ url: '/system/user/authRole/' + userId, method: 'get' }); -} +}; /** * 保存授权角色 * @param data 用户ID */ -export function updateAuthRole(data: { userId: string; roleIds: string }) { +export const updateAuthRole = (data: { userId: string; roleIds: string }) => { return request({ url: '/system/user/authRole', method: 'put', params: data }); -} +}; /** * 查询部门下拉树结构 */ -export function deptTreeSelect(): AxiosPromise { +export const deptTreeSelect = (): AxiosPromise => { return request({ url: '/system/user/deptTree', method: 'get' }); -} +}; + +export default { + listUser, + getUser, + addUser, + updateUser, + delUser, + resetUserPwd, + changeUserStatus, + getUserProfile, + updateUserProfile, + updateUserPwd, + uploadAvatar, + getAuthRole, + updateAuthRole, + deptTreeSelect +}; diff --git a/src/assets/styles/index.scss b/src/assets/styles/index.scss index e797f64..e31ea97 100644 --- a/src/assets/styles/index.scss +++ b/src/assets/styles/index.scss @@ -26,6 +26,10 @@ html { box-sizing: border-box; } +html.dark .svg-icon, html.dark svg { + fill: var(--el-text-color-regular); +} + #app { height: 100%; } @@ -137,6 +141,7 @@ aside { border: 1px solid var(--el-border-color-light); background-color: var(--el-bg-color-overlay); padding: 0.75rem; + transition: all ease 0.3s; &:hover { box-shadow: 0 2px 12px #0000001a; @@ -199,4 +204,4 @@ aside { vertical-align: middle; margin-bottom: 10px; } -} \ No newline at end of file +} diff --git a/src/assets/styles/ruoyi.scss b/src/assets/styles/ruoyi.scss index 2e00d00..d2ecb24 100644 --- a/src/assets/styles/ruoyi.scss +++ b/src/assets/styles/ruoyi.scss @@ -90,8 +90,8 @@ h6 { .el-table__fixed-header-wrapper { th { word-break: break-word; - background-color: #f8f8f9 !important; - color: #515a6e; + background-color: $table-header-bg !important; + color: $table-header-text-color; height: 40px !important; font-size: 13px; } diff --git a/src/assets/styles/sidebar.scss b/src/assets/styles/sidebar.scss index 1db15fa..06bf057 100644 --- a/src/assets/styles/sidebar.scss +++ b/src/assets/styles/sidebar.scss @@ -84,7 +84,7 @@ .sub-menu-title-noDropdown, .el-sub-menu__title { &:hover { - background-color: rgba(0, 0, 0, 0.06) !important; + background-color: $base-sub-menu-title-hover !important; } } @@ -211,7 +211,7 @@ .el-menu-item { &:hover { // you can use $sub-menuHover - background-color: rgba(0, 0, 0, 0.06) !important; + background-color: $base-menu-hover !important; } } diff --git a/src/assets/styles/variables.module.scss b/src/assets/styles/variables.module.scss index 639b23b..fdcb11c 100644 --- a/src/assets/styles/variables.module.scss +++ b/src/assets/styles/variables.module.scss @@ -1,3 +1,38 @@ +// 全局SCSS变量 +:root { + --menuBg: #304156; + --menuColor: #bfcbd9; + --menuActiveText: #f4f4f5; + --menuHover: #263445; + + --subMenuBg: #1f2d3d; + --subMenuActiveText: #f4f4f5; + --subMenuHover: #001528; + --subMenuTitleHover: #293444; + + --tableHeaderBg: #f8f8f9; + --tableHeaderTextColor: #515a6e; +} +html.dark { + --menuBg: #1d1e1f; + --menuColor: #bfcbd9; + --menuActiveText: #f4f4f5; + --menuHover: #171819; + + --subMenuBg: #1d1e1f; + --subMenuActiveText: #1d1e1f; + --subMenuHover: #171819; + --subMenuTitleHover: #171819; + + --tableHeaderBg: var(--el-bg-color); + --tableHeaderTextColor: var(--el-text-color); + + // 覆盖ele 高亮当前行的标准暗色 + .el-tree-node__content { + --el-color-primary-light-9: #262727; + } +} + // base color $blue: #324157; $light-blue: #3a71a8; @@ -9,32 +44,22 @@ $yellow: #fec171; $panGreen: #30b08f; // 默认菜单主题风格 -$base-menu-color: #bfcbd9; -$base-menu-color-active: #f4f4f5; -$base-menu-background: #304156; +$base-menu-color: var(--menuColor); +$base-menu-hover: var(--menuHover); +$base-menu-color-active: var(--menuActiveText); +$base-menu-background: var(--menuBg); $base-logo-title-color: #ffffff; $base-menu-light-color: rgba(0, 0, 0, 0.7); $base-menu-light-background: #ffffff; $base-logo-light-title-color: #001529; -$base-sub-menu-background: #1f2d3d; -$base-sub-menu-hover: #001528; - -// 自定义暗色菜单风格 -/** -$base-menu-color:hsla(0,0%,100%,.65); -$base-menu-color-active:#fff; -$base-menu-background:#001529; -$base-logo-title-color: #ffffff; - -$base-menu-light-color:rgba(0,0,0,.70); -$base-menu-light-background:#ffffff; -$base-logo-light-title-color: #001529; - -$base-sub-menu-background:#000c17; -$base-sub-menu-hover:#001528; -*/ +$base-sub-menu-background: var(--subMenuBg); +$base-sub-menu-hover: var(--subMenuHover); +$base-sub-menu-title-hover: var(--subMenuTitleHover); +// 表单头背景色和标题颜色 +$table-header-bg: var(--tableHeaderBg); +$table-header-text-color: var(--tableHeaderTextColor); $--color-primary: #409eff; $--color-success: #67c23a; diff --git a/src/components/Breadcrumb/index.vue b/src/components/Breadcrumb/index.vue index 435d0cc..b96829a 100644 --- a/src/components/Breadcrumb/index.vue +++ b/src/components/Breadcrumb/index.vue @@ -18,34 +18,34 @@ const router = useRouter(); const levelList = ref([]) const getBreadcrumb = () => { - // only show routes with meta.title - let matched = route.matched.filter(item => item.meta && item.meta.title); - const first = matched[0] - // 判断是否为首页 - if (!isDashboard(first)) { - matched = ([{ path: '/index', meta: { title: '首页' } }] as any).concat(matched) - } - levelList.value = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false) + // only show routes with meta.title + let matched = route.matched.filter(item => item.meta && item.meta.title); + const first = matched[0] + // 判断是否为首页 + if (!isDashboard(first)) { + matched = ([{ path: '/index', meta: { title: '首页' } }] as any).concat(matched) + } + levelList.value = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false) } const isDashboard = (route: RouteLocationMatched) => { - const name = route && route.name as string - if (!name) { - return false - } - return name.trim() === 'Index' + const name = route && route.name as string + if (!name) { + return false + } + return name.trim() === 'Index' } const handleLink = (item: RouteLocationMatched) => { - const { redirect, path } = item - redirect ? router.push(redirect as string) : router.push(path) + const { redirect, path } = item + redirect ? router.push(redirect as string) : router.push(path) } watchEffect(() => { - // if you go to the redirect page, do not update the breadcrumbs - if (route.path.startsWith('/redirect/')) return - getBreadcrumb() + // if you go to the redirect page, do not update the breadcrumbs + if (route.path.startsWith('/redirect/')) return + getBreadcrumb() }) onMounted(() => { - getBreadcrumb(); + getBreadcrumb(); }) diff --git a/src/components/BuildCode/index.vue b/src/components/BuildCode/index.vue new file mode 100644 index 0000000..b23665c --- /dev/null +++ b/src/components/BuildCode/index.vue @@ -0,0 +1,64 @@ + + + + + + diff --git a/src/components/BuildCode/render.vue b/src/components/BuildCode/render.vue new file mode 100644 index 0000000..5693ed8 --- /dev/null +++ b/src/components/BuildCode/render.vue @@ -0,0 +1,62 @@ + + + + diff --git a/src/components/DictTag/index.vue b/src/components/DictTag/index.vue index f27b16a..08aef21 100644 --- a/src/components/DictTag/index.vue +++ b/src/components/DictTag/index.vue @@ -24,7 +24,7 @@ diff --git a/src/components/Hamburger/index.vue b/src/components/Hamburger/index.vue index fffcedf..489ac43 100644 --- a/src/components/Hamburger/index.vue +++ b/src/components/Hamburger/index.vue @@ -1,6 +1,6 @@ diff --git a/src/components/HeaderSearch/index.vue b/src/components/HeaderSearch/index.vue index 60ebb9d..9b0f2c6 100644 --- a/src/components/HeaderSearch/index.vue +++ b/src/components/HeaderSearch/index.vue @@ -17,12 +17,12 @@ - @@ -58,13 +57,16 @@ const realHeight = computed(() => border-radius: 5px; background-color: #ebeef5; box-shadow: 0 0 5px 1px #ccc; + :deep(.el-image__inner) { transition: all 0.3s; cursor: pointer; + &:hover { transform: scale(1.2); } } + :deep(.image-slot) { display: flex; justify-content: center; diff --git a/src/components/ImageUpload/index.vue b/src/components/ImageUpload/index.vue index 0791f3e..01edc4f 100644 --- a/src/components/ImageUpload/index.vue +++ b/src/components/ImageUpload/index.vue @@ -17,7 +17,9 @@ :on-preview="handlePictureCardPreview" :class="{ hide: fileList.length >= limit }" > - + + +
@@ -42,25 +44,16 @@ import { getToken } from "@/utils/auth"; import { listByIds, delOss } from "@/api/system/oss"; import { ComponentInternalInstance, PropType } from "vue"; import { OssVO } from "@/api/system/oss/types"; -import { ElUpload, UploadFile } from "element-plus"; +import { propTypes } from '@/utils/propTypes'; const props = defineProps({ modelValue: [String, Object, Array], // 图片数量限制 - limit: { - type: Number, - default: 5, - }, + limit: propTypes.number.def(5), // 大小限制(MB) - fileSize: { - type: Number, - default: 5, - }, + fileSize: propTypes.number.def(5), // 文件类型, 例如['png', 'jpg', 'jpeg'] - fileType: { - type: Array as PropType, - default: () => ["png", "jpg", "jpeg"], - }, + fileType: propTypes.array.def(["png", "jpg", "jpeg"]), // 是否显示提示 isShowTip: { type: Boolean, @@ -84,12 +77,12 @@ const showTip = computed( () => props.isShowTip && (props.fileType || props.fileSize) ); -const imageUploadRef = ref(ElUpload); +const imageUploadRef = ref(); watch(() => props.modelValue, async val => { if (val) { // 首先将值转为数组 - let list:OssVO[] = []; + let list: OssVO[] = []; if (Array.isArray(val)) { list = val as OssVO[]; } else { @@ -112,7 +105,7 @@ watch(() => props.modelValue, async val => { fileList.value = []; return []; } -},{ deep: true, immediate: true }); +}, { deep: true, immediate: true }); /** 上传前loading加载 */ const handleBeforeUpload = (file: any) => { @@ -122,7 +115,7 @@ const handleBeforeUpload = (file: any) => { if (file.name.lastIndexOf(".") > -1) { fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1); } - isImg = props.fileType.some((type) => { + isImg = props.fileType.some((type: any) => { if (file.type.indexOf(type) > -1) return true; if (fileExtension && fileExtension.indexOf(type) > -1) return true; return false; @@ -161,7 +154,7 @@ const handleUploadSuccess = (res: any, file: UploadFile) => { number.value--; proxy?.$modal.closeLoading(); proxy?.$modal.msgError(res.msg); - imageUploadRef.value.handleRemove(file); + imageUploadRef.value?.handleRemove(file); uploadedSuccessfully(); } } @@ -207,7 +200,7 @@ const listToString = (list: any[], separator?: string) => { let strs = ""; separator = separator || ","; for (let i in list) { - if(undefined !== list[i].ossId && list[i].url.indexOf("blob:") !== 0) { + if (undefined !== list[i].ossId && list[i].url.indexOf("blob:") !== 0) { strs += list[i].ossId + separator; } } diff --git a/src/components/Pagination/index.vue b/src/components/Pagination/index.vue index de7b02c..df73ceb 100644 --- a/src/components/Pagination/index.vue +++ b/src/components/Pagination/index.vue @@ -22,52 +22,23 @@ export default { \ No newline at end of file + diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 156011f..d001ea8 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -20,8 +20,13 @@ - - + + + +
+ +
+
@@ -68,17 +73,18 @@ + + diff --git a/src/plugins/modal.ts b/src/plugins/modal.ts index 9526623..a8b0548 100644 --- a/src/plugins/modal.ts +++ b/src/plugins/modal.ts @@ -1,57 +1,57 @@ -import { ElMessage, ElMessageBox, ElNotification, ElLoading, MessageBoxData } from 'element-plus'; +import { MessageBoxData } from 'element-plus'; import { LoadingInstance } from 'element-plus/es/components/loading/src/loading'; let loadingInstance: LoadingInstance; export default { // 消息提示 - msg(content: string) { + msg(content: any) { ElMessage.info(content); }, // 错误消息 - msgError(content: string) { + msgError(content: any) { ElMessage.error(content); }, // 成功消息 - msgSuccess(content: string) { + msgSuccess(content: any) { ElMessage.success(content); }, // 警告消息 - msgWarning(content: string) { + msgWarning(content: any) { ElMessage.warning(content); }, // 弹出提示 - alert(content: string) { + alert(content: any) { ElMessageBox.alert(content, '系统提示'); }, // 错误提示 - alertError(content: string) { + alertError(content: any) { ElMessageBox.alert(content, '系统提示', { type: 'error' }); }, // 成功提示 - alertSuccess(content: string, s: string, p: { dangerouslyUseHTMLString: boolean }) { + alertSuccess(content: any) { ElMessageBox.alert(content, '系统提示', { type: 'success' }); }, // 警告提示 - alertWarning(content: string) { + alertWarning(content: any) { ElMessageBox.alert(content, '系统提示', { type: 'warning' }); }, // 通知提示 - notify(content: string) { + notify(content: any) { ElNotification.info(content); }, // 错误通知 - notifyError(content: string) { + notifyError(content: any) { ElNotification.error(content); }, // 成功通知 - notifySuccess(content: string) { + notifySuccess(content: any) { ElNotification.success(content); }, // 警告通知 - notifyWarning(content: string) { + notifyWarning(content: any) { ElNotification.warning(content); }, // 确认窗体 - confirm(content: string): Promise { + confirm(content: any): Promise { return ElMessageBox.confirm(content, '系统提示', { confirmButtonText: '确定', cancelButtonText: '取消', @@ -59,7 +59,7 @@ export default { }); }, // 提交内容 - prompt(content: string) { + prompt(content: any) { return ElMessageBox.prompt(content, '系统提示', { confirmButtonText: '确定', cancelButtonText: '取消', diff --git a/src/plugins/tab.ts b/src/plugins/tab.ts index a310154..97442ff 100644 --- a/src/plugins/tab.ts +++ b/src/plugins/tab.ts @@ -3,8 +3,11 @@ import router from '@/router'; import { TagView, RouteLocationRaw } from 'vue-router'; export default { - // 刷新当前tab页签 - async refreshPage(obj: TagView): Promise { + /** + * 刷新当前tab页签 + * @param obj 标签对象 + */ + async refreshPage(obj?: TagView): Promise { const { path, query, matched } = router.currentRoute.value; if (obj === undefined) { matched.forEach((m) => { @@ -15,11 +18,16 @@ export default { } }); } - // prettier-ignore - await useTagsViewStore().delCachedView(obj) - router.replace({ - path: '/redirect' + obj.path, - query: obj.query + let query1: undefined | {} = {}; + let path1: undefined | string = ''; + if (obj) { + query1 = obj.query; + path1 = obj.path; + } + await useTagsViewStore().delCachedView(obj); + await router.replace({ + path: '/redirect' + path1, + query: query1 }); }, // 关闭当前tab页签,打开新页签 @@ -34,9 +42,9 @@ export default { if (obj === undefined) { // prettier-ignore const { visitedViews } = await useTagsViewStore().delView(router.currentRoute.value) as any - const latestView = visitedViews.slice(-1)[0] + const latestView = visitedViews.slice(-1)[0]; if (latestView) { - return router.push(latestView.fullPath) + return router.push(latestView.fullPath); } return router.push('/'); } @@ -47,22 +55,31 @@ export default { return useTagsViewStore().delAllViews(); }, // 关闭左侧tab页签 - closeLeftPage(obj: TagView) { + closeLeftPage(obj?: TagView) { return useTagsViewStore().delLeftTags(obj || router.currentRoute.value); }, // 关闭右侧tab页签 - closeRightPage(obj: TagView) { + closeRightPage(obj?: TagView) { return useTagsViewStore().delRightTags(obj || router.currentRoute.value); }, // 关闭其他tab页签 - closeOtherPage(obj: TagView) { + closeOtherPage(obj?: TagView) { return useTagsViewStore().delOthersViews(obj || router.currentRoute.value); }, - // 打开tab页签 - openPage(url: RouteLocationRaw) { - return router.push(url); + /** + * 打开tab页签 + * @param url 路由地址 + * @param title 标题 + * @param query 参数 + */ + openPage(url: string, title?: string, query?: any) { + const obj = { path: url, query: { ...query, title } }; + return router.push(obj); }, - // 修改tab页签 + /** + * 修改tab页签 + * @param obj 标签对象 + */ updatePage(obj: TagView) { return useTagsViewStore().updateVisitedView(obj); } diff --git a/src/store/modules/tagsView.ts b/src/store/modules/tagsView.ts index af980ef..cd065d1 100644 --- a/src/store/modules/tagsView.ts +++ b/src/store/modules/tagsView.ts @@ -54,8 +54,11 @@ export const useTagsViewStore = defineStore('tagsView', () => { resolve([...visitedViews.value]); }); }; - const delCachedView = (view: TagView): Promise => { - const viewName = view.name as string; + const delCachedView = (view?: TagView): Promise => { + let viewName = ''; + if (view) { + viewName = view.name as string; + } return new Promise((resolve) => { const index = cachedViews.value.indexOf(viewName); index > -1 && cachedViews.value.splice(index, 1); @@ -167,6 +170,7 @@ export const useTagsViewStore = defineStore('tagsView', () => { const addCachedView = (view: TagView): void => { const viewName = view.name as string; + if (!viewName) return; if (cachedViews.value.includes(viewName)) return; if (!view.meta?.noCache) { cachedViews.value.push(viewName); diff --git a/src/types/element.d.ts b/src/types/element.d.ts index 8632484..e8d1f62 100644 --- a/src/types/element.d.ts +++ b/src/types/element.d.ts @@ -1 +1,35 @@ -declare type ElTagType = '' | 'success' | 'warning' | 'info' | 'danger' | 'default' | 'primary'; +import type * as ep from 'element-plus'; +declare global { + declare type ElTagType = '' | 'success' | 'warning' | 'info' | 'danger' | 'default' | 'primary'; + declare type ElFormInstance = InstanceType; + declare type ElTableInstance = InstanceType; + declare type ElTreeInstance = InstanceType; + declare type ElTreeSelectInstance = InstanceType; + declare type ElSelectInstance = InstanceType; + declare type ElUploadInstance = InstanceType; + declare type ElCardInstance = InstanceType; + declare type ElDialogInstance = InstanceType; + declare type ElInputInstance = InstanceType; + declare type ElInputNumberInstance = InstanceType; + declare type ElRadioInstance = InstanceType; + declare type ElRadioGroupInstance = InstanceType; + declare type ElRadioButtonInstance = InstanceType; + declare type ElCheckboxInstance = InstanceType; + declare type ElCheckboxGroupInstance = InstanceType; + declare type ElSwitchInstance = InstanceType; + declare type ElDatePickerInstance = InstanceType; + declare type ElTimePickerInstance = InstanceType; + declare type ElTimeSelectInstance = InstanceType; + declare type ElCascaderInstance = InstanceType; + declare type ElColorPickerInstance = InstanceType; + declare type ElRateInstance = InstanceType; + declare type ElSliderInstance = InstanceType; + declare type ElUploadInstance = InstanceType; + declare type ElScrollbarInstance = InstanceType; + + declare type TransferKey = ep.TransferKey; + declare type CheckboxValueType = ep.CheckboxValueType; + declare type ElFormRules = ep.FormRules; + declare type DateModelType = ep.DateModelType; + declare type UploadFile = typeof ep.UploadFile; +} diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 5a972a3..b9bc5f4 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -1,9 +1,15 @@ -import { FormRules } from 'element-plus'; +import type { ComponentInternalInstance as ComponentInstance, PropType as VuePropType } from 'vue'; + declare global { + /** vue Instance */ + declare type ComponentInternalInstance = ComponentInstance; + /**vue */ + declare type PropType = VuePropType; + /** * 界面字段隐藏属性 */ - interface FieldOption { + declare interface FieldOption { key: number; label: string; visible: boolean; @@ -12,7 +18,7 @@ declare global { /** * 弹窗属性 */ - interface DialogOption { + declare interface DialogOption { /** * 弹窗标题 */ @@ -23,7 +29,7 @@ declare global { visible: boolean; } - interface UploadOption { + declare interface UploadOption { /** 设置上传的请求头部 */ headers: { [key: string]: any }; @@ -34,7 +40,7 @@ declare global { /** * 导入属性 */ - interface ImportOption extends UploadOption { + declare interface ImportOption extends UploadOption { /** 是否显示弹出层 */ open: boolean; /** 弹出层标题 */ @@ -48,14 +54,14 @@ declare global { /** * 字典数据 数据配置 */ - interface DictDataOption { + declare interface DictDataOption { label: string; value: string; elTagType?: ElTagType; elTagClass?: string; } - interface BaseEntity { + declare interface BaseEntity { createBy?: any; createDept?: any; createTime?: string; @@ -68,15 +74,15 @@ declare global { * T : 表单数据 * D : 查询参数 */ - interface PageData { + declare interface PageData { form: T; queryParams: D; - rules: FormRules; + rules: ElFormRules; } /** * 分页查询参数 */ - interface PageQuery { + declare interface PageQuery { pageNum: number; pageSize: number; } diff --git a/src/types/module.d.ts b/src/types/module.d.ts index b99bc44..987c349 100644 --- a/src/types/module.d.ts +++ b/src/types/module.d.ts @@ -1,23 +1,27 @@ -import modal from '@/plugins/modal'; -import tab from '@/plugins/tab'; -import { useDict } from '@/utils/dict'; -import { addDateRange, handleTree, selectDictLabel, selectDictLabels, parseTime } from '@/utils/ruoyi'; -import { getConfigKey, updateConfigByKey } from '@/api/system/config'; -import { download as download1 } from '@/utils/request'; -import download from '@/plugins/download'; -import animate from '@/animate'; +import type modal from '@/plugins/modal'; +import type tab from '@/plugins/tab'; +import type download from '@/plugins/download'; +import type auth from '@/plugins/auth'; +import type cache from '@/plugins/cache'; +import type animate from '@/animate'; +import type { useDict } from '@/utils/dict'; +import type { addDateRange, handleTree, selectDictLabel, selectDictLabels, parseTime } from '@/utils/ruoyi'; +import type { getConfigKey, updateConfigByKey } from '@/api/system/config'; +import type { download as rd } from '@/utils/request'; -declare module 'vue' { - export interface ComponentCustomProperties { +declare module '@vue/runtime-core' { + interface ComponentCustomProperties { // 全局方法声明 $modal: typeof modal; $tab: typeof tab; $download: typeof download; + $auth: typeof auth; + $cache: typeof cache; animate: typeof animate; useDict: typeof useDict; addDateRange: typeof addDateRange; - download: typeof download1; + download: typeof rd; handleTree: typeof handleTree; getConfigKey: typeof getConfigKey; updateConfigByKey: typeof updateConfigByKey; diff --git a/src/types/router.d.ts b/src/types/router.d.ts index b60b831..9731fa2 100644 --- a/src/types/router.d.ts +++ b/src/types/router.d.ts @@ -1,7 +1,7 @@ import { RouteRecordRaw } from 'vue-router'; declare module 'vue-router' { - type RouteOption = { + declare type RouteOption = { hidden?: boolean; permissions?: string[]; roles?: string[]; @@ -16,15 +16,15 @@ declare module 'vue-router' { query?: string; } & RouteRecordRaw; - interface _RouteLocationBase { + declare interface _RouteLocationBase { children?: RouteOption[]; } - interface RouteLocationOptions { + declare interface RouteLocationOptions { fullPath?: string; } - interface TagView extends Partial<_RouteLocationBase> { + declare interface TagView extends Partial<_RouteLocationBase> { title?: string; meta?: { link?: string; diff --git a/src/types/vform3-builds.d.ts b/src/types/vform3-builds.d.ts new file mode 100644 index 0000000..82573de --- /dev/null +++ b/src/types/vform3-builds.d.ts @@ -0,0 +1,4 @@ +declare module 'vform3-builds' { + const content: any; + export = content; +} diff --git a/src/utils/propTypes.ts b/src/utils/propTypes.ts new file mode 100644 index 0000000..4d69bb6 --- /dev/null +++ b/src/utils/propTypes.ts @@ -0,0 +1,25 @@ +import { CSSProperties } from 'vue'; +import { createTypes, VueTypeValidableDef, VueTypesInterface } from 'vue-types'; + +type PropTypes = VueTypesInterface & { + readonly style: VueTypeValidableDef; +}; + +const propTypes = createTypes({ + func: undefined, + bool: undefined, + string: undefined, + number: undefined, + object: undefined, + integer: undefined +}) as PropTypes; + +propTypes.extend([ + { + name: 'style', + getter: true, + type: [String, Object], + default: undefined + } +]); +export { propTypes }; diff --git a/src/views/demo/demo/index.vue b/src/views/demo/demo/index.vue index 2786a51..54f7c86 100644 --- a/src/views/demo/demo/index.vue +++ b/src/views/demo/demo/index.vue @@ -1,32 +1,34 @@