From 62f6fd16d50c4da955c68e81d3f371499a3ffa9c Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Tue, 24 May 2022 23:02:40 +0200 Subject: [PATCH] refactor: ts on i18n --- src/renderer/i18n/{ar-SA.js => ar-SA.ts} | 0 src/renderer/i18n/{de-DE.js => de-DE.ts} | 0 src/renderer/i18n/{en-US.js => en-US.ts} | 0 src/renderer/i18n/{es-ES.js => es-ES.ts} | 0 src/renderer/i18n/{fr-FR.js => fr-FR.ts} | 0 src/renderer/i18n/{it-IT.js => it-IT.ts} | 0 src/renderer/i18n/{ja-JP.js => ja-JP.ts} | 0 src/renderer/i18n/{pt-BR.js => pt-BR.ts} | 62 +++++++++---------- src/renderer/i18n/supported-locales.ts | 2 +- src/renderer/i18n/{vi-VN.js => vi-VN.ts} | 0 src/renderer/i18n/{zh-CN.js => zh-CN.ts} | 0 .../stores/{scratchpad.js => scratchpad.ts} | 7 +-- .../stores/{settings.js => settings.ts} | 55 ++++++++-------- 13 files changed, 61 insertions(+), 65 deletions(-) rename src/renderer/i18n/{ar-SA.js => ar-SA.ts} (100%) rename src/renderer/i18n/{de-DE.js => de-DE.ts} (100%) rename src/renderer/i18n/{en-US.js => en-US.ts} (100%) rename src/renderer/i18n/{es-ES.js => es-ES.ts} (100%) rename src/renderer/i18n/{fr-FR.js => fr-FR.ts} (100%) rename src/renderer/i18n/{it-IT.js => it-IT.ts} (100%) rename src/renderer/i18n/{ja-JP.js => ja-JP.ts} (100%) rename src/renderer/i18n/{pt-BR.js => pt-BR.ts} (94%) rename src/renderer/i18n/{vi-VN.js => vi-VN.ts} (100%) rename src/renderer/i18n/{zh-CN.js => zh-CN.ts} (100%) rename src/renderer/stores/{scratchpad.js => scratchpad.ts} (79%) rename src/renderer/stores/{settings.js => settings.ts} (65%) diff --git a/src/renderer/i18n/ar-SA.js b/src/renderer/i18n/ar-SA.ts similarity index 100% rename from src/renderer/i18n/ar-SA.js rename to src/renderer/i18n/ar-SA.ts diff --git a/src/renderer/i18n/de-DE.js b/src/renderer/i18n/de-DE.ts similarity index 100% rename from src/renderer/i18n/de-DE.js rename to src/renderer/i18n/de-DE.ts diff --git a/src/renderer/i18n/en-US.js b/src/renderer/i18n/en-US.ts similarity index 100% rename from src/renderer/i18n/en-US.js rename to src/renderer/i18n/en-US.ts diff --git a/src/renderer/i18n/es-ES.js b/src/renderer/i18n/es-ES.ts similarity index 100% rename from src/renderer/i18n/es-ES.js rename to src/renderer/i18n/es-ES.ts diff --git a/src/renderer/i18n/fr-FR.js b/src/renderer/i18n/fr-FR.ts similarity index 100% rename from src/renderer/i18n/fr-FR.js rename to src/renderer/i18n/fr-FR.ts diff --git a/src/renderer/i18n/it-IT.js b/src/renderer/i18n/it-IT.ts similarity index 100% rename from src/renderer/i18n/it-IT.js rename to src/renderer/i18n/it-IT.ts diff --git a/src/renderer/i18n/ja-JP.js b/src/renderer/i18n/ja-JP.ts similarity index 100% rename from src/renderer/i18n/ja-JP.js rename to src/renderer/i18n/ja-JP.ts diff --git a/src/renderer/i18n/pt-BR.js b/src/renderer/i18n/pt-BR.ts similarity index 94% rename from src/renderer/i18n/pt-BR.js rename to src/renderer/i18n/pt-BR.ts index b9abe1be..caf0221f 100644 --- a/src/renderer/i18n/pt-BR.js +++ b/src/renderer/i18n/pt-BR.ts @@ -107,37 +107,37 @@ module.exports = { changelog: 'Logs de alteração', format: 'Formato', sshTunnel: 'SSH túnel', - structure: 'Estrutura', - small: 'Pequeno', - medium: 'Médio', - large: 'Grande', - row: 'Linha | Linhas', - cell: 'Celula | Células', - triggerFunction: 'Gatinho de função | Gatilhos de Funções', - all: 'Todos', - duplicate: 'Duplicado', - routine: 'Rotina', - new: 'Novo', - history: 'Histórico', - select: 'Seleciomar', - passphrase: 'Palavara-Passe', - filter: 'Filtrar', - change: 'Alterar', - views: 'Visualizações', - triggers: 'Gatilhos', - routines: 'Rotinas', - functions: 'Funções', - schedulers: 'Agendadores', - includes: 'Includes', - drop: 'Drop', - completed: 'Completo', - aborted: 'Abortado', - disabled: 'Inativo', - enable: 'Ativo', - disable: 'Disable', - commit: 'Enviar', - rollback: 'Reverter', - connectionString: 'String da conexão', + structure: 'Estrutura', + small: 'Pequeno', + medium: 'Médio', + large: 'Grande', + row: 'Linha | Linhas', + cell: 'Celula | Células', + triggerFunction: 'Gatinho de função | Gatilhos de Funções', + all: 'Todos', + duplicate: 'Duplicado', + routine: 'Rotina', + new: 'Novo', + history: 'Histórico', + select: 'Seleciomar', + passphrase: 'Palavara-Passe', + filter: 'Filtrar', + change: 'Alterar', + views: 'Visualizações', + triggers: 'Gatilhos', + routines: 'Rotinas', + functions: 'Funções', + schedulers: 'Agendadores', + includes: 'Includes', + drop: 'Drop', + completed: 'Completo', + aborted: 'Abortado', + disabled: 'Inativo', + enable: 'Ativo', + disable: 'Disable', + commit: 'Enviar', + rollback: 'Reverter', + connectionString: 'String da conexão', contributors: 'Contribuintes' }, message: { diff --git a/src/renderer/i18n/supported-locales.ts b/src/renderer/i18n/supported-locales.ts index f7dda013..b8c5df61 100644 --- a/src/renderer/i18n/supported-locales.ts +++ b/src/renderer/i18n/supported-locales.ts @@ -1,4 +1,4 @@ -export const localesNames = { +export const localesNames: {[key: string]: string} = { 'en-US': 'English', 'it-IT': 'Italiano', 'ar-SA': 'العربية', diff --git a/src/renderer/i18n/vi-VN.js b/src/renderer/i18n/vi-VN.ts similarity index 100% rename from src/renderer/i18n/vi-VN.js rename to src/renderer/i18n/vi-VN.ts diff --git a/src/renderer/i18n/zh-CN.js b/src/renderer/i18n/zh-CN.ts similarity index 100% rename from src/renderer/i18n/zh-CN.js rename to src/renderer/i18n/zh-CN.ts diff --git a/src/renderer/stores/scratchpad.js b/src/renderer/stores/scratchpad.ts similarity index 79% rename from src/renderer/stores/scratchpad.js rename to src/renderer/stores/scratchpad.ts index 6c4ad18f..3f224683 100644 --- a/src/renderer/stores/scratchpad.js +++ b/src/renderer/stores/scratchpad.ts @@ -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)); diff --git a/src/renderer/stores/settings.js b/src/renderer/stores/settings.ts similarity index 65% rename from src/renderer/stores/settings.js rename to src/renderer/stores/settings.ts index df803796..26f255b3 100644 --- a/src/renderer/stores/settings.js +++ b/src/renderer/stores/settings.ts @@ -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));