提交 22ff4d84 编写于 作者: Q qiang

feat(h5): useDocumentTitle

上级 650c3164
......@@ -117,7 +117,7 @@ const onError = /*#__PURE__*/ createHook(ON_ERROR);
const onThemeChange = /*#__PURE__*/ createHook(ON_THEME_CHANGE);
const onPageNotFound = /*#__PURE__*/ createHook(ON_PAGE_NOT_FOUND);
const onUnhandledRejection = /*#__PURE__*/ createHook(ON_UNHANDLE_REJECTION);
// export const onLoad = /*#__PURE__*/ createHook(ON_LOAD)
const onReady = /*#__PURE__*/ createHook(ON_READY);
const onUnload = /*#__PURE__*/ createHook(ON_UNLOAD);
const onResize = /*#__PURE__*/ createHook(ON_RESIZE);
......
......@@ -82,7 +82,7 @@ const onError = /*#__PURE__*/ createHook(ON_ERROR);
const onThemeChange = /*#__PURE__*/ createHook(ON_THEME_CHANGE);
const onPageNotFound = /*#__PURE__*/ createHook(ON_PAGE_NOT_FOUND);
const onUnhandledRejection = /*#__PURE__*/ createHook(ON_UNHANDLE_REJECTION);
// export const onLoad = /*#__PURE__*/ createHook(ON_LOAD)
const onReady = /*#__PURE__*/ createHook(ON_READY);
const onUnload = /*#__PURE__*/ createHook(ON_UNLOAD);
const onResize = /*#__PURE__*/ createHook(ON_RESIZE);
......
......@@ -10865,6 +10865,12 @@ function createRightWindowTsx(rightWindow, layoutState, windowState) {
}, windowState), null, 16)])], 12, ["data-show"]), [[vue.vShow, layoutState.showRightWindow || layoutState.apiShowRightWindow]]);
}
}
function useDocumentTitle(pageMeta) {
function update() {
document.title = pageMeta.navigationBar.titleText;
}
vue.watchEffect(update);
}
function hexToRgba(hex) {
let r;
let g2;
......@@ -11330,7 +11336,9 @@ function createPageRefreshTsx(refreshRef, pageMeta) {
var index$2 = defineSystemComponent({
name: "Page",
setup(_props, ctx) {
const {navigationBar} = providePageMeta(getStateId());
const pageMeta = providePageMeta(getStateId());
const navigationBar = pageMeta.navigationBar;
useDocumentTitle(pageMeta);
return () => vue.createVNode("uni-page", null, __UNI_FEATURE_NAVIGATIONBAR__ && navigationBar.style !== "custom" ? [vue.createVNode(PageHead), createPageBodyVNode(ctx)] : [createPageBodyVNode(ctx)]);
}
});
......
......@@ -19966,6 +19966,13 @@ const UniServiceJSBridge$1 = /* @__PURE__ */ extend(ServiceJSBridge, {
UniViewJSBridge.subscribeHandler(pageId + "." + event, args, pageId);
}
});
function useDocumentTitle(pageMeta) {
function update() {
document.title = pageMeta.navigationBar.titleText;
}
watchEffect(update);
onActivated(update);
}
function hexToRgba(hex) {
let r;
let g2;
......@@ -20679,7 +20686,9 @@ function createPageRefreshTsx(refreshRef, pageMeta) {
var index$2 = defineSystemComponent({
name: "Page",
setup(_props, ctx) {
const {navigationBar} = providePageMeta(getStateId());
const pageMeta = providePageMeta(getStateId());
const navigationBar = pageMeta.navigationBar;
useDocumentTitle(pageMeta);
return () => createVNode("uni-page", null, __UNI_FEATURE_NAVIGATIONBAR__ && navigationBar.style !== "custom" ? [createVNode(PageHead), createPageBodyVNode(ctx)] : [createPageBodyVNode(ctx)]);
}
});
......
......@@ -7,6 +7,7 @@ import {
SetupContext,
} from 'vue'
import { defineSystemComponent } from '@dcloudio/uni-components'
import { useDocumentTitle } from '../../../helpers/useDocumentTitle'
import PageHead from './pageHead'
import PageBody from './pageBody'
......@@ -16,7 +17,9 @@ import { getStateId } from '../../../helpers/dom'
export default defineSystemComponent({
name: 'Page',
setup(_props, ctx) {
const { navigationBar } = providePageMeta(getStateId())
const pageMeta = providePageMeta(getStateId())
const navigationBar = pageMeta.navigationBar
useDocumentTitle(pageMeta)
return () =>
createVNode(
'uni-page',
......
import { watchEffect, onActivated } from 'vue'
export function useDocumentTitle(pageMeta: UniApp.PageRouteMeta) {
function update() {
document.title = pageMeta.navigationBar.titleText!
}
watchEffect(update)
onActivated(update)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册