mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-09 02:18:55 +08:00
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:
65
im/src/stores/notify.js
Normal file
65
im/src/stores/notify.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
// 原 vuex notify 模块
|
||||
export const useNotifyStore = defineStore("notify", {
|
||||
state: () => ({
|
||||
// 聊天消息未读数
|
||||
unreadNum: 0,
|
||||
|
||||
// 好友申请未读数
|
||||
applyNum: 0,
|
||||
|
||||
// 好友键盘事件监听
|
||||
inputEvent: 0,
|
||||
|
||||
// 好友登录状态监听
|
||||
friendStatus: {
|
||||
// 登录状态[0:下线;1:在线;]
|
||||
status: 0,
|
||||
// 好友ID
|
||||
friend_id: 0,
|
||||
},
|
||||
}),
|
||||
actions: {
|
||||
// 消息未读数自增
|
||||
INCR_UNREAD_NUM() {
|
||||
console.log("触发消息未读");
|
||||
this.unreadNum++;
|
||||
},
|
||||
|
||||
// 好友申请事件监听
|
||||
INCR_APPLY_NUM() {
|
||||
this.applyNum++;
|
||||
},
|
||||
|
||||
// 设置消息未读数
|
||||
SET_UNREAD_NUM(value) {
|
||||
this.unreadNum = value;
|
||||
},
|
||||
|
||||
// 好友申请事件监听
|
||||
SET_APPLY_NUM(value) {
|
||||
this.applyNum = value;
|
||||
},
|
||||
|
||||
// 自增好友键盘输入事件
|
||||
UPDATE_KEYBOARD_EVENT() {
|
||||
this.inputEvent++;
|
||||
},
|
||||
|
||||
// 更新好友登录状态
|
||||
UPDATE_FRIEND_STATUS(value) {
|
||||
this.friendStatus = value;
|
||||
},
|
||||
|
||||
// 原 vuex action ACT_UPDATE_FRIEND_STATUS
|
||||
ACT_UPDATE_FRIEND_STATUS(value) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
this.UPDATE_FRIEND_STATUS(value);
|
||||
resolve();
|
||||
}, 0);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user