perf: 客户端新窗口皮肤不统一的问题

This commit is contained in:
kuaifan 2022-06-09 14:50:36 +08:00
parent 020be75f7b
commit a11eb11166
6 changed files with 65 additions and 13 deletions

View File

@ -235,6 +235,18 @@ class IndexController extends InvokeController
];
}
/**
* 设置语言和皮肤
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function setting__theme_language()
{
return view('setting', [
'theme' => Request::input('theme'),
'language' => Request::input('language')
]);
}
/**
* 提取所有中文
* @return array|string

View File

@ -22,8 +22,8 @@
<!--音频播放-->
<AudioManager/>
<!--Manifest-->
<iframe v-if="manifestUrl" v-show="false" :src="manifestUrl"></iframe>
<!--Hidden IFrame-->
<iframe v-for="item in iframes" :key="item.key" v-if="item.url" v-show="false" :src="item.url"></iframe>
</div>
</template>
@ -51,8 +51,8 @@ export default {
data() {
return {
routePath: null,
manifestUrl: null,
inter: null,
searchInter: null,
iframes: [],
}
},
@ -62,19 +62,20 @@ export default {
},
mounted() {
this.inter = setInterval(this.searchEnter, 1000);
window.addEventListener('resize', this.windowSizeListener);
window.addEventListener('scroll', this.windowScrollListener);
this.searchInter = setInterval(this.searchEnter, 1000);
this.synchThemeLanguage();
},
beforeDestroy() {
this.inter && clearInterval(this.inter);
window.removeEventListener('resize', this.windowSizeListener);
window.removeEventListener('scroll', this.windowScrollListener);
this.searchInter && clearInterval(this.searchInter);
},
computed: {
...mapState(['ws']),
...mapState(['ws', 'themeMode']),
},
watch: {
@ -131,6 +132,14 @@ export default {
},
immediate: true
},
themeMode() {
this.synchThemeLanguage();
},
languageType() {
this.synchThemeLanguage();
}
},
methods: {
@ -193,7 +202,10 @@ export default {
let {action, data} = args;
this.$store.dispatch(action, data);
})
this.manifestUrl = $A.apiUrl("../manifest")
this.iframes.push({
key: 'manifest',
url: $A.apiUrl("../manifest")
})
},
eeuiEvents() {
@ -226,7 +238,17 @@ export default {
}
}
}
}
},
synchThemeLanguage() {
if (this.$Electron || this.$isEEUiApp) {
this.iframes = this.iframes.filter(({key}) => key != 'synchThemeLanguage')
this.iframes.push({
key: 'synchThemeLanguage',
url: $A.apiUrl(`../setting/theme_language?theme=${this.themeMode}&language=${this.languageType}`)
})
}
},
}
}
</script>

View File

@ -590,6 +590,18 @@
}
},
/**
* 获取文本长度
* @param string
* @returns {number}
*/
stringLength(string) {
if (typeof string === "number" || typeof string === "string") {
return (string + "").length
}
return 0;
},
/**
* 获取数组长度处理数组不存在
* @param array

View File

@ -245,7 +245,7 @@ export default {
}
state.themeMode = mode;
state.themeIsDark = $A.dark.isDarkEnabled();
$A.setStorage("cacheThemeMode", mode);
window.localStorage['__theme:mode__'] = mode;
},
/**
@ -493,7 +493,6 @@ export default {
return new Promise(function (resolve) {
try {
const cacheLoginEmail = $A.getStorageString("cacheLoginEmail");
const cacheThemeMode = $A.getStorageString("cacheThemeMode");
const cacheFileSort = $A.getStorageJson("cacheFileSort");
//
window.localStorage.clear();
@ -507,7 +506,6 @@ export default {
$A.setStorage("cacheProjectParameter", state.cacheProjectParameter);
$A.setStorage("cacheServerUrl", state.cacheServerUrl);
$A.setStorage("cacheLoginEmail", cacheLoginEmail);
$A.setStorage("cacheThemeMode", cacheThemeMode);
$A.setStorage("cacheFileSort", cacheFileSort);
$A.setStorage("cacheTaskBrowse", state.cacheTaskBrowse);
dispatch("saveUserInfo", $A.isJson(userInfo) ? userInfo : state.userInfo);

View File

@ -124,7 +124,7 @@ const stateData = {
],
// 主题皮肤
themeMode: $A.getStorageString("cacheThemeMode"),
themeMode: window.localStorage['__theme:mode__'],
themeList: [
{name: '跟随系统', value: 'auto'},
{name: '明亮', value: 'light'},

View File

@ -0,0 +1,8 @@
<script>
@if ($theme)
window.localStorage['__theme:mode__'] = "{{ $theme }}";
@endif
@if ($language)
window.localStorage['__language:type__'] = "{{ $language }}";
@endif
</script>