-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
118 changed files
with
519 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { useStorage, RemovableRef } from '@vueuse/core'; | ||
|
||
import { LSNamespace, LSApp } from '@/types/ls'; | ||
|
||
interface LocalStorageOptions<Store> { | ||
namespace?: LSNamespace; | ||
app: LSApp; | ||
defaults?: Store; | ||
versionChecker?: (storedVersion: number, storeRef: RemovableRef<Store>) => number; | ||
} | ||
|
||
export default function useLocalStorage<Store extends object>(options: LocalStorageOptions<Store>) { | ||
const { | ||
namespace = LSNamespace.SoxFE, | ||
app, | ||
versionChecker = (_, storeRef) => { | ||
storeRef.value = null; | ||
return -1; | ||
}, | ||
defaults = {} as Store, | ||
} = options; | ||
const storage = window.localStorage; | ||
|
||
const baseKey = `${namespace}#${app}`; | ||
const versionCheckerKey = `${baseKey}##versionChecker`; | ||
|
||
const store = useStorage<Store>(baseKey, defaults, storage, { | ||
mergeDefaults: true, | ||
}); | ||
|
||
const versionStore = useStorage<Record<string, number>>(versionCheckerKey, {}, storage); | ||
const storedVersion = versionStore.value[baseKey]; | ||
const currentVersion = versionChecker(storedVersion, store); | ||
versionStore.value[baseKey] = currentVersion; | ||
|
||
function listItems() { | ||
return store.value; | ||
} | ||
|
||
function countItems() { | ||
return Object.keys(listItems()).length; | ||
} | ||
|
||
function getItem<K extends keyof Store>(key: K) { | ||
return store.value[key]; | ||
} | ||
|
||
function setItem<K extends keyof Store>(key: K, value: Store[K]) { | ||
store.value[key] = value; | ||
} | ||
|
||
function removeItem(key: keyof Store) { | ||
delete store.value[key]; | ||
} | ||
|
||
function clear() { | ||
store.value = null; | ||
} | ||
|
||
return { | ||
store, | ||
listItems, | ||
countItems, | ||
getItem, | ||
setItem, | ||
removeItem, | ||
clear, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
src/views/COCCardSections/PaperBack.vue → src/pages/coc-card/PaperBack.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletions
22
src/views/COCCardSections/PaperFront.vue → src/pages/coc-card/PaperFront.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/components/coc-card/DownloaderItem.vue → ...es/coc-card/components/DownloaderItem.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/components/coc-card/QunSection.vue → src/pages/coc-card/components/QunSection.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
src/components/coc-card/SkillTable.vue → src/pages/coc-card/components/SkillTable.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/components/coc-card/SkillTdInput.vue → ...ages/coc-card/components/SkillTdInput.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
src/components/coc-card/WeaponSectionRow.vue → .../coc-card/components/WeaponSectionRow.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/components/coc-card/WritableArea.vue → ...ages/coc-card/components/WritableArea.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.