初始提交

This commit is contained in:
2026-01-04 11:09:06 +08:00
commit 8fa31df250
1326 changed files with 213907 additions and 0 deletions

7
store/index.js Normal file
View File

@@ -0,0 +1,7 @@
import {
createPinia
} from 'pinia';
const store = createPinia();
export default store

147
store/modules/base.js Normal file
View File

@@ -0,0 +1,147 @@
import {
defineStore
} from 'pinia';
import {
getDictionaryDataAll,
getGroupSelector,
getRoleSelector,
} from '@/api/common'
export const useBaseStore = defineStore({
id: ' app-base',
state: () => ({
dictionaryList: [],
groupList: [],
roleList: [],
relationData: {},
}),
getters: {
getDictionaryList() {
return this.dictionaryList
},
getRelationData() {
return this.relationData
},
},
actions: {
setDictionaryList(dictionaryList) {
this.dictionaryList = dictionaryList || []
},
setGroupList(groupList) {
this.groupList = groupList
},
setRoleList(roleList) {
this.roleList = roleList
},
updateRelationData(val) {
this.relationData = val
},
getDictionaryDataAll() {
return new Promise((resolve, reject) => {
if (this.dictionaryList.length) {
resolve(this.dictionaryList)
} else {
getDictionaryDataAll().then(res => {
this.setDictionaryList(res.data.list)
resolve(res.data.list)
}).catch(error => {
reject(error)
})
}
})
},
getDictionaryData(info) {
return new Promise(async resolve => {
let list = [],
data = [],
json = []
if (!this.dictionaryList.length) {
list = await this.getDictionaryDataAll()
} else {
list = this.dictionaryList
}
if (info.sort) {
data = list.filter(o => o.enCode === info.sort)[0]
if (!info.id) {
json = data?.dictionaryList || []
} else {
let rowData = [];
if (!data.isTree) {
rowData = data.dictionaryList.fliter(o => o.id == info.id)
} else {
const findData = list => {
for (let i = 0; i < list.length; i++) {
const e = list[i];
if (e.id == info.id) {
rowData[0] = e
break
}
if (e.children && e.children.length) {
findData(e.children)
}
}
}
findData(data.dictionaryList)
}
if (rowData.length) {
json = rowData[0]
} else {
json = {
id: "",
fullName: ""
};
}
}
}
resolve(json)
})
},
getDicDataSelector(value, key = 'id') {
return new Promise(async resolve => {
let list = [],
data = {},
json = [];
if (!this.dictionaryList.length) {
list = await this.getDictionaryDataAll()
} else {
list = this.dictionaryList
}
if (!value) return resolve([])
let arr = list.filter(o => o[key] === value);
if (!arr.length) return resolve([])
data = arr[0];
json = data.dictionaryList;
resolve(json)
})
},
getGroupList() {
return new Promise((resolve, reject) => {
if (!this.groupList.length) {
getGroupSelector().then(res => {
this.setGroupList(res.data)
resolve(res.data)
}).catch(error => {
reject(error)
})
} else {
resolve(this.groupList)
}
})
},
getRoleList() {
return new Promise((resolve, reject) => {
if (!this.roleList.length) {
getRoleSelector().then(res => {
this.setRoleList(res.data.list)
resolve(res.data.list)
}).catch(error => {
reject(error)
})
} else {
resolve(this.roleList)
}
})
},
},
});

113
store/modules/chat.js Normal file
View File

@@ -0,0 +1,113 @@
import {
defineStore
} from 'pinia';
import store from '../index'
export const useChatStore = defineStore({
id: ' chat',
state: () => ({
socket: null,
badgeNum: 0,
msgInfo: {},
formUserId: ''
}),
getters: {
getSocket() {
return this.socket
},
getBadgeNum() {
return this.badgeNum
},
getMsgInfo() {
return this.msgInfo
}
},
actions: {
setSocket(socket) {
this.socket = socket
},
setBadgeNum(badgeNum) {
this.badgeNum = badgeNum
},
addBadgeNum(num) {
this.badgeNum += num
},
reduceBadgeNum(num) {
let badgeNum = this.badgeNum - num
if (badgeNum < 0) badgeNum = 0
this.badgeNum = badgeNum
},
setMsgInfo(msgInfo) {
this.msgInfo = msgInfo
},
setMsgInfoNum(num) {
if (num || num === 0) {
this.msgInfo.messageCount = num
this.msgInfo.count = num
this.badgeNum = num
return
}
this.msgInfo.messageCount -= 1
this.msgInfo.count = this.msgInfo.messageCount
let badgeNum = this.badgeNum - 1
if (badgeNum < 0) badgeNum = 0
this.badgeNum = badgeNum
},
setFormUserId(formUserId) {
this.formUserId = formUserId
},
sendMessage(data) {
const item = {
account: data.toAccount,
headIcon: data.toHeadIcon,
id: data.toUserId,
latestDate: data.latestDate,
latestMessage: data.toMessage,
messageType: data.messageType,
realName: data.toRealName,
unreadMessage: 0
}
const addItem = {
sendUserId: data.UserId,
contentType: data.messageType,
content: data.toMessage,
sendTime: data.dateTime,
method: data.method
}
uni.$emit('addMsg', addItem)
uni.$emit('updateList', item)
},
receiveMessage(data) {
if (this.formUserId === data.formUserId) {
data.unreadMessage = 0
const item = {
sendUserId: data.formUserId,
contentType: data.messageType,
content: data.formMessage,
sendTime: data.dateTime,
method: data.method
}
uni.$emit('addMsg', item)
} else {
data.unreadMessage = 1
this.addBadgeNum(1)
}
data.id = data.formUserId
data.latestMessage = data.formMessage
uni.$emit('updateList', data)
},
getMessageList(data) {
uni.$emit('getMessageList', data)
},
messagePush(data) {
this.msgInfo.messageText = data.title;
this.msgInfo.messageCount += data.unreadNoticeCount;
this.msgInfo.messageDate = data.messageDefaultTime
this.addBadgeNum(data.unreadNoticeCount || 1)
}
},
});
export function useChatStoreWithOut() {
return useChatStore(store);
}

18
store/modules/test.js Normal file
View File

@@ -0,0 +1,18 @@
import {
defineStore
} from 'pinia';
export const useTestStore = defineStore({
id: ' test',
state: () => ({
count: 0,
}),
actions: {
increment() {
this.count++;
},
decrement() {
this.count--;
},
},
});

88
store/modules/user.js Normal file
View File

@@ -0,0 +1,88 @@
import {
defineStore
} from 'pinia';
import {
logout,
getCurrentUser
} from '@/api/common'
import store from '../index'
import permission from '@/libs/permission'
export const useUserStore = defineStore({
id: ' user',
state: () => ({
token: "",
userInfo: {},
menuList: [],
}),
getters: {
getToken() {
return this.token
},
},
actions: {
setToken(token) {
this.token = token
uni.setStorageSync('token', token)
},
setCid(cid) {
this.cid = cid
uni.setStorageSync('cid', cid)
},
setUserInfo(userInfo) {
this.userInfo = userInfo
uni.setStorageSync('userInfo', userInfo)
},
setMenuList(menuList) {
this.menuList = menuList
uni.setStorageSync('menuList', menuList)
},
getCurrentUser() {
return new Promise((resolve, reject) => {
getCurrentUser().then(res => {
const userInfo = res.data.userInfo || {}
const permissionList = res.data.permissionList || []
const sysConfigInfo = res.data.sysConfigInfo || {}
const sysVersion = sysConfigInfo.sysVersion || ''
const copyright = sysConfigInfo.copyright || ''
uni.setStorageSync('sysVersion', sysVersion)
uni.setStorageSync('permissionList', permissionList)
permission && permission.updatePermissionList()
uni.setStorageSync('sysConfigInfo', sysConfigInfo)
uni.setStorageSync('copyright', copyright)
uni.setStorageSync('systemCode', userInfo.systemCode)
this.setUserInfo(userInfo)
this.setMenuList(res.data.menuList)
resolve(userInfo)
}).catch(error => {
reject(error)
})
})
},
logout() {
return new Promise((resolve, reject) => {
logout().then(() => {
this.setToken('')
this.setCid('')
this.setUserInfo({})
this.resetToken()
resolve()
}).catch(error => {
reject(error)
})
})
},
resetToken() {
uni.removeStorageSync('token')
uni.removeStorageSync('cid')
uni.removeStorageSync('userInfo')
uni.removeStorageSync('permissionList')
uni.removeStorageSync('sysVersion')
uni.removeStorageSync('dynamicModelExtra')
}
},
});
export function useUserStoreWithOut() {
return useUserStore(store);
}