diff --git a/packages/vue-cli-plugin-uni/lib/check-update.js b/packages/vue-cli-plugin-uni/lib/check-update.js index 5d327fa72873de0b009f3b53f0a354dd8760d56a..5e0779dfd30d97dbf6628b8440f5cdd7bf6f0e8e 100644 --- a/packages/vue-cli-plugin-uni/lib/check-update.js +++ b/packages/vue-cli-plugin-uni/lib/check-update.js @@ -13,12 +13,14 @@ class Upate { this._isAlpha = false this._uniId = '' this._appId = '' + this._wt = 0 + this._lc = '' + this._lcin = [] } get uniId () { return this._uniId } - set uniId (value) { this._uniId = value } @@ -26,7 +28,6 @@ class Upate { get appId () { return this._appId } - set appId (value) { this._appId = value } @@ -34,7 +35,6 @@ class Upate { get compilerVersion () { return this._compilerVersion } - set compilerVersion (value) { this._compilerVersion = value } @@ -42,11 +42,31 @@ class Upate { get isAlpha () { return this._isAlpha } - set isAlpha (value) { this._isAlpha = value } + get wt () { + return this._wt + } + set wt (value) { + this._wt = value + } + + get lc () { + return this._lc + } + set lc (value) { + this._lc = value + } + + get lcin () { + return this._lcin + } + set lcin (value) { + this._lcin = value + } + get versionType () { return (this.isAlpha ? 'a' : 'r') } @@ -156,6 +176,9 @@ class Upate { data.appid = this.uniId data.vtype = this.versionType data.vcode = this.compilerVersion + data.wt = this._wt + data.lc = this._lc + data.in = this._lcin delete data.lastCheck @@ -234,6 +257,28 @@ Object.assign(Upate.prototype, { DEFAULT_INTERVAL: 1000 * 60 * 60 * 24 }) +function getLc() { + let result = [] + const locale_dir = path.join(process.env.UNI_CLI_CONTEXT, 'src/locale') + if (!fs.existsSync(locale_dir)) { + return result + } + + let files = fs.readdirSync(locale_dir) + for (let i = files.length - 1; i >= 0; i--) { + let filePath = files[i] + let extName = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase() + if (extName !== 'json') { + continue + } + + if (files[i].indexOf('uni-app.') < 0) { + result.push(filePath.substring(0, filePath.lastIndexOf('.'))) + } + } + return result +} + module.exports = async function checkUpdate () { const { isInHBuilderX, @@ -255,6 +300,10 @@ module.exports = async function checkUpdate () { update.uniId = manifest.appid const appIdKey = process.env.UNI_PLATFORM.includes('quickapp') ? 'package' : 'appid' update.appId = manifest[process.env.UNI_PLATFORM] ? (manifest[process.env.UNI_PLATFORM][appIdKey] || '') : '' + const cf = manifest['mp-weixin'] ? manifest['mp-weixin']['cloudfunctionRoot'] : '' + update.wt = (cf && cf.length) ? 1 : 0 + update.lc = manifest['locale'] ? manifest['locale'] : '' + update.lcin = getLc().join(',') update.check() } catch (e) { }