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

@@ -43,62 +43,66 @@
</audio>
</div>
</template>
<script>
<script setup>
import { computed, watch } from "vue";
import Face from '../../components/face'
import { mapState } from "vuex";
import { useAppStore } from "@/stores/app";
import { useUserStore } from "@/stores/user";
import { useNotifyStore } from "@/stores/notify";
import { useSettingsStore } from "@/stores/settings";
import { ServeFindFriendApplyNum } from "@/api/contacts";
export default {
components: { Face },
name: "MainLayout",
props: {
idx: {
type: Number,
default: 0,
},
defineOptions({ name: "MainLayout" });
defineProps({
idx: {
type: Number,
default: 0,
},
computed: {
...mapState({
face: (state) => state.user.face,
name: (state) => state.user.name,
id: (state) => state.user.id,
defaultAvatar: (state) => state.defaultAvatar,
socketStatus: (state) => state.socketStatus,
unreadNum: (state) => state.notify.unreadNum,
applyNum: (state) => state.notify.applyNum,
notifyCueTone: (state) => state.settings.notifyCueTone,
themeMode: (state) => state.settings.themeMode,
themeBagImg: (state) => state.settings.themeBagImg,
}),
},
watch: {
unreadNum (n, o) {
if (n > 0 && n > o && this.notifyCueTone) {
this.play();
}
},
},
created () {
this.setApplyNum();
},
methods: {
play () {
document
.querySelector("#audio")
.play()
.catch(() => {
console.error("消息提示音播放异常");
});
},
logout () {
this.$store.dispatch("ACT_USER_LOGOUT");
},
setApplyNum () {
// TODO 暂且return
return;
},
},
};
});
const appStore = useAppStore();
const userStore = useUserStore();
const notifyStore = useNotifyStore();
const settingsStore = useSettingsStore();
const face = computed(() => userStore.face);
const name = computed(() => userStore.name);
const id = computed(() => userStore.id);
const defaultAvatar = computed(() => appStore.defaultAvatar);
const socketStatus = computed(() => appStore.socketStatus);
const unreadNum = computed(() => notifyStore.unreadNum);
const applyNum = computed(() => notifyStore.applyNum);
const notifyCueTone = computed(() => settingsStore.notifyCueTone);
const themeMode = computed(() => settingsStore.themeMode);
const themeBagImg = computed(() => settingsStore.themeBagImg);
watch(unreadNum, (n, o) => {
if (n > 0 && n > o && notifyCueTone.value) {
play();
}
});
// 原 created 钩子
setApplyNum();
function play () {
document
.querySelector("#audio")
.play()
.catch(() => {
console.error("消息提示音播放异常");
});
}
function logout () {
userStore.ACT_USER_LOGOUT();
}
function setApplyNum () {
// TODO 暂且return
return;
}
</script>
<style lang="less" >
.main-layout {

File diff suppressed because it is too large Load Diff

View File

@@ -16,39 +16,34 @@
</div>
</div>
</template>
<script>
<script setup>
import { ref, onBeforeUnmount } from 'vue'
import { useRouter } from 'vue-router'
import { SvgNotFount } from '@/core/icons'
export default {
name: 'NotFoundPage',
components: {
SvgNotFount,
},
data() {
return {
second: 10,
setInterval: null,
}
},
created() {
this.setInterval = setInterval(() => {
this.second--
if (this.second == 0) {
clearInterval(this.setInterval)
this.toHome()
}
}, 1000)
},
beforeUnmount() {
clearInterval(this.setInterval)
},
methods: {
toHome() {
this.$router.push({
path: '/',
})
},
},
defineOptions({ name: 'NotFoundPage' })
const router = useRouter()
const second = ref(10)
let timer = null
timer = setInterval(() => {
second.value--
if (second.value == 0) {
clearInterval(timer)
toHome()
}
}, 1000)
onBeforeUnmount(() => {
clearInterval(timer)
})
function toHome() {
router.push({
path: '/',
})
}
</script>
<style lang="less" scoped>