-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[platform] xurna123 提交组件改动:mip-qb-ad #177
Open
mip-audit-platform
wants to merge
1
commit into
master
Choose a base branch
from
dev-platform-714990e4b8ee40d87a17b7605f36ed23
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# mip-qb-ad | ||
|
||
mip-qb-ad 组件说明 | ||
|
||
标题|内容 | ||
----|---- | ||
类型|通用 | ||
支持布局|responsive,fixed-height,fill,container,fixed | ||
所需脚本|https://mipcache.bdstatic.com/static/v1/mip-qb-ad/mip-qb-ad.js | ||
|
||
## 示例 | ||
|
||
### 基本用法 | ||
`<mip-qb-ad>` 具有多种类型(`type`),`type` 取值由广告分类决定。 | ||
|
||
### 1. type=default | ||
| 参数 | 参数值 | 是否必须 | | ||
| -------- | -------- | ------------------------| | ||
| type | default | 是 | | ||
| src | script中src的值 | 是 | | ||
|
||
适用于以下广告格式: | ||
```html | ||
<script type="text/javascript" src="广告js地址"></script> | ||
``` | ||
示例: | ||
```html | ||
<mip-qb-ad type="default" src="//fzb01.qiushibaike.com/production/sesln1.js?togl=nkpqq"></mip-qb-ad> | ||
``` | ||
|
||
### 2. type=smua | ||
| 参数 | 参数值 | 是否必须 | | ||
| -------- | -------- | ------------------------| | ||
| type | smua | 是 | | ||
| src | script中smua的属性值 | 是 | | ||
|
||
适用于以下广告格式: | ||
```html | ||
<script type="text/javascript" smua="smua属性值" src="//www.smucdn.com/smu0/o.js"></script> | ||
``` | ||
示例: | ||
```html | ||
<mip-qb-ad type="smua" src="d=m&s=b&u=u3594595&h=330"></mip-qb-ad> | ||
``` | ||
|
||
### 3. type=sogou | ||
| 参数 | 参数值 | 是否必须 | | ||
| -------- | -------- | ------------------------| | ||
| type | sogou | 是 | | ||
| src | 搜狗id | 是 | | ||
| script | script中src的值 | 否,默认为`//theta.sogoucdn.com/wap/js/aw.js`| | ||
|
||
适用于以下广告格式: | ||
```html | ||
<div id="sogou_wap_搜狗id"></div> | ||
<script> | ||
var sogou_div = document.getElementById("sogou_wap_搜狗id"); | ||
window.sogou_un = window.sogou_un || []; | ||
window.sogou_un.push({id: "搜狗id",ele:sogou_div}); | ||
</script> | ||
<script async="async" src="//theta.sogoucdn.com/wap/js/aw.js"></script> | ||
``` | ||
示例: | ||
```html | ||
<mip-qb-ad type="sogou" src="1000745" script=""></mip-qb-ad> | ||
``` | ||
|
||
### 3. type=sogou_auto | ||
| 参数 | 参数值 | 是否必须 | | ||
| -------- | -------- | ------------------------| | ||
| type | sogou | 是 | | ||
| src | 搜狗id | 是 | | ||
| w | w值 | 是 | | ||
| h | h值 | 是 | | ||
| script | script中src的值 | 否,默认为`//theta.sogoucdn.com/wap/js/aw.js`| | ||
|
||
适用于以下广告格式: | ||
```html | ||
<div id="sogou_wap_搜狗id"></div> | ||
<script> | ||
var sogou_div = document.getElementById("sogou_wap_搜狗id"); | ||
window.sogou_un = window.sogou_un || []; | ||
window.sogou_un.push({id: "搜狗id",ele:sogou_div,w:20,h:5}); | ||
</script> | ||
<script async="async" src="//theta.sogoucdn.com/wap/js/aw.js"></script> | ||
``` | ||
示例: | ||
```html | ||
<mip-qb-ad type="sogou_auto" src="1001690" w="20" h="5" script=""></mip-qb-ad> | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* @file mip-qb-ad 组件 | ||
* @author | ||
*/ | ||
|
||
define(function (require) { | ||
'use strict'; | ||
|
||
let customElement = require('customElement').create(); | ||
|
||
/** | ||
* 第一次进入可视区回调,只会执行一次 | ||
*/ | ||
customElement.prototype.firstInviewCallback = function () { | ||
}; | ||
/** | ||
* 构造元素,只会运行一次 | ||
*/ | ||
// build说明: 异步广告备用组件 | ||
customElement.prototype.build = function () { | ||
let el = this.element; | ||
let type = el.getAttribute('type') || ''; | ||
let src = el.getAttribute('src') || ''; | ||
let sogouW = el.getAttribute('w') || ''; | ||
let sogouH = el.getAttribute('h') || ''; | ||
let script = el.getAttribute('script') || ''; | ||
let innerScriptNode = document.createElement('script'); | ||
let adScriptLoaderNode = document.createElement('script'); | ||
let container = document.createElement('div'); | ||
container.style.minHeight = '50px'; | ||
let scriptHtml = ''; | ||
if (type === 'default') { | ||
// 适合只有src属性的单条script | ||
adScriptLoaderNode.src = src; | ||
} else if (type === 'smua') { | ||
// 适合 <script type="text/javascript" smua="d=m&s=b&u=u3687389&h=106" src="//www.smucdn.com/smu0/o.js"></script> | ||
adScriptLoaderNode.src = '//www.smucdn.com/smu0/o.js'; | ||
adScriptLoaderNode.setAttribute('smua', src); | ||
} else if (type === 'sogou') { | ||
// 适合异步的sogou广告 | ||
container.id = 'sogou_wap_' + src; | ||
scriptHtml = 'var sogou_div = document.getElementById("sogou_wap_' + src + '"); '; | ||
scriptHtml += 'window.sogou_un = window.sogou_un || [];'; | ||
scriptHtml += 'window.sogou_un.push({id: ' + src + ',ele:sogou_div});'; | ||
adScriptLoaderNode.src = script || '//theta.sogoucdn.com/wap/js/aw.js'; | ||
} else if (type === 'sogou_auto') { | ||
// 适合需要自定义配置w和h的搜狗广告 | ||
container.id = 'sogou_wap_' + src; | ||
scriptHtml = 'var sogou_div = document.getElementById("sogou_wap_' + src + '"); '; | ||
scriptHtml += 'window.sogou_un = window.sogou_un || [];'; | ||
scriptHtml += 'window.sogou_un.push({id: ' + src + ',ele:sogou_div,w:' + sogouW + ',h:' + sogouH + '});'; | ||
adScriptLoaderNode.src = script || '//theta.sogoucdn.com/wap/js/aw.js'; | ||
} | ||
innerScriptNode.innerHTML = scriptHtml; | ||
// adScriptLoaderNode.onload = () => el.customElement.applyFillContent(container, true) | ||
container.appendChild(innerScriptNode); | ||
container.appendChild(adScriptLoaderNode); | ||
el.appendChild(container); | ||
}; | ||
|
||
return customElement; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* @file mip-qb-ad样式文件 | ||
*/ | ||
|
||
mip-qb-ad { | ||
// TODO | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "mip-qb-ad", | ||
"version": "1.0.0", | ||
"description": "支持smua,sogou等广告代码", | ||
"contributors": [ | ||
{ | ||
"name": "Xurna Yang", | ||
"email": "565627595@qq.com" | ||
} | ||
], | ||
"engines": { | ||
"mip": ">=1.1.0" | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mip 组件禁止动态插入 script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
除了官网提供的广告代码格式,如果有其他格式的广告代码,是不是不能通过自定义组件创建?