daikins/.svn/pristine/06/068c355dd0974ad72fe9b5f9dc3...

21 lines
592 B
Plaintext

import { defineStore } from 'pinia';
export const useMyStore = defineStore('myStore', {
state: () => ({
data: JSON.parse(localStorage.getItem('myData')) || null,
type: JSON.parse(localStorage.getItem('mType')) || null,
}),
actions: {
setData(data: any) {
this.data = data;
// 将数据保存到本地存储
localStorage.setItem('myData', JSON.stringify(data));
},
setType(data: any) {
this.type = data;
// 将数据保存到本地存储
localStorage.setItem('myType', JSON.stringify(data));
},
},
});