feat: 更新依赖包版本
This commit is contained in:
@@ -120,7 +120,7 @@ const File: FunctionComponent = () => {
|
||||
flexDirection: "row",
|
||||
}}
|
||||
size={"small"}>
|
||||
<Avatar src={ali} size={"small"} />{" "}
|
||||
<Avatar src={ali} size={"small"} />
|
||||
<span style={{ marginLeft: "10px", fontWeight: "bolder" }}>
|
||||
阿里云OSS
|
||||
</span>
|
||||
|
@@ -1,12 +1,10 @@
|
||||
/** @format */
|
||||
|
||||
import { useUserStore } from "./modules/user.ts";
|
||||
import { useFileStore } from "@/store/modules/file.ts";
|
||||
import { UseStorageSettingStore } from "@/store/modules/storage_setting.ts";
|
||||
|
||||
/** 将每个Store实例化 */
|
||||
export const RootStore = {
|
||||
user: new useUserStore(),
|
||||
file: new useFileStore(),
|
||||
storage: new UseStorageSettingStore(),
|
||||
};
|
||||
/** @format */
|
||||
|
||||
import { useUserStore } from "./modules/user.ts";
|
||||
import { useFileStore } from "@/store/modules/file.ts";
|
||||
|
||||
/** 将每个Store实例化 */
|
||||
export const RootStore = {
|
||||
user: new useUserStore(),
|
||||
file: new useFileStore(),
|
||||
};
|
||||
|
@@ -1,50 +0,0 @@
|
||||
/** @format */
|
||||
|
||||
import { action, makeObservable, observable } from "mobx";
|
||||
import { isHydrated, makePersistable } from "mobx-persist-store";
|
||||
import { handleLocalforage } from "@/utils/localforage";
|
||||
|
||||
export class UseStorageSettingStore {
|
||||
selectValue: string = "";
|
||||
|
||||
constructor() {
|
||||
makeObservable(this, {
|
||||
selectValue: observable,
|
||||
setSelectValue: action,
|
||||
getSelectValue: action,
|
||||
isHydrated: action,
|
||||
});
|
||||
makePersistable(
|
||||
this,
|
||||
{
|
||||
// 在构造函数内使用 makePersistable
|
||||
name: "storage_setting", // 保存的name,用于在storage中的名称标识,只要不和storage中其他名称重复就可以
|
||||
properties: ["selectValue"], // 要保存的字段,这些字段会被保存在name对应的storage中,注意:不写在这里面的字段将不会被保存,刷新页面也将丢失:get字段例外。get数据会在数据返回后再自动计算
|
||||
storage: handleLocalforage, // 保存的位置:可以是localStorage,sessionstorage
|
||||
removeOnExpiration: true, //如果 expireIn 具有值且已过期,则在调用 getItem 时将自动删除存储中的数据。默认值为 true。
|
||||
stringify: false, //如果为 true,则数据在传递给 setItem 之前将是 JSON.stringify。默认值为 true。
|
||||
expireIn: 2592000000, // 一个以毫秒为单位的值,用于确定 getItem 何时不应检索存储中的数据。默认情况下永不过期。
|
||||
debugMode: false, // 如果为 true,将为多个 mobx-persist-store 项调用 console.info。默认值为 false。
|
||||
},
|
||||
{
|
||||
delay: 0, // 允许您设置一个 delay 选项来限制 write 函数的调用次数。默认情况下没有延迟。
|
||||
fireImmediately: false, // 确定是应立即保留存储数据,还是等到存储中的属性发生更改。 false 默认情况下。
|
||||
},
|
||||
).then(
|
||||
action(() => {
|
||||
// persist 完成的回调,在这里可以执行一些拿到数据后需要执行的操作,如果在页面上要判断是否完成persist,使用 isHydrated
|
||||
// console.log(persistStore)
|
||||
}),
|
||||
);
|
||||
}
|
||||
getSelectValue() {
|
||||
return this.selectValue ? this.selectValue : null;
|
||||
}
|
||||
setSelectValue(value: any) {
|
||||
this.selectValue = value;
|
||||
}
|
||||
|
||||
isHydrated() {
|
||||
return isHydrated(this);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user