wangzhibo
2025-10-23 cad64c1de2c45856b0774933c5801b05b64984e8
1
"use strict";const e=require("../common/vendor.js"),s=require("../utils/uuid.js"),t=e.defineStore("user",{state:()=>({uuid:"",createdAt:"",username:"",avatarIndex:"",sex:"",phoneNumber:""}),actions:{initUser(){const t=e.index.getStorageSync("user_info");if(t&&t.uuid)Object.assign(this,t);else{const t={uuid:s.generateUUIDv4(),createdAt:(new Date).toISOString(),username:"",avatarIndex:"",sex:"",phoneNumber:""};Object.assign(this,t),e.index.setStorageSync("user_info",t)}},saveUserInfo({avatarIndex:s,sex:t,username:n,phoneNumber:r}){const a={username:n??this.username,avatarIndex:s??this.avatarIndex,sex:t??this.sex,phoneNumber:r??this.phoneNumber};Object.assign(this,a),e.index.setStorageSync("user_info",{...this.$state})}}});exports.useUserStore=t;