Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
9601bc88
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
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,发现更多精彩内容 >>
提交
9601bc88
编写于
2月 23, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(app): preloadPage
上级
0ec058ee
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
25 deletion
+37
-25
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+16
-10
packages/uni-app-plus/src/service/framework/page/preLoad.ts
packages/uni-app-plus/src/service/framework/page/preLoad.ts
+2
-3
packages/uni-app-plus/src/service/framework/page/register.ts
packages/uni-app-plus/src/service/framework/page/register.ts
+12
-8
packages/uni-app-plus/src/service/framework/page/routeOptions.ts
...s/uni-app-plus/src/service/framework/page/routeOptions.ts
+1
-0
packages/uni-app-vite/src/plugin/uni/index.ts
packages/uni-app-vite/src/plugin/uni/index.ts
+6
-4
未找到文件。
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
9601bc88
...
@@ -18154,7 +18154,8 @@ function initRouteOptions(path, openType) {
...
@@ -18154,7 +18154,8 @@ function initRouteOptions(path, openType) {
// 需要序列化一遍
// 需要序列化一遍
const routeOptions = JSON.parse(JSON.stringify(getRouteOptions(path)));
const routeOptions = JSON.parse(JSON.stringify(getRouteOptions(path)));
routeOptions.meta = initRouteMeta(routeOptions.meta);
routeOptions.meta = initRouteMeta(routeOptions.meta);
if (!__uniConfig.realEntryPagePath &&
if (openType !== 'preloadPage' &&
!__uniConfig.realEntryPagePath &&
(openType === 'reLaunch' || getCurrentPages().length === 0) // redirectTo
(openType === 'reLaunch' || getCurrentPages().length === 0) // redirectTo
) {
) {
routeOptions.meta.isQuit = true;
routeOptions.meta.isQuit = true;
...
@@ -18202,7 +18203,7 @@ function closePreloadWebview({ url }) {
...
@@ -18202,7 +18203,7 @@ function closePreloadWebview({ url }) {
}
}
function preloadWebview({ url, path, query, }) {
function preloadWebview({ url, path, query, }) {
if (!preloadWebviews[url]) {
if (!preloadWebviews[url]) {
const routeOptions =
JSON.parse(JSON.stringify(__uniRoutes.find((route) => route.path === path))
);
const routeOptions =
initRouteOptions(path, 'preloadPage'
);
preloadWebviews[url] = createWebview({
preloadWebviews[url] = createWebview({
path,
path,
routeOptions,
routeOptions,
...
@@ -18329,22 +18330,27 @@ function createNVuePage(pageId, webview, pageInstance) {
...
@@ -18329,22 +18330,27 @@ function createNVuePage(pageId, webview, pageInstance) {
return pageInstance.eventChannel;
return pageInstance.eventChannel;
},
},
__setup(vm, curFakeNVueVm) {
__setup(vm, curFakeNVueVm) {
vm.$getAppWebview = () => webview;
vm.getOpenerEventChannel = curFakeNVueVm.getOpenerEventChannel;
// 替换真实的 nvue 的 vm
initPageVm(vm, pageInstance);
if (webview.__preload__) {
webview.__page__ = vm;
}
const pages = getAllPages();
const pages = getAllPages();
const index = pages.findIndex((p) => p === curFakeNVueVm);
const index = pages.findIndex((p) => p === curFakeNVueVm);
if (index > -1) {
if (index > -1) {
vm.$getAppWebview = () => webview;
vm.getOpenerEventChannel = curFakeNVueVm.getOpenerEventChannel;
// 替换真实的 nvue 的 vm
initPageVm(vm, pageInstance);
pages.splice(index, 1, vm);
pages.splice(index, 1, vm);
if (webview.__preload__) {
webview.__page__ = vm;
}
}
}
},
},
};
};
initPageVm(fakeNVueVm, pageInstance);
initPageVm(fakeNVueVm, pageInstance);
addCurrentPage(fakeNVueVm);
if (webview.__preload__) {
webview.__page__ = fakeNVueVm;
}
else {
addCurrentPage(fakeNVueVm);
}
}
}
const $navigateTo = (args, { resolve, reject }) => {
const $navigateTo = (args, { resolve, reject }) => {
...
...
packages/uni-app-plus/src/service/framework/page/preLoad.ts
浏览文件 @
9601bc88
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
createWebview
}
from
'
../webview
'
import
{
createWebview
}
from
'
../webview
'
import
{
initRouteOptions
}
from
'
./routeOptions
'
export
interface
PreloadWebviewObject
extends
PlusWebviewWebviewObject
{
export
interface
PreloadWebviewObject
extends
PlusWebviewWebviewObject
{
__preload__
?:
boolean
__preload__
?:
boolean
...
@@ -51,9 +52,7 @@ export function preloadWebview({
...
@@ -51,9 +52,7 @@ export function preloadWebview({
query
:
Record
<
string
,
string
>
query
:
Record
<
string
,
string
>
})
{
})
{
if
(
!
preloadWebviews
[
url
])
{
if
(
!
preloadWebviews
[
url
])
{
const
routeOptions
:
UniApp
.
UniRoute
=
JSON
.
parse
(
const
routeOptions
:
UniApp
.
UniRoute
=
initRouteOptions
(
path
,
'
preloadPage
'
)
JSON
.
stringify
(
__uniRoutes
.
find
((
route
)
=>
route
.
path
===
path
))
)
preloadWebviews
[
url
]
=
createWebview
({
preloadWebviews
[
url
]
=
createWebview
({
path
,
path
,
routeOptions
,
routeOptions
,
...
...
packages/uni-app-plus/src/service/framework/page/register.ts
浏览文件 @
9601bc88
...
@@ -188,20 +188,24 @@ function createNVuePage(
...
@@ -188,20 +188,24 @@ function createNVuePage(
return
pageInstance
.
eventChannel
as
EventChannel
return
pageInstance
.
eventChannel
as
EventChannel
},
},
__setup
(
vm
:
ComponentPublicInstance
,
curFakeNVueVm
:
unknown
)
{
__setup
(
vm
:
ComponentPublicInstance
,
curFakeNVueVm
:
unknown
)
{
vm
.
$getAppWebview
=
()
=>
webview
vm
.
getOpenerEventChannel
=
(
curFakeNVueVm
as
any
).
getOpenerEventChannel
// 替换真实的 nvue 的 vm
initPageVm
(
vm
,
pageInstance
)
if
((
webview
as
PreloadWebviewObject
).
__preload__
)
{
;(
webview
as
PreloadWebviewObject
).
__page__
=
vm
}
const
pages
=
getAllPages
()
const
pages
=
getAllPages
()
const
index
=
pages
.
findIndex
((
p
)
=>
p
===
curFakeNVueVm
)
const
index
=
pages
.
findIndex
((
p
)
=>
p
===
curFakeNVueVm
)
if
(
index
>
-
1
)
{
if
(
index
>
-
1
)
{
vm
.
$getAppWebview
=
()
=>
webview
vm
.
getOpenerEventChannel
=
(
curFakeNVueVm
as
any
).
getOpenerEventChannel
// 替换真实的 nvue 的 vm
initPageVm
(
vm
,
pageInstance
)
pages
.
splice
(
index
,
1
,
vm
)
pages
.
splice
(
index
,
1
,
vm
)
if
((
webview
as
PreloadWebviewObject
).
__preload__
)
{
;(
webview
as
PreloadWebviewObject
).
__page__
=
vm
}
}
}
},
},
}
as
unknown
as
ComponentPublicInstance
}
as
unknown
as
ComponentPublicInstance
initPageVm
(
fakeNVueVm
,
pageInstance
)
initPageVm
(
fakeNVueVm
,
pageInstance
)
addCurrentPage
(
fakeNVueVm
)
if
((
webview
as
PreloadWebviewObject
).
__preload__
)
{
;(
webview
as
PreloadWebviewObject
).
__page__
=
fakeNVueVm
}
else
{
addCurrentPage
(
fakeNVueVm
)
}
}
}
packages/uni-app-plus/src/service/framework/page/routeOptions.ts
浏览文件 @
9601bc88
...
@@ -9,6 +9,7 @@ export function initRouteOptions(path: string, openType: UniApp.OpenType) {
...
@@ -9,6 +9,7 @@ export function initRouteOptions(path: string, openType: UniApp.OpenType) {
routeOptions
.
meta
=
initRouteMeta
(
routeOptions
.
meta
)
routeOptions
.
meta
=
initRouteMeta
(
routeOptions
.
meta
)
if
(
if
(
openType
!==
'
preloadPage
'
&&
!
__uniConfig
.
realEntryPagePath
&&
!
__uniConfig
.
realEntryPagePath
&&
(
openType
===
'
reLaunch
'
||
getCurrentPages
().
length
===
0
)
// redirectTo
(
openType
===
'
reLaunch
'
||
getCurrentPages
().
length
===
0
)
// redirectTo
)
{
)
{
...
...
packages/uni-app-vite/src/plugin/uni/index.ts
浏览文件 @
9601bc88
import
fs
from
'
fs
'
import
fs
from
'
fs
-extra
'
import
path
from
'
path
'
import
path
from
'
path
'
import
{
isAppNativeTag
,
isAppNVueNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
isAppNativeTag
,
isAppNVueNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
compileI18nJsonStr
}
from
'
@dcloudio/uni-i18n
'
import
{
compileI18nJsonStr
}
from
'
@dcloudio/uni-i18n
'
...
@@ -36,9 +36,11 @@ export function uniOptions(): UniVitePlugin['uni'] {
...
@@ -36,9 +36,11 @@ export function uniOptions(): UniVitePlugin['uni'] {
},
},
})
})
const
debugFilename
=
'
__nvue_debug__
'
const
debugFilename
=
'
__nvue_debug__
'
const
debugFilepath
=
path
.
resolve
(
inputDir
,
debugFilename
)
if
(
fs
.
existsSync
(
path
.
resolve
(
inputDir
,
debugFilename
)))
{
if
(
fs
.
existsSync
(
debugFilepath
))
{
targets
.
push
({
fs
.
copyFileSync
(
debugFilepath
,
path
.
resolve
(
outputDir
,
debugFilename
))
src
:
debugFilename
,
dest
:
outputDir
,
})
}
}
}
}
return
{
return
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录