mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-08-06 02:47:25 +08:00
- 将多个组件转换为 `<script setup>` 语法,提升可读性和性能 - 优化状态管理和事件处理逻辑,简化代码结构 - 更新样式和布局以适应新组件结构 - 添加新功能和修复已知问题,提升用户体验
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
import { createStore } from 'vuex'
|
|
import storage from '@/utils/storage'
|
|
import config from '@/config/config'
|
|
import { DEFAULT_THEME, loadCachedTheme } from '@/utils/theme'
|
|
|
|
const cachedTheme = loadCachedTheme()
|
|
|
|
const store = createStore({
|
|
state: {
|
|
isShowToast: false,
|
|
remark: [],
|
|
shareLink: '',
|
|
verificationKey: '',
|
|
distributionId: '',
|
|
hasLogin: storage.getHasLogin(),
|
|
userInfo: storage.getUserInfo(),
|
|
uuid: storage.getUuid(),
|
|
token: '',
|
|
theme: cachedTheme || { ...DEFAULT_THEME },
|
|
},
|
|
getters: {
|
|
mainColor: (state) => state.theme.mainColor,
|
|
lightColor: (state) => state.theme.lightColor,
|
|
aiderLightColor: (state) => state.theme.aiderLightColor,
|
|
},
|
|
mutations: {
|
|
login(state, userInfo) {
|
|
state.userInfo = userInfo || {}
|
|
state.userName =
|
|
userInfo.Name || userInfo.Nickname || userInfo.Username || '匿名用户'
|
|
state.hasLogin = true
|
|
},
|
|
logout(state) {
|
|
state.userName = ''
|
|
state.hasLogin = false
|
|
},
|
|
setRemark(state, remark) {
|
|
state.remark = remark
|
|
},
|
|
SET_THEME(state, theme) {
|
|
state.theme = {
|
|
mainColor: theme.mainColor || DEFAULT_THEME.mainColor,
|
|
lightColor: theme.lightColor || DEFAULT_THEME.lightColor,
|
|
aiderLightColor: theme.aiderLightColor || DEFAULT_THEME.aiderLightColor,
|
|
}
|
|
},
|
|
},
|
|
actions: {}
|
|
})
|
|
|
|
export function useStore() {
|
|
return store
|
|
}
|
|
|
|
export default store
|