Skip to content
  • Projects
  • Groups
  • Snippets
  • Help

h5 / vite-integral

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Settings
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • vite-integral
  • src
  • store
  • user.ts
  • 胡悦's avatar
    添加pinia持久化和移动端适配 · f53d499f
    胡悦 committed Aug 05, 2022
    f53d499f
user.ts 372 Bytes
RawBlameHistoryPermalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
import { defineStore } from 'pinia'
export const useUserStore = defineStore({
  id: 'user',
  state: () => ({
    name: 'huyue',
    sessionId: '34fasdfasdf'
  }),
  actions: {
    updateName(name: string) {
      this.name = name
    }
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'user',
        storage: localStorage,
      }
    ]
  }
})