diff options
author | zeroinformatique | 2021-07-05 20:19:48 +0200 |
---|---|---|
committer | GitHub | 2021-07-05 20:19:48 +0200 |
commit | 89cd6d8aa71870788765db489dd67c4ef237c551 (patch) | |
tree | 7250db7e0bcfbae85d5d1732ce887b624e080654 /viewer/src/store | |
parent | ac160f6879f9a2c74ca77c1c34742d24e69bf570 (diff) | |
parent | c83f44cd69a227f873a026c01653ef434b6ae045 (diff) | |
download | ldgallery-89cd6d8aa71870788765db489dd67c4ef237c551.tar.gz |
Merge pull request #304 from ldgallery/oz-splash-screen
viewer: optional user-defined markdown splash screen
Diffstat (limited to 'viewer/src/store')
-rw-r--r-- | viewer/src/store/uiStore.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index f5bb898..520fcf4 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts | |||
@@ -18,6 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | import { Config } from "@/@types/gallery"; | 20 | import { Config } from "@/@types/gallery"; |
21 | import { SplashScreenConfig } from "@/@types/splashscreen"; | ||
21 | import ItemComparators, { ItemSort } from "@/services/itemComparators"; | 22 | import ItemComparators, { ItemSort } from "@/services/itemComparators"; |
22 | import { action, createModule, mutation } from "vuex-class-component"; | 23 | import { action, createModule, mutation } from "vuex-class-component"; |
23 | 24 | ||
@@ -26,12 +27,17 @@ const VuexModule = createModule({ | |||
26 | strict: true, | 27 | strict: true, |
27 | }); | 28 | }); |
28 | 29 | ||
30 | const STORAGE_SPLASHSCREEN_ACKNOWLEDGMENT = "splashScreenAcknowledgment"; | ||
31 | |||
29 | export default class UIStore extends VuexModule { | 32 | export default class UIStore extends VuexModule { |
30 | fullscreen: boolean = false; | 33 | fullscreen: boolean = false; |
31 | fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); | 34 | fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); |
32 | searchMode: boolean = false; | 35 | searchMode: boolean = false; |
33 | sort: ItemSort = ItemComparators.DEFAULT; | 36 | sort: ItemSort = ItemComparators.DEFAULT; |
34 | 37 | ||
38 | splashScreenConfig: SplashScreenConfig | null = null; | ||
39 | splashScreenEnabled: boolean = false; | ||
40 | |||
35 | // --- | 41 | // --- |
36 | 42 | ||
37 | @mutation toggleFullscreen(value?: boolean) { | 43 | @mutation toggleFullscreen(value?: boolean) { |
@@ -50,11 +56,34 @@ export default class UIStore extends VuexModule { | |||
50 | this.sort = sort; | 56 | this.sort = sort; |
51 | } | 57 | } |
52 | 58 | ||
59 | @mutation setSplashScreenConfig(splashScreenConfig: SplashScreenConfig) { | ||
60 | this.splashScreenConfig = splashScreenConfig; | ||
61 | } | ||
62 | |||
63 | @mutation setSplashScreenEnabled(enabled: boolean) { | ||
64 | this.splashScreenEnabled = enabled; | ||
65 | } | ||
66 | |||
67 | // --- | ||
68 | |||
53 | @action async initFromConfig(config: Config) { | 69 | @action async initFromConfig(config: Config) { |
54 | if (config.initialItemSort) { | 70 | if (config.initialItemSort) { |
55 | const itemSort = ItemComparators.ITEM_SORTS[config.initialItemSort]; | 71 | const itemSort = ItemComparators.ITEM_SORTS[config.initialItemSort]; |
56 | if (itemSort) this.setSort(itemSort); | 72 | if (itemSort) this.setSort(itemSort); |
57 | else throw new Error("Unknown sort type: " + config.initialItemSort); | 73 | else throw new Error("Unknown sort type: " + config.initialItemSort); |
58 | } | 74 | } |
75 | if (config.splashScreen) { | ||
76 | this.setSplashScreenConfig(config.splashScreen); | ||
77 | const uid = config.splashScreen.acknowledgmentKey; | ||
78 | this.setSplashScreenEnabled(!uid || localStorage.getItem(STORAGE_SPLASHSCREEN_ACKNOWLEDGMENT) !== uid); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | // --- | ||
83 | |||
84 | @action async validateSpashScreen() { | ||
85 | this.setSplashScreenEnabled(false); | ||
86 | const uid = this.splashScreenConfig?.acknowledgmentKey; | ||
87 | if (uid) localStorage.setItem(STORAGE_SPLASHSCREEN_ACKNOWLEDGMENT, String(uid)); | ||
59 | } | 88 | } |
60 | } | 89 | } |