Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobao-mini-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinhaitao
taobao-mini-template
Commits
ad8ed9f3
Commit
ad8ed9f3
authored
Sep 17, 2021
by
qinhaitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
🎸
云告警
parent
940d97d2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
app.js
c_client/src/app.js
+5
-0
dingTalk.js
c_client/src/utils/dingTalk.js
+54
-0
No files found.
c_client/src/app.js
View file @
ad8ed9f3
...
...
@@ -6,11 +6,16 @@ import './taro-ui.scss'
import
config
from
'./config/config'
import
'./utils/mdProxy'
import
{
cloundAlarm
}
from
'./utils/dingTalk'
const
{
env
,
tornadoAPI
,
defaultActivityId
}
=
config
cloud
.
init
({
env
})
Taro
.
onError
(
msg
=>
{
cloundAlarm
(
msg
,
env
,
requestType
)
})
class
App
extends
Component
{
onLaunch
(
options
)
{
console
.
log
(
'options :>> '
,
options
)
...
...
c_client/src/utils/dingTalk.js
0 → 100644
View file @
ad8ed9f3
import
Taro
from
'@tarojs/taro'
;
import
*
as
configPackage
from
'../../package.json'
/**
* 告警信息
* @param message
*/
export
const
cloundAlarm
=
async
(
message
,
env
,
requestType
)
=>
{
console
.
warn
(
configPackage
)
const
{
title
,
author
,
phone
}
=
configPackage
const
envTxt
=
{
'test'
:
'测试环境'
,
'pre'
:
'预发环境'
,
'online'
:
'线上环境'
,
'local'
:
'本地环境'
}
if
(
requestType
!==
'cloud'
)
return
// https://oapi.dingtalk.com/robot/send?access_token= f6d0d8ecdab3ad77dc51b5173f630f1c0e0fcbe90e994d0a642fb0b516dfd24c
// 测试 d452c99b12d3fe67472c681e76b13ed5b2355c3e2c3b856a1c3a9897a103986b
const
text
=
{
"msgtype"
:
"markdown"
,
"markdown"
:
{
"title"
:
"小程序客户端云告警"
,
"text"
:
`### 活动名称:
${
title
}
\n > #### 来源:小程序Taro客户端\n > \n > #### 环境:
${
envTxt
[
env
]}
\n > #### 告警内容:
${
message
}
\n > @
${
author
}
`
},
"at"
:
{
"isAtAll"
:
false
,
"atMobiles"
:
[],
"atUserIds"
:
[]
}
}
await
Taro
.
request
(
{
'url'
:
'https://oapi.dingtalk.com/robot/send?access_token=f6d0d8ecdab3ad77dc51b5173f630f1c0e0fcbe90e994d0a642fb0b516dfd24c'
,
'method'
:
'POST'
,
'header'
:
{
'content-type'
:
'application/json;charset=UTF-8'
,
},
'data'
:
text
}
);
Taro
.
request
(
{
'url'
:
'https://oapi.dingtalk.com/robot/send?access_token=f6d0d8ecdab3ad77dc51b5173f630f1c0e0fcbe90e994d0a642fb0b516dfd24c'
,
'method'
:
'POST'
,
'header'
:
{
'content-type'
:
'application/json;charset=UTF-8'
,
},
'data'
:
{
"msgtype"
:
"text"
,
"at"
:
{
"isAtAll"
:
false
,
"atMobiles"
:
[
phone
],
"atUserIds"
:
[]
},
"text"
:
{
'content'
:
'云告警↑↑↑↑↑'
}
}
}
);
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment