From a6a671def532802073fa5a84b63de5653935c8e6 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Sat, 11 Mar 2023 11:13:26 +0800 Subject: [PATCH] chore: fix typescript type hint --- .../admin/components/admin/paginate/index.vue | 10 ++- .../admin/components/admin/select/index.vue | 2 +- .../admin/components/admin/status/index.vue | 14 +++- .../admin/components/admin/upload/oss.vue | 82 +++++++++---------- .../admin/components/breadcrumbs/index.vue | 6 +- resources/admin/components/editor/index.vue | 4 +- resources/admin/router/constantRoutes.ts | 2 + resources/admin/support/catchAdmin.ts | 1 + resources/admin/support/http.ts | 3 +- .../admin/views/dashboard/dependencies.vue | 2 +- 10 files changed, 72 insertions(+), 54 deletions(-) diff --git a/resources/admin/components/admin/paginate/index.vue b/resources/admin/components/admin/paginate/index.vue index 3d046af..7682223 100644 --- a/resources/admin/components/admin/paginate/index.vue +++ b/resources/admin/components/admin/paginate/index.vue @@ -11,7 +11,15 @@ const layout = 'total,sizes,prev, pager,next' const pageSizes = [10, 20, 30, 50] -const { page, limit, total, changePage, changeLimit } = inject('paginate') +interface paginate { + page: number + limit: number + total: number + changePage: number + changeLimit: number +} + +const { page, limit, total, changePage, changeLimit } = inject('paginate') as paginate diff --git a/resources/admin/components/admin/select/index.vue b/resources/admin/components/admin/select/index.vue index 86e2414..8aaa4d6 100644 --- a/resources/admin/components/admin/select/index.vue +++ b/resources/admin/components/admin/select/index.vue @@ -48,7 +48,7 @@ const getOptions = () => { }) } -const elOptions = props.group ? ref>() : ref>() +const elOptions: any = props.group ? ref>() : ref>() if (props.api) { if (!props.query) { getOptions() diff --git a/resources/admin/components/admin/status/index.vue b/resources/admin/components/admin/status/index.vue index 3917009..1a74ddc 100644 --- a/resources/admin/components/admin/status/index.vue +++ b/resources/admin/components/admin/status/index.vue @@ -8,13 +8,19 @@ import { Status } from '/admin/enum/app' import { ref } from 'vue' const props = defineProps({ - modelValue: Boolean | Number | String, - api: String, - id: Number | String, + modelValue: [Boolean, Number, String], + api: { + required: true, + type: String, + }, + id: { + required: true, + type: [String, Number], + }, }) const emits = defineEmits(['update:modelValue', 'refresh']) - +// @ts-ignore const { enabled, success, loading, afterEnabled } = useEnabled() const activeValue = ref() diff --git a/resources/admin/components/admin/upload/oss.vue b/resources/admin/components/admin/upload/oss.vue index 632c390..e83a757 100644 --- a/resources/admin/components/admin/upload/oss.vue +++ b/resources/admin/components/admin/upload/oss.vue @@ -1,59 +1,59 @@ diff --git a/resources/admin/components/breadcrumbs/index.vue b/resources/admin/components/breadcrumbs/index.vue index 0972e43..c1a658a 100644 --- a/resources/admin/components/breadcrumbs/index.vue +++ b/resources/admin/components/breadcrumbs/index.vue @@ -21,7 +21,7 @@ const breadcrumbs = ref([]) watch(router.currentRoute, (newValue, oldValue) => { // 激活菜单 if (newValue.meta.active_menu) { - appStore.setActiveMenu(newValue.meta.active_menu) + appStore.setActiveMenu(newValue.meta.active_menu as string) } setActiveMenu(newValue) getBreadcrumbs(newValue) @@ -33,11 +33,11 @@ onMounted(() => { getBreadcrumbs(router.currentRoute.value) }) -const setActiveMenu = route => { +const setActiveMenu = (route: RouteLocationNormalizedLoaded) => { if (route.path !== '/') { // 如果是内页,并且设置激活菜单 if (route.meta.active_menu) { - appStore.setActiveMenu(route.meta.active_menu) + appStore.setActiveMenu(route.meta.active_menu as string) } else { appStore.setActiveMenu(route.path) } diff --git a/resources/admin/components/editor/index.vue b/resources/admin/components/editor/index.vue index 4cb182b..39e87b8 100644 --- a/resources/admin/components/editor/index.vue +++ b/resources/admin/components/editor/index.vue @@ -90,7 +90,7 @@ const props = defineProps({ }) const aipKey: string = 's1ntkmnev0ggx0hhaqnubrdxhv0ly99uyrdbckeaycx7iz6v' -const uploaded = (blobInfo, progress) => +const uploaded = (blobInfo: any, progress: any) => new Promise((resolve, reject) => { if (blobInfo.blob().size / 1024 / 1024 > 10) { Message.error('上传失败,图片大小请控制在 10M 以内') @@ -102,7 +102,7 @@ const uploaded = (blobInfo, progress) => if (res.data.code === 10000) { resolve(res.data.data.path) } else { - Message.error(res.message) + Message.error(res.data.message) } }) .catch(() => { diff --git a/resources/admin/router/constantRoutes.ts b/resources/admin/router/constantRoutes.ts index f49c1dd..b26e582 100644 --- a/resources/admin/router/constantRoutes.ts +++ b/resources/admin/router/constantRoutes.ts @@ -6,7 +6,9 @@ export function getModuleRoutes() { let moduleRoutes: RouteRecordRaw[] = [] Object.keys(modules).forEach(routePath => { + // @ts-ignore if (!isUndefined(modules[routePath].default)) { + // @ts-ignore moduleRoutes = moduleRoutes.concat(modules[routePath].default) } }) diff --git a/resources/admin/support/catchAdmin.ts b/resources/admin/support/catchAdmin.ts index 33fb635..61ab151 100644 --- a/resources/admin/support/catchAdmin.ts +++ b/resources/admin/support/catchAdmin.ts @@ -62,6 +62,7 @@ export default class CatchAdmin { * @returns */ protected useElementPlus(): CatchAdmin { + // @ts-ignore this.app.use(ElementPlus, { locale: Cache.get('language') === 'zh' && zh, }) diff --git a/resources/admin/support/http.ts b/resources/admin/support/http.ts index c63d3e3..d1d4cd6 100644 --- a/resources/admin/support/http.ts +++ b/resources/admin/support/http.ts @@ -153,7 +153,8 @@ class Http { * */ public interceptorsOfRequest(): void { - this.request.interceptors.request.use(function (config: AxiosRequestConfig) { + // @ts-ignore + this.request.interceptors.request.use((config: AxiosRequestConfig) => { const token = getAuthToken() if (token) { if (!config.headers) { diff --git a/resources/admin/views/dashboard/dependencies.vue b/resources/admin/views/dashboard/dependencies.vue index 6adeec1..44267c1 100644 --- a/resources/admin/views/dashboard/dependencies.vue +++ b/resources/admin/views/dashboard/dependencies.vue @@ -14,7 +14,7 @@