Skip to content

Commit 3a55b29

Browse files
authored
新增自动推送组件 mip-linksubmit (#686)
* add mip-autopush * add doc url and change name * change to support submit type
1 parent 0a25dab commit 3a55b29

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# mip-linksubmit
2+
3+
自动推送组件。
4+
5+
标题|内容
6+
----|----
7+
类型|通用
8+
支持布局|N/S
9+
所需脚本| [https://c.mipcdn.com/static/v2/mip-linksubmit/mip-linksubmit.js](https://c.mipcdn.com/static/v2/mip-linksubmit/mip-linksubmit.js)
10+
11+
## 说明
12+
13+
在页面被访问时,页面 URL 将立即被推送给百度。百度自动推送相关[文档说明](https://ziyuan.baidu.com/college/courseinfo?id=267&page=2)
14+
15+
## 示例
16+
17+
```html
18+
<mip-linksubmit type="baidu"></mip-linksubmit>
19+
```
20+
21+
## 属性
22+
23+
### type
24+
25+
说明:自动推送类型
26+
27+
必选项:是
28+
29+
类型:字符串
30+
31+
取值:'baidu'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html mip>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,user-scalable=no">
6+
<title>MIP page</title>
7+
<link rel="canonical" href="对应的原页面地址">
8+
<link rel="stylesheet" href="https://c.mipcdn.com/static/v2/mip.css">
9+
<style mip-custom>
10+
/* 自定义样式 */
11+
</style>
12+
</head>
13+
<body>
14+
<div>
15+
<mip-linksubmit type="baidu"></mip-linksubmit>
16+
</div>
17+
<script src="https://c.mipcdn.com/static/v2/mip.js"></script>
18+
<script src="/mip-linksubmit/mip-linksubmit.js"></script>
19+
</body>
20+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export default class MIPLinksubmit extends MIP.CustomElement {
2+
build () {
3+
const type = this.element.getAttribute('type') || ''
4+
const bp = document.createElement('script')
5+
const curProtocol = window.location.protocol.split(':')[0]
6+
if (type === 'baidu') {
7+
if (curProtocol === 'https') {
8+
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'
9+
} else {
10+
bp.src = 'http://push.zhanzhang.baidu.com/push.js'
11+
}
12+
}
13+
const s = document.getElementsByTagName('script')[0]
14+
s.parentNode.insertBefore(bp, s)
15+
}
16+
}

0 commit comments

Comments
 (0)