优化细节
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
|
import { watch } from "vue";
|
||||||
import { scroller } from "./scroller";
|
import { scroller } from "./scroller";
|
||||||
import { initTheme, setH5 } from "./theme";
|
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) {
|
export function cool(app: VueApp) {
|
||||||
app.mixin({
|
app.mixin({
|
||||||
@@ -8,11 +10,20 @@ export function cool(app: VueApp) {
|
|||||||
scroller.emit(e.scrollTop);
|
scroller.emit(e.scrollTop);
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
|
// 更新标题
|
||||||
|
updateTitle();
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setH5();
|
setH5();
|
||||||
}, 0);
|
}, 0);
|
||||||
// #endif
|
// #endif
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
// 监听语言切换,更新标题
|
||||||
|
watch(locale, () => {
|
||||||
|
updateTitle();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
20
pages.json
20
pages.json
@@ -15,7 +15,7 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/index/template",
|
"path": "pages/index/template",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "%模板%"
|
"navigationBarTitleText": "模板"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -26,19 +26,19 @@
|
|||||||
{
|
{
|
||||||
"path": "index",
|
"path": "index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "%设置%"
|
"navigationBarTitleText": "设置"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "general",
|
"path": "general",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "%通用设置%"
|
"navigationBarTitleText": "通用设置"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "notice",
|
"path": "notice",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "%通知设置%"
|
"navigationBarTitleText": "通知设置"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
{
|
{
|
||||||
"path": "cs",
|
"path": "cs",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "%联系客服%"
|
"navigationBarTitleText": "联系客服"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
{
|
{
|
||||||
"path": "edit",
|
"path": "edit",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "%编辑资料%"
|
"navigationBarTitleText": "编辑资料"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -432,7 +432,7 @@
|
|||||||
{
|
{
|
||||||
"path": "shop/goods-category",
|
"path": "shop/goods-category",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "%商品分类%"
|
"navigationBarTitleText": "商品分类"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -463,19 +463,19 @@
|
|||||||
"pagePath": "pages/index/home",
|
"pagePath": "pages/index/home",
|
||||||
"iconPath": "/static/icon/tabbar/home.png",
|
"iconPath": "/static/icon/tabbar/home.png",
|
||||||
"selectedIconPath": "/static/icon/tabbar/home2.png",
|
"selectedIconPath": "/static/icon/tabbar/home2.png",
|
||||||
"text": "%首页%"
|
"text": "首页"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pagePath": "pages/index/template",
|
"pagePath": "pages/index/template",
|
||||||
"iconPath": "/static/icon/tabbar/template.png",
|
"iconPath": "/static/icon/tabbar/template.png",
|
||||||
"selectedIconPath": "/static/icon/tabbar/template2.png",
|
"selectedIconPath": "/static/icon/tabbar/template2.png",
|
||||||
"text": "%模板%"
|
"text": "模板"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pagePath": "pages/index/my",
|
"pagePath": "pages/index/my",
|
||||||
"iconPath": "/static/icon/tabbar/my.png",
|
"iconPath": "/static/icon/tabbar/my.png",
|
||||||
"selectedIconPath": "/static/icon/tabbar/my2.png",
|
"selectedIconPath": "/static/icon/tabbar/my2.png",
|
||||||
"text": "%我的%"
|
"text": "我的"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
</demo-item>
|
</demo-item>
|
||||||
|
|
||||||
<demo-item :label="t('弹窗中使用')">
|
<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('选择地区')">
|
<cl-popup v-model="visible3" direction="center" size="80%" :title="t('选择地区')">
|
||||||
<view class="p-3 pt-0">
|
<view class="p-3 pt-0">
|
||||||
|
|||||||
@@ -22,12 +22,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref, watch } from "vue";
|
import { ref } from "vue";
|
||||||
import Theme from "./theme.uvue";
|
import Theme from "./theme.uvue";
|
||||||
import Ui from "./ui.uvue";
|
import Ui from "./ui.uvue";
|
||||||
import { locale, t } from "@/locale";
|
|
||||||
import { config } from "@/config";
|
import { config } from "@/config";
|
||||||
import { router, scroller } from "@/cool";
|
import { scroller } from "@/cool";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "cl-page"
|
name: "cl-page"
|
||||||
@@ -81,29 +80,6 @@ function scrollToTop() {
|
|||||||
scrollTo(0 + Math.random() / 1000);
|
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({
|
defineExpose({
|
||||||
scrollTop,
|
scrollTop,
|
||||||
scrollTo,
|
scrollTo,
|
||||||
|
|||||||
Reference in New Issue
Block a user