Skip to content

Commit

Permalink
chore: source storage 一体。
Browse files Browse the repository at this point in the history
  • Loading branch information
radiorz committed Jan 2, 2025
1 parent a251655 commit 264efd6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/config-for-web/lib/LocalStorageSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import { ConfigSource } from '@tikkhun/config-core';
import { optionsMerge } from '@tikkhun/utils-core';
import { debounce, merge, set } from 'lodash-es';
import { debounce, set } from 'lodash-es';
export const LocalStorageSourceDefaultOptions = {
// 存储的键值对
key: 'config',
Expand Down Expand Up @@ -45,7 +45,9 @@ export class LocalStorageSource implements ConfigSource {
reset(path?: string) {
if (!path) {
this.save('', {});
return;
}
this.save(path, undefined);
}
// 这里应该搞个debounce
save(path: string, value: any) {
Expand Down
9 changes: 4 additions & 5 deletions packages/config-for-web/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from "@tikkhun/config-core";
export * from "./LocalStorageSource";
export * from "./instance";
export * from "./LocalStorageStore";
export * from "./ViteEnvSoruce";
export * from '@tikkhun/config-core';
export * from './LocalStorageSource';
export * from './instance';
export * from './ViteEnvSource';
2 changes: 1 addition & 1 deletion packages/config-for-web/lib/instance.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Config } from "@tikkhun/config-core";
import { LocalStorageSource } from "./LocalStorageSource";
import { ViteEnvSource } from "./ViteEnvSoruce";
import { ViteEnvSource } from "./ViteEnvSource";
export const DEFAULT_CONFIG_MANAGER = Config.create({
sources: [new ViteEnvSource(), new LocalStorageSource()],
});

0 comments on commit 264efd6

Please sign in to comment.