From 9b33bffdca7985e71e0dd6ff1b19f759f150a87a Mon Sep 17 00:00:00 2001 From: DEV_DSW <562304744@qq.com> Date: Thu, 4 Jun 2026 13:36:32 +0800 Subject: [PATCH] refactor: improve TypeScript type safety across codebase Add global pinia type declaration for the custom unistorage option. Add typed interfaces for all Pinia stores and enforce type safety on state and actions. Add strict type annotations to all utility classes and helper functions. Fix API response typing in the quick booking list page. Remove unused iconsMap import in RefundPopup component. Update package build scripts and add missing terser dependency. Clean up outdated auto-generated component type definitions. --- components.d.ts | 44 ------- package.json | 9 +- src/components/RefundPopup/index.vue | 1 - src/constants/longTextCard.ts | 61 ++++++++-- src/pages/quick/index.vue | 9 +- src/store/modules/app.ts | 9 +- src/store/modules/location.ts | 7 +- src/store/modules/picture.ts | 2 +- src/store/modules/selectedDate.ts | 10 +- src/types/pinia.d.ts | 7 ++ src/utils/CallbackUtils.ts | 11 +- src/utils/DebounceUtils.ts | 6 +- src/utils/MessageUtils.ts | 88 ++++---------- src/utils/StreamManager.ts | 86 ++++++++++---- src/utils/ThrottleUtils.ts | 4 +- src/utils/TimerUtils.ts | 18 ++- src/utils/UrlParams.ts | 14 +-- src/utils/WebSocketManager.ts | 165 +++++++++++++++++++++------ src/utils/dateUtils.ts | 4 +- yarn.lock | 43 ++++++- 20 files changed, 384 insertions(+), 214 deletions(-) create mode 100644 src/types/pinia.d.ts diff --git a/components.d.ts b/components.d.ts index 1f374d1..742dacd 100644 --- a/components.d.ts +++ b/components.d.ts @@ -12,111 +12,67 @@ export {} /* prettier-ignore */ declare module 'vue' { export interface GlobalComponents { - AddCarCrad: typeof import('./src/components/AddCarCrad/index.vue')['default'] - AiTabSwitch: typeof import('./src/components/AiTabSwitch/index.vue')['default'] Calender: typeof import('./src/components/Calender/index.vue')['default'] - CheckBox: typeof import('./src/components/CheckBox/index.vue')['default'] - CommandWrapper: typeof import('./src/components/CommandWrapper/index.vue')['default'] - CreateServiceOrder: typeof import('./src/components/CreateServiceOrder/index.vue')['default'] CustomEmpty: typeof import('./src/components/CustomEmpty/index.vue')['default'] DateRangeSection: typeof import('./src/components/DateRangeSection/index.vue')['default'] - Demo: typeof import('./src/components/FormCard/demo.vue')['default'] - DetailPopup: typeof import('./src/components/DetailPopup/index.vue')['default'] - Divider: typeof import('./src/components/Divider/index.vue')['default'] - Feedback: typeof import('./src/components/Feedback/index.vue')['default'] FormCard: typeof import('./src/components/FormCard/index.vue')['default'] GoodDetail: typeof import('./src/components/GoodDetail/index.vue')['default'] ImageSwiper: typeof import('./src/components/ImageSwiper/index.vue')['default'] - LocationCard: typeof import('./src/components/LocationCard/index.vue')['default'] - LocationInfo: typeof import('./src/components/LocationInfo/index.vue')['default'] ModuleTitle: typeof import('./src/components/ModuleTitle/index.vue')['default'] - Privacy: typeof import('./src/components/Privacy/index.vue')['default'] Qrcode: typeof import('./src/components/Qrcode/index.vue')['default'] RefundPopup: typeof import('./src/components/RefundPopup/index.vue')['default'] - ResponseIntro: typeof import('./src/components/ResponseIntro/index.vue')['default'] - ResponseWrapper: typeof import('./src/components/ResponseWrapper/index.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] - ServiceTipsWord: typeof import('./src/components/ServiceTipsWord/index.vue')['default'] SpriteAnimator: typeof import('./src/components/SpriteAnimator/index.vue')['default'] Stepper: typeof import('./src/components/Stepper/index.vue')['default'] SumCard: typeof import('./src/components/SumCard/index.vue')['default'] - SurveyQuestionnaire: typeof import('./src/components/SurveyQuestionnaire/index.vue')['default'] SwipeCards: typeof import('./src/components/SwipeCards/index.vue')['default'] - TagsGroup: typeof import('./src/components/TagsGroup/index.vue')['default'] TopNavBar: typeof import('./src/components/TopNavBar/index.vue')['default'] UseDateRange: typeof import('./src/components/UseDateRange/index.vue')['default'] VanButton: typeof import('vant/es')['Button'] VanCell: typeof import('vant/es')['Cell'] - VanCheckbox: typeof import('vant/es')['Checkbox'] VanDivider: typeof import('vant/es')['Divider'] VanField: typeof import('vant/es')['Field'] VanIcon: typeof import('vant/es')['Icon'] - VanIcons: typeof import('vant/es')['Icons'] VanList: typeof import('vant/es')['List'] VanPopup: typeof import('vant/es')['Popup'] VanPullRefresh: typeof import('vant/es')['PullRefresh'] VanSearch: typeof import('vant/es')['Search'] VanSwipe: typeof import('vant/es')['Swipe'] VanSwipeItem: typeof import('vant/es')['SwipeItem'] - VanSwiperItem: typeof import('vant/es')['SwiperItem'] - VanTab: typeof import('vant/es')['Tab'] - VanTabs: typeof import('vant/es')['Tabs'] ZnIcon: typeof import('./src/components/ZnIcon/index.vue')['default'] } } // For TSX support declare global { - const AddCarCrad: typeof import('./src/components/AddCarCrad/index.vue')['default'] - const AiTabSwitch: typeof import('./src/components/AiTabSwitch/index.vue')['default'] const Calender: typeof import('./src/components/Calender/index.vue')['default'] - const CheckBox: typeof import('./src/components/CheckBox/index.vue')['default'] - const CommandWrapper: typeof import('./src/components/CommandWrapper/index.vue')['default'] - const CreateServiceOrder: typeof import('./src/components/CreateServiceOrder/index.vue')['default'] const CustomEmpty: typeof import('./src/components/CustomEmpty/index.vue')['default'] const DateRangeSection: typeof import('./src/components/DateRangeSection/index.vue')['default'] - const Demo: typeof import('./src/components/FormCard/demo.vue')['default'] - const DetailPopup: typeof import('./src/components/DetailPopup/index.vue')['default'] - const Divider: typeof import('./src/components/Divider/index.vue')['default'] - const Feedback: typeof import('./src/components/Feedback/index.vue')['default'] const FormCard: typeof import('./src/components/FormCard/index.vue')['default'] const GoodDetail: typeof import('./src/components/GoodDetail/index.vue')['default'] const ImageSwiper: typeof import('./src/components/ImageSwiper/index.vue')['default'] - const LocationCard: typeof import('./src/components/LocationCard/index.vue')['default'] - const LocationInfo: typeof import('./src/components/LocationInfo/index.vue')['default'] const ModuleTitle: typeof import('./src/components/ModuleTitle/index.vue')['default'] - const Privacy: typeof import('./src/components/Privacy/index.vue')['default'] const Qrcode: typeof import('./src/components/Qrcode/index.vue')['default'] const RefundPopup: typeof import('./src/components/RefundPopup/index.vue')['default'] - const ResponseIntro: typeof import('./src/components/ResponseIntro/index.vue')['default'] - const ResponseWrapper: typeof import('./src/components/ResponseWrapper/index.vue')['default'] const RouterLink: typeof import('vue-router')['RouterLink'] const RouterView: typeof import('vue-router')['RouterView'] - const ServiceTipsWord: typeof import('./src/components/ServiceTipsWord/index.vue')['default'] const SpriteAnimator: typeof import('./src/components/SpriteAnimator/index.vue')['default'] const Stepper: typeof import('./src/components/Stepper/index.vue')['default'] const SumCard: typeof import('./src/components/SumCard/index.vue')['default'] - const SurveyQuestionnaire: typeof import('./src/components/SurveyQuestionnaire/index.vue')['default'] const SwipeCards: typeof import('./src/components/SwipeCards/index.vue')['default'] - const TagsGroup: typeof import('./src/components/TagsGroup/index.vue')['default'] const TopNavBar: typeof import('./src/components/TopNavBar/index.vue')['default'] const UseDateRange: typeof import('./src/components/UseDateRange/index.vue')['default'] const VanButton: typeof import('vant/es')['Button'] const VanCell: typeof import('vant/es')['Cell'] - const VanCheckbox: typeof import('vant/es')['Checkbox'] const VanDivider: typeof import('vant/es')['Divider'] const VanField: typeof import('vant/es')['Field'] const VanIcon: typeof import('vant/es')['Icon'] - const VanIcons: typeof import('vant/es')['Icons'] const VanList: typeof import('vant/es')['List'] const VanPopup: typeof import('vant/es')['Popup'] const VanPullRefresh: typeof import('vant/es')['PullRefresh'] const VanSearch: typeof import('vant/es')['Search'] const VanSwipe: typeof import('vant/es')['Swipe'] const VanSwipeItem: typeof import('vant/es')['SwipeItem'] - const VanSwiperItem: typeof import('vant/es')['SwiperItem'] - const VanTab: typeof import('vant/es')['Tab'] - const VanTabs: typeof import('vant/es')['Tabs'] const ZnIcon: typeof import('./src/components/ZnIcon/index.vue')['default'] } \ No newline at end of file diff --git a/package.json b/package.json index 518bba2..a09014b 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,11 @@ "type": "module", "scripts": { "dev": "vite", - "build": "vue-tsc --noEmit && vite build --mode production", - "build:staging": "vue-tsc --noEmit && vite build --mode staging", - "build:prod": "vue-tsc --noEmit && vite build --mode production", + "build": "node ./node_modules/vue-tsc/bin/vue-tsc.js --noEmit && node ./node_modules/vite/bin/vite.js build --mode production", + "build:staging": "node ./node_modules/vue-tsc/bin/vue-tsc.js --noEmit && node ./node_modules/vite/bin/vite.js build --mode staging", + "build:prod": "node ./node_modules/vue-tsc/bin/vue-tsc.js --noEmit && node ./node_modules/vite/bin/vite.js build --mode production", "preview": "vite preview --host 0.0.0.0", - "typecheck": "vue-tsc --noEmit", + "typecheck": "node ./node_modules/vue-tsc/bin/vue-tsc.js --noEmit", "test": "node --test src/**/*.test.ts" }, "dependencies": { @@ -36,6 +36,7 @@ "concurrently": "^9.2.1", "sass": "^1.70.0", "tailwindcss": "^4.1.12", + "terser": "^5.16.0", "typescript": "^5.8.3", "unplugin-auto-import": "^21.0.0", "unplugin-vue-components": "^32.1.0", diff --git a/src/components/RefundPopup/index.vue b/src/components/RefundPopup/index.vue index 2dc39e5..3b66dbd 100644 --- a/src/components/RefundPopup/index.vue +++ b/src/components/RefundPopup/index.vue @@ -28,7 +28,6 @@