提交 bb075ada 编写于 作者: Q qiang

Merge tag 'v2.0.0-31920210609001'

v2.0.0-31920210609001

# Conflicts:
#	packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js
......@@ -13,6 +13,8 @@ const {
generateApiManifest
} = require('./manifest')
const fixInnerHTML = require('./fixInnerHTML')
const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd(), {
inlineOptions: require('./vue.config.js')
})
......@@ -53,6 +55,9 @@ service.run('build', {
JSON.parse(JSON.stringify(process.UNI_SERVICE_API_PROTOCOL))
)
}
if (process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_VIEW === 'true' && process.env.UNI_WATCH !== 'true') {
fixInnerHTML()
}
}).catch(err => {
error(err)
process.exit(1)
......@@ -85,4 +90,4 @@ if (process.env.UNI_PLATFORM === 'h5' && process.env.UNI_WATCH === 'false') {
.catch(err => {
throw err
})
}
}
const path = require('path')
const fs = require('fs')
module.exports = function () {
const files = [
path.join(__dirname, '../packages/uni-app-plus/dist/view.umd.min.js'),
path.join(__dirname, '../packages/uni-app-plus/template/v3/__uniappquill.js'),
path.join(__dirname, '../packages/uni-app-plus/template/v3/__uniappquillimageresize.js')
]
files.forEach(filePath => {
const fileContent = fs.readFileSync(filePath, {
encoding: 'utf8'
})
fs.writeFileSync(filePath, fileContent.replace(/\.innerHTML\b/g, '["inner"+"HTML"]'), {
encoding: 'utf8'
})
})
}
......@@ -256,14 +256,14 @@ export default {
|参数名 |类型 |说明 |平台差异说明|
|:- |:- |:- ||
|orientation|string |画面方向 |微信小程序|
|type |string |视频格式 |微信小程序|
|duration |number |视频长度 |微信小程序、App、H5|
|size |number |视频大小,单位 kB |微信小程序、App、H5|
|height |number |视频的长,单位 px |微信小程序、App、H5|
|width |number |视频的宽,单位 px |微信小程序、App、H5|
|fps |number |视频帧率 |微信小程序、App|
|bitrate |number |视频码率,单位 kbps|微信小程序|
|orientation|string |画面方向 |微信小程序、App(3.1.14+)|
|type |string |视频格式 |微信小程序、App(3.1.14+)|
|duration |number |视频长度 |微信小程序、App(3.1.10+)、H5|
|size |number |视频大小,单位 kB |微信小程序、App(3.1.10+)、H5|
|height |number |视频的长,单位 px |微信小程序、App(3.1.10+)、H5|
|width |number |视频的宽,单位 px |微信小程序、App(3.1.10+)、H5|
|fps |number |视频帧率 |微信小程序、App(3.1.14+)|
|bitrate |number |视频码率,单位 kbps|微信小程序、App(3.1.14+)|
**res.orientation参数说明**
......
......@@ -12,6 +12,9 @@ H5平台登录注意事项:
- 普通浏览器上实现微信登录,并非开放API,需要向微信申请,仅个别开发者有此权限
- H5平台的其他登录,比如QQ登录、微博登录,uni-app未封装,请在条件编译里按普通H5写法编写。
百度小程序登录注意事项:
- 百度小程序平台需要在button组件的@login事件后再调用 uni.login ,[详见](https://smartprogram.baidu.com/docs/develop/function/login/),否则会返回“请登录”的错误信息,建议在@login事件中调用。
**OBJECT 参数说明**
|参数名|类型|必填|说明|平台差异说明|
......
......@@ -14,7 +14,7 @@
|backgroundColor|Color |#EBEBEB |未选择的进度条的颜色 | |
|active |Boolean |false |进度条从左往右的动画 | |
|active-mode |String |backwards |backwards: 动画从头播;forwards:动画从上次结束点接着播|App、H5、微信小程序、QQ小程序 |
|duration|number|30|进度增加1%所需毫秒数|App-nvue2.6.1+、微信基础库2.8.2+|
|duration|number|30|进度增加1%所需毫秒数|App-nvue2.6.1+、微信基础库2.8.2+、H5 3.1.11+|
|@activeend |EventHandle| |动画完成事件 |微信小程序 |
**示例** [查看演示](https://hellouniapp.dcloud.net.cn/pages/component/progress/progress)
......
......@@ -12,5 +12,5 @@
"message": "chore(release): publish %s"
}
},
"version": "2.0.0-31920210422002"
"version": "2.0.0-31920210609001"
}
......@@ -214,6 +214,7 @@ const third = [
'login',
'checkSession',
'getUserInfo',
'getUserProfile',
'preLogin',
'closeAuthView',
'share',
......@@ -240,8 +241,9 @@ const third = [
const ad = [
'createRewardedVideoAd',
'createFullScreenVideoAd',
'createInterstitialAd'
'createFullScreenVideoAd',
'createInterstitialAd',
'createInteractiveAd'
]
const apis = [
......
......@@ -206,6 +206,7 @@
"uni.login": true,
"uni.checkSession": true,
"uni.getUserInfo": true,
"uni.getUserProfile": true,
"uni.share": true,
"uni.showShareMenu": true,
"uni.hideShareMenu": true,
......@@ -223,7 +224,8 @@
"title": "广告",
"apiList": {
"uni.createRewardedVideoAd": true,
"uni.createFullScreenVideoAd": true,
"uni.'createInterstitialAd'": true
"uni.createFullScreenVideoAd": true,
"uni.'createInterstitialAd'": true,
"uni.'createInteractiveAd'": true
}
}]
{
"name": "@dcloudio/uni-app-plus-nvue",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app app-plus-nvue",
"main": "dist/index.js",
"repository": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
import Vue from 'vue';
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
function getCurrentUserInfo () {
const token = ( uni ).getStorageSync('uni_id_token') || '';
const tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
}
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo
}
function uniIdMixin (Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {
const {
role
} = getCurrentUserInfo();
return role.indexOf(roleId) > -1
};
Vue.prototype.uniIDHasPermission = function (permissionId) {
const {
permission
} = getCurrentUserInfo();
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
};
Vue.prototype.uniIDTokenValid = function () {
const {
tokenExpired
} = getCurrentUserInfo();
return tokenExpired > Date.now()
};
}
const _toString = Object.prototype.toString;
const hasOwnProperty = Object.prototype.hasOwnProperty;
......@@ -1292,6 +1342,7 @@ function parseBaseApp (vm, {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "app-plus";
......@@ -1750,10 +1801,10 @@ canIUses.forEach(canIUseApi => {
}
});
let uni = {};
let uni$1 = {};
if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') {
uni = new Proxy({}, {
uni$1 = new Proxy({}, {
get (target, name) {
if (hasOwn(target, name)) {
return target[name]
......@@ -1779,27 +1830,27 @@ if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') {
});
} else {
Object.keys(baseApi).forEach(name => {
uni[name] = baseApi[name];
uni$1[name] = baseApi[name];
});
Object.keys(eventApi).forEach(name => {
uni[name] = eventApi[name];
uni$1[name] = eventApi[name];
});
Object.keys(api).forEach(name => {
uni[name] = promisify(name, api[name]);
uni$1[name] = promisify(name, api[name]);
});
Object.keys(wx).forEach(name => {
if (hasOwn(wx, name) || hasOwn(protocols, name)) {
uni[name] = promisify(name, wrapper(name, wx[name]));
uni$1[name] = promisify(name, wrapper(name, wx[name]));
}
});
}
{
if (typeof global !== 'undefined') {
global.uni = uni;
global.uni = uni$1;
global.UniEmitter = eventApi;
}
}
......@@ -1810,7 +1861,7 @@ wx.createComponent = createComponent;
wx.createSubpackageApp = createSubpackageApp;
wx.createPlugin = createPlugin;
var uni$1 = uni;
var uni$2 = uni$1;
export default uni$1;
export default uni$2;
export { createApp, createComponent, createPage, createPlugin, createSubpackageApp };
......@@ -225,6 +225,7 @@ var serviceContext = (function () {
'login',
'checkSession',
'getUserInfo',
'getUserProfile',
'preLogin',
'closeAuthView',
'share',
......@@ -251,8 +252,9 @@ var serviceContext = (function () {
const ad = [
'createRewardedVideoAd',
'createFullScreenVideoAd',
'createInterstitialAd'
'createFullScreenVideoAd',
'createInterstitialAd',
'createInteractiveAd'
];
const apis = [
......@@ -286,6 +288,56 @@ var serviceContext = (function () {
window.addEventListener('test-passive', null, opts);
} catch (e) {}
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
function getCurrentUserInfo () {
const token = ( uni ).getStorageSync('uni_id_token') || '';
const tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
}
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo
}
function uniIdMixin (Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {
const {
role
} = getCurrentUserInfo();
return role.indexOf(roleId) > -1
};
Vue.prototype.uniIDHasPermission = function (permissionId) {
const {
permission
} = getCurrentUserInfo();
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
};
Vue.prototype.uniIDTokenValid = function () {
const {
tokenExpired
} = getCurrentUserInfo();
return tokenExpired > Date.now()
};
}
const _toString = Object.prototype.toString;
const hasOwnProperty = Object.prototype.hasOwnProperty;
......@@ -1630,10 +1682,13 @@ var serviceContext = (function () {
function getRealPath (filePath) {
if (filePath.indexOf('/') === 0) {
if (filePath.indexOf('//') === 0) {
filePath = 'https:' + filePath;
} else {
return addBase(filePath.substr(1))
return 'https:' + filePath
}
// 平台绝对路径 安卓、iOS
if (filePath.startsWith('/storage/') || filePath.includes('/Containers/Data/Application/')) {
return 'file://' + filePath
}
return addBase(filePath.substr(1))
}
// 网络资源或base64
if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf('blob:') === 0) {
......@@ -3851,7 +3906,7 @@ var serviceContext = (function () {
// 无协议的情况补全 https
if (filePath.indexOf('//') === 0) {
filePath = 'https:' + filePath;
return 'https:' + filePath
}
// 网络资源或base64
......@@ -3866,6 +3921,10 @@ var serviceContext = (function () {
const wwwPath = 'file://' + _handleLocalPath('_www');
// 绝对路径转换为本地文件系统路径
if (filePath.indexOf('/') === 0) {
// 平台绝对路径 安卓、iOS
if (filePath.startsWith('/storage/') || filePath.includes('/Containers/Data/Application/')) {
return 'file://' + filePath
}
return wwwPath + filePath
}
// 相对资源
......@@ -6756,7 +6815,7 @@ var serviceContext = (function () {
}, () => {
resolve(tempFilePath);
});
}) : Promise.resolve();
}) : Promise.resolve(tempFilePath);
if (compressed) {
plus.nativeUI.showWaiting();
}
......@@ -6777,7 +6836,7 @@ var serviceContext = (function () {
result.height = videoInfo.height;
invoke$1(callbackId, result);
},
errorCallback
fail: errorCallback
});
});
}
......@@ -6866,11 +6925,14 @@ var serviceContext = (function () {
return options
}, data => {
return {
orientation: data.orientation,
type: data.type,
duration: data.duration,
fps: data.fps || 30,
size: data.size,
height: data.height,
width: data.width,
size: data.size
fps: data.fps || 30,
bitrate: data.bitrate
}
});
......@@ -7165,6 +7227,7 @@ var serviceContext = (function () {
responseType,
sslVerify = true,
firstIpv4 = false,
tls,
timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.request) || 60 * 1000
} = {}) {
const stream = requireNativePlugin('stream');
......@@ -7218,7 +7281,8 @@ var serviceContext = (function () {
timeout: timeout || 6e5,
// 配置和weex模块内相反
sslVerify: !sslVerify,
firstIpv4: firstIpv4
firstIpv4: firstIpv4,
tls
};
if (method !== 'GET') {
options.body = typeof data === 'string' ? data : JSON.stringify(data);
......@@ -7623,7 +7687,7 @@ var serviceContext = (function () {
authResult: authResult,
errMsg: 'login:ok'
});
}, errorCallback, provider === 'apple' ? { scope: 'email' } : { univerifyStyle: params.univerifyStyle } || {});
}, errorCallback, provider === 'apple' ? { scope: 'email' } : { univerifyStyle: univerifyButtonsClickHandling(params.univerifyStyle, errorCallback) } || {});
}
// 先注销再登录
// apple登录logout之后无法重新触发获取email,fullname;一键登录无logout
......@@ -7691,6 +7755,12 @@ var serviceContext = (function () {
});
});
}
/**
* 获取用户信息-兼容
*/
function getUserProfile (params, callbackId) {
return getUserInfo(params, callbackId)
}
/**
* 获取用户信息
......@@ -7714,7 +7784,30 @@ var serviceContext = (function () {
}
function closeAuthView () {
getService('univerify').then(service => service.closeAuthView());
return getService('univerify').then(service => service.closeAuthView())
}
/**
* 一键登录自定义登陆按钮点击处理
*/
function univerifyButtonsClickHandling (univerifyStyle, errorCallback) {
if (univerifyStyle && isPlainObject(univerifyStyle) && univerifyStyle.buttons &&
Object.prototype.toString.call(univerifyStyle.buttons.list) === '[object Array]' &&
univerifyStyle.buttons.list.length > 0
) {
univerifyStyle.buttons.list.forEach((button, index) => {
univerifyStyle.buttons.list[index].onclick = function () {
closeAuthView().then(() => {
errorCallback({
code: '30008',
message: '用户点击了自定义按钮',
index
});
});
};
});
}
return univerifyStyle
}
function requestPayment (params, callbackId) {
......@@ -10778,7 +10871,6 @@ var serviceContext = (function () {
ad.onLoad((e) => {
this._isLoaded = true;
this._isLoading = false;
this._dispatchEvent(eventTypes.load, {});
if (this._loadPromiseResolve != null) {
this._loadPromiseResolve();
......@@ -10789,6 +10881,8 @@ var serviceContext = (function () {
this._showPromiseResolve = null;
this._showAd();
}
this._dispatchEvent(eventTypes.load, {});
});
ad.onClose((e) => {
this._isLoaded = false;
......@@ -10811,17 +10905,17 @@ var serviceContext = (function () {
this._dispatchEvent(eventTypes.error, data);
const promiseError = new Error(JSON.stringify(this._adError));
promiseError.code = e.code;
promiseError.errMsg = e.message;
const error = new Error(JSON.stringify(this._adError));
error.code = e.code;
error.errMsg = e.message;
if (this._loadPromiseReject != null) {
this._loadPromiseReject(promiseError);
this._loadPromiseReject(error);
this._loadPromiseReject = null;
}
if (this._showPromiseReject != null) {
this._showPromiseReject(promiseError);
this._showPromiseReject(error);
this._showPromiseReject = null;
}
});
......@@ -10906,7 +11000,7 @@ var serviceContext = (function () {
constructor (options = {}) {
super(plus.ad.createInterstitialAd(options), options);
this.load();
this._loadAd();
}
}
......@@ -10914,6 +11008,255 @@ var serviceContext = (function () {
return new InterstitialAd(options)
}
const sdkCache = {};
const sdkQueue = {};
function initSDK (options) {
const provider = options.provider;
if (!sdkCache[provider]) {
sdkCache[provider] = {};
}
if (typeof sdkCache[provider].plugin === 'object') {
options.success(sdkCache[provider].plugin);
return
}
if (!sdkQueue[provider]) {
sdkQueue[provider] = [];
}
sdkQueue[provider].push(options);
if (sdkCache[provider].status === true) {
options.__plugin = sdkCache[provider].plugin;
return
}
sdkCache[provider].status = true;
const plugin = requireNativePlugin(provider);
if (!plugin || !plugin.initSDK) {
sdkQueue[provider].forEach((item) => {
item.fail({
code: -1,
message: 'provider [' + provider + '] invalid'
});
});
sdkQueue[provider].length = 0;
sdkCache[provider].status = false;
return
}
// TODO
sdkCache[provider].plugin = plugin;
options.__plugin = plugin;
plugin.initSDK((res) => {
const isSuccess = (res.code === 1 || res.code === '1');
if (isSuccess) {
sdkCache[provider].plugin = plugin;
} else {
sdkCache[provider].status = false;
}
sdkQueue[provider].forEach((item) => {
if (isSuccess) {
item.success(item.__plugin);
} else {
item.fail(res);
}
});
sdkQueue[provider].length = 0;
});
}
class InteractiveAd {
constructor (options) {
const _callbacks = this._callbacks = {};
eventNames$1.forEach(item => {
_callbacks[item] = [];
const name = item[0].toUpperCase() + item.substr(1);
this[`on${name}`] = function (callback) {
_callbacks[item].push(callback);
};
});
this._ad = null;
this._adError = '';
this._adpid = options.adpid;
this._provider = options.provider;
this._userData = options.userData;
this._isLoaded = false;
this._isLoading = false;
this._loadPromiseResolve = null;
this._loadPromiseReject = null;
this._showPromiseResolve = null;
this._showPromiseReject = null;
setTimeout(() => {
this._init();
});
}
_init () {
this._adError = '';
initSDK({
provider: this._provider,
success: (res) => {
this._ad = res;
if (this._userData) {
this.bindUserData(this._userData);
}
this._loadAd();
},
fail: (err) => {
this._adError = err;
this._dispatchEvent(eventTypes.error, err);
}
});
}
getProvider () {
return this._provider
}
load () {
return new Promise((resolve, reject) => {
this._loadPromiseResolve = resolve;
this._loadPromiseReject = reject;
if (this._isLoading) {
return
}
if (this._adError) {
this._init();
return
}
if (this._isLoaded) {
resolve();
} else {
this._loadAd();
}
})
}
show () {
return new Promise((resolve, reject) => {
this._showPromiseResolve = resolve;
this._showPromiseReject = reject;
if (this._isLoading) {
return
}
if (this._adError) {
this._init();
return
}
if (this._isLoaded) {
this._showAd();
resolve();
} else {
this._loadAd();
}
})
}
destroy () {
if (this._ad !== null && this._ad.destroy) {
this._ad.destroy({
adpid: this._adpid
});
}
}
bindUserData (data) {
if (this._ad !== null) {
this._ad.bindUserData(data);
}
}
_loadAd () {
if (this._ad !== null) {
if (this._isLoading === true) {
return
}
this._isLoading = true;
this._ad.loadData({
adpid: this._adpid
}, (res) => {
this._isLoaded = true;
this._isLoading = false;
if (this._loadPromiseResolve != null) {
this._loadPromiseResolve();
this._loadPromiseResolve = null;
}
if (this._showPromiseResolve != null) {
this._showPromiseResolve();
this._showPromiseResolve = null;
this._showAd();
}
this._dispatchEvent(eventTypes.load, res);
}, (err) => {
this._isLoading = false;
if (this._showPromiseReject != null) {
this._showPromiseReject(this._createError(err));
this._showPromiseReject = null;
}
this._dispatchEvent(eventTypes.error, err);
});
}
}
_showAd () {
if (this._ad !== null && this._isLoaded === true) {
this._ad.show({
adpid: this._adpid
}, (res) => {
this._isLoaded = false;
}, (err) => {
this._isLoaded = false;
if (this._showPromiseReject != null) {
this._showPromiseReject(this._createError(err));
this._showPromiseReject = null;
}
this._dispatchEvent(eventTypes.error, err);
});
}
}
_createError (err) {
const error = new Error(JSON.stringify(err));
error.code = err.code;
error.errMsg = err.message;
return error
}
_dispatchEvent (name, data) {
this._callbacks[name].forEach(callback => {
if (typeof callback === 'function') {
callback(data || {});
}
});
}
}
function createInteractiveAd (options) {
if (!options.provider) {
return new Error('provider invalid')
}
if (!options.adpid) {
return new Error('adpid invalid')
}
return new InteractiveAd(options)
}
var api = /*#__PURE__*/Object.freeze({
__proto__: null,
startPullDownRefresh: startPullDownRefresh,
......@@ -11020,6 +11363,7 @@ var serviceContext = (function () {
getProvider: getProvider$1,
login: login,
getUserInfo: getUserInfo,
getUserProfile: getUserProfile,
operateWXData: operateWXData,
preLogin: preLogin$1,
closeAuthView: closeAuthView,
......@@ -11076,7 +11420,8 @@ var serviceContext = (function () {
requestComponentInfo: requestComponentInfo$2,
createRewardedVideoAd: createRewardedVideoAd,
createFullScreenVideoAd: createFullScreenVideoAd,
createInterstitialAd: createInterstitialAd
createInterstitialAd: createInterstitialAd,
createInteractiveAd: createInteractiveAd
});
var platformApi = Object.assign(Object.create(null), api, eventApis);
......@@ -22096,6 +22441,8 @@ var serviceContext = (function () {
initPolyfill(Vue);
uniIdMixin(Vue);
Vue.prototype.getOpenerEventChannel = function () {
if (!this.$root.$scope.eventChannel) {
this.$root.$scope.eventChannel = new EventChannel();
......
此差异已折叠。
{
"name": "@dcloudio/uni-app-plus",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app app-plus",
"main": "dist/index.js",
"repository": {
......@@ -17,5 +17,5 @@
"name": "app-plus",
"title": "APP-PLUS"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
{
"name": "@dcloudio/uni-automator",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app automator",
"main": "dist/index.js",
"repository": {
......@@ -30,5 +30,5 @@
"node-simctl": "^6.1.0",
"puppeteer": "^3.0.1"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
......@@ -314,7 +314,7 @@ export default {
db = db.action(action)
}
db.collection(this.collection).add(value).then((res) => {
db.collection(this._getCollection()).add(value).then((res) => {
success && success(res)
if (showToast) {
uni.showToast({
......@@ -388,7 +388,7 @@ export default {
db = db.action(action)
}
return db.collection(this.collection).doc(id).update(value).then((res) => {
return db.collection(this._getCollection()).doc(id).update(value).then((res) => {
success && success(res)
if (showToast) {
uni.showToast({
......@@ -546,7 +546,7 @@ export default {
exec = exec.action(action)
}
exec.collection(this.collection).where({
exec.collection(this._getCollection()).where({
_id: dbCmd.in(ids)
}).remove().then((res) => {
success && success(res.result)
......@@ -570,6 +570,11 @@ export default {
complete && complete()
})
},
_getCollection() {
const index = this.collection.indexOf(',')
const collection = index > 0 ? this.collection.substring(0, index) : this.collection
return collection
},
removeData (ids) {
const il = ids.slice(0)
const dl = this.dataList
......
{
"name": "@dcloudio/uni-cli-shared",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-cli-shared",
"main": "lib/index.js",
"repository": {
......@@ -23,5 +23,5 @@
"postcss-urlrewrite": "^0.2.2",
"strip-json-comments": "^2.0.1"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
{
"name": "@dcloudio/uni-h5-ui",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app h5 ui",
"main": "dist/index.umd.min.js",
"repository": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
此差异已折叠。
{
"name": "@dcloudio/uni-h5",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app h5",
"main": "dist/index.umd.min.js",
"repository": {
......@@ -25,5 +25,5 @@
"title": "H5",
"main": "lib/h5/uni.config.js"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
{
"name": "@dcloudio/uni-i18n",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "@dcloudio/uni-i18n",
"main": "dist/uni-i18n.cjs.js",
"module": "dist/uni-i18n.esm.js",
......@@ -17,5 +17,6 @@
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/dcloudio/uni-app/issues"
}
},
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
{
"name": "@dcloudio/uni-migration",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app migration",
"main": "lib/index.js",
"repository": {
......@@ -20,7 +20,7 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed",
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121",
"dependencies": {
"commander": "^4.0.1",
"fs-extra": "^8.1.0",
......
import Vue from 'vue';
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
function getCurrentUserInfo () {
const token = ( my).getStorageSync('uni_id_token') || '';
const tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
}
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo
}
function uniIdMixin (Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {
const {
role
} = getCurrentUserInfo();
return role.indexOf(roleId) > -1
};
Vue.prototype.uniIDHasPermission = function (permissionId) {
const {
permission
} = getCurrentUserInfo();
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
};
Vue.prototype.uniIDTokenValid = function () {
const {
tokenExpired
} = getCurrentUserInfo();
return tokenExpired > Date.now()
};
}
const _toString = Object.prototype.toString;
const hasOwnProperty = Object.prototype.hasOwnProperty;
......@@ -930,6 +980,23 @@ const protocols = { // 需要做转换的 API 列表
};
}
},
getUserProfile: {
name: my.canIUse('getOpenUserInfo') ? 'getOpenUserInfo' : 'getAuthUserInfo',
returnValue (result) {
if (my.canIUse('getOpenUserInfo')) {
let response = {};
try {
response = JSON.parse(result.response).response;
} catch (e) {}
result.nickName = response.nickName;
result.avatar = response.avatar;
}
result.userInfo = {
nickName: result.nickName,
avatarUrl: result.avatar
};
}
},
requestPayment: {
name: 'tradePay',
args: {
......@@ -1982,6 +2049,7 @@ function parseBaseApp (vm, {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-alipay";
......
{
"name": "@dcloudio/uni-mp-alipay",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app mp-alipay",
"main": "dist/index.js",
"repository": {
......@@ -17,5 +17,5 @@
"name": "mp-alipay",
"title": "支付宝小程序"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
import Vue from 'vue';
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
function getCurrentUserInfo () {
const token = ( swan).getStorageSync('uni_id_token') || '';
const tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
}
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo
}
function uniIdMixin (Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {
const {
role
} = getCurrentUserInfo();
return role.indexOf(roleId) > -1
};
Vue.prototype.uniIDHasPermission = function (permissionId) {
const {
permission
} = getCurrentUserInfo();
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
};
Vue.prototype.uniIDTokenValid = function () {
const {
tokenExpired
} = getCurrentUserInfo();
return tokenExpired > Date.now()
};
}
const _toString = Object.prototype.toString;
const hasOwnProperty = Object.prototype.hasOwnProperty;
......@@ -560,6 +610,13 @@ var getSystemInfo = {
}
};
const oName = 'getUserInfo';
const nName = 'getUserProfile';
var getUserProfile = {
name: swan.canIUse(nName) ? nName : oName
};
// 不支持的 API 列表
const todos = [
'preloadPage',
......@@ -646,6 +703,7 @@ const protocols = {
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo,
getUserProfile,
getRecorderManager: {
returnValue (fromRet) {
fromRet.onFrameRecorded = createTodoMethod('RecorderManager', 'onFrameRecorded');
......@@ -679,6 +737,9 @@ const protocols = {
getAccountInfoSync: {
name: 'getEnvInfoSync',
returnValue: _handleEnvInfo
},
login: {
name: 'getLoginCode'
}
};
......@@ -1675,6 +1736,7 @@ function parseBaseApp (vm, {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-baidu";
......
{
"name": "@dcloudio/uni-mp-baidu",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app mp-baidu",
"main": "dist/index.js",
"repository": {
......@@ -17,5 +17,5 @@
"name": "mp-baidu",
"title": "百度小程序"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
import Vue from 'vue';
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
function getCurrentUserInfo () {
const token = ( ks).getStorageSync('uni_id_token') || '';
const tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
}
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo
}
function uniIdMixin (Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {
const {
role
} = getCurrentUserInfo();
return role.indexOf(roleId) > -1
};
Vue.prototype.uniIDHasPermission = function (permissionId) {
const {
permission
} = getCurrentUserInfo();
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
};
Vue.prototype.uniIDTokenValid = function () {
const {
tokenExpired
} = getCurrentUserInfo();
return tokenExpired > Date.now()
};
}
const _toString = Object.prototype.toString;
const hasOwnProperty = Object.prototype.hasOwnProperty;
......@@ -560,12 +610,20 @@ var getSystemInfo = {
}
};
const oName = 'getUserInfo';
const nName = 'getUserProfile';
var getUserProfile = {
name: ks.canIUse(nName) ? nName : oName
};
const protocols = {
navigateTo,
redirectTo,
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo
getSystemInfoSync: getSystemInfo,
getUserProfile
};
const todos = [
'vibrate'
......@@ -1427,6 +1485,7 @@ function parseBaseApp (vm, {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-kuaishou";
......
{
"name": "@dcloudio/uni-mp-kuaishou",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app mp-kuaishou",
"main": "dist/index.js",
"repository": {
......@@ -17,5 +17,5 @@
"name": "mp-kuaishou",
"title": "快手小程序"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
import Vue from 'vue';
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
function getCurrentUserInfo () {
const token = ( wx).getStorageSync('uni_id_token') || '';
const tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
}
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo
}
function uniIdMixin (Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {
const {
role
} = getCurrentUserInfo();
return role.indexOf(roleId) > -1
};
Vue.prototype.uniIDHasPermission = function (permissionId) {
const {
permission
} = getCurrentUserInfo();
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
};
Vue.prototype.uniIDTokenValid = function () {
const {
tokenExpired
} = getCurrentUserInfo();
return tokenExpired > Date.now()
};
}
const _toString = Object.prototype.toString;
const hasOwnProperty = Object.prototype.hasOwnProperty;
......@@ -560,12 +610,20 @@ var getSystemInfo = {
}
};
const oName = 'getUserInfo';
const nName = 'getUserProfile';
var getUserProfile = {
name: wx.canIUse(nName) ? nName : oName
};
const protocols = {
navigateTo,
redirectTo,
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo
getSystemInfoSync: getSystemInfo,
getUserProfile
};
const todos = [
'preloadPage',
......@@ -1588,6 +1646,7 @@ function parseBaseApp (vm, {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-qq";
......
{
"name": "@dcloudio/uni-mp-qq",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app mp-qq",
"main": "dist/index.js",
"repository": {
......@@ -17,5 +17,5 @@
"name": "mp-qq",
"title": "QQ小程序"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
import Vue from 'vue';
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
function getCurrentUserInfo () {
const token = ( tt).getStorageSync('uni_id_token') || '';
const tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
}
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo
}
function uniIdMixin (Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {
const {
role
} = getCurrentUserInfo();
return role.indexOf(roleId) > -1
};
Vue.prototype.uniIDHasPermission = function (permissionId) {
const {
permission
} = getCurrentUserInfo();
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
};
Vue.prototype.uniIDTokenValid = function () {
const {
tokenExpired
} = getCurrentUserInfo();
return tokenExpired > Date.now()
};
}
const _toString = Object.prototype.toString;
const hasOwnProperty = Object.prototype.hasOwnProperty;
......@@ -560,6 +610,13 @@ var getSystemInfo = {
}
};
const oName = 'getUserInfo';
const nName = 'getUserProfile';
var getUserProfile = {
name: tt.canIUse(nName) ? nName : oName
};
// 不支持的 API 列表
const todos = [
'preloadPage',
......@@ -664,6 +721,7 @@ const protocols = {
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo,
getUserProfile,
connectSocket: {
args: {
method: false
......@@ -1680,6 +1738,7 @@ function parseBaseApp (vm, {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-toutiao";
......
{
"name": "@dcloudio/uni-mp-toutiao",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app mp-toutiao",
"main": "dist/index.js",
"repository": {
......@@ -17,5 +17,5 @@
"name": "mp-toutiao",
"title": "字节跳动小程序"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
{
"name": "@dcloudio/uni-mp-vue",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "@dcloudio/uni-mp-vue",
"main": "dist/vue.runtime.esm.js",
"module": "dist/vue.runtime.esm.js",
......@@ -23,5 +23,5 @@
"bugs": {
"url": "https://github.com/dcloudio/uni-app/issues"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
import Vue from 'vue';
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
function getCurrentUserInfo () {
const token = ( wx).getStorageSync('uni_id_token') || '';
const tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
}
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo
}
function uniIdMixin (Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {
const {
role
} = getCurrentUserInfo();
return role.indexOf(roleId) > -1
};
Vue.prototype.uniIDHasPermission = function (permissionId) {
const {
permission
} = getCurrentUserInfo();
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
};
Vue.prototype.uniIDTokenValid = function () {
const {
tokenExpired
} = getCurrentUserInfo();
return tokenExpired > Date.now()
};
}
const _toString = Object.prototype.toString;
const hasOwnProperty = Object.prototype.hasOwnProperty;
......@@ -1345,6 +1395,7 @@ function parseBaseApp (vm, {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "mp-weixin";
......
{
"name": "@dcloudio/uni-mp-weixin",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app mp-weixin",
"main": "dist/index.js",
"repository": {
......@@ -17,5 +17,5 @@
"name": "mp-weixin",
"title": "微信小程序"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
{
"name": "@dcloudio/uni-quickapp-native",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app quickapp-native",
"main": "dist/vue.prod.js",
"repository": {
......@@ -19,7 +19,7 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed",
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121",
"uni-app": {
"name": "quickapp-native",
"title": "快应用(Native)版"
......
import Vue from 'vue';
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
function getCurrentUserInfo () {
const token = ( qa).getStorageSync('uni_id_token') || '';
const tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
}
}
let userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo
}
function uniIdMixin (Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {
const {
role
} = getCurrentUserInfo();
return role.indexOf(roleId) > -1
};
Vue.prototype.uniIDHasPermission = function (permissionId) {
const {
permission
} = getCurrentUserInfo();
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
};
Vue.prototype.uniIDTokenValid = function () {
const {
tokenExpired
} = getCurrentUserInfo();
return tokenExpired > Date.now()
};
}
const _toString = Object.prototype.toString;
const hasOwnProperty = Object.prototype.hasOwnProperty;
......@@ -1350,6 +1400,7 @@ function parseBaseApp (vm, {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
uniIdMixin(Vue);
Vue.prototype.mpHost = "quickapp-webview";
......
{
"name": "@dcloudio/uni-quickapp-webview",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app quickapp-webview",
"main": "dist/index.js",
"repository": {
......@@ -17,5 +17,5 @@
"name": "quickapp-webview",
"title": "快应用(Webview)版"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
{
"name": "@dcloudio/uni-stat",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "",
"main": "dist/index.js",
"repository": {
......@@ -34,5 +34,5 @@
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-uglify": "^6.0.2"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
......@@ -727,6 +727,16 @@ describe('mp:compiler-extra', () => {
'<block wx:for="{{[{x:[1,2,3,4]}]}}" wx:for-item="item" wx:for-index="index"><view><block wx:for="{{item.x}}" wx:for-item="item2" wx:for-index="__i0__"><view data-event-opts="{{[[\'tap\',[[\'e0\',[\'$event\']]]]]}}" data-event-params="{{({item2})}}" bindtap="__e">{{item2+"+"+index}}</view></block></view></block>',
'with(this){if(!_isMounted){e0=function($event,item2){var _temp=arguments[arguments.length-1].currentTarget.dataset,_temp2=_temp.eventParams||_temp["event-params"],item2=_temp2.item2;var _temp,_temp2;return test(item2)}}}'
)
assertCodegen(
'<view v-for="(item, index) in array()"><view @click="test"></view></view>',
'<block wx:for="{{$root.l0}}" wx:for-item="item" wx:for-index="index"><view><view data-event-opts="{{[[\'tap\',[[\'test\',[\'$event\']]]]]}}" bindtap="__e"></view></view></block>',
'with(this){var l0=array();$mp.data=Object.assign({},{$root:{l0:l0}})}'
)
assertCodegen(
'<view v-for="(item, index) in array()"><view @click="test(item)"></view></view>',
'<block wx:for="{{$root.l0}}" wx:for-item="item" wx:for-index="index"><view><view data-event-opts="{{[[\'tap\',[[\'e0\',[\'$event\']]]]]}}" data-event-params="{{({item})}}" bindtap="__e"></view></view></block>',
'with(this){var l0=array();if(!_isMounted){e0=function($event,item){var _temp=arguments[arguments.length-1].currentTarget.dataset,_temp2=_temp.eventParams||_temp["event-params"],item=_temp2.item;var _temp,_temp2;return test(item)}}$mp.data=Object.assign({},{$root:{l0:l0}})}'
)
})
it('generate bool attr', () => {
assertCodegen(
......
......@@ -206,6 +206,22 @@ function isValuePath (path) {
return path.key !== 'key' && path.key !== 'id' && (path.key !== 'property' || path.parent.computed) && !(path.key === 'value' && path.parentPath.parentPath.isObjectPattern()) && !(path.key === 'left' && path.parentPath.parentPath.parentPath.isObjectPattern())
}
/**
* 判断 v-for 中是否包含复杂表达式:数组、对象、方法
*/
const isSafeScoped = (state) => {
const scopedArray = state.scoped
for (let index = 0; index < scopedArray.length; index++) {
const scoped = scopedArray[index]
const arrayExtra = scoped.forExtra[0].elements[0].value
// 简易判断
if (typeof arrayExtra === 'string' && (arrayExtra.startsWith('[') || arrayExtra.startsWith('{') || /\(.*\)/.test(arrayExtra))) {
return false
}
}
return true
}
function parseEvent (keyPath, valuePath, state, isComponent, isNativeOn = false, tagName, ret) {
const key = keyPath.node
let type = key.value || key.name || ''
......@@ -304,18 +320,9 @@ function parseEvent (keyPath, valuePath, state, isComponent, isNativeOn = false,
}
}
// 判断是否是复杂表达式 数组 或 对象
const isNotDynamicExpression = (state) => {
if (!(state.scoped[0])) {
return true
}
const value = state.scoped[0].forExtra[0].elements[0].value
return !(typeof value === 'string' && (value.startsWith('[') || value.startsWith('}')))
}
// 如果v-for遍历的值为 数组、对象 则进入复杂表达式
if (isNotDynamicExpression(state)) {
anonymous && funcPath.traverse({
// 如果 v-for 遍历的值为 数组、对象、方法 则进入底部匿名表达式处理
if (anonymous && isSafeScoped(state)) {
funcPath.traverse({
noScope: true,
MemberExpression (path) {
if (path.node.object.name === '$event' && path.node.property.name ===
......
......@@ -30,5 +30,4 @@ module.exports = function getRenderSlot (path, state) {
state.renderSlotStatementArray.push(t.expressionStatement(t.callExpression(t.identifier('$setScopedSlotsParams'), [t.stringLiteral(name.node.value), valueNode])))
}
// TODO 组件嵌套
path.skip()
}
{
"name": "@dcloudio/uni-template-compiler",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-template-compiler",
"main": "lib/index.js",
"repository": {
......@@ -22,5 +22,5 @@
"@babel/types": "^7.3.3",
"vue-template-compiler": "^2.6.10"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
{
"name": "@dcloudio/vue-cli-plugin-hbuilderx",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "HBuilderX plugin for vue-cli 3",
"main": "index.js",
"repository": {
......@@ -18,5 +18,5 @@
"css": "~2.2.1",
"escodegen": "^1.8.1"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
{
"name": "@dcloudio/vue-cli-plugin-uni-optimize",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app optimize plugin for vue-cli 3",
"main": "index.js",
"repository": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
......@@ -21,14 +21,14 @@ module.exports = (api, options) => {
'--host': `specify host (default: ${defaults.host})`,
'--port': `specify port (default: ${defaults.port})`,
'--https': `use https (default: ${defaults.https})`,
'--public': 'specify the public network URL for the HMR client',
'--auto-host': 'specify automator host',
'--public': 'specify the public network URL for the HMR client',
'--auto-host': 'specify automator host',
'--auto-port': 'specify automator port'
}
}, async function serve (args) {
info('Starting development server...')
info('Starting development server...')
require('./util').initAutomator(args)
require('./util').initAutomator(args)
// although this is primarily a dev server, it is possible that we
// are running it in a mode with a production env, e.g. in E2E tests.
......@@ -199,10 +199,10 @@ module.exports = (api, options) => {
})
}
return new Promise((resolve, reject) => {
const {
runByHBuilderX
} = require('@dcloudio/uni-cli-shared')
return new Promise((resolve, reject) => {
const {
runByHBuilderX
} = require('@dcloudio/uni-cli-shared')
// log instructions & open browser on first compilation complete
let isFirstCompile = true
compiler.hooks.done.tap('vue-cli-service uni-serve', stats => {
......@@ -224,9 +224,9 @@ module.exports = (api, options) => {
printRunningAt && console.log(' App running at:')
printRunningAt && console.log(
` - Local: ${chalk.cyan(urls.localUrlForTerminal)} ${copied}`
)
if (!printRunningAt) {
console.log('Build complete. Watching for changes...')
)
if (!printRunningAt) {
console.log('Build complete. Watching for changes...')
}
if (!isInContainer) {
printRunningAt && console.log(` - Network: ${chalk.cyan(networkUrl)}`)
......@@ -260,11 +260,6 @@ module.exports = (api, options) => {
isFirstCompile = false
if (!isProduction) {
if (process.UNI_CLOUD) {
console.warn(
'当前项目使用了uniCloud,为避免云函数调用跨域问题,建议在HBuilderX内置浏览器里调试,如使用外部浏览器需处理跨域,详见:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5'
)
}
// const buildCommand = hasProjectYarn(api.getCwd()) ? `yarn build` : `npm run build`
// console.log(` Note that the development build is not optimized.`)
// console.log(` To create a production build, run ${chalk.cyan(buildCommand)}.`)
......@@ -343,4 +338,4 @@ function checkInContainer () {
module.exports.defaultModes = {
serve: 'development'
}
}
......@@ -96,6 +96,7 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
'process.env.UNI_ENV': JSON.stringify(process.env.UNI_PLATFORM),
'process.env.UNI_CLOUD_PROVIDER': process.env.UNI_CLOUD_PROVIDER,
'process.env.UNICLOUD_DEBUG': process.env.UNICLOUD_DEBUG,
'process.env.RUN_BY_HBUILDERX': process.env.RUN_BY_HBUILDERX,
'process.env.UNI_AUTOMATOR_WS_ENDPOINT': JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT)
}
if (process.env.UNI_USING_VUE3) {
......@@ -138,4 +139,4 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
webpackConfig.plugins.delete('progress')
}
}
}
}
......@@ -32,22 +32,38 @@ process.env.VUE_APP_NAME = manifestJsonObj.name
process.env.UNI_USING_V3_SCOPED = true
process.UNI_CLOUD = false
process.UNI_CLOUD_TCB = false
process.UNI_CLOUD_ALIYUN = false
process.env.UNI_CLOUD_PROVIDER = JSON.stringify([])
const isH5 = !process.env.UNI_SUB_PLATFORM && process.env.UNI_PLATFORM === 'h5'
const isProduction = process.env.NODE_ENV === 'production'
if (process.env.UNI_CLOUD_SPACES) {
try {
const spaces = JSON.parse(process.env.UNI_CLOUD_SPACES)
if (Array.isArray(spaces)) {
process.UNI_CLOUD = spaces.length > 0
process.UNI_CLOUD_TCB = !!spaces.find(space => !space.clientSecret)
process.UNI_CLOUD_ALIYUN = !!spaces.find(space => space.clientSecret)
const hasUniCloudSpace = spaces.length > 0
if (spaces.length === 1) {
const space = spaces[0]
console.log(`本项目的uniCloud使用的默认服务空间spaceId为:${space.id}`)
}
if (
hasUniCloudSpace &&
isH5 &&
isProduction
) {
console.warn(
'发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5')
} else if (
hasUniCloudSpace &&
isH5 &&
!isProduction
) {
console.warn(
'当前项目使用了uniCloud,为避免云函数调用跨域问题,建议在HBuilderX内置浏览器里调试,如使用外部浏览器需处理跨域,详见:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5'
)
}
process.env.UNI_CLOUD_PROVIDER = JSON.stringify(spaces.map(space => {
if (space.clientSecret) {
return {
......@@ -69,16 +85,6 @@ if (process.env.UNI_CLOUD_SPACES) {
} catch (e) {}
}
if (
process.UNI_CLOUD &&
!process.env.UNI_SUB_PLATFORM &&
process.env.UNI_PLATFORM === 'h5' &&
process.env.NODE_ENV === 'production'
) {
console.warn(
'发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5')
}
// 初始化环境变量
const defaultOutputDir = '../../../../dist/' +
(process.env.NODE_ENV === 'production' ? 'build' : 'dev') + '/' +
......@@ -110,7 +116,9 @@ const {
isSupportSubPackages,
runByHBuilderX,
getPagesJson
} = require('@dcloudio/uni-cli-shared')
} = require('@dcloudio/uni-cli-shared')
process.env.RUN_BY_HBUILDERX = JSON.stringify(runByHBuilderX)
const {
initUniModules
......
......@@ -26,6 +26,7 @@ module.exports = function initOptions (options) {
// 增加 src/node_modules 解析
options.transpileDependencies.push(genTranspileDepRegex(path.resolve(process.env.UNI_INPUT_DIR, 'node_modules')))
options.transpileDependencies.push('@dcloudio/uni-' + process.env.UNI_PLATFORM)
options.transpileDependencies.push('@dcloudio/uni-i18n')
options.transpileDependencies.push('@dcloudio/uni-stat')
options.transpileDependencies.push('@dcloudio/vue-cli-plugin-uni/packages/uni-cloud')
......@@ -85,7 +86,7 @@ module.exports = function initOptions (options) {
if (sassLoaderVersion < 8) {
options.css.loaderOptions.sass.data = sassData
} else {
} else {
const name = sassLoaderVersion >= 9 ? 'additionalData' : 'prependData'
options.css.loaderOptions.sass[name] = sassData
}
......
{
"name": "@dcloudio/vue-cli-plugin-uni",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app plugin for vue-cli 3",
"main": "index.js",
"repository": {
......@@ -17,7 +17,7 @@
"author": "fxy060608",
"license": "Apache-2.0",
"dependencies": {
"@dcloudio/uni-stat": "^2.0.0-31920210422002",
"@dcloudio/uni-stat": "^2.0.0-31920210609001",
"buffer-json": "^2.0.0",
"copy-webpack-plugin": "^5.1.1",
"cross-env": "^5.2.0",
......@@ -37,5 +37,5 @@
"wrap-loader": "^0.2.0",
"xregexp": "4.0.0"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
......@@ -8,6 +8,11 @@ const trim_1 = __importDefault(require("./stylePlugins/trim"));
const scoped_1 = __importDefault(require("./stylePlugins/scoped"));
const styleProcessors_1 = require("./styleProcessors");
const removeScoped_1 = __importDefault(require("./stylePlugins/remove-scoped"));
let comments;
try{
comments = require('postcss-discard-comments')
}catch(e){}
function compileStyle(options) {
return doCompileStyle(Object.assign({}, options, { isAsync: false }));
}
......@@ -31,6 +36,12 @@ function doCompileStyle(options) {
} else { // fixed by xxxxxx
plugins.push(removeScoped_1.default(id));
}
// fixed by xxxxxx
if (process.env.UNI_PLATFORM === 'app-plus' && process.env.NODE_ENV === 'production') {
if (comments) {
plugins.push(comments);
}
}
const postCSSOptions = Object.assign({}, postcssOptions, { to: filename, from: filename });
if (map) {
postCSSOptions.map = {
......
{
"name": "@dcloudio/webpack-uni-mp-loader",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "webpack-uni-mp-loader",
"main": "index.js",
"repository": {
......@@ -16,5 +16,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
......@@ -12,6 +12,10 @@ const {
parseTabBar
} = require('../util')
function defaultCopy (name, value, json) {
json[name] = value
}
const pagesJson2AppJson = {
globalStyle: function (name, value, json) {
json.window = parseStyle(value)
......@@ -22,7 +26,8 @@ const pagesJson2AppJson = {
},
tabBar: function (name, value, json) {
json.tabBar = parseTabBar(value)
}
},
preloadRule: defaultCopy
}
function copyToJson (json, fromJson, options) {
......@@ -62,19 +67,19 @@ module.exports = function (pagesJson, manifestJson) {
app.subPackages.push(subPackages[root])
})
copyToJson(app, pagesJson, pagesJson2AppJson)
const platformJson = manifestJson['mp-alipay'] || {}
if (hasOwn(platformJson, 'plugins')) {
app.plugins = platformJson.plugins
}
copyToJson(app, pagesJson, pagesJson2AppJson)
const platformJson = manifestJson['mp-alipay'] || {}
if (hasOwn(platformJson, 'plugins')) {
app.plugins = platformJson.plugins
}
if (app.usingComponents) {
updateAppJsonUsingComponents(app.usingComponents)
}
const project = Object.assign({}, manifestJson['mp-alipay'] || {})
delete project.usingComponents
delete project.usingComponents
delete project.plugins
return [{
......@@ -84,4 +89,4 @@ module.exports = function (pagesJson, manifestJson) {
name: 'mini.project',
content: project
}]
}
}
{
"name": "@dcloudio/webpack-uni-pages-loader",
"version": "2.0.0-31920210422002",
"version": "2.0.0-31920210609001",
"description": "uni-app pages.json loader",
"main": "lib/index.js",
"repository": {
......@@ -21,7 +21,7 @@
"strip-json-comments": "^2.0.1"
},
"uni-app": {
"compilerVersion": "3.1.11"
"compilerVersion": "3.1.18"
},
"gitHead": "b366367ac0b63f41ef205dc93eee55d8e9f8f3ed"
"gitHead": "2033cd540cff5d8469ff77e87779cd4daa5c9121"
}
......@@ -45,7 +45,7 @@ export function getTargetDataset (target) {
const $attrs = vm.$attrs
for (const key in $attrs) {
if (key.startsWith('data-')) {
const newKey = camelize(key.substr(5))
const newKey = camelize(key.substr(5).toLowerCase())
const value = $attrs[key]
dataset[newKey] = force ? value : dataset[newKey] || value
}
......
......@@ -24,6 +24,10 @@ import {
getTabBarScrollPosition
} from './app/router-guard'
import {
uniIdMixin
} from 'uni-shared'
function getMinId (routes) {
let minId = 0
routes.forEach(route => {
......@@ -74,6 +78,8 @@ export default {
lifecycleMixin(Vue)
uniIdMixin(Vue)
/* eslint-disable no-undef */
if (typeof __UNI_ROUTER_BASE__ !== 'undefined') {
__uniConfig.router.base = __UNI_ROUTER_BASE__
......
......@@ -196,9 +196,9 @@ export default {
img.src = realImagePath
} else {
this._clearImage()
this._resetData()
// 与微信小程序保持一致,保留之前样式
// this._resetData()
this._resetSize()
// this._resetSize()
}
},
_clearImage () {
......
<template>
<uni-progress
class="uni-progress"
v-on="$listeners"
<uni-progress
class="uni-progress"
v-on="$listeners"
>
<div
:style="outerBarStyle"
class="uni-progress-bar"
<div
:style="outerBarStyle"
class="uni-progress-bar"
>
<div
:style="innerBarStyle"
class="uni-progress-inner-bar"
<div
:style="innerBarStyle"
class="uni-progress-inner-bar"
/>
</div>
<template v-if="showInfo">
<p class="uni-progress-info">
{{ currentPercent }}%
<p class="uni-progress-info">
{{ currentPercent }}%
</p>
</template>
</uni-progress>
......@@ -65,6 +65,13 @@ export default {
activeMode: {
type: String,
default: VALUES.activeMode
},
duration: {
type: [Number, String],
default: 30,
validator (value) {
return !isNaN(parseFloat(value, 10))
}
}
},
data () {
......@@ -117,7 +124,7 @@ export default {
} else {
this.currentPercent += 1
}
}, 30)
}, parseFloat(this.duration))
} else {
this.currentPercent = this.realPercent
}
......@@ -154,4 +161,4 @@ export default {
margin-left: 15px;
font-size: 16px;
}
</style>
</style>
......@@ -253,7 +253,7 @@ export default {
_onTrack: function (e) {
if (!this.disabled) {
return e.detail.state === 'move' ? (this._onUserChangedValue({
x: e.detail.x0
x: e.detail.x
}), this.$trigger('changing', e, {
value: this.sliderValue
}), !1) : (e.detail.state === 'end' && this.$trigger('change', e, {
......
<template>
<uni-textarea v-on="$listeners">
<div class="uni-textarea-wrapper">
<div
ref="wrapper"
class="uni-textarea-wrapper"
>
<div
v-show="!(composing || valueSync.length)"
ref="placeholder"
......@@ -144,7 +147,8 @@ export default {
lineCount
})
if (this.autoHeight) {
this.$el.style.height = this.height + 'px'
this.$el.style.height = 'auto'
this.$refs.wrapper.style.height = this.height + 'px'
}
}
},
......@@ -246,7 +250,6 @@ uni-textarea {
line-height: normal;
white-space: pre-wrap;
word-break: break-all;
box-sizing: content-box !important;
}
uni-textarea[hidden] {
display: none;
......
......@@ -194,20 +194,31 @@ export default {
this._onInput($event, true)
}
this.focusSync = false
const field = $event.target
let cursor
if (field.type === 'number') {
field.type = 'text'
cursor = field.selectionEnd
field.type = 'number'
} else {
cursor = field.selectionEnd
}
this.$trigger('blur', $event, {
value: this.valueSync,
cursor: $event.target.selectionEnd
cursor
})
},
_checkSelection () {
if (this.focusSync && this.selectionStartNumber > -1 && this.selectionEndNumber > -1) {
this._field.selectionStart = this.selectionStartNumber
this._field.selectionEnd = this.selectionEndNumber
const field = this._field
if (this.focusSync && this.selectionStartNumber > -1 && this.selectionEndNumber > -1 && field.type !== 'number') {
field.selectionStart = this.selectionStartNumber
field.selectionEnd = this.selectionEndNumber
}
},
_checkCursor () {
if (this.focusSync && this.selectionStartNumber < 0 && this.selectionEndNumber < 0 && this.cursorNumber > -1) {
this._field.selectionEnd = this._field.selectionStart = this.cursorNumber
const field = this._field
if (this.focusSync && this.selectionStartNumber < 0 && this.selectionEndNumber < 0 && this.cursorNumber > -1 && field.type !== 'number') {
field.selectionEnd = field.selectionStart = this.cursorNumber
}
}
}
......
......@@ -35,8 +35,8 @@ export default {
changedTouches: $event.changedTouches,
detail: {
state,
x0: x,
y0: y,
x: x,
y: y,
dx: x - x0,
dy: y - y0,
ddx: x - x1,
......
......@@ -22,10 +22,13 @@ function addBase (filePath) {
export default function getRealPath (filePath) {
if (filePath.indexOf('/') === 0) {
if (filePath.indexOf('//') === 0) {
filePath = 'https:' + filePath
} else {
return addBase(filePath.substr(1))
return 'https:' + filePath
}
// 平台绝对路径 安卓、iOS
if (filePath.startsWith('/storage/') || filePath.includes('/Containers/Data/Application/')) {
return 'file://' + filePath
}
return addBase(filePath.substr(1))
}
// 网络资源或base64
if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf('blob:') === 0) {
......@@ -43,4 +46,4 @@ export default function getRealPath (filePath) {
}
return filePath
}
}
......@@ -37,7 +37,6 @@ class AdBase {
ad.onLoad((e) => {
this._isLoaded = true
this._isLoading = false
this._dispatchEvent(eventTypes.load, {})
if (this._loadPromiseResolve != null) {
this._loadPromiseResolve()
......@@ -48,6 +47,8 @@ class AdBase {
this._showPromiseResolve = null
this._showAd()
}
this._dispatchEvent(eventTypes.load, {})
})
ad.onClose((e) => {
this._isLoaded = false
......@@ -70,17 +71,17 @@ class AdBase {
this._dispatchEvent(eventTypes.error, data)
const promiseError = new Error(JSON.stringify(this._adError))
promiseError.code = e.code
promiseError.errMsg = e.message
const error = new Error(JSON.stringify(this._adError))
error.code = e.code
error.errMsg = e.message
if (this._loadPromiseReject != null) {
this._loadPromiseReject(promiseError)
this._loadPromiseReject(error)
this._loadPromiseReject = null
}
if (this._showPromiseReject != null) {
this._showPromiseReject(promiseError)
this._showPromiseReject(error)
this._showPromiseReject = null
}
})
......@@ -152,5 +153,7 @@ class AdBase {
}
export {
eventTypes,
eventNames,
AdBase
}
import {
requireNativePlugin
} from '../../bridge'
import {
eventTypes,
eventNames
} from './ad-base.js'
const sdkCache = {}
const sdkQueue = {}
function initSDK (options) {
const provider = options.provider
if (!sdkCache[provider]) {
sdkCache[provider] = {}
}
if (typeof sdkCache[provider].plugin === 'object') {
options.success(sdkCache[provider].plugin)
return
}
if (!sdkQueue[provider]) {
sdkQueue[provider] = []
}
sdkQueue[provider].push(options)
if (sdkCache[provider].status === true) {
options.__plugin = sdkCache[provider].plugin
return
}
sdkCache[provider].status = true
const plugin = requireNativePlugin(provider)
if (!plugin || !plugin.initSDK) {
sdkQueue[provider].forEach((item) => {
item.fail({
code: -1,
message: 'provider [' + provider + '] invalid'
})
})
sdkQueue[provider].length = 0
sdkCache[provider].status = false
return
}
// TODO
sdkCache[provider].plugin = plugin
options.__plugin = plugin
plugin.initSDK((res) => {
const isSuccess = (res.code === 1 || res.code === '1')
if (isSuccess) {
sdkCache[provider].plugin = plugin
} else {
sdkCache[provider].status = false
}
sdkQueue[provider].forEach((item) => {
if (isSuccess) {
item.success(item.__plugin)
} else {
item.fail(res)
}
})
sdkQueue[provider].length = 0
})
}
class InteractiveAd {
constructor (options) {
const _callbacks = this._callbacks = {}
eventNames.forEach(item => {
_callbacks[item] = []
const name = item[0].toUpperCase() + item.substr(1)
this[`on${name}`] = function (callback) {
_callbacks[item].push(callback)
}
})
this._ad = null
this._adError = ''
this._adpid = options.adpid
this._provider = options.provider
this._userData = options.userData
this._isLoaded = false
this._isLoading = false
this._loadPromiseResolve = null
this._loadPromiseReject = null
this._showPromiseResolve = null
this._showPromiseReject = null
setTimeout(() => {
this._init()
})
}
_init () {
this._adError = ''
initSDK({
provider: this._provider,
success: (res) => {
this._ad = res
if (this._userData) {
this.bindUserData(this._userData)
}
this._loadAd()
},
fail: (err) => {
this._adError = err
this._dispatchEvent(eventTypes.error, err)
}
})
}
getProvider () {
return this._provider
}
load () {
return new Promise((resolve, reject) => {
this._loadPromiseResolve = resolve
this._loadPromiseReject = reject
if (this._isLoading) {
return
}
if (this._adError) {
this._init()
return
}
if (this._isLoaded) {
resolve()
} else {
this._loadAd()
}
})
}
show () {
return new Promise((resolve, reject) => {
this._showPromiseResolve = resolve
this._showPromiseReject = reject
if (this._isLoading) {
return
}
if (this._adError) {
this._init()
return
}
if (this._isLoaded) {
this._showAd()
resolve()
} else {
this._loadAd()
}
})
}
destroy () {
if (this._ad !== null && this._ad.destroy) {
this._ad.destroy({
adpid: this._adpid
})
}
}
bindUserData (data) {
if (this._ad !== null) {
this._ad.bindUserData(data)
}
}
_loadAd () {
if (this._ad !== null) {
if (this._isLoading === true) {
return
}
this._isLoading = true
this._ad.loadData({
adpid: this._adpid
}, (res) => {
this._isLoaded = true
this._isLoading = false
if (this._loadPromiseResolve != null) {
this._loadPromiseResolve()
this._loadPromiseResolve = null
}
if (this._showPromiseResolve != null) {
this._showPromiseResolve()
this._showPromiseResolve = null
this._showAd()
}
this._dispatchEvent(eventTypes.load, res)
}, (err) => {
this._isLoading = false
if (this._showPromiseReject != null) {
this._showPromiseReject(this._createError(err))
this._showPromiseReject = null
}
this._dispatchEvent(eventTypes.error, err)
})
}
}
_showAd () {
if (this._ad !== null && this._isLoaded === true) {
this._ad.show({
adpid: this._adpid
}, (res) => {
this._isLoaded = false
}, (err) => {
this._isLoaded = false
if (this._showPromiseReject != null) {
this._showPromiseReject(this._createError(err))
this._showPromiseReject = null
}
this._dispatchEvent(eventTypes.error, err)
})
}
}
_createError (err) {
const error = new Error(JSON.stringify(err))
error.code = err.code
error.errMsg = err.message
return error
}
_dispatchEvent (name, data) {
this._callbacks[name].forEach(callback => {
if (typeof callback === 'function') {
callback(data || {})
}
})
}
}
export function createInteractiveAd (options) {
if (!options.provider) {
return new Error('provider invalid')
}
if (!options.adpid) {
return new Error('adpid invalid')
}
return new InteractiveAd(options)
}
......@@ -6,7 +6,7 @@ class InterstitialAd extends AdBase {
constructor (options = {}) {
super(plus.ad.createInterstitialAd(options), options)
this.load()
this._loadAd()
}
}
......
......@@ -82,3 +82,4 @@ export * from './ad/ad'
export * from './ad/rewarded-video-ad'
export * from './ad/full-screen-video-ad'
export * from './ad/interstitial-ad'
export * from './ad/interactive-ad'
......@@ -34,7 +34,7 @@ export function chooseVideo ({
}, () => {
resolve(tempFilePath)
})
}) : Promise.resolve()
}) : Promise.resolve(tempFilePath)
if (compressed) {
plus.nativeUI.showWaiting()
}
......@@ -55,7 +55,7 @@ export function chooseVideo ({
result.height = videoInfo.height
invoke(callbackId, result)
},
errorCallback
fail: errorCallback
})
})
}
......
......@@ -7,10 +7,13 @@ export const getVideoInfo = warpPlusMethod('io', 'getVideoInfo', options => {
return options
}, data => {
return {
orientation: data.orientation,
type: data.type,
duration: data.duration,
fps: data.fps || 30,
size: data.size,
height: data.height,
width: data.width,
size: data.size
fps: data.fps || 30,
bitrate: data.bitrate
}
})
......@@ -46,6 +46,7 @@ export function createRequestTaskById (requestTaskId, {
responseType,
sslVerify = true,
firstIpv4 = false,
tls,
timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.request) || 60 * 1000
} = {}) {
const stream = requireNativePlugin('stream')
......@@ -99,7 +100,8 @@ export function createRequestTaskById (requestTaskId, {
timeout: timeout || 6e5,
// 配置和weex模块内相反
sslVerify: !sslVerify,
firstIpv4: firstIpv4
firstIpv4: firstIpv4,
tls
}
if (method !== 'GET') {
options.body = typeof data === 'string' ? data : JSON.stringify(data)
......
......@@ -5,6 +5,7 @@ import {
warpPlusSuccessCallback,
warpPlusErrorCallback
} from '../util'
import { isPlainObject } from 'uni-shared'
function getService (provider) {
return new Promise((resolve, reject) => {
......@@ -31,7 +32,7 @@ export function login (params, callbackId) {
authResult: authResult,
errMsg: 'login:ok'
})
}, errorCallback, provider === 'apple' ? { scope: 'email' } : { univerifyStyle: params.univerifyStyle } || {})
}, errorCallback, provider === 'apple' ? { scope: 'email' } : { univerifyStyle: univerifyButtonsClickHandling(params.univerifyStyle, errorCallback) } || {})
}
// 先注销再登录
// apple登录logout之后无法重新触发获取email,fullname;一键登录无logout
......@@ -99,6 +100,12 @@ export function getUserInfo (params, callbackId) {
})
})
}
/**
* 获取用户信息-兼容
*/
export function getUserProfile (params, callbackId) {
return getUserInfo(params, callbackId)
}
/**
* 获取用户信息
......@@ -122,5 +129,28 @@ export function preLogin (params, callbackId) {
}
export function closeAuthView () {
getService('univerify').then(service => service.closeAuthView())
return getService('univerify').then(service => service.closeAuthView())
}
/**
* 一键登录自定义登陆按钮点击处理
*/
function univerifyButtonsClickHandling (univerifyStyle, errorCallback) {
if (univerifyStyle && isPlainObject(univerifyStyle) && univerifyStyle.buttons &&
Object.prototype.toString.call(univerifyStyle.buttons.list) === '[object Array]' &&
univerifyStyle.buttons.list.length > 0
) {
univerifyStyle.buttons.list.forEach((button, index) => {
univerifyStyle.buttons.list[index].onclick = function () {
closeAuthView().then(() => {
errorCallback({
code: '30008',
message: '用户点击了自定义按钮',
index
})
})
}
})
}
return univerifyStyle
}
......@@ -60,7 +60,7 @@ export function getRealPath (filePath) {
// 无协议的情况补全 https
if (filePath.indexOf('//') === 0) {
filePath = 'https:' + filePath
return 'https:' + filePath
}
// 网络资源或base64
......@@ -75,6 +75,10 @@ export function getRealPath (filePath) {
const wwwPath = 'file://' + _handleLocalPath('_www')
// 绝对路径转换为本地文件系统路径
if (filePath.indexOf('/') === 0) {
// 平台绝对路径 安卓、iOS
if (filePath.startsWith('/storage/') || filePath.includes('/Containers/Data/Application/')) {
return 'file://' + filePath
}
return wwwPath + filePath
}
// 相对资源
......
......@@ -22,6 +22,10 @@ import {
vdSyncCallbacks
} from '../subscribe-handlers/on-vd-sync-callback'
import {
uniIdMixin
} from 'uni-shared'
export default {
install (Vue, options) {
initVue(Vue)
......@@ -31,6 +35,8 @@ export default {
initPolyfill(Vue)
uniIdMixin(Vue)
Vue.prototype.getOpenerEventChannel = function () {
if (!this.$root.$scope.eventChannel) {
this.$root.$scope.eventChannel = new EventChannel()
......@@ -94,4 +100,4 @@ export default {
return callback ? undefined : result
}
}
}
}
......@@ -143,9 +143,6 @@ export default {
}
})
},
beforeDestroy () {
window.removeEventListener('message', this.__messageHandle, false)
},
methods: {
_choose () {
if (this.selected) {
......
......@@ -23,10 +23,11 @@ const passiveOptions = supportsPassive ? {
function updateCssVar (vm) {
if (uni.canIUse('css.var')) {
const uniConfigTabbarHeight = parseFloat(__uniConfig.tabBar.height)
const pageVm = vm.$parent.$parent
const navigationBarType = pageVm.navigationBar.type
const windowTopValue = navigationBarType === 'default' || navigationBarType === 'float' ? NAVBAR_HEIGHT : 0
const windowBottomValue = getApp().$children[0].showTabBar ? TABBAR_HEIGHT : 0
const windowBottomValue = getApp().$children[0].showTabBar ? isNaN(uniConfigTabbarHeight) ? TABBAR_HEIGHT : uniConfigTabbarHeight : 0
const envMethod = uni.canIUse('css.env') ? 'env' : (uni.canIUse('css.constant') ? 'constant' : '')
const windowTop = windowTopValue && envMethod ? `calc(${windowTopValue}px + ${envMethod}(safe-area-inset-top))`
: `${windowTopValue}px`
......@@ -87,4 +88,4 @@ export default function initSubscribe (subscribe) {
})
}
})
}
}
......@@ -364,7 +364,7 @@ export default {
}
const danmuList = this.otherData.danmuList = JSON.parse(JSON.stringify(this.danmuList || []))
danmuList.sort(function (a, b) {
return (a.time || 0) - (a.time || 0)
return (a.time || 0) - (b.time || 0)
})
},
mounted () {
......
......@@ -381,6 +381,23 @@ const protocols = { // 需要做转换的 API 列表
}
}
},
getUserProfile: {
name: my.canIUse('getOpenUserInfo') ? 'getOpenUserInfo' : 'getAuthUserInfo',
returnValue (result) {
if (my.canIUse('getOpenUserInfo')) {
let response = {}
try {
response = JSON.parse(result.response).response
} catch (e) {}
result.nickName = response.nickName
result.avatar = response.avatar
}
result.userInfo = {
nickName: result.nickName,
avatarUrl: result.avatar
}
}
},
requestPayment: {
name: 'tradePay',
args: {
......
......@@ -2,6 +2,7 @@ import navigateTo from 'uni-helpers/navigate-to'
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
import getSystemInfo from '../../../mp-weixin/helpers/system-info'
import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
// 不支持的 API 列表
const todos = [
......@@ -89,6 +90,7 @@ const protocols = {
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo,
getUserProfile,
getRecorderManager: {
returnValue (fromRet) {
fromRet.onFrameRecorded = createTodoMethod('RecorderManager', 'onFrameRecorded')
......@@ -122,6 +124,9 @@ const protocols = {
getAccountInfoSync: {
name: 'getEnvInfoSync',
returnValue: _handleEnvInfo
},
login: {
name: 'getLoginCode'
}
}
......
......@@ -2,13 +2,15 @@ import navigateTo from 'uni-helpers/navigate-to'
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
import getSystemInfo from '../../../mp-weixin/helpers/system-info'
import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
export const protocols = {
navigateTo,
redirectTo,
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo
getSystemInfoSync: getSystemInfo,
getUserProfile
}
export const todos = [
'vibrate'
......
......@@ -2,13 +2,15 @@ import navigateTo from 'uni-helpers/navigate-to'
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
import getSystemInfo from '../../../mp-weixin/helpers/system-info'
import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
export const protocols = {
navigateTo,
redirectTo,
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo
getSystemInfoSync: getSystemInfo,
getUserProfile
}
export const todos = [
'preloadPage',
......
......@@ -2,6 +2,7 @@ import navigateTo from 'uni-helpers/navigate-to'
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
import getSystemInfo from '../../../mp-weixin/helpers/system-info'
import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
// 不支持的 API 列表
const todos = [
......@@ -107,6 +108,7 @@ const protocols = {
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo,
getUserProfile,
connectSocket: {
args: {
method: false
......
const oName = 'getUserInfo'
const nName = 'getUserProfile'
export default {
name: __GLOBAL__.canIUse(nName) ? nName : oName
}
......@@ -11,6 +11,10 @@ import {
getEventChannel
} from 'uni-helpers/navigate-to'
import {
uniIdMixin
} from 'uni-shared'
const hooks = [
'onShow',
'onHide',
......@@ -101,6 +105,7 @@ export default function parseBaseApp (vm, {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store
}
uniIdMixin(Vue)
Vue.prototype.mpHost = __PLATFORM__
......
function b64DecodeUnicode (str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
function getCurrentUserInfo () {
const token = (__PLATFORM__ === 'h5' || __PLATFORM__ === 'app-plus' ? uni : __GLOBAL__).getStorageSync('uni_id_token') || ''
const tokenArr = token.split('.')
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
}
}
let userInfo
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]))
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
}
userInfo.tokenExpired = userInfo.exp * 1000
delete userInfo.exp
delete userInfo.iat
return userInfo
}
export function uniIdMixin (Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {
const {
role
} = getCurrentUserInfo()
return role.indexOf(roleId) > -1
}
Vue.prototype.uniIDHasPermission = function (permissionId) {
const {
permission
} = getCurrentUserInfo()
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
}
Vue.prototype.uniIDTokenValid = function () {
const {
tokenExpired
} = getCurrentUserInfo()
return tokenExpired > Date.now()
}
}
......@@ -193,3 +193,5 @@ export function deepClone (vnodes, createElement) {
return vnodes.map(cloneVNode)
}
export * from './uni-id-mixin'
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册