提交 0b4bcfba 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -90,7 +90,11 @@ module.exports = {
},
getMPRuntimePath () {
if (process.env.UNI_USING_VUE3) {
return require.resolve('@dcloudio/uni-' + process.env.UNI_PLATFORM + '/dist/uni.mp.esm.js')
try {
return require.resolve('@dcloudio/uni-' + process.env.UNI_PLATFORM + '/dist/uni.mp.esm.js')
} catch (error) {
throw new Error('Vue3 项目暂不支持当前小程序')
}
}
return require.resolve('@dcloudio/uni-' + process.env.UNI_PLATFORM)
},
......
......@@ -195,6 +195,9 @@ module.exports = {
alias['@dcloudio/uni-app'] = require.resolve('@dcloudio/vue-cli-plugin-uni/packages/uni-app')
}
// 使用外层依赖的版本
alias['regenerator-runtime'] = require.resolve('regenerator-runtime')
return {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
entry () {
......
......@@ -78,11 +78,11 @@ function ModuleBuildError (err) {
builtinCompile = 'pug/jade'
}
if (builtinCompile) {
const autoInstall = supportAutoInstallPlugin()
autoInstall && sendSignal(name)
installHBuilderXPlugin(name)
return {
message: '预编译器错误:代码使用了' + builtinCompile +
'语言,但未安装相应的编译器插件,' + (autoInstall ? '正在从' : '请前往') + '插件市场安装该插件:\nhttps://ext.dcloud.net.cn/plugin?name=' +
'语言,但未安装相应的编译器插件,' + (supportAutoInstallPlugin() ? '正在从' : '请前往') +
'插件市场安装该插件:\nhttps://ext.dcloud.net.cn/plugin?name=' +
name
}
}
......@@ -98,10 +98,11 @@ function ModuleBuildError (err) {
}
function supportAutoInstallPlugin () {
return false
// 只要有 HBuilderX 版本号,就一定支持自动安装
return !!process.env.HX_Version
}
function sendSignal (lang) {
function installHBuilderXPlugin (lang) {
if (supportAutoInstallPlugin()) {
return console.error(
`%HXRunUniAPPPluginName%${lang}%HXRunUniAPPPluginName%`
......
......@@ -158,7 +158,7 @@ export function initPullToRefreshI18n (pullToRefresh) {
}
export function initTabBarI18n (tabBar) {
if (isEnableLocale()) {
if (isEnableLocale() && tabBar.list) {
tabBar.list.forEach(item => {
defineI18nProperty(item, ['text'])
})
......
......@@ -12,7 +12,7 @@
"uni.chooseVideo.cancel": "取消",
"uni.chooseVideo.sourceType.album": "从相册选择",
"uni.chooseVideo.sourceType.camera": "拍摄",
"uni.chooseFile.notUserActivation": "文件选择器对话框只能在用户激活时显示",
"uni.chooseFile.notUserActivation": "文件选择器对话框只能在用户激活时显示",
"uni.previewImage.cancel": "取消",
"uni.previewImage.button.save": "保存图像",
"uni.previewImage.save.success": "保存图像到相册成功",
......
......@@ -12,7 +12,7 @@
"uni.chooseVideo.cancel": "取消",
"uni.chooseVideo.sourceType.album": "從相冊選擇",
"uni.chooseVideo.sourceType.camera": "拍攝",
"uni.chooseFile.notUserActivation": "文件選擇器對話框只能在用戶激活時顯示",
"uni.chooseFile.notUserActivation": "文件選擇器對話框只能在用戶激活時顯示",
"uni.previewImage.cancel": "取消",
"uni.previewImage.button.save": "保存圖像",
"uni.previewImage.save.success": "保存圖像到相冊成功",
......
......@@ -446,15 +446,15 @@ export default {
callbackId
}) {
try {
if (__PLATFORM__ === 'app-plus' && compressed) {
const pako = require('pako')
data = pako.inflateRaw(data)
}
if (!height) {
height = Math.round(data.length / 4 / width)
}
const canvas = getTempCanvas(width, height)
const context = canvas.getContext('2d')
if (__PLATFORM__ === 'app-plus' && compressed) {
const pako = require('pako')
data = pako.inflateRaw(data)
}
context.putImageData(new ImageData(new Uint8ClampedArray(data), width, height), 0, 0)
this.$refs.canvas.getContext('2d').drawImage(canvas, x, y, width, height)
canvas.height = canvas.width = 0
......
......@@ -5,6 +5,8 @@ import {
import {
publish
} from '../../bridge'
const AUDIO_DEFAULT_CATEGORY = 'ambient'
const audios = {}
......@@ -12,7 +14,7 @@ const evts = ['play', 'canplay', 'ended', 'stop', 'waiting', 'seeking', 'seeked'
const publishAudioStateChange = (state, res = {}) => publish('onAudioStateChange', Object.assign({
state
}, res))
}, res))
const initStateChage = audioId => {
const audio = audios[audioId]
......@@ -51,7 +53,8 @@ export function createAudioInstance () {
const audio = audios[audioId] = plus.audio.createPlayer('')
audio.src = ''
audio.volume = 1
audio.startTime = 0
audio.startTime = 0
audio.setSessionCategory(AUDIO_DEFAULT_CATEGORY)
return {
errMsg: 'createAudioInstance:ok',
audioId
......@@ -78,7 +81,8 @@ export function setAudioState ({
autoplay = false,
loop = false,
obeyMuteSwitch,
volume
volume,
category = AUDIO_DEFAULT_CATEGORY
}) {
const audio = audios[audioId]
if (audio) {
......@@ -95,7 +99,10 @@ export function setAudioState ({
if (typeof volume === 'number') {
audio.volume = style.volume = volume
}
audio.setStyles(style)
audio.setStyles(style)
if (category) {
audio.setSessionCategory(category)
}
initStateChage(audioId)
}
return {
......
......@@ -9,7 +9,7 @@ export const sendHostEvent = sendNativeEvent
export function navigateToMiniProgram (data, callbackId) {
sendHostEvent(
'navigateToMiniProgram',
'navigateToUniMP',
data,
(res) => {
if (res.errMsg && res.errMsg.indexOf(':ok') === -1) {
......
......@@ -57,11 +57,9 @@ export function chooseFile ({
// TODO 用户取消选择时,触发 fail,目前尚未找到合适的方法。
})
if (interact.getStatus()) {
fileInput.click()
} else {
invoke(callbackId, {
errMsg: `chooseFile:fail ${t('uni.chooseFile.notUserActivation')}`
})
fileInput.click()
if (!interact.getStatus()) {
console.warn(`${t('uni.chooseFile.notUserActivation')}`)
}
}
......@@ -55,11 +55,9 @@ export function chooseImage ({
// TODO 用户取消选择时,触发 fail,目前尚未找到合适的方法。
})
if (interact.getStatus()) {
imageInput.click()
} else {
invoke(callbackId, {
errMsg: `chooseImage:fail ${t('uni.chooseFile.notUserActivation')}`
})
imageInput.click()
if (!interact.getStatus()) {
console.warn(`${t('uni.chooseFile.notUserActivation')}`)
}
}
......@@ -69,11 +69,9 @@ export function chooseVideo ({
// TODO 用户取消选择时,触发 fail,目前尚未找到合适的方法。
})
if (interact.getStatus()) {
videoInput.click()
} else {
invoke(callbackId, {
errMsg: `chooseVideo:fail ${t('uni.chooseFile.notUserActivation')}`
})
videoInput.click()
if (!interact.getStatus()) {
console.warn(`${t('uni.chooseFile.notUserActivation')}`)
}
}
......@@ -252,10 +252,9 @@ class AdScript {
this._cache = {}
}
load (data, success, fail) {
const provider = data.provider
load (provider, script, success, fail) {
if (this._cache[provider] === undefined) {
this.loadScript(data)
this.loadScript(script)
}
if (this._cache[provider] === 1) {
......@@ -271,12 +270,10 @@ class AdScript {
}
}
loadScript (data) {
const provider = data.provider
loadScript (provider, script) {
this._cache[provider] = 0
var ads = document.createElement('script')
ads.setAttribute('id', 'uniad_provider' + provider)
const script = data.script
for (const var1 in script) {
ads.setAttribute(var1, script[var1])
}
......@@ -298,6 +295,59 @@ class AdScript {
}
}
class AdTencent {
static get instance () {
if (this._instance == null) {
this._instance = new AdTencent()
}
return this._instance
}
constructor () {
this._instance = null
this._callback = {}
this._cache = {}
window.TencentGDT = window.TencentGDT || []
}
load (appid, placementid, success, fail) {
if (!this._callback[placementid]) {
this._callback[placementid] = []
}
this._callback[placementid].push({
success,
fail
})
if (!this._cache[placementid]) {
this._cache[placementid] = {
isReady: false
}
window.TencentGDT.push({
app_id: appid,
placement_id: placementid,
type: 'native',
count: 1,
onComplete: (res) => {
this._cache[placementid].isReady = true
this._callback[placementid].forEach(({ success, fail }) => {
if (res && Array.isArray(res) && res.length) {
success(res[0])
} else {
fail(res)
}
this._callback[placementid].length = 0
})
}
})
}
if (this._cache[placementid].isReady === true) {
window.TencentGDT.NATIVE.loadAd(placementid)
}
}
}
const CHECK_RENDER_DELAY = 1000
const CHECK_RENDER_RETRY = 5
const DEFAULT_WIDESCREEN_WIDTH = 750
......@@ -361,10 +411,12 @@ export default {
this._pi = 0
this._clearCheckTimer()
this.$refs.container.innerHTML = ''
this._isReady = false
},
_loadData (adpid) {
this._reset()
const aid = adpid || (this._isWidescreen ? this.adpidWidescreen : this.adpid)
const id = adpid || this.adpid
const aid = (this._isWidescreen ? (this.adpidWidescreen || id) : id)
AdConfig.instance.get(aid, (b, a) => {
this._b = b
this._pl = a
......@@ -379,26 +431,47 @@ export default {
}
const data = this._pl[this._pi]
const providerId = data.a1
this._b[providerId].provider = providerId
const providerConfig = this._b[data.a1][data.t]
AdScript.instance.load(this._b[providerId], () => {
this._renderAdView(this._b[providerId], data)
}, (err) => {
this.$trigger('error', {}, err)
})
},
_renderAdView (provider, data) {
var randomId = this._randomId()
if (data.a1 === '10011') {
AdTencent.instance.load(data.a3, data.a2, (res) => {
window.TencentGDT.NATIVE.renderAd(res, randomId)
})
this._startCheckTimer()
} else if (data.a1 === '10012') {
this._renderAdView(providerConfig, data, randomId)
} else {
AdScript.instance.load(data.t, providerConfig.script, () => {
this._renderAdView(providerConfig, data, randomId)
}, (err) => {
this.$trigger('error', {}, err)
})
}
},
_renderAdView (providerConfig, data, randomId) {
var adView = document.createElement('div')
adView.setAttribute('class', randomId)
adView.setAttribute('id', randomId)
this.$refs.container.innerHTML = ''
this.$refs.container.append(adView)
let bindThis = window
provider.s.split('.').reduce((total, currentValue) => {
bindThis = total
return total[currentValue]
}, window).bind(bindThis)(data.a2, randomId, 2)
if (data.a1 === '10011') {
} else if (data.a1 === '10012') {
var adScript = document.createElement('script')
const script = providerConfig.script
for (const var1 in script) {
adScript.setAttribute(var1, script[var1])
}
adView.appendChild(adScript)
} else {
let bindThis = window
providerConfig.s.split('.').reduce((total, currentValue) => {
bindThis = total
return total[currentValue]
}, window).bind(bindThis)(data.a2, randomId, 2)
}
this._startCheckTimer()
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册