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

wip(mp): mp-alipay

上级 da1dab32
......@@ -1395,6 +1395,10 @@ var serviceContext = (function (vue) {
return locale;
}
locale = locale.toLowerCase();
if (locale === 'chinese') {
// 支付宝
return LOCALE_ZH_HANS;
}
if (locale.indexOf('zh') === 0) {
if (locale.indexOf('-hans') > -1) {
return LOCALE_ZH_HANS;
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -13,6 +13,9 @@ export function initDefine(stringifyBoolean: boolean = false) {
'process.env.UNI_APP_ID': JSON.stringify(manifestJson.appid || ''),
'process.env.UNI_APP_NAME': JSON.stringify(manifestJson.name || ''),
'process.env.UNI_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM),
'process.env.UNI_COMPILER_VERSION': JSON.stringify(
process.env.UNI_COMPILER_VERSION
),
'process.env.RUN_BY_HBUILDERX': stringifyBoolean
? JSON.stringify(isRunByHBuilderX)
: isRunByHBuilderX,
......
......@@ -34,6 +34,8 @@ function parsePagesJson(
networkTimeout,
subpackages,
windowOptionsMap,
tabBarOptionsMap,
tabBarItemOptionsMap,
}: ParsePagesJsonOptions = {
subpackages: false,
}
......@@ -107,7 +109,12 @@ function parsePagesJson(
// tabBar
if (pagesJson.tabBar) {
const tabBar = parseTabBar(pagesJson.tabBar!, platform)
const tabBar = parseTabBar(
pagesJson.tabBar!,
platform,
tabBarOptionsMap,
tabBarItemOptionsMap
)
if (tabBar) {
appJson.tabBar = tabBar
}
......
......@@ -125,6 +125,10 @@ function normalizeLocale(locale, messages) {
return locale;
}
locale = locale.toLowerCase();
if (locale === 'chinese') {
// 支付宝
return LOCALE_ZH_HANS;
}
if (locale.indexOf('zh') === 0) {
if (locale.indexOf('-hans') > -1) {
return LOCALE_ZH_HANS;
......
......@@ -121,6 +121,10 @@ function normalizeLocale(locale, messages) {
return locale;
}
locale = locale.toLowerCase();
if (locale === 'chinese') {
// 支付宝
return LOCALE_ZH_HANS;
}
if (locale.indexOf('zh') === 0) {
if (locale.indexOf('-hans') > -1) {
return LOCALE_ZH_HANS;
......
......@@ -59,6 +59,10 @@ export function normalizeLocale(
return locale as BuiltInLocale
}
locale = locale.toLowerCase()
if (locale === 'chinese') {
// 支付宝
return LOCALE_ZH_HANS
}
if (locale.indexOf('zh') === 0) {
if (locale.indexOf('-hans') > -1) {
return LOCALE_ZH_HANS
......
......@@ -95,7 +95,8 @@ const miniProgram = {
},
slot: {
$slots: true,
fallback: true,
// 支付宝 fallback 有 bug,当多个带默认 slot 组件嵌套使用时,所有的默认slot均会显示,如uni-file-picker(image)
fallback: false,
},
directive: 'a:',
};
......@@ -133,6 +134,33 @@ const options = {
},
},
global: 'my',
json: {
windowOptionsMap: {
defaultTitle: 'navigationBarTitleText',
pullRefresh: 'enablePullDownRefresh',
allowsBounceVertical: 'allowsBounceVertical',
titleBarColor: 'navigationBarBackgroundColor',
optionMenu: 'optionMenu',
backgroundColor: 'backgroundColor',
usingComponents: 'usingComponents',
navigationBarShadow: 'navigationBarShadow',
titleImage: 'titleImage',
transparentTitle: 'transparentTitle',
titlePenetrate: 'titlePenetrate',
},
tabBarOptionsMap: {
textColor: 'color',
selectedColor: 'selectedColor',
backgroundColor: 'backgroundColor',
items: 'list',
},
tabBarItemOptionsMap: {
pagePath: 'pagePath',
name: 'text',
icon: 'iconPath',
activeIcon: 'selectedIconPath',
},
},
app: {
darkmode: false,
subpackages: true,
......
......@@ -163,7 +163,16 @@ function initBaseInstance(instance, options) {
{
Object.defineProperty(instance, 'slots', {
get() {
return this.$scope && this.$scope.props.$slots;
if (this.$scope) {
const slots = this.$scope.props.$slots;
if (slots.$default) {
slots.default = slots.$default;
}
else {
delete slots.default;
}
return slots;
}
},
});
}
......
......@@ -19,7 +19,8 @@ export const miniProgram: MiniProgramCompilerOptions = {
},
slot: {
$slots: true,
fallback: true,
// 支付宝 fallback 有 bug,当多个带默认 slot 组件嵌套使用时,所有的默认slot均会显示,如uni-file-picker(image)
fallback: false,
},
directive: 'a:',
}
......@@ -57,6 +58,33 @@ export const options: UniMiniProgramPluginOptions = {
},
},
global: 'my',
json: {
windowOptionsMap: {
defaultTitle: 'navigationBarTitleText',
pullRefresh: 'enablePullDownRefresh',
allowsBounceVertical: 'allowsBounceVertical',
titleBarColor: 'navigationBarBackgroundColor',
optionMenu: 'optionMenu',
backgroundColor: 'backgroundColor',
usingComponents: 'usingComponents',
navigationBarShadow: 'navigationBarShadow',
titleImage: 'titleImage',
transparentTitle: 'transparentTitle',
titlePenetrate: 'titlePenetrate',
},
tabBarOptionsMap: {
textColor: 'color',
selectedColor: 'selectedColor',
backgroundColor: 'backgroundColor',
items: 'list',
},
tabBarItemOptionsMap: {
pagePath: 'pagePath',
name: 'text',
icon: 'iconPath',
activeIcon: 'selectedIconPath',
},
},
app: {
darkmode: false,
subpackages: true,
......
......@@ -68,7 +68,15 @@ export function initBaseInstance(
if (__PLATFORM__ === 'mp-alipay') {
Object.defineProperty(instance, 'slots', {
get() {
return this.$scope && this.$scope.props.$slots
if (this.$scope) {
const slots = this.$scope.props.$slots
if (slots.$default) {
slots.default = slots.$default
} else {
delete slots.default
}
return slots
}
},
})
} else {
......
......@@ -13,7 +13,7 @@ import {
resolveMainPathOnce,
normalizeMiniProgramFilename,
} from '@dcloudio/uni-cli-shared'
import { GetManualChunk, GetModuleInfo } from 'rollup'
import { GetManualChunk, GetModuleInfo, Plugin, PreRenderedChunk } from 'rollup'
import {
isUniComponentUrl,
isUniPageUrl,
......@@ -44,25 +44,9 @@ export function buildOptions(): UserConfig['build'] {
output: {
entryFileNames: 'app.js',
manualChunks: createMoveToVendorChunkFn(),
chunkFileNames(chunk) {
if (chunk.isDynamicEntry && chunk.facadeModuleId) {
let id = chunk.facadeModuleId
if (isUniPageUrl(id)) {
id = path.resolve(
process.env.UNI_INPUT_DIR,
parseVirtualPagePath(id)
)
} else if (isUniComponentUrl(id)) {
id = path.resolve(
process.env.UNI_INPUT_DIR,
parseVirtualComponentPath(id)
)
}
return removeExt(normalizeMiniProgramFilename(id, inputDir)) + '.js'
}
return '[name].js'
},
chunkFileNames: createChunkFileNames(inputDir),
assetFileNames: '[name][extname]',
plugins: [dynamicImportPolyfill()],
},
},
}
......@@ -148,3 +132,35 @@ function staticImportedByEntry(
cache.set(id, someImporterIs)
return someImporterIs
}
function createChunkFileNames(
inputDir: string
): (chunkInfo: PreRenderedChunk) => string {
return function chunkFileNames(chunk) {
if (chunk.isDynamicEntry && chunk.facadeModuleId) {
let id = chunk.facadeModuleId
if (isUniPageUrl(id)) {
id = path.resolve(process.env.UNI_INPUT_DIR, parseVirtualPagePath(id))
} else if (isUniComponentUrl(id)) {
id = path.resolve(
process.env.UNI_INPUT_DIR,
parseVirtualComponentPath(id)
)
}
return removeExt(normalizeMiniProgramFilename(id, inputDir)) + '.js'
}
return '[name].js'
}
}
function dynamicImportPolyfill(): Plugin {
return {
name: 'dynamic-import-polyfill',
renderDynamicImport() {
return {
left: '(',
right: ')',
}
},
}
}
......@@ -27,6 +27,11 @@ export interface UniMiniProgramPluginOptions {
}
}
global: string
json?: {
windowOptionsMap?: Record<string, string>
tabBarOptionsMap?: Record<string, string>
tabBarItemOptionsMap?: Record<string, string>
}
app: {
darkmode: boolean
subpackages: boolean
......
......@@ -54,6 +54,7 @@ export function uniPagesJsonPlugin(
fs.existsSync(path.resolve(inputDir, 'theme.json')),
networkTimeout: manifestJson.networkTimeout,
subpackages: options.app.subpackages,
...options.json,
}
)
nvueCssPathsCache.set(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册