提交 3b58ad6d 编写于 作者: d-u-a's avatar d-u-a

check update

上级 ccfb7f5a
...@@ -13,12 +13,14 @@ class Upate { ...@@ -13,12 +13,14 @@ class Upate {
this._isAlpha = false this._isAlpha = false
this._uniId = '' this._uniId = ''
this._appId = '' this._appId = ''
this._wt = 0
this._lc = ''
this._lcin = []
} }
get uniId () { get uniId () {
return this._uniId return this._uniId
} }
set uniId (value) { set uniId (value) {
this._uniId = value this._uniId = value
} }
...@@ -26,7 +28,6 @@ class Upate { ...@@ -26,7 +28,6 @@ class Upate {
get appId () { get appId () {
return this._appId return this._appId
} }
set appId (value) { set appId (value) {
this._appId = value this._appId = value
} }
...@@ -34,7 +35,6 @@ class Upate { ...@@ -34,7 +35,6 @@ class Upate {
get compilerVersion () { get compilerVersion () {
return this._compilerVersion return this._compilerVersion
} }
set compilerVersion (value) { set compilerVersion (value) {
this._compilerVersion = value this._compilerVersion = value
} }
...@@ -42,11 +42,31 @@ class Upate { ...@@ -42,11 +42,31 @@ class Upate {
get isAlpha () { get isAlpha () {
return this._isAlpha return this._isAlpha
} }
set isAlpha (value) { set isAlpha (value) {
this._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 () { get versionType () {
return (this.isAlpha ? 'a' : 'r') return (this.isAlpha ? 'a' : 'r')
} }
...@@ -156,6 +176,9 @@ class Upate { ...@@ -156,6 +176,9 @@ class Upate {
data.appid = this.uniId data.appid = this.uniId
data.vtype = this.versionType data.vtype = this.versionType
data.vcode = this.compilerVersion data.vcode = this.compilerVersion
data.wt = this._wt
data.lc = this._lc
data.in = this._lcin
delete data.lastCheck delete data.lastCheck
...@@ -234,6 +257,28 @@ Object.assign(Upate.prototype, { ...@@ -234,6 +257,28 @@ Object.assign(Upate.prototype, {
DEFAULT_INTERVAL: 1000 * 60 * 60 * 24 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 () { module.exports = async function checkUpdate () {
const { const {
isInHBuilderX, isInHBuilderX,
...@@ -255,6 +300,10 @@ module.exports = async function checkUpdate () { ...@@ -255,6 +300,10 @@ module.exports = async function checkUpdate () {
update.uniId = manifest.appid update.uniId = manifest.appid
const appIdKey = process.env.UNI_PLATFORM.includes('quickapp') ? 'package' : 'appid' const appIdKey = process.env.UNI_PLATFORM.includes('quickapp') ? 'package' : 'appid'
update.appId = manifest[process.env.UNI_PLATFORM] ? (manifest[process.env.UNI_PLATFORM][appIdKey] || '') : '' 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() update.check()
} catch (e) { } catch (e) {
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册