mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
refactor: ts on i18n
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
export const localesNames = {
|
||||
export const localesNames: {[key: string]: string} = {
|
||||
'en-US': 'English',
|
||||
'it-IT': 'Italiano',
|
||||
'ar-SA': 'العربية',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { defineStore, acceptHMRUpdate } from 'pinia';
|
||||
import { defineStore } from 'pinia';
|
||||
import Store from 'electron-store';
|
||||
const persistentStore = new Store({ name: 'notes' });
|
||||
|
||||
@ -7,12 +7,9 @@ export const useScratchpadStore = defineStore('scratchpad', {
|
||||
notes: persistentStore.get('notes', '# HOW TO SUPPORT ANTARES\n\n- [ ] Leave a star to Antares [GitHub repo](https://github.com/antares-sql/antares)\n- [ ] Send feedbacks and advices\n- [ ] Report for bugs\n- [ ] If you enjoy, share Antares with friends\n\n# ABOUT SCRATCHPAD\n\nThis is a scratchpad where you can save your **personal notes**. It supports `markdown` format, but you are free to use plain text.\nThis content is just a placeholder, feel free to clear it to make space for your notes.\n')
|
||||
}),
|
||||
actions: {
|
||||
changeNotes (notes) {
|
||||
changeNotes (notes: string) {
|
||||
this.notes = notes;
|
||||
persistentStore.set('notes', this.notes);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (import.meta.webpackHot)
|
||||
import.meta.webpackHot.accept(acceptHMRUpdate(useScratchpadStore, import.meta.webpackHot));
|
@ -1,4 +1,4 @@
|
||||
import { defineStore, acceptHMRUpdate } from 'pinia';
|
||||
import { defineStore } from 'pinia';
|
||||
import i18n from '@/i18n';
|
||||
import Store from 'electron-store';
|
||||
const persistentStore = new Store({ name: 'settings' });
|
||||
@ -6,73 +6,72 @@ const isDarkTheme = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
const defaultAppTheme = isDarkTheme.matches ? 'dark' : 'light';
|
||||
const defaultEditorTheme = isDarkTheme.matches ? 'twilight' : 'sqlserver';
|
||||
|
||||
export type EditorFontSize = 'small' | 'medium' | 'large';
|
||||
|
||||
export const useSettingsStore = defineStore('settings', {
|
||||
state: () => ({
|
||||
locale: persistentStore.get('locale', 'en-US'),
|
||||
allowPrerelease: persistentStore.get('allow_prerelease', true),
|
||||
explorebarSize: persistentStore.get('explorebar_size', null),
|
||||
notificationsTimeout: persistentStore.get('notifications_timeout', 5),
|
||||
dataTabLimit: persistentStore.get('data_tab_limit', 1000),
|
||||
autoComplete: persistentStore.get('auto_complete', true),
|
||||
lineWrap: persistentStore.get('line_wrap', true),
|
||||
applicationTheme: persistentStore.get('application_theme', defaultAppTheme),
|
||||
editorTheme: persistentStore.get('editor_theme', defaultEditorTheme),
|
||||
editorFontSize: persistentStore.get('editor_font_size', 'medium'),
|
||||
restoreTabs: persistentStore.get('restore_tabs', true),
|
||||
disableBlur: persistentStore.get('disable_blur', false)
|
||||
locale: persistentStore.get('locale', 'en-US') as string,
|
||||
allowPrerelease: persistentStore.get('allow_prerelease', true) as boolean,
|
||||
explorebarSize: persistentStore.get('explorebar_size', null) as number,
|
||||
notificationsTimeout: persistentStore.get('notifications_timeout', 5) as number,
|
||||
dataTabLimit: persistentStore.get('data_tab_limit', 1000) as number,
|
||||
autoComplete: persistentStore.get('auto_complete', true) as boolean,
|
||||
lineWrap: persistentStore.get('line_wrap', true) as boolean,
|
||||
applicationTheme: persistentStore.get('application_theme', defaultAppTheme) as string,
|
||||
editorTheme: persistentStore.get('editor_theme', defaultEditorTheme) as string,
|
||||
editorFontSize: persistentStore.get('editor_font_size', 'medium') as EditorFontSize,
|
||||
restoreTabs: persistentStore.get('restore_tabs', true) as boolean,
|
||||
disableBlur: persistentStore.get('disable_blur', false) as boolean
|
||||
}),
|
||||
actions: {
|
||||
changeLocale (locale) {
|
||||
changeLocale (locale: string) {
|
||||
this.locale = locale;
|
||||
i18n.global.locale = locale;
|
||||
persistentStore.set('locale', this.locale);
|
||||
},
|
||||
changePageSize (limit) {
|
||||
changePageSize (limit: number) {
|
||||
this.dataTabLimit = limit;
|
||||
persistentStore.set('data_tab_limit', this.dataTabLimit);
|
||||
},
|
||||
changeAllowPrerelease (allow) {
|
||||
changeAllowPrerelease (allow: boolean) {
|
||||
this.allowPrerelease = allow;
|
||||
persistentStore.set('allow_prerelease', this.allowPrerelease);
|
||||
},
|
||||
updateNotificationsTimeout (timeout) {
|
||||
updateNotificationsTimeout (timeout: number) {
|
||||
this.notificationsTimeout = timeout;
|
||||
persistentStore.set('notifications_timeout', this.notificationsTimeout);
|
||||
},
|
||||
changeExplorebarSize (size) {
|
||||
changeExplorebarSize (size: number) {
|
||||
this.explorebarSize = size;
|
||||
persistentStore.set('explorebar_size', this.explorebarSize);
|
||||
},
|
||||
changeAutoComplete (val) {
|
||||
changeAutoComplete (val: boolean) {
|
||||
this.autoComplete = val;
|
||||
persistentStore.set('auto_complete', this.autoComplete);
|
||||
},
|
||||
changeLineWrap (val) {
|
||||
changeLineWrap (val: boolean) {
|
||||
this.lineWrap = val;
|
||||
persistentStore.set('line_wrap', this.lineWrap);
|
||||
},
|
||||
changeApplicationTheme (theme) {
|
||||
changeApplicationTheme (theme: string) {
|
||||
this.applicationTheme = theme;
|
||||
persistentStore.set('application_theme', this.applicationTheme);
|
||||
},
|
||||
changeEditorTheme (theme) {
|
||||
changeEditorTheme (theme: string) {
|
||||
this.editorTheme = theme;
|
||||
persistentStore.set('editor_theme', this.editorTheme);
|
||||
},
|
||||
changeEditorFontSize (size) {
|
||||
changeEditorFontSize (size: EditorFontSize) {
|
||||
this.editorFontSize = size;
|
||||
persistentStore.set('editor_font_size', this.editorFontSize);
|
||||
},
|
||||
changeRestoreTabs (val) {
|
||||
changeRestoreTabs (val: boolean) {
|
||||
this.restoreTabs = val;
|
||||
persistentStore.set('restore_tabs', this.restoreTabs);
|
||||
},
|
||||
changeDisableBlur (val) {
|
||||
changeDisableBlur (val: boolean) {
|
||||
this.disableBlur = val;
|
||||
persistentStore.set('disable_blur', this.disableBlur);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (import.meta.webpackHot)
|
||||
import.meta.webpackHot.accept(acceptHMRUpdate(useSettingsStore, import.meta.webpackHot));
|
Reference in New Issue
Block a user