Files
crawler-plugin/frontend-vue/src/shared/utils/ziniao-version.ts
T
2026-07-19 22:23:26 +08:00

21 lines
546 B
TypeScript

import { ref, watch } from 'vue'
export type ZiniaoVersion = 'new' | 'old'
const STORAGE_KEY = 'ziniao:version'
function loadZiniaoVersion(): ZiniaoVersion {
if (typeof window === 'undefined') return 'new'
return window.localStorage.getItem(STORAGE_KEY) === 'old' ? 'old' : 'new'
}
export function useZiniaoVersion() {
const ziniaoVersion = ref<ZiniaoVersion>(loadZiniaoVersion())
watch(ziniaoVersion, (value) => {
if (typeof window !== 'undefined') window.localStorage.setItem(STORAGE_KEY, value)
})
return ziniaoVersion
}