Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
e586001f
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e586001f
编写于
5月 08, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(ssr): vuex
上级
626051bf
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
13 addition
and
2 deletion
+13
-2
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/render.js
packages/vite-plugin-uni/lib/ssr/render.js
+5
-0
packages/vite-plugin-uni/src/configResolved/plugins/mainJs.ts
...ages/vite-plugin-uni/src/configResolved/plugins/mainJs.ts
+1
-1
未找到文件。
packages/uni-shared/dist/uni-shared.cjs.js
浏览文件 @
e586001f
...
...
@@ -298,6 +298,7 @@ const RESPONSIVE_MIN_WIDTH = 768;
const
COMPONENT_NAME_PREFIX
=
'
VUni
'
;
const
PRIMARY_COLOR
=
'
#007aff
'
;
const
UNI_SSR
=
'
__uniSSR
'
;
const
UNI_SSR_STORE
=
'
store
'
;
const
UNI_SSR_DATA
=
'
data
'
;
const
UNI_SSR_GLOBAL_DATA
=
'
globalData
'
;
...
...
@@ -321,6 +322,7 @@ exports.TAGS = TAGS;
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
.
addFont
=
addFont
;
exports
.
debounce
=
debounce
;
exports
.
decode
=
decode
;
...
...
packages/uni-shared/dist/uni-shared.d.ts
浏览文件 @
e586001f
...
...
@@ -93,6 +93,8 @@ export declare const UNI_SSR_DATA = "data";
export
declare
const
UNI_SSR_GLOBAL_DATA
=
"
globalData
"
;
export
declare
const
UNI_SSR_STORE
=
"
store
"
;
export
declare
function
updateElementStyle
(
element
:
HTMLElement
,
styles
:
Partial
<
CSSStyleDeclaration
>
):
void
;
export
{
}
packages/uni-shared/dist/uni-shared.es.js
浏览文件 @
e586001f
...
...
@@ -294,6 +294,7 @@ const RESPONSIVE_MIN_WIDTH = 768;
const
COMPONENT_NAME_PREFIX
=
'
VUni
'
;
const
PRIMARY_COLOR
=
'
#007aff
'
;
const
UNI_SSR
=
'
__uniSSR
'
;
const
UNI_SSR_STORE
=
'
store
'
;
const
UNI_SSR_DATA
=
'
data
'
;
const
UNI_SSR_GLOBAL_DATA
=
'
globalData
'
;
...
...
@@ -303,4 +304,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
,
addFont
,
debounce
,
decode
,
decodedQuery
,
getEnvLocale
,
getLen
,
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
,
addFont
,
debounce
,
decode
,
decodedQuery
,
getEnvLocale
,
getLen
,
invokeArrayFns
,
isBuiltInComponent
,
isCustomElement
,
isNativeTag
,
normalizeDataset
,
normalizeTarget
,
once
,
parseQuery
,
passive
,
plusReady
,
removeLeadingSlash
,
sanitise
,
scrollTo
,
stringifyQuery
,
updateElementStyle
};
packages/uni-shared/src/constants.ts
浏览文件 @
e586001f
...
...
@@ -8,5 +8,6 @@ export const COMPONENT_NAME_PREFIX = 'VUni'
export
const
PRIMARY_COLOR
=
'
#007aff
'
export
const
UNI_SSR
=
'
__uniSSR
'
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/render.js
浏览文件 @
e586001f
...
...
@@ -3,6 +3,7 @@ import { renderToString } from '@vue/server-renderer'
import
{
UNI_SSR
,
UNI_SSR_DATA
,
UNI_SSR_STORE
,
UNI_SSR_GLOBAL_DATA
,
}
from
'
@dcloudio/uni-shared
'
...
...
@@ -11,6 +12,7 @@ import { getSsrGlobalData } from '@dcloudio/uni-app'
export
async
function
render
(
url
,
manifest
=
{})
{
const
app
=
createVueSSRAppInstance
()
const
router
=
app
.
router
const
store
=
app
.
config
.
globalProperties
.
$store
// set the router to the desired URL before rendering
await
router
.
push
(
url
)
...
...
@@ -33,6 +35,9 @@ export async function render(url, manifest = {}) {
__uniSSR
[
UNI_SSR_DATA
]
=
{}
}
__uniSSR
[
UNI_SSR_GLOBAL_DATA
]
=
getSsrGlobalData
()
if
(
store
)
{
__uniSSR
[
UNI_SSR_STORE
]
=
store
.
state
}
const
appContext
=
renderAppContext
(
ctx
)
return
[
html
,
preloadLinks
,
appContext
]
}
...
...
packages/vite-plugin-uni/src/configResolved/plugins/mainJs.ts
浏览文件 @
e586001f
...
...
@@ -39,7 +39,7 @@ function createApp(code: string) {
}
function
createSSRClientApp
(
code
:
string
)
{
return
`
function createApp(rootComponent, rootProps) {const app = createSSRApp(rootComponent, rootProps).use(plugin);const oldMount = app.mount;app.mount = (selector) => app.router.isReady().then(() => oldMount.call(app, selector))
;return app;};
${
code
.
replace
(
return
`
import { UNI_SSR, UNI_SSR_STORE } from '@dcloudio/uni-shared';function createApp(rootComponent, rootProps) {const app = createSSRApp(rootComponent, rootProps).use(plugin);const oldMount = app.mount;app.mount = (selector) => {window[UNI_SSR] && window[UNI_SSR][UNI_SSR_STORE] && app.config.globalProperties.$store.replaceState(window[UNI_SSR][UNI_SSR_STORE]);app.router.isReady().then(() => oldMount.call(app, selector));}
;return app;};
${
code
.
replace
(
'
createApp
'
,
'
createSSRApp
'
)}
`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录