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

wip(app): subNVue

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