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

wip(app): subNVue

上级 60d5a983
...@@ -161,6 +161,12 @@ declare namespace UniApp { ...@@ -161,6 +161,12 @@ declare namespace UniApp {
'quickapp-webview-union'?: PagesJsonPageStyle 'quickapp-webview-union'?: PagesJsonPageStyle
} }
interface PagesJsonPageStyleSubNVue {
id?: string
path: string
type: 'popup' | 'navigationBar'
style?: unknown
}
interface PagesJsonPageStyle extends PagesJsonPagePlatformStyle { interface PagesJsonPageStyle extends PagesJsonPagePlatformStyle {
isNVue?: boolean isNVue?: boolean
disableScroll?: boolean disableScroll?: boolean
...@@ -174,6 +180,7 @@ declare namespace UniApp { ...@@ -174,6 +180,7 @@ declare namespace UniApp {
// app-plus // app-plus
animationType?: string animationType?: string
animationDuration?: number animationDuration?: number
subNVues?: PagesJsonPageStyleSubNVue[]
} }
interface PageRouteMeta extends PagesJsonPageStyle { interface PageRouteMeta extends PagesJsonPageStyle {
id?: number id?: number
......
...@@ -5,6 +5,7 @@ export function createOptimization(): Configuration['optimization'] { ...@@ -5,6 +5,7 @@ export function createOptimization(): Configuration['optimization'] {
return { return {
nodeEnv: false, // 禁用,由 define 统一设置 nodeEnv: false, // 禁用,由 define 统一设置
moduleIds: 'deterministic', moduleIds: 'deterministic',
chunkIds: 'deterministic',
minimizer: [ minimizer: [
new TerserPlugin({ new TerserPlugin({
terserOptions: { terserOptions: {
......
import fs from 'fs' import fs from 'fs'
import path from 'path' import path from 'path'
import { normalizePath } from '../../../utils' import { normalizePath, removeExt } from '../../../utils'
export function initWebpackNVueEntry(pages: UniApp.PagesJsonPageOptions[]) { export function initWebpackNVueEntry(pages: UniApp.PagesJsonPageOptions[]) {
process.UNI_NVUE_ENTRY = {} process.UNI_NVUE_ENTRY = {}
pages.forEach((page) => { pages.forEach(({ path, style: { isNVue, subNVues } }) => {
if (page.style.isNVue) { if (isNVue) {
process.UNI_NVUE_ENTRY[page.path] = genWebpackBase64Code( process.UNI_NVUE_ENTRY[path] = genWebpackBase64Code(
genNVueEntryCode(page.path) genNVueEntryCode(path)
) )
} }
if (!Array.isArray(subNVues)) {
return
}
subNVues.forEach(({ path }) => {
if (!path) {
return
}
const subNVuePath = removeExt(path.split('?')[0])
process.UNI_NVUE_ENTRY[subNVuePath] = genWebpackBase64Code(
genNVueEntryCode(subNVuePath)
)
})
}) })
} }
......
...@@ -94,6 +94,7 @@ function normalizeSubpackages( ...@@ -94,6 +94,7 @@ function normalizeSubpackages(
if (root && subPages.length) { if (root && subPages.length) {
subPages.forEach((subPage) => { subPages.forEach((subPage) => {
subPage.path = normalizePath(path.join(root, subPage.path)) subPage.path = normalizePath(path.join(root, subPage.path))
subPage.style = normalizeSubpackageSubNVues(root, subPage.style)
pages.push(subPage) pages.push(subPage)
}) })
} }
...@@ -102,6 +103,24 @@ function normalizeSubpackages( ...@@ -102,6 +103,24 @@ function normalizeSubpackages(
return pages return pages
} }
function normalizeSubpackageSubNVues(
root: string,
style: UniApp.PagesJsonPageStyle
) {
const platformStyle = style['app'] || style['app-plus']
if (!platformStyle) {
return style
}
if (Array.isArray(platformStyle.subNVues)) {
platformStyle.subNVues.forEach((subNVue) => {
if (subNVue.path) {
subNVue.path = normalizePath(path.join(root, subNVue.path))
}
})
}
return style
}
function normalizePageStyle( function normalizePageStyle(
pagePath: string | null, pagePath: string | null,
pageStyle: UniApp.PagesJsonPageStyle | undefined, pageStyle: UniApp.PagesJsonPageStyle | undefined,
......
import fs from 'fs' import fs from 'fs'
import path from 'path' import path from 'path'
import { ResolvedConfig } from 'vite'
import { isInHBuilderX, UniVitePlugin } from '@dcloudio/uni-cli-shared' import { isInHBuilderX, UniVitePlugin } from '@dcloudio/uni-cli-shared'
import { uniCssPlugin } from './plugins/css' import { uniCssPlugin } from './plugins/css'
import { uniCssScopedPlugin } from './plugins/cssScoped' import { uniCssScopedPlugin } from './plugins/cssScoped'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册