From b0136bba4d214e43eac1819d5ab7752f55c4921a Mon Sep 17 00:00:00 2001 From: Methapon Metanipat <162551568+Methapon-Frappet@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:55:44 +0700 Subject: [PATCH] refactor: global shared state and function (#79) * refactor: expose i18n instance * feat: add global app utility function * refactor: use global utility function * refactor: avoid undefined when use outside vue refactor: avoid undefined when use outside vue * refactor: remove dup code and use util * refactor: auto fetch option when use store --- src/boot/i18n.ts | 15 +-- src/layouts/MainLayout.vue | 61 +++--------- src/layouts/ProfileMenu.vue | 113 ++++------------------- src/pages/05_quotation/QuotationForm.vue | 62 +------------ src/stores/options/index.ts | 29 +++--- src/utils/ui.ts | 72 +++++++++++++++ 6 files changed, 136 insertions(+), 216 deletions(-) create mode 100644 src/utils/ui.ts diff --git a/src/boot/i18n.ts b/src/boot/i18n.ts index b2c5036c..3f15bad7 100644 --- a/src/boot/i18n.ts +++ b/src/boot/i18n.ts @@ -21,13 +21,16 @@ declare module 'vue-i18n' { } /* eslint-enable @typescript-eslint/no-empty-interface */ -export default boot(({ app }) => { - const i18n = createI18n({ - locale: 'tha', - legacy: false, - messages, - }); +export const i18n = createI18n({ + locale: 'tha', + legacy: false, + messages: { + 'en-US': {}, + ...messages, + }, +}); +export default boot(({ app }) => { // Set i18n instance on app app.use(i18n); }); diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 95d53dac..89aa8043 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -1,5 +1,5 @@