From 1c6d8ad108d9f63821bdf5f04a6953f1445c7ead Mon Sep 17 00:00:00 2001 From: qiang Date: Tue, 31 Aug 2021 16:22:54 +0800 Subject: [PATCH] chore: lint --- packages/uni-cli-i18n/lib/index.js | 4 ++-- packages/uni-cli-i18n/lib/lang.js | 4 ++-- packages/uni-cli-i18n/lib/locale.js | 2 +- packages/uni-cli-shared/lib/package.js | 4 ++-- packages/uni-cli-shared/lib/pages.js | 4 ++-- packages/uni-cli-shared/lib/plugin.js | 8 ++++---- packages/uni-migration/lib/index.js | 2 +- packages/uni-migration/lib/validate.js | 6 +++--- packages/uni-mp-weixin/lib/uni.compiler.js | 4 ++-- packages/uni-template-compiler/lib/mp.js | 4 ++-- .../lib/script/traverse/data/class.js | 2 +- .../lib/script/traverse/visitor.js | 2 +- .../lib/template/generate.js | 2 +- .../lib/template/traverse.js | 2 +- packages/uni-template-compiler/lib/util.js | 2 +- packages/vue-cli-plugin-uni/commands/build.js | 6 +++--- packages/vue-cli-plugin-uni/lib/env.js | 18 +++++++++--------- .../lib/babel-plugin-global-component.js | 4 ++-- .../lib/babel-plugin-scoped-component.js | 2 +- .../lib/babel/global-component-traverse.js | 4 ++-- .../webpack-uni-mp-loader/lib/babel/util.js | 2 +- packages/webpack-uni-mp-loader/lib/main-new.js | 2 +- .../webpack-uni-mp-loader/lib/script-new.js | 2 +- .../webpack-uni-pages-loader/lib/index-new.js | 2 +- .../lib/platforms/mp.js | 4 ++-- .../app-plus/service/api/media/choose-image.js | 18 +++++++++--------- 26 files changed, 58 insertions(+), 58 deletions(-) diff --git a/packages/uni-cli-i18n/lib/index.js b/packages/uni-cli-i18n/lib/index.js index 5e991ca10..0be98feeb 100644 --- a/packages/uni-cli-i18n/lib/index.js +++ b/packages/uni-cli-i18n/lib/index.js @@ -33,8 +33,8 @@ i18n.configure({ }, fallbacks: { 'en_*': 'en', - 'zh': 'zh_CN', - 'zh_*': 'zh_CN', + zh: 'zh_CN', + 'zh_*': 'zh_CN' } }) diff --git a/packages/uni-cli-i18n/lib/lang.js b/packages/uni-cli-i18n/lib/lang.js index 5ad340fb5..4ee765a2f 100644 --- a/packages/uni-cli-i18n/lib/lang.js +++ b/packages/uni-cli-i18n/lib/lang.js @@ -1,5 +1,5 @@ function format (lang) { - const array = lang.split(/[\.,]/)[0].split(/[_-]/) + const array = lang.split(/[.,]/)[0].split(/[_-]/) array[0] = array[0].toLowerCase() if (array[0] === 'zh') { array[1] = (array[1] || 'CN').toUpperCase() @@ -10,4 +10,4 @@ function format (lang) { module.exports = { format -} \ No newline at end of file +} diff --git a/packages/uni-cli-i18n/lib/locale.js b/packages/uni-cli-i18n/lib/locale.js index 3271f2b6a..cc1dc5755 100644 --- a/packages/uni-cli-i18n/lib/locale.js +++ b/packages/uni-cli-i18n/lib/locale.js @@ -2,7 +2,7 @@ const { format } = require('./lang') const { osLocale } = require('os-locale-s-fix/cjs') function getLocale () { - return format(process.env.UNI_HBUILDERX_LANGID || osLocale.sync({ spawn: true, cache: false }) || defaultLocale) + return format(process.env.UNI_HBUILDERX_LANGID || osLocale.sync({ spawn: true, cache: false }) || 'en') } module.exports = { diff --git a/packages/uni-cli-shared/lib/package.js b/packages/uni-cli-shared/lib/package.js index 8526df658..034e498d4 100644 --- a/packages/uni-cli-shared/lib/package.js +++ b/packages/uni-cli-shared/lib/package.js @@ -27,12 +27,12 @@ module.exports = { } if (!scriptOptions.env || !scriptOptions.env.UNI_PLATFORM) { - console.error(uniI18n.__('cliShared.requireConfigUniPlatform', { "0": `package.json->uni-app->scripts->${name}->env ` })) + console.error(uniI18n.__('cliShared.requireConfigUniPlatform', { 0: `package.json->uni-app->scripts->${name}->env ` })) process.exit(0) } if (PLATFORMS.indexOf(scriptOptions.env.UNI_PLATFORM) === -1) { - console.error(uniI18n.__('cliShared.supportPlatform', { "0": 'UNI_PLATFORM', "1": JSON.stringify(PLATFORMS)})) + console.error(uniI18n.__('cliShared.supportPlatform', { 0: 'UNI_PLATFORM', 1: JSON.stringify(PLATFORMS) })) process.exit(0) } diff --git a/packages/uni-cli-shared/lib/pages.js b/packages/uni-cli-shared/lib/pages.js index 5eb3f5ff2..c61f6a96b 100644 --- a/packages/uni-cli-shared/lib/pages.js +++ b/packages/uni-cli-shared/lib/pages.js @@ -113,7 +113,7 @@ function isNVuePage (page, root = '') { function isValidPage (page, root = '') { if (typeof page === 'string' || !page.path) { // 不合法的配置 - console.warn(uniI18n.__('cliShared.pagesJsonError', { "0": 'https://uniapp.dcloud.io/collocation/pages?id=pages' })) + console.warn(uniI18n.__('cliShared.pagesJsonError', { 0: 'https://uniapp.dcloud.io/collocation/pages?id=pages' })) return false } let pagePath = page.path @@ -391,7 +391,7 @@ function initAutoComponents () { }) if (conflictFiles.length > 0) { conflictFiles.forEach(files => { - console.warn(uniI18n.__('cliShared.easycomConflict', { "0": '[' + files.map((file, index) => { return file }).join(',') + ']' })) + console.warn(uniI18n.__('cliShared.easycomConflict', { 0: '[' + files.map((file, index) => { return file }).join(',') + ']' })) console.log('\n') }) } diff --git a/packages/uni-cli-shared/lib/plugin.js b/packages/uni-cli-shared/lib/plugin.js index beb79bb91..d2be1a13f 100644 --- a/packages/uni-cli-shared/lib/plugin.js +++ b/packages/uni-cli-shared/lib/plugin.js @@ -25,7 +25,7 @@ function initPlugin (plugin) { try { pluginApi = require(path.join(plugin.id, (plugin.config.main || '/lib/uni.config.js'))) } catch (e) { - console.warn(uniI18n.__('cliShared.missingUniConfig', { "0": plugin.id })) + console.warn(uniI18n.__('cliShared.missingUniConfig', { 0: plugin.id })) } pluginApi && PLUGIN_KEYS.forEach(name => { @@ -56,7 +56,7 @@ function resolvePlugins () { return } if (!config.name) { - return console.warn(uniI18n.__('cliShared.missingNameAttribute', { "0": `${id}/package.json->uni-app` })) + return console.warn(uniI18n.__('cliShared.missingNameAttribute', { 0: `${id}/package.json->uni-app` })) } return { id, @@ -75,7 +75,7 @@ function initExtends (name, plugin, plugins) { process.exit(0) } if (!plugin) { - console.error(uniI18n.__('cliShared.noFoundPlatformPlugin', { "0": extendsPlatform })) + console.error(uniI18n.__('cliShared.noFoundPlatformPlugin', { 0: extendsPlatform })) process.exit(0) } const extendsPlugin = plugins.find(plugin => plugin.name === extendsPlatform) @@ -102,7 +102,7 @@ module.exports = { const plugins = resolvePlugins() const plugin = plugins.find(plugin => plugin.name === process.env.UNI_PLATFORM) if (!plugin) { - console.error(uniI18n.__('cliShared.noFoundPlatformPlugin', { "0": process.env.UNI_PLATFORM })) + console.error(uniI18n.__('cliShared.noFoundPlatformPlugin', { 0: process.env.UNI_PLATFORM })) process.exit(0) } const name = plugin.name diff --git a/packages/uni-migration/lib/index.js b/packages/uni-migration/lib/index.js index 965ec0442..87d76a2b2 100644 --- a/packages/uni-migration/lib/index.js +++ b/packages/uni-migration/lib/index.js @@ -13,7 +13,7 @@ module.exports = function migrate (input, out, options = {}) { options.platform = options.platform || 'mp-weixin' const migrater = migraters[options.platform] if (!migrater) { - return console.error(uniI18n.__('migration.errorOnlySupportConvert', { "0": Object.keys(migraters).join(',') })) + return console.error(uniI18n.__('migration.errorOnlySupportConvert', { 0: Object.keys(migraters).join(',') })) } input = path.resolve(input) out = path.resolve(out || input) diff --git a/packages/uni-migration/lib/validate.js b/packages/uni-migration/lib/validate.js index acfbb999b..bc56eb4cc 100644 --- a/packages/uni-migration/lib/validate.js +++ b/packages/uni-migration/lib/validate.js @@ -7,7 +7,7 @@ const migraters = { module.exports = function validate (input, out, options) { if (!fs.existsSync(input)) { - return console.error(uniI18n.__('migration.errorInputNotExists', { "0": input })) + return console.error(uniI18n.__('migration.errorInputNotExists', { 0: input })) } Object.assign(options, migraters[options.platform].options) const templateExtname = options.extname.template @@ -15,7 +15,7 @@ module.exports = function validate (input, out, options) { const stat = fs.lstatSync(input) if (stat.isFile()) { if (path.extname(input) !== templateExtname) { - return console.error(uniI18n.__('migration.errorConvertRequireFileUrl', { "0": templateExtname.substr(1) })) + return console.error(uniI18n.__('migration.errorConvertRequireFileUrl', { 0: templateExtname.substr(1) })) } options.target = 'file' } else if (stat.isDirectory()) { @@ -26,7 +26,7 @@ module.exports = function validate (input, out, options) { options.target = 'folder' } } else { - return console.error(uniI18n.__('migration.errorCannotConvert', { "0": input })) + return console.error(uniI18n.__('migration.errorCannotConvert', { 0: input })) } return true } diff --git a/packages/uni-mp-weixin/lib/uni.compiler.js b/packages/uni-mp-weixin/lib/uni.compiler.js index e5a8f5653..4ddd67ebf 100644 --- a/packages/uni-mp-weixin/lib/uni.compiler.js +++ b/packages/uni-mp-weixin/lib/uni.compiler.js @@ -107,7 +107,7 @@ module.exports = { ] if (t.isIdentifier(value)) { if (value.name !== key.name) { - state.errors.add(uniI18n.__('mpWeChat.slotPropNoSupportReanme', { "0": key.name, "1": value.name })) + state.errors.add(uniI18n.__('mpWeChat.slotPropNoSupportReanme', { 0: key.name, 1: value.name })) } } else if (t.isAssignmentPattern(value)) { valueObjectProperties.push(t.objectProperty(t.identifier('default'), value.right)) @@ -115,7 +115,7 @@ module.exports = { objectProperties.push(t.objectProperty(key, t.objectExpression(valueObjectProperties))) }) } else { - state.errors.add(uniI18n.__('mpWeChat.onlySupportDestructuringSlot', { "0": paramExprNode.name, "1": 'v-slot="{ user }"'})) + state.errors.add(uniI18n.__('mpWeChat.onlySupportDestructuringSlot', { 0: paramExprNode.name, 1: 'v-slot="{ user }"' })) } const jsContent = generateJsCode(genCode(t.objectExpression(objectProperties), true)) state.files[jsFile] = jsContent diff --git a/packages/uni-template-compiler/lib/mp.js b/packages/uni-template-compiler/lib/mp.js index 4ce22873b..f5c068e2b 100644 --- a/packages/uni-template-compiler/lib/mp.js +++ b/packages/uni-template-compiler/lib/mp.js @@ -111,7 +111,7 @@ ${content} return `${eventType}${eventName}` // 原生组件不支持 bind:input 等写法,统一使用 bindinput }, createScopedSlots (slotName, props, state) { - state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', { "0": `[${slotName}]` })) + state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', { 0: `[${slotName}]` })) return { type: 'slot', attr: { @@ -124,7 +124,7 @@ ${content} traverseExpr, normalizeChildren }, state) { - state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', { "0": `[${slotName}]` })) + state.errors.add(uniI18n.__('templateCompiler.notCurrentlySupportScopedSlot', { 0: `[${slotName}]` })) return { type: 'view', attr: { diff --git a/packages/uni-template-compiler/lib/script/traverse/data/class.js b/packages/uni-template-compiler/lib/script/traverse/data/class.js index ac7a0cc3e..9ea60a580 100644 --- a/packages/uni-template-compiler/lib/script/traverse/data/class.js +++ b/packages/uni-template-compiler/lib/script/traverse/data/class.js @@ -133,7 +133,7 @@ module.exports = function processClass (paths, path, state) { // ) // ) } else { - state.errors.add(':class' + uniI18n.__('templateCompiler.noSupportSyntax', { "0": getCode(classValuePath.node) })) + state.errors.add(':class' + uniI18n.__('templateCompiler.noSupportSyntax', { 0: getCode(classValuePath.node) })) } } return [] diff --git a/packages/uni-template-compiler/lib/script/traverse/visitor.js b/packages/uni-template-compiler/lib/script/traverse/visitor.js index 089d69aa3..5868959d7 100644 --- a/packages/uni-template-compiler/lib/script/traverse/visitor.js +++ b/packages/uni-template-compiler/lib/script/traverse/visitor.js @@ -78,7 +78,7 @@ function addVueId (path, state) { const scoped = scopeds[i] forIndexSet.add(scoped.forIndex) if (forIndexSet.size !== i + 1) { - state.errors.add(uniI18n.__('templateCompiler.forNestedIndexNameNoArrowRepeat', { "0": 'v-for', "1": scoped.forIndex })) + state.errors.add(uniI18n.__('templateCompiler.forNestedIndexNameNoArrowRepeat', { 0: 'v-for', 1: scoped.forIndex })) break } } diff --git a/packages/uni-template-compiler/lib/template/generate.js b/packages/uni-template-compiler/lib/template/generate.js index ab98c29ce..0271b25fe 100644 --- a/packages/uni-template-compiler/lib/template/generate.js +++ b/packages/uni-template-compiler/lib/template/generate.js @@ -82,7 +82,7 @@ function processElement (ast, state, isRoot) { ast.attr['vue-slots'] = '{{[' + slots.reverse().map(slotName => `'${slotName}'`).join(',') + ']}}' } if (ast.attr.id && ast.attr.id.indexOf('{{') === 0) { - state.tips.add(uniI18n.__('templateCompiler.idAttribNotAllowInCustomComponentProps', { "0": ast.type })) + state.tips.add(uniI18n.__('templateCompiler.idAttribNotAllowInCustomComponentProps', { 0: ast.type })) } if (hasOwn(ast.attr, 'data') && platformName !== 'mp-toutiao') { // 百度中会出现异常情况 // TODO 暂不输出 diff --git a/packages/uni-template-compiler/lib/template/traverse.js b/packages/uni-template-compiler/lib/template/traverse.js index 6639c22a8..7303c990c 100644 --- a/packages/uni-template-compiler/lib/template/traverse.js +++ b/packages/uni-template-compiler/lib/template/traverse.js @@ -298,7 +298,7 @@ function genSlotNode (slotName, slotNode, fallbackNodes, state) { function traverseRenderSlot (callExprNode, state) { if (!t.isStringLiteral(callExprNode.arguments[0])) { - state.errors.add(uniI18n.__('templateCompiler.notSupportDynamicSlotName', { "0": 'v-slot' })) + state.errors.add(uniI18n.__('templateCompiler.notSupportDynamicSlotName', { 0: 'v-slot' })) return } diff --git a/packages/uni-template-compiler/lib/util.js b/packages/uni-template-compiler/lib/util.js index cd3d76957..505ed6183 100644 --- a/packages/uni-template-compiler/lib/util.js +++ b/packages/uni-template-compiler/lib/util.js @@ -116,7 +116,7 @@ function getForKey (forKey, forIndex, state) { } else if (t.isMemberExpression(forKey)) { return forKey.property.name || forKey.property.value } else { - state.tips.add(uniI18n.__('templateCompiler.noH5KeyNoSupportExpression', { "0": getCode(forKey), "1": 'https://uniapp.dcloud.io/use?id=key' })) + state.tips.add(uniI18n.__('templateCompiler.noH5KeyNoSupportExpression', { 0: getCode(forKey), 1: 'https://uniapp.dcloud.io/use?id=key' })) } } return '' diff --git a/packages/vue-cli-plugin-uni/commands/build.js b/packages/vue-cli-plugin-uni/commands/build.js index 2e58a9ce6..6d5acabd1 100644 --- a/packages/vue-cli-plugin-uni/commands/build.js +++ b/packages/vue-cli-plugin-uni/commands/build.js @@ -133,7 +133,7 @@ async function build (args, api, options) { log() if (!runByHBuilderX && !runByAliIde) { - logWithSpinner(uniI18n.__('pluginUni.startCompileProjectToPlatform', { "0": process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM, "1": process.env.UNI_MP_PLUGIN ? uniI18n.__('platform') : uniI18n.__('plugin') })) + logWithSpinner(uniI18n.__('pluginUni.startCompileProjectToPlatform', { 0: process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM, 1: process.env.UNI_MP_PLUGIN ? uniI18n.__('platform') : uniI18n.__('plugin') })) } const targetDir = api.resolve(options.outputDir) @@ -219,7 +219,7 @@ function analysisPluginDir () { if (!fs.pathExistsSync(pluginJsonPath)) { console.log() - console.error(uniI18n.__('pluginUni.fileNoExistsCheckAfterRetry', { "0": pluginJsonName })) + console.error(uniI18n.__('pluginUni.fileNoExistsCheckAfterRetry', { 0: pluginJsonName })) console.log() process.exit(0) } @@ -233,7 +233,7 @@ function analysisPluginDir () { if (UNI_MP_PLUGIN_MAIN && !fs.pathExistsSync(mainFilePath)) { console.log() - console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', { "0": UNI_MP_PLUGIN_MAIN })) + console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', { 0: UNI_MP_PLUGIN_MAIN })) console.log() process.exit(0) } diff --git a/packages/vue-cli-plugin-uni/lib/env.js b/packages/vue-cli-plugin-uni/lib/env.js index 2588b4849..81541b865 100644 --- a/packages/vue-cli-plugin-uni/lib/env.js +++ b/packages/vue-cli-plugin-uni/lib/env.js @@ -58,7 +58,7 @@ if (process.env.UNI_CLOUD_SPACES) { const hasUniCloudSpace = spaces.length > 0 if (spaces.length === 1) { const space = spaces[0] - console.log(uniI18n.__('pluginUni.currentProjectDefaultSpaceId', { "0": space.id })) + console.log(uniI18n.__('pluginUni.currentProjectDefaultSpaceId', { 0: space.id })) } if ( @@ -66,13 +66,13 @@ if (process.env.UNI_CLOUD_SPACES) { isH5 && isProduction ) { - console.warn(uniI18n.__('pluginUni.unicloudReleaseH5', { "0": 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' })) + console.warn(uniI18n.__('pluginUni.unicloudReleaseH5', { 0: 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' })) } else if ( hasUniCloudSpace && isH5 && !isProduction ) { - console.warn(uniI18n.__('pluginUni.unicloudShowedRunByHBuilderX', { "0": 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' })) + console.warn(uniI18n.__('pluginUni.unicloudShowedRunByHBuilderX', { 0: 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' })) } process.env.UNI_CLOUD_PROVIDER = JSON.stringify(spaces.map(space => { @@ -295,7 +295,7 @@ if ( process.env.UNI_USING_STAT = true if (!process.UNI_STAT_CONFIG.appid && process.env.NODE_ENV === 'production') { console.log() - console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', { "0": 'https://ask.dcloud.net.cn/article/36303' })) + console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', { 0: 'https://ask.dcloud.net.cn/article/36303' })) console.log() } } @@ -321,10 +321,10 @@ const warningMsg = const needWarning = !platformOptions.usingComponents || usingComponentsAbsent let hasNVue = false // 输出编译器版本等信息 -const compile_mode_url = 'https://ask.dcloud.net.cn/article/36074' +const compileModeUrl = 'https://ask.dcloud.net.cn/article/36074' if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) { - let compile_mode = (process.env.UNI_USING_V3_NATIVE ? '(v3)' : '') + ':' + (isNVueCompiler ? 'uni-app' : 'weex') - console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { "0": compile_mode, "1": compile_mode_url })) + const compileMode = (process.env.UNI_USING_V3_NATIVE ? '(v3)' : '') + ':' + (isNVueCompiler ? 'uni-app' : 'weex') + console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { 0: compileMode, 1: compileModeUrl })) } else if (process.env.UNI_PLATFORM !== 'h5' && process.env.UNI_PLATFORM !== 'quickapp-native') { try { let info = '' @@ -346,7 +346,7 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) { if (needWarning) { console.log(warningMsg) } - console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { "0": (isNVueCompiler ? 'uni-app' : 'weex'), "1": compile_mode_url })) + console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { 0: (isNVueCompiler ? 'uni-app' : 'weex'), 1: compileModeUrl })) } else { console.log(info) if (needWarning) { @@ -467,7 +467,7 @@ if ( } if (process.env.UNI_PLATFORM.startsWith('mp-')) { - console.log(uniI18n.__('pluginUni.mpBrowserKernelDifference', { "0": "https://uniapp.dcloud.io/matter?id=mp" })) + console.log(uniI18n.__('pluginUni.mpBrowserKernelDifference', { 0: 'https://uniapp.dcloud.io/matter?id=mp' })) } runByHBuilderX && console.log(uniI18n.__('compiling')) diff --git a/packages/webpack-uni-mp-loader/lib/babel-plugin-global-component.js b/packages/webpack-uni-mp-loader/lib/babel-plugin-global-component.js index beef36992..a3c85036d 100644 --- a/packages/webpack-uni-mp-loader/lib/babel-plugin-global-component.js +++ b/packages/webpack-uni-mp-loader/lib/babel-plugin-global-component.js @@ -31,10 +31,10 @@ module.exports = function babelPluginGlobalComponent ({ } if (callee.object.name === 'Vue' && callee.property.name === 'component') { if (!args[0] || args[0].type !== 'StringLiteral') { - throw new Error(uniI18n.__('mpLoader.firstParameterNeedStaticString', { "0": "Vue.component()" })) + throw new Error(uniI18n.__('mpLoader.firstParameterNeedStaticString', { 0: 'Vue.component()' })) } if (!args[1]) { - throw new Error(uniI18n.__('mpLoader.requireTwoParameter', { "0": "Vue.component()" })) + throw new Error(uniI18n.__('mpLoader.requireTwoParameter', { 0: 'Vue.component()' })) } if (!metadata.globalComponents) { metadata.globalComponents = {} diff --git a/packages/webpack-uni-mp-loader/lib/babel-plugin-scoped-component.js b/packages/webpack-uni-mp-loader/lib/babel-plugin-scoped-component.js index 8714f3dae..9f8473c8f 100644 --- a/packages/webpack-uni-mp-loader/lib/babel-plugin-scoped-component.js +++ b/packages/webpack-uni-mp-loader/lib/babel-plugin-scoped-component.js @@ -65,7 +65,7 @@ module.exports = function ({ const value = prop.value.name const source = findSource(value, path.scope.bindings) if (!source) { - throw new Error(uniI18n.__('mpLoader.componentReferenceError', { "0": key })) + throw new Error(uniI18n.__('mpLoader.componentReferenceError', { 0: key })) } if (process.UNI_LIBRARIES.includes(source)) { const componentName = hyphenate(key) diff --git a/packages/webpack-uni-mp-loader/lib/babel/global-component-traverse.js b/packages/webpack-uni-mp-loader/lib/babel/global-component-traverse.js index 7825671ae..f3628fe28 100644 --- a/packages/webpack-uni-mp-loader/lib/babel/global-component-traverse.js +++ b/packages/webpack-uni-mp-loader/lib/babel/global-component-traverse.js @@ -24,10 +24,10 @@ module.exports = function (ast, state = {}) { const nameNode = args[0] const valueNode = args[1] if (!t.isStringLiteral(nameNode)) { - throw new Error(uniI18n.__('mpLoader.firstParameterNeedStaticString', { "0": "Vue.component()" })) + throw new Error(uniI18n.__('mpLoader.firstParameterNeedStaticString', { 0: 'Vue.component()' })) } if (!t.isIdentifier(valueNode)) { - throw new Error(uniI18n.__('mpLoader.requireTwoParameter', { "0": "Vue.component()" })) + throw new Error(uniI18n.__('mpLoader.requireTwoParameter', { 0: 'Vue.component()' })) } imports.push({ name: nameNode.value, diff --git a/packages/webpack-uni-mp-loader/lib/babel/util.js b/packages/webpack-uni-mp-loader/lib/babel/util.js index eef366b94..aee190271 100644 --- a/packages/webpack-uni-mp-loader/lib/babel/util.js +++ b/packages/webpack-uni-mp-loader/lib/babel/util.js @@ -35,7 +35,7 @@ function parseComponents (names, bindings, path) { }) => { const importDeclaration = findImportDeclaration(value, bindings) if (!importDeclaration) { - throw new Error(uniI18n.__('mpLoader.componentReferenceErrorOnlySupportImport', { "0": name })) + throw new Error(uniI18n.__('mpLoader.componentReferenceErrorOnlySupportImport', { 0: name })) } let source = importDeclaration.node.source.value if (process.UNI_LIBRARIES && process.UNI_LIBRARIES.includes(source)) { diff --git a/packages/webpack-uni-mp-loader/lib/main-new.js b/packages/webpack-uni-mp-loader/lib/main-new.js index f43efdb79..08b567531 100644 --- a/packages/webpack-uni-mp-loader/lib/main-new.js +++ b/packages/webpack-uni-mp-loader/lib/main-new.js @@ -97,7 +97,7 @@ createPage(Page) const babelLoader = findBabelLoader(this.loaders) if (!babelLoader) { - throw new Error(uniI18n.__('mpLoader.findFail', { "0": "babel-loader" })) + throw new Error(uniI18n.__('mpLoader.findFail', { 0: 'babel-loader' })) } else { addCreateApp(babelLoader) } diff --git a/packages/webpack-uni-mp-loader/lib/script-new.js b/packages/webpack-uni-mp-loader/lib/script-new.js index 4783ba1ac..adfe74955 100644 --- a/packages/webpack-uni-mp-loader/lib/script-new.js +++ b/packages/webpack-uni-mp-loader/lib/script-new.js @@ -126,7 +126,7 @@ module.exports = function (content, map) { const babelLoader = findBabelLoader(this.loaders) if (!babelLoader) { - callback(new Error(uniI18n.__('mpLoader.findFail', { "0": "babel-loader" })), content) + callback(new Error(uniI18n.__('mpLoader.findFail', { 0: 'babel-loader' })), content) } else { addDynamicImport(babelLoader, resourcePath, dynamicImports) diff --git a/packages/webpack-uni-pages-loader/lib/index-new.js b/packages/webpack-uni-pages-loader/lib/index-new.js index 554ab79fb..2e36528bd 100644 --- a/packages/webpack-uni-pages-loader/lib/index-new.js +++ b/packages/webpack-uni-pages-loader/lib/index-new.js @@ -112,7 +112,7 @@ module.exports = function (content, map) { if (!isAppView && jsonFile.name === 'manifest.json') { const content = JSON.parse(jsonFile.content) if (!content.launch_path && content.plus['uni-app'].nvueLaunchMode === 'fast') { - console.log(uniI18n.__('pagesLoader.nvueFirstPageStartModeIsFast', { "0": "https://ask.dcloud.net.cn/article/36749" })) + console.log(uniI18n.__('pagesLoader.nvueFirstPageStartModeIsFast', { 0: 'https://ask.dcloud.net.cn/article/36749' })) } } if (jsonFile.name === 'define-pages.js') { diff --git a/packages/webpack-uni-pages-loader/lib/platforms/mp.js b/packages/webpack-uni-pages-loader/lib/platforms/mp.js index 92503f4ea..1b804013d 100644 --- a/packages/webpack-uni-pages-loader/lib/platforms/mp.js +++ b/packages/webpack-uni-pages-loader/lib/platforms/mp.js @@ -42,7 +42,7 @@ const pagesJson2AppJson = { tabBar: function (name, value, json, fromJson) { if (value && value.list && value.list.length) { if (value.list.length < 2) { - console.error(uniI18n.__('pagesLoader.pagesTabbarMinItem2', { "0": "tabBar.list" })) + console.error(uniI18n.__('pagesLoader.pagesTabbarMinItem2', { 0: 'tabBar.list' })) } const pages = json.pages value.list.forEach((page, index) => { @@ -57,7 +57,7 @@ const pagesJson2AppJson = { }) => path === (page.pagePath + '.html')) ) ) { - console.error(uniI18n.__('pagesLoader.needInPagesNode', { "0": `pages.json tabBar['list'][${index}]['pagePath'] "${page.pagePath}"` })) + console.error(uniI18n.__('pagesLoader.needInPagesNode', { 0: `pages.json tabBar['list'][${index}]['pagePath'] "${page.pagePath}"` })) } } }) diff --git a/src/platforms/app-plus/service/api/media/choose-image.js b/src/platforms/app-plus/service/api/media/choose-image.js index ef8b6f311..5e9822eb7 100644 --- a/src/platforms/app-plus/service/api/media/choose-image.js +++ b/src/platforms/app-plus/service/api/media/choose-image.js @@ -81,22 +81,22 @@ export function chooseImage ({ // fix By Lxh 暂时添加拍照压缩逻辑,等客户端增加逻辑后修改 // 判断是否需要压缩 if (sizeType && sizeType.includes('compressed')) { - return getFileInfo(path).then(({size}) => { + return getFileInfo(path).then(({ size }) => { // 压缩阈值 0.5 兆 const THRESHOLD = 1024 * 1024 * 0.5 - return size && size > THRESHOLD - ? compressImage(path).then(dstPath => successCallback([dstPath])) - :successCallback([path]) + return size && size > THRESHOLD + ? compressImage(path).then(dstPath => successCallback([dstPath])) + : successCallback([path]) }).catch(errorCallback) } return successCallback([path]) }, - errorCallback, { - filename: TEMP_PATH + '/camera/', - resolution: 'high', - crop - }) + errorCallback, { + filename: TEMP_PATH + '/camera/', + resolution: 'high', + crop + }) } function openAlbum () { -- GitLab