提交 6f77d014 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -474,7 +474,6 @@ const is_debug = debug;
* @param {*} data
*/
const log = (data, type) => {
let msg_type = '';
switch (data.lt) {
case '1':
......@@ -500,7 +499,7 @@ const log = (data, type) => {
// #ifdef APP
// 在 app 中,日志转为 字符串
if(typeof data === 'object') {
if (typeof data === 'object') {
data = JSON.stringify(data);
}
// #endif
......@@ -534,6 +533,17 @@ const get_report_Interval = (defaultTime) => {
return Number(time)
};
/**
* 获取隐私协议配置
*/
const is_push_clientid = () => {
if (uniStatisticsConfig.collectItems) {
const ClientID = uniStatisticsConfig.collectItems.uniPushClientID;
return typeof ClientID === 'boolean' ? ClientID : false
}
return false
};
const appid = process.env.UNI_APP_ID; // 做应用隔离
const dbSet = (name, value) => {
let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
......@@ -1304,7 +1314,8 @@ class Stat extends Report {
* 获取推送id
*/
pushEvent(options) {
if (uni.getPushClientId) {
const ClientID = is_push_clientid();
if (uni.getPushClientId && ClientID) {
uni.getPushClientId({
success: (res) => {
const cid = res.cid || false;
......
......@@ -472,7 +472,6 @@ const is_debug = debug;
* @param {*} data
*/
const log = (data, type) => {
let msg_type = '';
switch (data.lt) {
case '1':
......@@ -498,7 +497,7 @@ const log = (data, type) => {
// #ifdef APP
// 在 app 中,日志转为 字符串
if(typeof data === 'object') {
if (typeof data === 'object') {
data = JSON.stringify(data);
}
// #endif
......@@ -532,6 +531,17 @@ const get_report_Interval = (defaultTime) => {
return Number(time)
};
/**
* 获取隐私协议配置
*/
const is_push_clientid = () => {
if (uniStatisticsConfig.collectItems) {
const ClientID = uniStatisticsConfig.collectItems.uniPushClientID;
return typeof ClientID === 'boolean' ? ClientID : false
}
return false
};
const appid = process.env.UNI_APP_ID; // 做应用隔离
const dbSet = (name, value) => {
let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
......@@ -1302,7 +1312,8 @@ class Stat extends Report {
* 获取推送id
*/
pushEvent(options) {
if (uni.getPushClientId) {
const ClientID = is_push_clientid();
if (uni.getPushClientId && ClientID) {
uni.getPushClientId({
success: (res) => {
const cid = res.cid || false;
......
......@@ -453,7 +453,6 @@ const is_debug = debug;
* @param {*} data
*/
const log = (data, type) => {
let msg_type = '';
switch (data.lt) {
case '1':
......@@ -479,7 +478,7 @@ const log = (data, type) => {
// #ifdef APP
// 在 app 中,日志转为 字符串
if(typeof data === 'object') {
if (typeof data === 'object') {
data = JSON.stringify(data);
}
// #endif
......@@ -513,6 +512,17 @@ const get_report_Interval = (defaultTime) => {
return Number(time)
};
/**
* 获取隐私协议配置
*/
const is_push_clientid = () => {
if (uniStatisticsConfig.collectItems) {
const ClientID = uniStatisticsConfig.collectItems.uniPushClientID;
return typeof ClientID === 'boolean' ? ClientID : false
}
return false
};
const appid = process.env.UNI_APP_ID; // 做应用隔离
const dbSet = (name, value) => {
let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
......@@ -1268,7 +1278,8 @@ class Stat extends Report {
* 获取推送id
*/
pushEvent(options) {
if (uni.getPushClientId) {
const ClientID = is_push_clientid();
if (uni.getPushClientId && ClientID) {
uni.getPushClientId({
success: (res) => {
const cid = res.cid || false;
......
......@@ -451,7 +451,6 @@ const is_debug = debug;
* @param {*} data
*/
const log = (data, type) => {
let msg_type = '';
switch (data.lt) {
case '1':
......@@ -477,7 +476,7 @@ const log = (data, type) => {
// #ifdef APP
// 在 app 中,日志转为 字符串
if(typeof data === 'object') {
if (typeof data === 'object') {
data = JSON.stringify(data);
}
// #endif
......@@ -511,6 +510,17 @@ const get_report_Interval = (defaultTime) => {
return Number(time)
};
/**
* 获取隐私协议配置
*/
const is_push_clientid = () => {
if (uniStatisticsConfig.collectItems) {
const ClientID = uniStatisticsConfig.collectItems.uniPushClientID;
return typeof ClientID === 'boolean' ? ClientID : false
}
return false
};
const appid = process.env.UNI_APP_ID; // 做应用隔离
const dbSet = (name, value) => {
let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
......@@ -1266,7 +1276,8 @@ class Stat extends Report {
* 获取推送id
*/
pushEvent(options) {
if (uni.getPushClientId) {
const ClientID = is_push_clientid();
if (uni.getPushClientId && ClientID) {
uni.getPushClientId({
success: (res) => {
const cid = res.cid || false;
......
......@@ -103,6 +103,36 @@ var GtPush = /*@__PURE__*/getDefaultExportFromCjs(gtpushMin);
function initPushNotification() {
// 仅 App 端
if (typeof plus !== 'undefined' && plus.push) {
plus.globalEvent.addEventListener('newPath', ({ path }) => {
if (!path) {
return;
}
// 指定的页面为当前页面
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
if (currentPage &&
currentPage.$page &&
currentPage.$page.fullPath === path) {
return;
}
// 简单起见,先尝试 navigateTo 跳转,失败后,再尝试 tabBar 跳转
uni.navigateTo({
url: path,
fail(res) {
if (res.errMsg.indexOf('tabbar') > -1) {
uni.switchTab({
url: path,
fail(res) {
console.error(res.errMsg);
},
});
}
else {
console.error(res.errMsg);
}
},
});
});
plus.push.addEventListener('click', (result) => {
// @ts-expect-error
uni.invokePushCallback({
......@@ -141,7 +171,9 @@ if (!appid) {
});
}
else {
// #ifdef APP
initPushNotification();
// #endif
GtPush.init({
appid,
onError: (res) => {
......
// @ts-expect-error
uni.invokePushCallback({
type: 'enabled',
offline: true,
});
Promise.resolve().then(() => {
plus.push.setAutoNotification && plus.push.setAutoNotification(false);
function initPushNotification() {
// 仅 App 端
if (typeof plus !== 'undefined' && plus.push) {
plus.globalEvent.addEventListener('newPath', ({ path }) => {
if (!path) {
return;
}
// 指定的页面为当前页面
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
if (currentPage &&
currentPage.$page &&
currentPage.$page.fullPath === path) {
return;
}
// 简单起见,先尝试 navigateTo 跳转,失败后,再尝试 tabBar 跳转
uni.navigateTo({
url: path,
fail(res) {
if (res.errMsg.indexOf('tabbar') > -1) {
uni.switchTab({
url: path,
fail(res) {
console.error(res.errMsg);
},
});
}
else {
console.error(res.errMsg);
}
},
});
});
plus.push.addEventListener('click', (result) => {
// @ts-expect-error
uni.invokePushCallback({
......@@ -12,6 +38,26 @@ Promise.resolve().then(() => {
message: result,
});
});
uni.onPushMessage((res) => {
if (res.type === 'receive' &&
res.data &&
res.data.force_notification) {
// 创建通知栏
uni.createPushMessage(res.data);
res.stopped = true;
}
});
}
}
// @ts-expect-error
uni.invokePushCallback({
type: 'enabled',
offline: true,
});
Promise.resolve().then(() => {
initPushNotification();
plus.push.setAutoNotification && plus.push.setAutoNotification(false);
plus.push.addEventListener('receive', (result) => {
// @ts-expect-error
uni.invokePushCallback({
......
......@@ -9,6 +9,7 @@ import {
let cid
let cidErrMsg
let enabled
let offline
function normalizePushMessage (message) {
try {
......@@ -22,6 +23,9 @@ export function invokePushCallback (
) {
if (args.type === 'enabled') {
enabled = true
if (__PLATFORM__ === 'app') {
offline = args.offline
}
} else if (args.type === 'clientId') {
cid = args.cid
cidErrMsg = args.errMsg
......@@ -70,11 +74,34 @@ export function getPushClientId (args) {
const hasSuccess = isFn(success)
const hasFail = isFn(fail)
const hasComplete = isFn(complete)
// App 端且启用离线时,使用 getClientInfoAsync 来调用
if (__PLATFORM__ === 'app' && offline) {
plus.push.getClientInfoAsync(
(info) => {
const res = {
errMsg: 'getPushClientId:ok',
cid
}
hasSuccess && success(res)
hasComplete && complete(res)
},
(res) => {
res = {
errMsg: 'getPushClientId:fail ' + (res.code + ': ' + res.message)
}
hasFail && fail(res)
hasComplete && complete(res)
}
)
return
}
Promise.resolve().then(() => {
if (typeof enabled === 'undefined') {
enabled = false
cid = ''
cidErrMsg = 'unipush is not enabled'
cidErrMsg = 'uniPush is not enabled'
}
getPushCidCallbacks.push((cid, errMsg) => {
let res
......
......@@ -54,5 +54,18 @@ uni-cover-view .uni-cover-view {
width: 100%;
height: 100%;
visibility: hidden;
text-overflow: inherit;
overflow: hidden;
white-space: inherit;
-webkit-align-items: inherit;
align-items: inherit;
-webkit-justify-content: inherit;
justify-content: inherit;
-webkit-flex-direction: inherit;
flex-direction: inherit;
-webkit-flex-wrap: inherit;
flex-wrap: inherit;
display: inherit;
overflow: inherit;
}
</style>
......@@ -7,8 +7,9 @@
:style="{'flex-direction':direction==='vertical'?'column':'row',backgroundColor:tabBarOptions.backgroundColor}"
class="uni-tabbar"
>
<template v-for="(item,index) in tabBarOptions.list">
<div
v-for="(item,index) in tabBarOptions.list"
v-if="item.visible !== false"
:key="item.pagePath"
class="uni-tabbar__item"
@click="_switchTab(item,index)"
......@@ -44,6 +45,7 @@
</div>
</div>
</div>
</template>
</div>
</uni-tabbar>
</template>
......
import {
isPage,
initRelation,
handleLink
handleLink,
components
} from './util'
import {
......@@ -11,17 +12,26 @@ import {
import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-base-parser'
const components = []
function currentComponents (mpInstance, callback) {
const webviewId = mpInstance.__webviewId__
const currentComponents = components[webviewId]
if (currentComponents) {
callback(currentComponents)
}
}
export default function parseComponent (vueOptions) {
const [componentOptions, VueComponent] = parseBaseComponent(vueOptions)
const lifetimes = componentOptions.lifetimes
// 基础库 2.0 以上 attached 顺序错乱,按照 created 顺序强制纠正
componentOptions.lifetimes.created = function created () {
lifetimes.created = function created () {
currentComponents(this, components => {
components.push(this)
})
}
componentOptions.lifetimes.attached = function attached () {
lifetimes.attached = function attached () {
this.__lifetimes_attached = function () {
const properties = this.properties
......@@ -48,6 +58,7 @@ export default function parseComponent (vueOptions) {
// 触发首次 setData
this.$vm.$mount()
}
currentComponents(this, components => {
let component = this
while (component && component.__lifetimes_attached && components[0] && component === components[0]) {
components.shift()
......@@ -55,10 +66,20 @@ export default function parseComponent (vueOptions) {
delete component.__lifetimes_attached
component = components[0]
}
})
}
lifetimes.detached = function detached () {
currentComponents(this, components => {
const index = components.indexOf(this)
if (index >= 0) {
components.splice(index, 1)
}
})
}
// ready 比 handleLink 还早,初始化逻辑放到 handleLink 中
delete componentOptions.lifetimes.ready
delete lifetimes.ready
componentOptions.methods.__l = handleLink
......
import {
isPage,
instances,
components,
initRelation
} from './util'
......@@ -11,8 +12,17 @@ export default function parsePage (vuePageOptions) {
isPage,
initRelation
})
const lifetimes = pageOptions.lifetimes
const oldCreated = lifetimes.created
lifetimes.created = function created () {
const webviewId = this.__webviewId__
components[webviewId] = []
if (typeof oldCreated === 'function') {
oldCreated.call(this)
}
}
// 页面需要在 ready 中触发,其他组件是在 handleLink 中触发
pageOptions.lifetimes.ready = function ready () {
lifetimes.ready = function ready () {
if (this.$vm && this.$vm.mpType === 'page') {
this.$vm.__call_hook('created')
this.$vm.__call_hook('beforeMount')
......@@ -23,8 +33,11 @@ export default function parsePage (vuePageOptions) {
this.is && console.warn(this.is + ' is not ready')
}
}
pageOptions.lifetimes.detached = function detached () {
const oldDetached = lifetimes.detached
lifetimes.detached = function detached () {
if (typeof oldDetached === 'function') {
oldDetached.call(this)
}
this.$vm && this.$vm.$destroy()
// 清理
const webviewId = this.__webviewId__
......@@ -33,6 +46,7 @@ export default function parsePage (vuePageOptions) {
delete instances[key]
}
})
delete components[webviewId]
}
return pageOptions
......
......@@ -52,6 +52,7 @@ export function initRefs (vm) {
}
export const instances = Object.create(null)
export const components = Object.create(null)
export function initRelation ({
vuePid,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册