Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
aaaaa38a
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
725
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aaaaa38a
编写于
5月 27, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(ssr): support title
上级
22ff4d84
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
33 addition
and
13 deletion
+33
-13
packages/playground/ssr/src/pages.json
packages/playground/ssr/src/pages.json
+2
-2
packages/uni-app/dist/uni-app.cjs.js
packages/uni-app/dist/uni-app.cjs.js
+1
-1
packages/uni-app/dist/uni-app.es.js
packages/uni-app/dist/uni-app.es.js
+1
-1
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+4
-1
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+6
-2
packages/uni-h5/src/helpers/useDocumentTitle.ts
packages/uni-h5/src/helpers/useDocumentTitle.ts
+8
-3
packages/uni-shared/dist/uni-shared.cjs.js
packages/uni-shared/dist/uni-shared.cjs.js
+2
-0
packages/uni-shared/dist/uni-shared.d.ts
packages/uni-shared/dist/uni-shared.d.ts
+2
-0
packages/uni-shared/dist/uni-shared.es.js
packages/uni-shared/dist/uni-shared.es.js
+2
-1
packages/uni-shared/src/constants.ts
packages/uni-shared/src/constants.ts
+1
-0
packages/vite-plugin-uni/lib/ssr/entry-server.js
packages/vite-plugin-uni/lib/ssr/entry-server.js
+2
-1
packages/vite-plugin-uni/src/cli/server.ts
packages/vite-plugin-uni/src/cli/server.ts
+2
-1
未找到文件。
packages/playground/ssr/src/pages.json
浏览文件 @
aaaaa38a
...
...
@@ -3,7 +3,7 @@
{
"path"
:
"pages/index/index"
,
"style"
:
{
"navigationBarTitleText"
:
"
uni-app
"
"navigationBarTitleText"
:
"
ssr
"
}
}
],
...
...
@@ -13,4 +13,4 @@
"navigationBarBackgroundColor"
:
"#F8F8F8"
,
"backgroundColor"
:
"#F8F8F8"
}
}
}
packages/uni-app/dist/uni-app.cjs.js
浏览文件 @
aaaaa38a
...
...
@@ -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
);
...
...
packages/uni-app/dist/uni-app.es.js
浏览文件 @
aaaaa38a
...
...
@@ -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
);
...
...
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
aaaaa38a
...
...
@@ -10866,8 +10866,11 @@ function createRightWindowTsx(rightWindow, layoutState, windowState) {
}
}
function
useDocumentTitle
(
pageMeta
)
{
const
ctx
=
vue
.
useSSRContext
();
function
update
()
{
document
.
title
=
pageMeta
.
navigationBar
.
titleText
;
{
ctx
[
uniShared
.
UNI_SSR_TITLE
]
=
pageMeta
.
navigationBar
.
titleText
;
}
}
vue
.
watchEffect
(
update
);
}
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
aaaaa38a
import {isFunction, extend, hyphenate, isPlainObject, isString, isArray, hasOwn, isObject, capitalize, toRawType, makeMap as makeMap$1, isPromise, invokeArrayFns as invokeArrayFns$1} from "@vue/shared";
import {injectHook, withModifiers, createVNode, getCurrentInstance, inject, provide, reactive, openBlock, createBlock, mergeProps, toDisplayString, defineComponent, ref, computed, watch, onUnmounted, onBeforeUnmount, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, Teleport, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent, resolveComponent, createCommentVNode, renderSlot} from "vue";
import {injectHook, withModifiers, createVNode, getCurrentInstance, inject, provide, reactive, openBlock, createBlock, mergeProps, toDisplayString, defineComponent, ref, computed, watch, onUnmounted, onBeforeUnmount, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, Teleport, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent, resolveComponent, createCommentVNode, renderSlot
, useSSRContext
} from "vue";
import {once, passive, normalizeTarget, isBuiltInComponent, initCustomDataset, invokeArrayFns, NAVBAR_HEIGHT, parseQuery, PRIMARY_COLOR, debounce, getCustomDataset, callOptions, removeLeadingSlash, getLen, ON_REACH_BOTTOM_DISTANCE, decodedQuery, updateElementStyle, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime} from "@dcloudio/uni-shared";
import {initVueI18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT} from "@dcloudio/uni-i18n";
import {useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView} from "vue-router";
...
...
@@ -15766,6 +15766,7 @@ function useKeyboard() {
if (res) {
key.value = res;
}
nextTick(() => key.value = "");
};
onMounted(() => {
document.addEventListener("keyup", onKeyup);
...
...
@@ -19967,8 +19968,11 @@ const UniServiceJSBridge$1 = /* @__PURE__ */ extend(ServiceJSBridge, {
}
});
function useDocumentTitle(pageMeta) {
useSSRContext();
function update() {
document.title = pageMeta.navigationBar.titleText;
{
document.title = pageMeta.navigationBar.titleText;
}
}
watchEffect(update);
onActivated(update);
...
...
packages/uni-h5/src/helpers/useDocumentTitle.ts
浏览文件 @
aaaaa38a
import
{
watchEffect
,
onActivated
}
from
'
vue
'
import
{
watchEffect
,
onActivated
,
useSSRContext
}
from
'
vue
'
import
{
UNI_SSR_TITLE
}
from
'
@dcloudio/uni-shared
'
export
function
useDocumentTitle
(
pageMeta
:
UniApp
.
PageRouteMeta
)
{
const
ctx
=
useSSRContext
()
function
update
()
{
document
.
title
=
pageMeta
.
navigationBar
.
titleText
!
if
(
__NODE_JS__
)
{
ctx
!
[
UNI_SSR_TITLE
]
=
pageMeta
.
navigationBar
.
titleText
}
else
{
document
.
title
=
pageMeta
.
navigationBar
.
titleText
!
}
}
watchEffect
(
update
)
onActivated
(
update
)
...
...
packages/uni-shared/dist/uni-shared.cjs.js
浏览文件 @
aaaaa38a
...
...
@@ -382,6 +382,7 @@ const RESPONSIVE_MIN_WIDTH = 768;
const
COMPONENT_NAME_PREFIX
=
'
VUni
'
;
const
PRIMARY_COLOR
=
'
#007aff
'
;
const
UNI_SSR
=
'
__uniSSR
'
;
const
UNI_SSR_TITLE
=
'
title
'
;
const
UNI_SSR_STORE
=
'
store
'
;
const
UNI_SSR_DATA
=
'
data
'
;
const
UNI_SSR_GLOBAL_DATA
=
'
globalData
'
;
...
...
@@ -407,6 +408,7 @@ exports.UNI_SSR = UNI_SSR;
exports
.
UNI_SSR_DATA
=
UNI_SSR_DATA
;
exports
.
UNI_SSR_GLOBAL_DATA
=
UNI_SSR_GLOBAL_DATA
;
exports
.
UNI_SSR_STORE
=
UNI_SSR_STORE
;
exports
.
UNI_SSR_TITLE
=
UNI_SSR_TITLE
;
exports
.
addFont
=
addFont
;
exports
.
callOptions
=
callOptions
;
exports
.
createRpx2Unit
=
createRpx2Unit
;
...
...
packages/uni-shared/dist/uni-shared.d.ts
浏览文件 @
aaaaa38a
...
...
@@ -131,6 +131,8 @@ export declare const UNI_SSR_GLOBAL_DATA = "globalData";
export
declare
const
UNI_SSR_STORE
=
"
store
"
;
export
declare
const
UNI_SSR_TITLE
=
"
title
"
;
export
declare
function
updateElementStyle
(
element
:
HTMLElement
,
styles
:
Partial
<
CSSStyleDeclaration
>
):
void
;
export
{
}
packages/uni-shared/dist/uni-shared.es.js
浏览文件 @
aaaaa38a
...
...
@@ -378,6 +378,7 @@ const RESPONSIVE_MIN_WIDTH = 768;
const
COMPONENT_NAME_PREFIX
=
'
VUni
'
;
const
PRIMARY_COLOR
=
'
#007aff
'
;
const
UNI_SSR
=
'
__uniSSR
'
;
const
UNI_SSR_TITLE
=
'
title
'
;
const
UNI_SSR_STORE
=
'
store
'
;
const
UNI_SSR_DATA
=
'
data
'
;
const
UNI_SSR_GLOBAL_DATA
=
'
globalData
'
;
...
...
@@ -388,4 +389,4 @@ function getEnvLocale() {
return
(
lang
&&
lang
.
replace
(
/
[
.:
]
.*/
,
''
))
||
'
en
'
;
}
export
{
BUILT_IN_TAGS
,
COMPONENT_NAME_PREFIX
,
COMPONENT_PREFIX
,
COMPONENT_SELECTOR_PREFIX
,
NAVBAR_HEIGHT
,
ON_REACH_BOTTOM_DISTANCE
,
PLUS_RE
,
PRIMARY_COLOR
,
RESPONSIVE_MIN_WIDTH
,
TABBAR_HEIGHT
,
TAGS
,
UNI_SSR
,
UNI_SSR_DATA
,
UNI_SSR_GLOBAL_DATA
,
UNI_SSR_STORE
,
addFont
,
callOptions
,
createRpx2Unit
,
debounce
,
decode
,
decodedQuery
,
defaultRpx2Unit
,
formatDateTime
,
getCustomDataset
,
getEnvLocale
,
getLen
,
initCustomDataset
,
invokeArrayFns
,
isBuiltInComponent
,
isCustomElement
,
isNativeTag
,
normalizeDataset
,
normalizeTarget
,
once
,
parseQuery
,
passive
,
plusReady
,
removeLeadingSlash
,
sanitise
,
scrollTo
,
stringifyQuery
,
updateElementStyle
};
export
{
BUILT_IN_TAGS
,
COMPONENT_NAME_PREFIX
,
COMPONENT_PREFIX
,
COMPONENT_SELECTOR_PREFIX
,
NAVBAR_HEIGHT
,
ON_REACH_BOTTOM_DISTANCE
,
PLUS_RE
,
PRIMARY_COLOR
,
RESPONSIVE_MIN_WIDTH
,
TABBAR_HEIGHT
,
TAGS
,
UNI_SSR
,
UNI_SSR_DATA
,
UNI_SSR_GLOBAL_DATA
,
UNI_SSR_STORE
,
UNI_SSR_TITLE
,
addFont
,
callOptions
,
createRpx2Unit
,
debounce
,
decode
,
decodedQuery
,
defaultRpx2Unit
,
formatDateTime
,
getCustomDataset
,
getEnvLocale
,
getLen
,
initCustomDataset
,
invokeArrayFns
,
isBuiltInComponent
,
isCustomElement
,
isNativeTag
,
normalizeDataset
,
normalizeTarget
,
once
,
parseQuery
,
passive
,
plusReady
,
removeLeadingSlash
,
sanitise
,
scrollTo
,
stringifyQuery
,
updateElementStyle
};
packages/uni-shared/src/constants.ts
浏览文件 @
aaaaa38a
...
...
@@ -8,6 +8,7 @@ export const COMPONENT_NAME_PREFIX = 'VUni'
export
const
PRIMARY_COLOR
=
'
#007aff
'
export
const
UNI_SSR
=
'
__uniSSR
'
export
const
UNI_SSR_TITLE
=
'
title
'
export
const
UNI_SSR_STORE
=
'
store
'
export
const
UNI_SSR_DATA
=
'
data
'
export
const
UNI_SSR_GLOBAL_DATA
=
'
globalData
'
packages/vite-plugin-uni/lib/ssr/entry-server.js
浏览文件 @
aaaaa38a
...
...
@@ -4,6 +4,7 @@ import {
UNI_SSR
,
UNI_SSR_DATA
,
UNI_SSR_STORE
,
UNI_SSR_TITLE
,
UNI_SSR_GLOBAL_DATA
,
}
from
'
@dcloudio/uni-shared
'
import
{
plugin
}
from
'
@dcloudio/uni-h5
'
...
...
@@ -39,7 +40,7 @@ export async function render(url, manifest = {}) {
__uniSSR
[
UNI_SSR_STORE
]
=
store
.
state
}
const
appContext
=
renderAppContext
(
ctx
)
return
[
html
,
preloadLinks
,
appContext
]
return
[
html
,
preloadLinks
,
appContext
,
ctx
[
UNI_SSR_TITLE
]
||
''
]
}
function
renderPreloadLinks
(
modules
,
manifest
)
{
...
...
packages/vite-plugin-uni/src/cli/server.ts
浏览文件 @
aaaaa38a
...
...
@@ -63,9 +63,10 @@ export async function createSSRServer(options: CliOptions & ServerOptions) {
)
).
render
const
[
appHtml
,
preloadLinks
,
appContext
]
=
await
render
(
url
)
const
[
appHtml
,
preloadLinks
,
appContext
,
title
]
=
await
render
(
url
)
const
html
=
template
.
replace
(
/<title>
(
.*
?)
<
\/
title>/
,
`<title>
${
title
}
</title>`
)
.
replace
(
`<!--preload-links-->`
,
preloadLinks
)
.
replace
(
`<!--app-html-->`
,
appHtml
)
.
replace
(
`<!--app-context-->`
,
appContext
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录