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

refactor(h5): system info

上级 aa71541d
......@@ -35,7 +35,6 @@ export function uniManifestJsonPlugin(): Plugin {
}
const manifest = parseJson(code)
const { debug, h5 } = manifest
const appid = (manifest.appid || '').replace('__UNI__', '')
const router = { ...defaultRouter, ...((h5 && h5.router) || {}) }
if (!router.base) {
router.base = '/'
......@@ -72,7 +71,11 @@ export function uniManifestJsonPlugin(): Plugin {
'column'
return {
code: `export const appid = '${appid || ''}'
code: `export const appId = ${JSON.stringify(manifest.appid || '')}
export const appName = ${JSON.stringify(manifest.name || '')}
export const appVersion = ${JSON.stringify(manifest.versionName || '')}
export const appVersionCode = ${JSON.stringify(manifest.versionCode || '')}
export const debug = ${!!debug}
export const nvue = ${JSON.stringify({
'flex-direction': flexDirection,
......
......@@ -53,7 +53,7 @@ function generatePagesJsonCode(
return `
import { defineAsyncComponent, resolveComponent, createVNode, withCtx, openBlock, createBlock } from 'vue'
import { PageComponent, AsyncLoadingComponent, AsyncErrorComponent, useI18n, setupWindow, setupPage } from '@dcloudio/uni-h5'
import { appid, debug, networkTimeout, router, async, sdkConfigs, qqMapKey, googleMapKey, nvue, locale, fallbackLocale } from './${MANIFEST_JSON_JS}'
import { appId, appName, appVersion, appVersionCode, debug, networkTimeout, router, async, sdkConfigs, qqMapKey, googleMapKey, nvue, locale, fallbackLocale } from './${MANIFEST_JSON_JS}'
const locales = import.meta.globEager('./locale/*.json')
${importLayoutComponentsCode}
const extend = Object.assign
......@@ -247,26 +247,15 @@ function generateConfig(
pagesJson: Record<string, any>,
config: ResolvedConfig
) {
const extraParameters = {
appId: process.env.UNI_APP_ID,
appName: process.env.UNI_APP_NAME,
appVersion: process.env.UNI_APP_VERSION,
appVersionCode: process.env.UNI_APP_VERSION_CODE,
}
delete pagesJson.pages
delete pagesJson.subPackages
delete pagesJson.subpackages
pagesJson.compilerVersion = process.env.UNI_COMPILER_VERSION
return (
(config.command === 'serve'
? ''
: `${globalName}['____'+appid+'____']=true
delete ${globalName}['____'+appid+'____']
`) +
`${globalName}.__uniConfig=extend(
${JSON.stringify(extraParameters)},
${JSON.stringify(pagesJson)},{
return `${globalName}.__uniConfig=extend(${JSON.stringify(pagesJson)},{
appId,
appName,
appVersion,
appVersionCode,
async,
debug,
networkTimeout,
......@@ -280,5 +269,4 @@ delete ${globalName}['____'+appid+'____']
router,
})
`
)
}
import { extend } from '@vue/shared'
import { getDeviceBrand } from '@dcloudio/uni-shared'
const UUID_KEY = '__DC_STAT_UUID'
......@@ -125,5 +126,5 @@ export function populateParameters(
browseVersion: '',
}
Object.assign(toRes, parameters)
extend(toRes, parameters)
}
......@@ -11,7 +11,6 @@ import {
CopyOptions,
initModuleAlias,
initPreContext,
parseManifestJsonOnce,
} from '@dcloudio/uni-cli-shared'
import { createConfig } from './config'
......@@ -34,8 +33,6 @@ const debugUni = debug('uni:plugin')
const pkg = require(path.resolve(__dirname, '../package.json'))
const manifestJson = parseManifestJsonOnce(process.env.UNI_INPUT_DIR)
initModuleAlias()
rewriteCompilerSfcParse()
......@@ -45,10 +42,6 @@ process.env.UNI_COMPILER_VERSION_TYPE = pkg.version.includes('alpha')
? 'a'
: 'r'
process.env.UNI_APP_ID = manifestJson.appid || ''
process.env.UNI_APP_NAME = manifestJson.name || ''
process.env.UNI_APP_VERSION = manifestJson.versionName || ''
process.env.UNI_APP_VERSION_CODE = manifestJson.versionCode || ''
export interface VitePluginUniOptions {
vueOptions?: VueOptions
vueJsxOptions?: (VueJSXPluginOptions & { babelPlugins?: any[] }) | boolean
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册