Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈庄旺
uni-app
提交
77951dd9
U
uni-app
项目概览
陈庄旺
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
77951dd9
编写于
2月 15, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(app): nvue
上级
ac3a53cf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
69 addition
and
41 deletion
+69
-41
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+29
-15
packages/uni-app-plus/src/service/framework/app/index.ts
packages/uni-app-plus/src/service/framework/app/index.ts
+11
-0
packages/uni-app-plus/src/service/framework/page/register.ts
packages/uni-app-plus/src/service/framework/page/register.ts
+25
-22
packages/uni-app-vite/src/nvue/plugins/esbuild.ts
packages/uni-app-vite/src/nvue/plugins/esbuild.ts
+3
-3
packages/uni-app-vite/src/nvue/plugins/mainJs.ts
packages/uni-app-vite/src/nvue/plugins/mainJs.ts
+1
-1
未找到文件。
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
77951dd9
...
...
@@ -18148,7 +18148,7 @@ function preloadWebview({ url, path, query, }) {
return preloadWebviews[url];
}
function registerPage({ url, path, query, openType, webview, eventChannel, }) {
function registerPage({ url, path, query, openType, webview,
nvuePageVm,
eventChannel, }) {
// fast 模式,nvue 首页时,会在nvue中主动调用registerPage并传入首页webview,此时初始化一下首页(因为此时可能还未调用registerApp)
if (webview) {
initEntry();
...
...
@@ -18196,12 +18196,17 @@ function registerPage({ url, path, query, openType, webview, eventChannel, }) {
const route = path.substr(1);
webview.__uniapp_route = route;
const pageInstance = initPageInternalInstance(openType, url, query, routeOptions.meta, eventChannel);
initNVueEntryPage(webview
);
const id = parseInt(webview.id
);
if (webview.nvue) {
createNVuePage(parseInt(webview.id), webview, pageInstance);
if (id === 1 && nvuePageVm) {
initNVueEntryPage(webview, nvuePageVm, pageInstance);
}
else {
createNVuePage(id, webview, pageInstance);
}
}
else {
createVuePage(
parseInt(webview.id)
, route, query, pageInstance, initPageOptions(routeOptions));
createVuePage(
id
, route, query, pageInstance, initPageOptions(routeOptions));
}
return webview;
}
...
...
@@ -18227,19 +18232,18 @@ function initPageOptions({ meta }) {
windowBottom: tabBarInstance.indexOf(meta.route) >= 0 && tabBarInstance.cover ? tabBarInstance.height : 0,
};
}
function initNVueEntryPage(webview) {
const isLaunchNVuePage = webview.id === '1' && webview.nvue;
function initNVueEntryPage(webview, nvuePageVm, pageInstance) {
initPageVm(nvuePageVm, pageInstance);
addCurrentPage(nvuePageVm);
// 首页是 nvue 时,在 registerPage 时,执行路由堆栈
if (isLaunchNVuePage) {
if (__uniConfig.splashscreen &&
__uniConfig.splashscreen.autoclose &&
!__uniConfig.splashscreen.alwaysShowBeforeRender) {
plus.navigator.closeSplashscreen();
}
__uniConfig.onReady(function () {
navigateFinish();
});
if (__uniConfig.splashscreen &&
__uniConfig.splashscreen.autoclose &&
!__uniConfig.splashscreen.alwaysShowBeforeRender) {
plus.navigator.closeSplashscreen();
}
__uniConfig.onReady(function () {
navigateFinish();
});
}
function createNVuePage(pageId, webview, pageInstance) {
const fakeNVueVm = {
...
...
@@ -19140,6 +19144,16 @@ function registerApp(appVm) {
if ((process.env.NODE_ENV !== 'production')) {
console.log(formatLog('registerApp'));
}
// 定制 useStore (主要是为了 nvue 共享)
if (uni.Vuex && appVm.$store) {
const { useStore } = uni.Vuex;
uni.Vuex.useStore = (key) => {
if (!key) {
return appVm.$store;
}
return useStore(key);
};
}
initVueApp(appVm);
appCtx = appVm;
initAppVm(appCtx);
...
...
packages/uni-app-plus/src/service/framework/app/index.ts
浏览文件 @
77951dd9
...
...
@@ -35,6 +35,17 @@ export function registerApp(appVm: ComponentPublicInstance) {
console
.
log
(
formatLog
(
'
registerApp
'
))
}
// 定制 useStore (主要是为了 nvue 共享)
if
((
uni
as
any
).
Vuex
&&
(
appVm
as
any
).
$store
)
{
const
{
useStore
}
=
(
uni
as
any
).
Vuex
;(
uni
as
any
).
Vuex
.
useStore
=
(
key
:
string
)
=>
{
if
(
!
key
)
{
return
(
appVm
as
any
).
$store
}
return
useStore
(
key
)
}
}
initVueApp
(
appVm
)
appCtx
=
appVm
...
...
packages/uni-app-plus/src/service/framework/page/register.ts
浏览文件 @
77951dd9
...
...
@@ -26,6 +26,7 @@ interface RegisterPageOptions {
query
:
Record
<
string
,
string
>
openType
:
UniApp
.
OpenType
webview
?:
PlusWebviewWebviewObject
nvuePageVm
?:
ComponentPublicInstance
eventChannel
?:
EventChannel
}
...
...
@@ -35,6 +36,7 @@ export function registerPage({
query
,
openType
,
webview
,
nvuePageVm
,
eventChannel
,
}:
RegisterPageOptions
)
{
// fast 模式,nvue 首页时,会在nvue中主动调用registerPage并传入首页webview,此时初始化一下首页(因为此时可能还未调用registerApp)
...
...
@@ -105,18 +107,16 @@ export function registerPage({
eventChannel
)
initNVueEntryPage
(
webview
)
const
id
=
parseInt
(
webview
.
id
!
)
if
((
webview
as
any
).
nvue
)
{
createNVuePage
(
parseInt
(
webview
.
id
!
),
webview
,
pageInstance
)
if
(
id
===
1
&&
nvuePageVm
)
{
initNVueEntryPage
(
webview
,
nvuePageVm
,
pageInstance
)
}
else
{
createNVuePage
(
id
,
webview
,
pageInstance
)
}
}
else
{
createVuePage
(
parseInt
(
webview
.
id
!
),
route
,
query
,
pageInstance
,
initPageOptions
(
routeOptions
)
)
createVuePage
(
id
,
route
,
query
,
pageInstance
,
initPageOptions
(
routeOptions
))
}
return
webview
}
...
...
@@ -146,21 +146,24 @@ function initPageOptions({ meta }: UniApp.UniRoute): PageNodeOptions {
}
}
function
initNVueEntryPage
(
webview
:
PlusWebviewWebviewObject
)
{
const
isLaunchNVuePage
=
webview
.
id
===
'
1
'
&&
(
webview
as
any
).
nvue
function
initNVueEntryPage
(
webview
:
PlusWebviewWebviewObject
,
nvuePageVm
:
ComponentPublicInstance
,
pageInstance
:
Page
.
PageInstance
[
'
$page
'
]
)
{
initPageVm
(
nvuePageVm
,
pageInstance
)
addCurrentPage
(
nvuePageVm
)
// 首页是 nvue 时,在 registerPage 时,执行路由堆栈
if
(
isLaunchNVuePage
)
{
if
(
__uniConfig
.
splashscreen
&&
__uniConfig
.
splashscreen
.
autoclose
&&
!
__uniConfig
.
splashscreen
.
alwaysShowBeforeRender
)
{
plus
.
navigator
.
closeSplashscreen
()
}
__uniConfig
.
onReady
(
function
()
{
navigateFinish
()
})
if
(
__uniConfig
.
splashscreen
&&
__uniConfig
.
splashscreen
.
autoclose
&&
!
__uniConfig
.
splashscreen
.
alwaysShowBeforeRender
)
{
plus
.
navigator
.
closeSplashscreen
()
}
__uniConfig
.
onReady
(
function
()
{
navigateFinish
()
})
}
function
createNVuePage
(
...
...
packages/uni-app-vite/src/nvue/plugins/esbuild.ts
浏览文件 @
77951dd9
...
...
@@ -5,7 +5,7 @@ import path from 'path'
import
fs
from
'
fs-extra
'
import
debug
from
'
debug
'
import
{
transformWithEsbuild
}
from
'
@dcloudio/uni-cli-shared
'
import
{
removeExt
,
transformWithEsbuild
}
from
'
@dcloudio/uni-cli-shared
'
import
{
nvueOutDir
}
from
'
../../utils
'
import
{
esbuildGlobals
}
from
'
../utils
'
...
...
@@ -74,11 +74,11 @@ ${
}
const webview = plus.webview.currentWebview()
const __pageId = parseInt(webview.id)
const __pagePath =
webview.__path__
const __pagePath =
'
${
removeExt
(
filename
)}
'
let __pageQuery = {}
try{ __pageQuery = JSON.parse(webview.__query__) }catch(e){}
App.mpType = 'page'
const app = Vue.createApp(App,{$store:getApp().$store,__pageId,__pagePath,__pageQuery})
const app = Vue.create
Page
App(App,{$store:getApp().$store,__pageId,__pagePath,__pageQuery})
app.provide('__globalStyles', Vue.useCssStyles([...AppStyles, ...(App.styles||[])]))
app.mount('#root')`
,
path
.
join
(
nvueOutDir
(),
'
main.js
'
),
...
...
packages/uni-app-vite/src/nvue/plugins/mainJs.ts
浏览文件 @
77951dd9
...
...
@@ -49,7 +49,7 @@ function createApp(code: string) {
return
`
${
code
.
replace
(
'
createSSRApp
'
,
'
createVueApp as createSSRApp
'
)}
;const {app:__app__,Vuex:__Vuex__,Pinia:__Pinia__}=createApp();uni.Vuex=__Vuex__;uni.Pinia=__Pinia__;__app__._component.mpType='app';__app__._component.render=()=>{};__app__.mount(
{appendChild(){}}
);`
)}
;const {app:__app__,Vuex:__Vuex__,Pinia:__Pinia__}=createApp();uni.Vuex=__Vuex__;uni.Pinia=__Pinia__;__app__._component.mpType='app';__app__._component.render=()=>{};__app__.mount(
'#app'
);`
}
function
createLegacyApp
(
code
:
string
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录