refactor: migrate to Vant and set up auto-imports
- replace uni-ui drawer and icon components with Vant equivalents - add unplugin-auto-import and unplugin-vue-components to Vite config - update project dependencies to compatible versions - generate auto-import and component type declaration files - clean up deprecated imports and commented code in home page components - fix App.vue to use lowercase router-view and script setup
This commit is contained in:
10
auto-imports.d.ts
vendored
Normal file
10
auto-imports.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* prettier-ignore */
|
||||||
|
// @ts-nocheck
|
||||||
|
// noinspection JSUnusedGlobalSymbols
|
||||||
|
// Generated by unplugin-auto-import
|
||||||
|
// biome-ignore lint: disable
|
||||||
|
export {}
|
||||||
|
declare global {
|
||||||
|
|
||||||
|
}
|
||||||
96
components.d.ts
vendored
Normal file
96
components.d.ts
vendored
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
// biome-ignore lint: disable
|
||||||
|
// oxlint-disable
|
||||||
|
// ------
|
||||||
|
// Generated by unplugin-vue-components
|
||||||
|
// Read more: https://github.com/vuejs/core/pull/3399
|
||||||
|
import { GlobalComponents } from 'vue'
|
||||||
|
|
||||||
|
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']
|
||||||
|
RecordingWaveBtn: typeof import('./src/components/Speech/RecordingWaveBtn.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/Sprite/SpriteAnimator.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']
|
||||||
|
VanIcon: typeof import('vant/es')['Icon']
|
||||||
|
VanPopup: typeof import('vant/es')['Popup']
|
||||||
|
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 RecordingWaveBtn: typeof import('./src/components/Speech/RecordingWaveBtn.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/Sprite/SpriteAnimator.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 VanIcon: typeof import('vant/es')['Icon']
|
||||||
|
const VanPopup: typeof import('vant/es')['Popup']
|
||||||
|
const ZnIcon: typeof import('./src/components/ZnIcon/index.vue')['default']
|
||||||
|
}
|
||||||
17
package.json
17
package.json
@@ -11,12 +11,11 @@
|
|||||||
"test": "node --test src/**/*.test.ts"
|
"test": "node --test src/**/*.test.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vitejs/plugin-vue": "^6.0.7",
|
|
||||||
"axios": "^1.16.1",
|
"axios": "^1.16.1",
|
||||||
"mitt": "^3.0.1",
|
"mitt": "^3.0.1",
|
||||||
"pinia": "^3.0.3",
|
"pinia": "^3.0.3",
|
||||||
"vant": "^4.9.24",
|
"vant": "^4.9.24",
|
||||||
"vue": "^3.4.21",
|
"vue": "^3.5.13",
|
||||||
"vue-i18n": "11.4.4",
|
"vue-i18n": "11.4.4",
|
||||||
"vue-router": "^4.5.1"
|
"vue-router": "^4.5.1"
|
||||||
},
|
},
|
||||||
@@ -24,15 +23,19 @@
|
|||||||
"@tailwindcss/vite": "^4.1.12",
|
"@tailwindcss/vite": "^4.1.12",
|
||||||
"@tsconfig/node20": "^20.1.6",
|
"@tsconfig/node20": "^20.1.6",
|
||||||
"@types/node": "^22.13.14",
|
"@types/node": "^22.13.14",
|
||||||
"@vitejs/plugin-legacy": "^8.0.2",
|
"@vant/auto-import-resolver": "^1.3.0",
|
||||||
"@vitejs/plugin-vue-jsx": "^5.1.5",
|
"@vitejs/plugin-legacy": "^6.0.1",
|
||||||
|
"@vitejs/plugin-vue": "^5.2.1",
|
||||||
|
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
||||||
"@vue/tsconfig": "^0.7.0",
|
"@vue/tsconfig": "^0.7.0",
|
||||||
"concurrently": "^9.2.1",
|
"concurrently": "^9.2.1",
|
||||||
"sass": "1.58.3",
|
"sass": "^1.70.0",
|
||||||
"tailwindcss": "^4.1.12",
|
"tailwindcss": "^4.1.12",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "^5.8.3",
|
||||||
|
"unplugin-auto-import": "^21.0.0",
|
||||||
|
"unplugin-vue-components": "^32.1.0",
|
||||||
"vconsole": "^3.15.1",
|
"vconsole": "^3.15.1",
|
||||||
"vite": "5.2.8",
|
"vite": "^6.1.1",
|
||||||
"vue-tsc": "^2.2.10"
|
"vue-tsc": "^2.1.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-viewport text-ink-900">
|
<router-view />
|
||||||
<RouterView />
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<uni-drawer ref="drawerRef" mode="left" :width="320">
|
<van-popup v-model:show="show" ref="drawerRef" position="left">
|
||||||
<div class="drawer-home">
|
<div class="drawer-home">
|
||||||
<div class="drawer-home-nav">
|
<div class="drawer-home-nav">
|
||||||
<uni-icons type="closeempty" size="22" color="#333333" class="close-icon" @click="close" />
|
<van-icon name="cross" size="22" color="#333333" class="close-icon" @click="close" />
|
||||||
<span class="title">我的</span>
|
<span class="title">我的</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MineSetting ref="mineSettingRef" @close="close" />
|
<!-- <MineSetting ref="mineSettingRef" @close="close" /> -->
|
||||||
</div>
|
</div>
|
||||||
</uni-drawer>
|
</van-popup>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -20,10 +20,12 @@ const drawerRef = ref(null);
|
|||||||
|
|
||||||
// 监听抽屉显示事件
|
// 监听抽屉显示事件
|
||||||
const mineSettingRef = ref(null);
|
const mineSettingRef = ref(null);
|
||||||
|
const show = ref(false);
|
||||||
|
|
||||||
const open = async () => {
|
const open = async () => {
|
||||||
await checkToken();
|
await checkToken();
|
||||||
|
|
||||||
drawerRef.value?.open?.();
|
show.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await mineSettingRef.value?.getLoginUserPhoneInfo?.();
|
await mineSettingRef.value?.getLoginUserPhoneInfo?.();
|
||||||
@@ -33,7 +35,7 @@ const open = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 监听抽屉隐藏事件
|
// 监听抽屉隐藏事件
|
||||||
const close = () => drawerRef.value?.close?.();
|
const close = () => show.value = false;
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open,
|
open,
|
||||||
|
|||||||
@@ -1,69 +1,70 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="index-page w-full h-screen overflow-hidden bg-liner">
|
<div class="index-page w-full h-screen overflow-hidden bg-liner">
|
||||||
<ChatMainList @showDrawer="showDrawer" />
|
<!-- <ChatMainList @showDrawer="showDrawer" /> -->
|
||||||
|
|
||||||
<!-- 日历组件 -->
|
<!-- 日历组件 -->
|
||||||
<Calender :visible="calendarVisible" mode="single" :default-value="selectedDate" @close="handleCalendarClose"
|
<!-- <Calender :visible="calendarVisible" mode="single" :default-value="selectedDate" @close="handleCalendarClose"
|
||||||
@select="handleDateSelect" />
|
@select="handleDateSelect" /> -->
|
||||||
|
|
||||||
<!-- 更多服务 -->
|
<!-- 更多服务 -->
|
||||||
<MoreService />
|
<!-- <MoreService /> -->
|
||||||
|
|
||||||
<!-- 抽屉组件 -->
|
<!-- 抽屉组件 -->
|
||||||
<DrawerSection ref="drawerRef" @close="closeDrawer" />
|
<DrawerSection ref="drawerRef" @close="closeDrawer" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { ref, onUnmounted, onMounted } from "vue";
|
import { ref, onUnmounted, onMounted } from "vue";
|
||||||
import { getUrlParams } from "@/utils/UrlParams";
|
import { emitter } from '@/utils/events'
|
||||||
import { useAppStore } from "@/store";
|
// import { getUrlParams } from "@/utils/UrlParams";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
// import { useAppStore } from "@/store";
|
||||||
import ChatMainList from "./components/ChatMainList/index.vue";
|
// import { checkToken } from "@/hooks/useGoLogin";
|
||||||
import MoreService from "./components/MoreService/index.vue";
|
// import ChatMainList from "./components/ChatMainList/index.vue";
|
||||||
|
// import MoreService from "./components/MoreService/index.vue";
|
||||||
import DrawerSection from "./components/DrawerSection/index.vue";
|
import DrawerSection from "./components/DrawerSection/index.vue";
|
||||||
import Calender from "@/components/Calender/index.vue";
|
// import Calender from "@/components/Calender/index.vue";
|
||||||
|
|
||||||
const appStore = useAppStore();
|
// const appStore = useAppStore();
|
||||||
const calendarVisible = ref(false);
|
// const calendarVisible = ref(false);
|
||||||
const selectedDate = ref("");
|
// const selectedDate = ref("");
|
||||||
|
|
||||||
// 处理日历关闭
|
// // 处理日历关闭
|
||||||
const handleCalendarClose = () => {
|
// const handleCalendarClose = () => {
|
||||||
calendarVisible.value = false;
|
// calendarVisible.value = false;
|
||||||
};
|
// };
|
||||||
|
|
||||||
// 处理日期选择
|
// // 处理日期选择
|
||||||
const handleDateSelect = (data) => {
|
// const handleDateSelect = (data) => {
|
||||||
selectedDate.value = data.date;
|
// selectedDate.value = data.date;
|
||||||
calendarVisible.value = false;
|
// calendarVisible.value = false;
|
||||||
console.log("选择的日期:", data.date);
|
// console.log("选择的日期:", data.date);
|
||||||
uni.$emit("selectCalendarDate", selectedDate.value); // 传回父组件
|
// uni.$emit("selectCalendarDate", selectedDate.value); // 传回父组件
|
||||||
};
|
// };
|
||||||
|
|
||||||
const openCalendar = () => {
|
// const openCalendar = () => {
|
||||||
calendarVisible.value = true;
|
// calendarVisible.value = true;
|
||||||
};
|
// };
|
||||||
|
|
||||||
// 打开窗口
|
// 打开窗口
|
||||||
const drawerRef = ref(null);
|
const drawerRef = ref(null);
|
||||||
const showDrawer = async (e) => {
|
const showDrawer = async () => {
|
||||||
await checkToken();
|
// await checkToken();
|
||||||
|
|
||||||
drawerRef.value?.open?.();
|
drawerRef.value?.open?.();
|
||||||
};
|
};
|
||||||
// 关闭窗口
|
// 关闭窗口
|
||||||
const closeDrawer = (e) => drawerRef.value?.close?.();
|
const closeDrawer = () => drawerRef.value?.close?.();
|
||||||
|
|
||||||
///获取到二维码原始链接内容
|
// ///获取到二维码原始链接内容
|
||||||
const getWeixinMiniProgramParams = (e) => {
|
// const getWeixinMiniProgramParams = (e) => {
|
||||||
console.log("Params:", e);
|
// console.log("Params:", e);
|
||||||
if (e.q && e.q != "undefined") {
|
// if (e.q && e.q != "undefined") {
|
||||||
const qrUrl = decodeURIComponent(e.q);
|
// const qrUrl = decodeURIComponent(e.q);
|
||||||
const params = getUrlParams(qrUrl);
|
// const params = getUrlParams(qrUrl);
|
||||||
appStore.setSceneId(params.sceneId || params.tagId);
|
// appStore.setSceneId(params.sceneId || params.tagId);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// onLoad((e) => {
|
// onLoad((e) => {
|
||||||
@@ -71,13 +72,13 @@ const getWeixinMiniProgramParams = (e) => {
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
uni.$on("openCalendar", openCalendar);
|
// uni.$on("openCalendar", openCalendar);
|
||||||
uni.$on("SHOW_DRAWER", showDrawer);
|
emitter.on("SHOW_DRAWER", showDrawer);
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
uni.$off("openCalendar", openCalendar);
|
// uni.$off("openCalendar", openCalendar);
|
||||||
uni.$off("SHOW_DRAWER", showDrawer);
|
emitter.off("SHOW_DRAWER", showDrawer);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,26 @@
|
|||||||
|
import vue from "@vitejs/plugin-vue";
|
||||||
|
import AutoImport from "unplugin-auto-import/vite";
|
||||||
|
import Components from "unplugin-vue-components/vite";
|
||||||
|
import { VantResolver } from "@vant/auto-import-resolver";
|
||||||
import tailwindcss from "@tailwindcss/vite";
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
import viteLegacy from "@vitejs/plugin-legacy";
|
import viteLegacy from "@vitejs/plugin-legacy";
|
||||||
import viteVue from "@vitejs/plugin-vue";
|
|
||||||
import viteVueJsx from "@vitejs/plugin-vue-jsx";
|
import viteVueJsx from "@vitejs/plugin-vue-jsx";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [viteVue(), viteLegacy(), viteVueJsx(), tailwindcss()],
|
plugins: [
|
||||||
|
vue(),
|
||||||
|
AutoImport({
|
||||||
|
resolvers: [VantResolver()],
|
||||||
|
}),
|
||||||
|
Components({
|
||||||
|
resolvers: [VantResolver()],
|
||||||
|
}),
|
||||||
|
viteLegacy(),
|
||||||
|
viteVueJsx(),
|
||||||
|
tailwindcss(),
|
||||||
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"@": path.join(__dirname, "./src"),
|
"@": path.join(__dirname, "./src"),
|
||||||
|
|||||||
Reference in New Issue
Block a user