You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
944 B
44 lines
944 B
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
|
|
// 定义 Store
|
|
export const useDeepExplorationStore = defineStore(
|
|
'deepExploration',
|
|
() => {
|
|
// 会员信息
|
|
const deepExplorationInfo = ref()
|
|
|
|
// 保存会员信息,登录时使用
|
|
const setDeepExplorationInfo = (val) => {
|
|
deepExplorationInfo.value = val
|
|
}
|
|
|
|
// 清理会员信息,退出时使用
|
|
const clearDeepExplorationInfo = () => {
|
|
deepExplorationInfo.value = undefined
|
|
}
|
|
|
|
// 记得 return
|
|
return {
|
|
deepExplorationInfo,
|
|
setDeepExplorationInfo,
|
|
clearDeepExplorationInfo,
|
|
}
|
|
},
|
|
// TODO: 持久化
|
|
{
|
|
// 网页端持久化
|
|
// persist: true,
|
|
// 小程序端持久化
|
|
persist: {
|
|
storage: {
|
|
getItem(key) {
|
|
return uni.getStorageSync(key)
|
|
},
|
|
setItem(key, value) {
|
|
uni.setStorageSync(key, value)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
)
|