From 264efd628782aab18cbeac35dec8e7216a17c906 Mon Sep 17 00:00:00 2001 From: tikkhun Date: Thu, 2 Jan 2025 15:00:56 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20source=20storage=20=E4=B8=80=E4=BD=93?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/config-for-web/lib/LocalStorageSource.ts | 4 +++- .../lib/{ViteEnvSoruce.ts => ViteEnvSource.ts} | 0 packages/config-for-web/lib/index.ts | 9 ++++----- packages/config-for-web/lib/instance.ts | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) rename packages/config-for-web/lib/{ViteEnvSoruce.ts => ViteEnvSource.ts} (100%) diff --git a/packages/config-for-web/lib/LocalStorageSource.ts b/packages/config-for-web/lib/LocalStorageSource.ts index 3616ac4..e81ab51 100644 --- a/packages/config-for-web/lib/LocalStorageSource.ts +++ b/packages/config-for-web/lib/LocalStorageSource.ts @@ -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', @@ -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) { diff --git a/packages/config-for-web/lib/ViteEnvSoruce.ts b/packages/config-for-web/lib/ViteEnvSource.ts similarity index 100% rename from packages/config-for-web/lib/ViteEnvSoruce.ts rename to packages/config-for-web/lib/ViteEnvSource.ts diff --git a/packages/config-for-web/lib/index.ts b/packages/config-for-web/lib/index.ts index fda2650..a9f99b9 100644 --- a/packages/config-for-web/lib/index.ts +++ b/packages/config-for-web/lib/index.ts @@ -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'; diff --git a/packages/config-for-web/lib/instance.ts b/packages/config-for-web/lib/instance.ts index c34018a..e811e77 100644 --- a/packages/config-for-web/lib/instance.ts +++ b/packages/config-for-web/lib/instance.ts @@ -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()], });