Skip to content

Commit

Permalink
feat: remember i18n select in console page. (#550)
Browse files Browse the repository at this point in the history
* fix: default dev mode can not run success.

* feat: remember i18n select in console page.

* docs: update CHANGELOG.MD
  • Loading branch information
li-guohao authored Jun 7, 2024
1 parent dddb45f commit 8f38b5f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

## 新特性
- 添加关于是否展示web端主题的配置开关
- 浏览器记住console的多语言切换选择 #549

## 问题修复

Expand Down
14 changes: 13 additions & 1 deletion console/src/layouts/components/LanguageSelect.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { ElSelect, ElOption } from 'element-plus';
import { ref } from 'vue';
import { onMounted, ref } from 'vue';
import { locales, changeI18nLocal } from '@/locales';
import { useLayoutStore } from '@/stores/layout';
const { locale } = useI18n();
const selectedLanguage = ref(locale);
const layoutStore = useLayoutStore();
const changeLanguage = () => {
changeI18nLocal(selectedLanguage.value);
// console.debug('selectedLanguage.value', selectedLanguage.value);
layoutStore.setI18nCode(selectedLanguage.value);
};
onMounted(()=>{
const selectdI18nCode = layoutStore.i18nCode
if (selectdI18nCode && selectdI18nCode != '') {
// console.debug('selectdI18nCode', selectdI18nCode)
selectedLanguage.value = selectdI18nCode;
changeI18nLocal(selectedLanguage.value);
}
})
</script>

<template>
Expand Down
5 changes: 5 additions & 0 deletions console/src/stores/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { defineStore } from 'pinia';
interface LayoutStoreState {
asideIsExtend: boolean;
currentActivePath: string;
i18nCode: string;
}

export const useLayoutStore = defineStore('layout', {
state: (): LayoutStoreState => ({
asideIsExtend: true,
currentActivePath: '/dashboard',
i18nCode: 'zh-CN',
}),
actions: {
switchLayoutAsideExtendState() {
Expand All @@ -17,6 +19,9 @@ export const useLayoutStore = defineStore('layout', {
updatecurrentActivePathByRoutePath(path) {
this.currentActivePath = path;
},
setI18nCode(code:string) {
this.i18nCode = code;
},
},
// In order to config pinia-plugin-persist, please see https://github.com/Seb-L/pinia-plugin-persist
persist: {
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ikaros:
plugin:
runtime-mode: development
fixed-plugin-path:
- C:\Users\li-guohao\GitRepo\ikaros-dev\plugin-alist
# - C:\Users\li-guohao\GitRepo\ikaros-dev\plugin-alist
# - C:\Develop\GitRepos\ikaros-dev\plugins\plugin-bgmtv
# - C:\Develop\GitRepos\ikaros-dev\plugins\plugin-local-files-import
# - C:\Develop\GitRepos\ikaros-dev\plugins\plugin-jellyfin
Expand Down

0 comments on commit 8f38b5f

Please sign in to comment.