1 line
2.0 KiB
Plaintext
1 line
2.0 KiB
Plaintext
{"version":3,"file":"user.js","sources":["../../../../src/store/user.js"],"sourcesContent":["import { defineStore } from 'pinia'\r\nimport { ref, computed } from 'vue'\r\n\r\nconst initState = {\r\n nickname: '',\r\n avatar: '',\r\n id: null,\r\n name: '',\r\n phone: '',\r\n email: '',\r\n typeId: '',\r\n createTime: '',\r\n updateTime: '',\r\n token: '',\r\n sex: '',\r\n openid: '', // 微信openid,如果不为空就证明用户是用微信登录的\r\n isRealName: false,\r\n isPetNursery: false,\r\n shopLoginUser: null,\r\n}\r\n\r\nexport const useUserStore = defineStore(\r\n 'user',\r\n () => {\r\n const userInfo = ref({ ...initState })\r\n\r\n const setUserInfo = (val) => {\r\n userInfo.value = {\r\n ...userInfo.value,\r\n ...val,\r\n }\r\n }\r\n\r\n const clearUserInfo = () => {\r\n userInfo.value = { ...initState }\r\n }\r\n\r\n // 一般没有reset需求,不需要的可以删除\r\n const reset = () => {\r\n userInfo.value = { ...initState }\r\n }\r\n\r\n const isLogined = computed(() => userInfo.value.token != '')\r\n\r\n return {\r\n userInfo,\r\n setUserInfo,\r\n clearUserInfo,\r\n isLogined,\r\n reset,\r\n }\r\n },\r\n {\r\n persist: true,\r\n },\r\n)\r\n"],"names":["defineStore","ref","computed"],"mappings":";;;;;;;;;;;;;;;;;;AAGA,MAAM,YAAY;AAAA,EAChB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA;AAAA,EACR,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,eAAe;AACjB;AAEY,MAAC,eAAeA,cAAW;AAAA,EACrC;AAAA,EACA,MAAM;AACJ,UAAM,WAAWC,cAAAA,IAAI,mBAAK,UAAW;AAErC,UAAM,cAAc,CAAC,QAAQ;AAC3B,eAAS,QAAQ,kCACZ,SAAS,QACT;AAAA,IAEN;AAED,UAAM,gBAAgB,MAAM;AAC1B,eAAS,QAAQ,mBAAK;AAAA,IACvB;AAGD,UAAM,QAAQ,MAAM;AAClB,eAAS,QAAQ,mBAAK;AAAA,IACvB;AAED,UAAM,YAAYC,cAAAA,SAAS,MAAM,SAAS,MAAM,SAAS,EAAE;AAE3D,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACF;AAAA,EACD;AAAA,IACE,SAAS;AAAA,EACV;AACH;;"} |