feat:移除了弹窗,服务器添加sls

This commit is contained in:
2026-09-08 22:39:45 +08:00
commit 6a295f9a7a
4082 changed files with 1322534 additions and 0 deletions

View File

@ -0,0 +1,53 @@
export type LabCategoryFilter = 'all' | 'creation' | 'maintenance' | 'world'
export type LabFavoriteFilter = 'all' | 'favorite' | 'unfavorite'
const LAB_FAVORITE_TOOL_IDS_STORAGE_KEY = 'axolotl-lab-favorite-tool-ids'
const LAB_CATEGORY_FILTER_STORAGE_KEY = 'axolotl-lab-category-filter'
const LAB_FAVORITE_FILTER_STORAGE_KEY = 'axolotl-lab-favorite-filter'
function readStringArray(key: string): string[] {
try {
const parsed = JSON.parse(globalThis.localStorage?.getItem(key) ?? '[]')
return Array.isArray(parsed)
? parsed.filter((item): item is string => typeof item === 'string')
: []
} catch {
return []
}
}
export function getLabFavoriteToolIds(): string[] {
return readStringArray(LAB_FAVORITE_TOOL_IDS_STORAGE_KEY)
}
export function setLabFavoriteToolIds(ids: string[]) {
globalThis.localStorage?.setItem(LAB_FAVORITE_TOOL_IDS_STORAGE_KEY, JSON.stringify(ids))
}
export function isLabCategoryFilter(value: string): value is LabCategoryFilter {
return value === 'creation' || value === 'maintenance' || value === 'world'
}
export function getLabCategoryFilter(): LabCategoryFilter {
const value = globalThis.localStorage?.getItem(LAB_CATEGORY_FILTER_STORAGE_KEY)
return value && isLabCategoryFilter(value) ? value : 'all'
}
export function setLabCategoryFilter(filter: LabCategoryFilter) {
if (filter === 'all') globalThis.localStorage?.removeItem(LAB_CATEGORY_FILTER_STORAGE_KEY)
else globalThis.localStorage?.setItem(LAB_CATEGORY_FILTER_STORAGE_KEY, filter)
}
export function isLabFavoriteFilter(value: string): value is LabFavoriteFilter {
return value === 'favorite' || value === 'unfavorite'
}
export function getLabFavoriteFilter(): LabFavoriteFilter {
const value = globalThis.localStorage?.getItem(LAB_FAVORITE_FILTER_STORAGE_KEY)
return value && isLabFavoriteFilter(value) ? value : 'all'
}
export function setLabFavoriteFilter(filter: LabFavoriteFilter) {
if (filter === 'all') globalThis.localStorage?.removeItem(LAB_FAVORITE_FILTER_STORAGE_KEY)
else globalThis.localStorage?.setItem(LAB_FAVORITE_FILTER_STORAGE_KEY, filter)
}