优化细节

This commit is contained in:
icssoa
2025-08-25 10:07:41 +08:00
parent cda540da64
commit 570f5e278c
4 changed files with 25 additions and 38 deletions

View File

@@ -1,6 +1,8 @@
import { watch } from "vue";
import { scroller } from "./scroller";
import { initTheme, setH5 } from "./theme";
import { initLocale } from "@/locale";
import { initLocale, locale, updateTitle } from "@/locale";
import "@/uni_modules/cool-ui";
export function cool(app: VueApp) {
app.mixin({
@@ -8,11 +10,20 @@ export function cool(app: VueApp) {
scroller.emit(e.scrollTop);
},
onShow() {
// 更新标题
updateTitle();
// #ifdef H5
setTimeout(() => {
setH5();
}, 0);
// #endif
},
onLoad() {
// 监听语言切换,更新标题
watch(locale, () => {
updateTitle();
});
}
});

View File

@@ -15,7 +15,7 @@
{
"path": "pages/index/template",
"style": {
"navigationBarTitleText": "%模板%"
"navigationBarTitleText": "模板"
}
}
],
@@ -26,19 +26,19 @@
{
"path": "index",
"style": {
"navigationBarTitleText": "%设置%"
"navigationBarTitleText": "设置"
}
},
{
"path": "general",
"style": {
"navigationBarTitleText": "%通用设置%"
"navigationBarTitleText": "通用设置"
}
},
{
"path": "notice",
"style": {
"navigationBarTitleText": "%通知设置%"
"navigationBarTitleText": "通知设置"
}
},
{
@@ -50,7 +50,7 @@
{
"path": "cs",
"style": {
"navigationBarTitleText": "%联系客服%"
"navigationBarTitleText": "联系客服"
}
}
]
@@ -61,7 +61,7 @@
{
"path": "edit",
"style": {
"navigationBarTitleText": "%编辑资料%"
"navigationBarTitleText": "编辑资料"
}
},
{
@@ -432,7 +432,7 @@
{
"path": "shop/goods-category",
"style": {
"navigationBarTitleText": "%商品分类%"
"navigationBarTitleText": "商品分类"
}
},
{
@@ -463,19 +463,19 @@
"pagePath": "pages/index/home",
"iconPath": "/static/icon/tabbar/home.png",
"selectedIconPath": "/static/icon/tabbar/home2.png",
"text": "%首页%"
"text": "首页"
},
{
"pagePath": "pages/index/template",
"iconPath": "/static/icon/tabbar/template.png",
"selectedIconPath": "/static/icon/tabbar/template2.png",
"text": "%模板%"
"text": "模板"
},
{
"pagePath": "pages/index/my",
"iconPath": "/static/icon/tabbar/my.png",
"selectedIconPath": "/static/icon/tabbar/my2.png",
"text": "%我的%"
"text": "我的"
}
]
},

View File

@@ -31,7 +31,7 @@
</demo-item>
<demo-item :label="t('弹窗中使用')">
<cl-button @tap="visible3 = true">打开</cl-button>
<cl-button @tap="visible3 = true">{{ t("打开") }}</cl-button>
<cl-popup v-model="visible3" direction="center" size="80%" :title="t('选择地区')">
<view class="p-3 pt-0">

View File

@@ -22,12 +22,11 @@
</template>
<script setup lang="ts">
import { computed, onMounted, ref, watch } from "vue";
import { ref } from "vue";
import Theme from "./theme.uvue";
import Ui from "./ui.uvue";
import { locale, t } from "@/locale";
import { config } from "@/config";
import { router, scroller } from "@/cool";
import { scroller } from "@/cool";
defineOptions({
name: "cl-page"
@@ -81,29 +80,6 @@ function scrollToTop() {
scrollTo(0 + Math.random() / 1000);
}
onMounted(() => {
// 标题多语言
// #ifdef H5 || APP
watch(
computed(() => locale.value),
() => {
const style = router.route()?.style;
if (style != null) {
if (style.navigationBarTitleText != null) {
uni.setNavigationBarTitle({
title: t((style.navigationBarTitleText as string).replaceAll("%", ""))
});
}
}
},
{
immediate: true
}
);
// #endif
});
defineExpose({
scrollTop,
scrollTo,