合并 智慧就业第一版
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
/*
|
||||
* @Date: 2025-10-23 14:48:48
|
||||
* @LastEditors: shirlwang
|
||||
* @LastEditTime: 2025-10-23 15:02:32
|
||||
*/
|
||||
// BaseStore.js - 基础Store类
|
||||
import IndexedDBHelper from '@/common/IndexedDBHelper.js'
|
||||
// import UniStorageHelper from '../common/UniStorageHelper'
|
||||
import UniStorageHelper from '../common/UniStorageHelper'
|
||||
import useChatGroupDBStore from './userChatGroupStore'
|
||||
import config from '@/config'
|
||||
|
||||
@@ -39,29 +34,29 @@ class BaseStore {
|
||||
this.db = new IndexedDBHelper(this.dbName, config.DBversion);
|
||||
// // #endif
|
||||
// // #ifndef H5
|
||||
// this.db = new UniStorageHelper(this.dbName, config.DBversion);
|
||||
this.db = new UniStorageHelper(this.dbName, config.DBversion);
|
||||
// // #endif
|
||||
// this.db.openDB([{
|
||||
// name: 'record',
|
||||
// keyPath: "id",
|
||||
// autoIncrement: true,
|
||||
// }, {
|
||||
// name: 'messageGroup',
|
||||
// keyPath: "id",
|
||||
// autoIncrement: true,
|
||||
// }, {
|
||||
// name: 'messages',
|
||||
// keyPath: "id",
|
||||
// autoIncrement: true,
|
||||
// indexes: [{
|
||||
// name: 'parentGroupId',
|
||||
// key: 'parentGroupId',
|
||||
// unique: false
|
||||
// }]
|
||||
// }]).then(async () => {
|
||||
// useChatGroupDBStore().init()
|
||||
// this.isDBReady = true
|
||||
// });
|
||||
this.db.openDB([{
|
||||
name: 'record',
|
||||
keyPath: "id",
|
||||
autoIncrement: true,
|
||||
}, {
|
||||
name: 'messageGroup',
|
||||
keyPath: "id",
|
||||
autoIncrement: true,
|
||||
}, {
|
||||
name: 'messages',
|
||||
keyPath: "id",
|
||||
autoIncrement: true,
|
||||
indexes: [{
|
||||
name: 'parentGroupId',
|
||||
key: 'parentGroupId',
|
||||
unique: false
|
||||
}]
|
||||
}]).then(async () => {
|
||||
useChatGroupDBStore().init()
|
||||
this.isDBReady = true
|
||||
});
|
||||
}
|
||||
async clearDB() {
|
||||
return new Promise((resolve, rejetc) => {
|
||||
|
||||
@@ -98,7 +98,7 @@ const useDictStore = defineStore("dict", () => {
|
||||
}
|
||||
|
||||
function dictLabel(dictType, value) {
|
||||
if (state[dictType]) {
|
||||
if (state[dictType] && Array.isArray(state[dictType])) {
|
||||
for (let i = 0; i < state[dictType].length; i++) {
|
||||
let element = state[dictType][i];
|
||||
if (element.value === value) {
|
||||
@@ -135,6 +135,7 @@ const useDictStore = defineStore("dict", () => {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
async function getDictSelectOption(dictType, isDigital) {
|
||||
const resp = await createRequest(`/app/common/dict/${dictType}`);
|
||||
if (resp.code === 200 && resp.data) {
|
||||
@@ -175,6 +176,7 @@ const useDictStore = defineStore("dict", () => {
|
||||
|
||||
// 导入
|
||||
return {
|
||||
state,
|
||||
getDictData,
|
||||
dictLabel,
|
||||
oneDictData,
|
||||
|
||||
@@ -64,17 +64,21 @@ const useUserStore = defineStore("user", () => {
|
||||
});
|
||||
}
|
||||
|
||||
const logOut = () => {
|
||||
const logOut = (redirect = true) => {
|
||||
hasLogin.value = false;
|
||||
token.value = ''
|
||||
resume.value = {}
|
||||
userInfo.value = {}
|
||||
role.value = {}
|
||||
uni.clearStorageSync('userInfo')
|
||||
uni.clearStorageSync('token')
|
||||
uni.redirectTo({
|
||||
url: '/pages/login/login',
|
||||
});
|
||||
uni.removeStorageSync('userInfo')
|
||||
uni.removeStorageSync('token')
|
||||
|
||||
// 只有在明确需要跳转时才跳转到登录页
|
||||
if (redirect) {
|
||||
uni.redirectTo({
|
||||
url: '/pages/complete-info/complete-info',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const getUserInfo = () => {
|
||||
@@ -101,7 +105,7 @@ const useUserStore = defineStore("user", () => {
|
||||
token.value = value
|
||||
uni.setStorageSync('token', value);
|
||||
// 获取消息列表
|
||||
useReadMsg().fetchMessages()
|
||||
// useReadMsg().fetchMessages()
|
||||
// 获取用户信息
|
||||
return getUserResume()
|
||||
}
|
||||
@@ -111,6 +115,12 @@ const useUserStore = defineStore("user", () => {
|
||||
resume.value = values.data; // 将用户信息同时存储到resume中
|
||||
// role.value = values.role;
|
||||
hasLogin.value = true;
|
||||
|
||||
// 模拟添加用户类型字段,实际项目中应该从接口获取
|
||||
if (!userInfo.value.userType) {
|
||||
userInfo.value.userType = 0; // 默认设置为企业用户
|
||||
}
|
||||
|
||||
// 持久化存储用户信息到本地缓存
|
||||
uni.setStorageSync('userInfo', values.data);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,11 @@ const useChatGroupDBStore = defineStore("messageGroup", () => {
|
||||
};
|
||||
});
|
||||
}
|
||||
window.addEventListener("unload", handleUnload);
|
||||
// #ifdef H5
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener("unload", handleUnload);
|
||||
}
|
||||
// #endif
|
||||
|
||||
function onDataReceived(data) {
|
||||
// 支持追加多个部分
|
||||
@@ -180,7 +184,11 @@ const useChatGroupDBStore = defineStore("messageGroup", () => {
|
||||
...newMsg
|
||||
};
|
||||
toggleTyping(false);
|
||||
window.removeEventListener("unload", handleUnload);
|
||||
// #ifdef H5
|
||||
if (typeof window !== 'undefined') {
|
||||
window.removeEventListener("unload", handleUnload);
|
||||
}
|
||||
// #endif
|
||||
handleUnload();
|
||||
// 调用外部传入的onComplete回调
|
||||
if (options.onComplete) {
|
||||
|
||||
Reference in New Issue
Block a user