chore: update

This commit is contained in:
Stephen Zhou 2025-01-22 22:48:30 +08:00
parent c18da69de1
commit 73ec9079cc
No known key found for this signature in database
3 changed files with 6 additions and 10 deletions

View File

@ -12,7 +12,7 @@ import { logger } from "~/logger"
import { getMainWindow } from "~/window"
import { t } from "./i18n"
import { store, StoreKey } from "./store"
import { store } from "./store"
const require = createRequire(import.meta.url)
const fastFolderSize = require("fast-folder-size") as any as typeof import("fast-folder-size")
@ -101,7 +101,7 @@ export const clearCacheCronJob = () => {
}
timer = setInterval(
async () => {
const hasLimit = store.get(StoreKey.CacheSizeLimit)
const hasLimit = store.get("cacheSizeLimit")
if (!hasLimit) {
return

View File

@ -21,7 +21,3 @@ type StoreData = {
} | null
}
export const store = new Store<StoreData>({ name: "db" })
export enum StoreKey {
CacheSizeLimit = "cacheSizeLimit",
}

View File

@ -9,7 +9,7 @@ import { app, BrowserWindow, clipboard, dialog, shell } from "electron"
import { registerMenuAndContextMenu } from "~/init"
import { clearAllData, getCacheSize } from "~/lib/cleaner"
import { store, StoreKey } from "~/lib/store"
import { store } from "~/lib/store"
import { registerAppTray } from "~/lib/tray"
import { logger, revealLogFile } from "~/logger"
import { cleanupOldRender, loadDynamicRenderEntry } from "~/updater/hot-updater"
@ -290,7 +290,7 @@ ${content}
shell.openPath(dir)
}),
getCacheLimit: t.procedure.action(async () => {
return store.get(StoreKey.CacheSizeLimit)
return store.get("cacheSizeLimit")
}),
clearCache: t.procedure.action(async () => {
@ -318,9 +318,9 @@ ${content}
limitCacheSize: t.procedure.input<number>().action(async ({ input }) => {
logger.info("set limitCacheSize", input)
if (input === 0) {
store.delete(StoreKey.CacheSizeLimit)
store.delete("cacheSizeLimit")
} else {
store.set(StoreKey.CacheSizeLimit, input)
store.set("cacheSizeLimit", input)
}
}),