refactor: 四端完成 Options API → script setup + vuex → pinia 迁移

- buyer(95) / seller(169) / im(53) / manager(280) 共 597 个组件全部从 Options API 转换为 <script setup>
- 四端 vuex 全部移除,状态管理统一迁移至 pinia 4(stores/ 目录)
- util.js 等基础设施去除 vm 首参依赖;全局属性($Message/$filters 等)在 script 内改为具名导入
- 被外部 ref 访问的公共组件均已补齐 defineExpose(清单见各端 MIGRATION-VUE3.md)
- 各端 eslint 启用 vue/component-api-style 防止新代码回退 Options API
- 四端 yarn build 全部通过;迁移约定与注意事项已更新至各端 MIGRATION-VUE3.md
This commit is contained in:
lifenlong
2026-10-13 07:06:59 +08:00
parent 870bacdd8c
commit 88fc1b0b2a
674 changed files with 71220 additions and 69943 deletions

View File

@@ -55,7 +55,9 @@
</div>
</template>
<script>
<script setup>
import { computed, onBeforeUnmount, onMounted } from "vue";
import { useRouter } from "vue-router";
import {
Bell,
ChatDotRound,
@@ -78,6 +80,12 @@ import {
import menuList from "./menu";
import Storage from "@/plugins/storage.js";
import { refreshUnreadMessage } from "@/utils/unreadMessage";
import { useAppStore } from "@/stores/app";
defineOptions({ name: "Home" });
const router = useRouter();
const appStore = useAppStore();
const MENU_ICONS = {
Bell,
@@ -99,44 +107,35 @@ const MENU_ICONS = {
Warning,
};
export default {
components: { House, User },
name: "Home",
data() {
return {
menuList,
};
},
computed: {
userInfo() {
if (Storage.getItem("userInfo")) {
return JSON.parse(Storage.getItem("userInfo"));
}
return {};
},
unreadMsg() {
return Number(this.$store.state.unreadMsg) || 0;
},
unreadLabel() {
return this.unreadMsg > 99 ? "99+" : String(this.unreadMsg);
},
},
mounted() {
document.body.classList.add("buyer-user-center");
refreshUnreadMessage();
},
beforeUnmount() {
document.body.classList.remove("buyer-user-center");
},
methods: {
menuIcon(name) {
return MENU_ICONS[name] || Goods;
},
onSelect(name) {
this.$router.push({ name });
},
},
};
const userInfo = computed(() => {
if (Storage.getItem("userInfo")) {
return JSON.parse(Storage.getItem("userInfo"));
}
return {};
});
const unreadMsg = computed(() => appStore.unreadMsg);
const unreadLabel = computed(() => {
return unreadMsg.value > 99 ? "99+" : String(unreadMsg.value);
});
function menuIcon(name) {
return MENU_ICONS[name] || Goods;
}
function onSelect(name) {
router.push({ name });
}
onMounted(() => {
document.body.classList.add("buyer-user-center");
refreshUnreadMessage();
});
onBeforeUnmount(() => {
document.body.classList.remove("buyer-user-center");
});
</script>
<style scoped lang="scss">