提交 30567f7b 编写于 作者: fxy060608's avatar fxy060608

wip(app): subNVues

上级 27e21a6f
1. subnvue
2. preloadPage
<!-- 2. preloadPage -->
3. navigateTo eventChannel
\ No newline at end of file
......@@ -190,6 +190,7 @@ declare namespace UniApp {
}
interface PagesJsonPageStyle extends PagesJsonPagePlatformStyle {
isNVue?: boolean
isSubNVue?: boolean
disableScroll?: boolean
enablePullDownRefresh?: boolean
navigationBar: PageNavigationBar
......
......@@ -129,14 +129,16 @@ function buildNVuePage(filename: string, options: BuildOptions) {
return transformWithEsbuild(
`import App from './${filename}'
const webview = plus.webview.currentWebview()
const __pageId = parseInt(webview.id)
const __pagePath = '${removeExt(filename)}'
let __pageQuery = {}
try{ __pageQuery = JSON.parse(webview.__query__) }catch(e){}
App.mpType = 'page'
const app = Vue.createPageApp(App,{$store:getApp({allowDefault:true}).$store,__pageId,__pagePath,__pageQuery})
app.provide('__globalStyles', Vue.useCssStyles([...__uniConfig.styles, ...(App.styles||[])]))
app.mount('#root')`,
if(webview){
const __pageId = parseInt(webview.id)
const __pagePath = '${removeExt(filename)}'
let __pageQuery = {}
try{ __pageQuery = JSON.parse(webview.__query__) }catch(e){}
App.mpType = 'page'
const app = Vue.createPageApp(App,{$store:getApp({allowDefault:true}).$store,__pageId,__pagePath,__pageQuery})
app.provide('__globalStyles', Vue.useCssStyles([...__uniConfig.styles, ...(App.styles||[])]))
app.mount('#root')
}`,
path.join(nvueOutDir(), 'main.js'),
options
).then((res) => {
......
......@@ -130,9 +130,30 @@ function normalizePages(
pages: UniApp.PagesJsonPageOptions[],
platform: UniApp.PLATFORM
) {
return pages.forEach((page) => {
pages.forEach((page) => {
page.style = normalizePageStyle(page.path, page.style!, platform)
})
if (platform !== 'app') {
return
}
const subNVuePages: UniApp.PagesJsonPageOptions[] = []
// subNVues
pages.forEach(({ style: { subNVues } }) => {
if (!isArray(subNVues)) {
return
}
subNVues.forEach((subNVue) => {
if (subNVue && subNVue.path) {
subNVuePages.push({
path: subNVue.path,
style: { isSubNVue: true, isNVue: true, navigationBar: {} },
})
}
})
})
if (subNVuePages.length) {
pages.push(...subNVuePages)
}
}
function normalizeSubpackages(
......@@ -161,7 +182,7 @@ function normalizeSubpackageSubNVues(
if (!platformStyle) {
return style
}
if (Array.isArray(platformStyle.subNVues)) {
if (isArray(platformStyle.subNVues)) {
platformStyle.subNVues.forEach((subNVue) => {
if (subNVue.path) {
subNVue.path = normalizePath(path.join(root, subNVue.path))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册