// 导入定义仓库的方法 import { defineStore } from 'pinia'; // 导入响应式和计算 import { ref } from 'vue'; const useUserStore = defineStore("user", () => { // 定义一个状态用户信息 const userInfo = ref(uni.getStorageSync('userInfo')||{}); // 定义一个设置状态的方法 const setUserInfo = (data) => { userInfo.value = data; uni.setStorageSync('userInfo', data) } userInfo.value = { "nickname": "哈哈", "mobile": "17685151643", "avatar": "https://lihaiim.oss-cn-chengdu.aliyuncs.com/image/admin/avatar.png", "token": "a8670fe7f1014c0f5125f6ca0c3b9cb3" } const token = ref(uni.getStorageSync('token')||''); const setToken = (data) => { token.value = data; uni.setStorageSync('token', data) } token.value = "a8670fe7f1014c0f5125f6ca0c3b9cb3" return { userInfo, setToken, token, setToken } }) export default useUserStore;