-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
61 lines (53 loc) · 1.67 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { defineStore } from 'pinia';
import packageJson from '@root/package.json';
export const useCoreStore = defineStore('core', () => {
const scopedPackageName = packageJson.name;
const packageName = scopedPackageName.split('/')[1];
// Links //
const repoBaseUrl = `https://github.com/webdevnerdstuff/${packageName}`;
const links = {
changeLog: `${repoBaseUrl}/blob/main/CHANGELOG.md`,
discord: 'https://discord.com/users/979453275369783346',
github: repoBaseUrl,
githubProfile: 'https://github.com/webdevnerdstuff',
license: `${repoBaseUrl}/blob/main/LICENSE.md`,
npm: `https://www.npmjs.com/package/${scopedPackageName}`,
vue: 'https://vuejs.org/',
vueUse: 'https://vueuse.org/',
vuetify: 'https://vuetifyjs.com/',
vuetifyGithub: 'https://github.com/vuetifyjs/vuetify',
};
const actions = {
setLocalStorage(val: string): string {
const oldValue = localStorage.getItem(packageName);
const newValue = val ?? oldValue;
localStorage.setItem(packageName, newValue);
return newValue;
},
setTheme(val: string): string {
const themeName = val === 'dark' ? 'light' : 'dark';
const currentTheme = localStorage.getItem(`${packageName}-theme`);
const newTheme = themeName ?? currentTheme;
localStorage.setItem(`${packageName}-theme`, newTheme);
return newTheme;
},
};
const getters = {
getLocalStorage: () => (): unknown => {
const value = localStorage.getItem(packageName);
return value;
},
getTheme: () => {
const value = localStorage.getItem(`${packageName}-theme`);
return value;
},
};
return {
...actions,
...getters,
links,
package: packageJson,
packageName,
pluginVersion: packageJson.version,
};
});