Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
菜鸟程序猿_c
uni-app
提交
313f85a4
U
uni-app
项目概览
菜鸟程序猿_c
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
313f85a4
编写于
8月 24, 2021
作者:
M
mehaotian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(stat): 统计兼容vue3
上级
f4733de0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
38 deletion
+36
-38
packages/uni-stat/src/index.js
packages/uni-stat/src/index.js
+20
-6
packages/uni-stat/src/parameter.js
packages/uni-stat/src/parameter.js
+5
-17
packages/uni-stat/src/stat.js
packages/uni-stat/src/stat.js
+11
-15
未找到文件。
packages/uni-stat/src/index.js
浏览文件 @
313f85a4
...
...
@@ -3,12 +3,15 @@ const stat = Stat.getInstance()
let
isHide
=
false
const
lifecycle
=
{
onLaunch
(
options
)
{
console
.
log
(
'
report onLaunch init
'
)
stat
.
report
(
options
,
this
)
},
onReady
()
{
console
.
log
(
'
report onReady init
'
)
stat
.
ready
(
this
)
},
onLoad
(
options
)
{
console
.
log
(
'
report onLoad init
'
)
stat
.
load
(
options
,
this
)
// 重写分享,获取分享上报事件
if
(
this
.
$scope
&&
this
.
$scope
.
onShareAppMessage
)
{
...
...
@@ -20,14 +23,17 @@ const lifecycle = {
}
},
onShow
()
{
console
.
log
(
'
report onShow init
'
)
isHide
=
false
stat
.
show
(
this
)
},
onHide
()
{
console
.
log
(
'
report onHide init
'
)
isHide
=
true
stat
.
hide
(
this
)
},
onUnload
()
{
console
.
log
(
'
report onUnload init
'
)
if
(
isHide
)
{
isHide
=
false
return
...
...
@@ -35,20 +41,28 @@ const lifecycle = {
stat
.
hide
(
this
)
},
onError
(
e
)
{
console
.
log
(
'
report onError init
'
)
stat
.
error
(
e
)
},
}
function
main
()
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
uni
.
report
=
function
(
type
,
options
)
{}
}
else
{
const
Vue
=
require
(
'
vue
'
)
;(
Vue
.
default
||
Vue
).
mixin
(
lifecycle
)
console
.
log
(
'
stat onload ----
'
)
setTimeout
(()
=>
{
getApp
().
$
.
appContext
.
app
.
mixin
(
lifecycle
)
uni
.
report
=
function
(
type
,
options
)
{
stat
.
sendEvent
(
type
,
options
)
}
}
},
1
)
// if (process.env.NODE_ENV === 'development') {
// uni.report = function (type, options) {}
// } else {
// const Vue = require('vue')
// ;(Vue.default || Vue).mixin(lifecycle)
// uni.report = function (type, options) {
// stat.sendEvent(type, options)
// }
// }
}
main
()
packages/uni-stat/src/parameter.js
浏览文件 @
313f85a4
...
...
@@ -238,41 +238,29 @@ export const getRoute = () => {
var
pages
=
getCurrentPages
()
var
page
=
pages
[
pages
.
length
-
1
]
if
(
!
page
)
return
''
// TODO 需要确认如果不用 $vm ,其他平台会不会出错
let
_self
=
page
.
$vm
if
(
getPlatformName
()
===
'
bd
'
)
{
return
_self
.
$mp
&&
_self
.
$mp
.
page
.
is
}
else
{
return
(
(
_self
.
$scope
&&
_self
.
$scope
.
route
)
||
(
_self
.
$mp
&&
_self
.
$mp
.
page
.
route
)
)
return
_self
.
route
||
(
_self
.
$mp
&&
_self
.
$mp
.
page
.
route
)
}
}
export
const
getPageRoute
=
(
self
)
=>
{
var
pages
=
getCurrentPages
()
var
page
=
pages
[
pages
.
length
-
1
]
if
(
!
page
)
return
''
let
_self
=
page
.
$vm
let
route
=
getRoute
()
let
query
=
self
.
_query
let
str
=
query
&&
JSON
.
stringify
(
query
)
!==
'
{}
'
?
'
?
'
+
JSON
.
stringify
(
query
)
:
''
// clear
self
.
_query
=
''
if
(
getPlatformName
()
===
'
bd
'
)
{
return
_self
.
$mp
&&
_self
.
$mp
.
page
.
is
+
str
}
else
{
return
(
(
_self
.
$scope
&&
_self
.
$scope
.
route
+
str
)
||
(
_self
.
$mp
&&
_self
.
$mp
.
page
.
route
+
str
)
)
}
return
route
+
str
}
export
const
getPageTypes
=
(
self
)
=>
{
if
(
self
.
mpType
===
'
page
'
||
self
.
$
mpType
===
'
page
'
||
(
self
.
$mp
&&
self
.
$mp
.
mpType
===
'
page
'
)
||
self
.
$options
.
mpType
===
'
page
'
)
{
...
...
packages/uni-stat/src/stat.js
浏览文件 @
313f85a4
...
...
@@ -26,7 +26,7 @@ import {
import
{
STAT_URL
,
STAT_VERSION
,
STAT_H5_URL
,
OPERATING_TIME
}
from
'
./config
'
const
titleJsons
=
process
.
env
.
UNI_STAT_
PAGES_TITLE
const
titleJsons
=
process
.
env
.
UNI_STAT_
TITLE_JSON
const
statConfig
=
{
appid
:
process
.
env
.
UNI_APP_ID
,
}
...
...
@@ -130,11 +130,11 @@ class Util {
}
getLastTime
()
this
.
_lastPageRoute
=
route
const
time
=
getResidenceTime
(
'
page
'
)
// 停留时间
if
(
time
.
overtime
)
{
let
options
=
{
path
:
this
.
_lastPageR
oute
,
path
:
r
oute
,
scene
:
this
.
statData
.
sc
,
}
this
.
_sendReportRequest
(
options
)
...
...
@@ -146,11 +146,13 @@ class Util {
if
(
!
this
.
__licationHide
)
{
getLastTime
()
const
time
=
getResidenceTime
(
'
page
'
)
const
route
=
getPageRoute
(
this
)
this
.
_sendPageRequest
({
url
:
this
.
_lastPageR
oute
,
url
:
r
oute
,
urlref
:
this
.
_lastPageRoute
,
urlref_ts
:
time
.
residenceTime
,
})
this
.
_lastPageRoute
=
route
this
.
_navigationBarTitle
=
{
config
:
''
,
page
:
''
,
...
...
@@ -306,7 +308,6 @@ class Util {
data
.
ttn
=
title
.
page
data
.
ttpj
=
title
.
config
data
.
ttc
=
title
.
report
let
requestData
=
this
.
_reportingRequestData
if
(
getPlatformName
()
===
'
n
'
)
{
requestData
=
uni
.
getStorageSync
(
'
__UNI__STAT__DATA
'
)
||
{}
...
...
@@ -376,9 +377,6 @@ class Util {
uni
.
request
({
url
:
STAT_URL
,
method
:
'
POST
'
,
// header: {
// 'content-type': 'application/json' // 默认值
// },
data
:
optionsData
,
success
:
()
=>
{
// if (process.env.NODE_ENV === 'development') {
...
...
@@ -494,19 +492,17 @@ class Stat extends Util {
report
(
options
,
self
)
{
this
.
self
=
self
// if (process.env.NODE_ENV === 'development') {
// console.log('report init');
// }
setPageResidenceTime
()
this
.
__licationShow
=
true
this
.
_sendReportRequest
(
options
,
true
)
}
load
(
options
,
self
)
{
if
(
!
self
.
$scope
&&
!
self
.
$mp
)
{
const
page
=
getCurrentPages
()
self
.
$scope
=
page
[
page
.
length
-
1
]
}
// if (!self.$scope && !self.$mp) {
// const page = getCurrentPages()
// console.log();
// self.$scope = page[page.length - 1]
// }
this
.
self
=
self
this
.
_query
=
options
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录