Skip to content

Commit

Permalink
update(ui): init state for pinia
Browse files Browse the repository at this point in the history
  • Loading branch information
Enubia committed Mar 14, 2024
1 parent 1ff6790 commit 29571bb
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/store/app.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
import { defineStore } from 'pinia';

import type ElectronStore from 'electron-store';
import { inject } from 'vue';
import ElectronStore from 'electron-store';
import { StoreDefaults } from '@shared/constants';
import type { AppStore } from '@shared/types';

const electronStore = new ElectronStore<AppStore>();

const initialState = {
...StoreDefaults,
...electronStore.store,
};

export const useAppStore = defineStore({
id: 'app',
state: () => ({
...StoreDefaults,
...initialState,

/**
* @summary The file store, do not use directly, use the `saveToElectronStore` action instead
* @summary The file store, do not use directly if you can avoid it.
*/
$electronStore: inject<ElectronStore<AppStore>>('electronStore'),
$electronStore: electronStore,
}),
actions: {
setLanguage(language: string) {
this.general.language = language;
resetSettings() {
this.$reset();
this.saveToElectronStore();
},

saveToElectronStore() {
Expand Down

0 comments on commit 29571bb

Please sign in to comment.