Skip to content
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

非移动端访问移动端页面时,进行跳转到pc页面 #841

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
82 changes: 41 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
{
"name": "mip2-extensions-platform",
"version": "1.0.0",
"description": "MIP 2.0 站长组件",
"scripts": {
"lint": "eslint --ext .vue,.js .",
"validate": "sh tools/validate.sh",
"deploy:preview": "sh tools/build.sh",
"fix": "eslint --ext .vue,.js . --fix"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/mipengine/mip2-extensions-platform.git"
},
"keywords": [
"MIP"
],
"author": "MIP",
"license": "MIT",
"devDependencies": {
"babel-eslint": "^8.2.5",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jsdoc": "^3.7.1",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"eslint-plugin-vue": "^4.5.0",
"execa": "^0.11.0",
"fs-extra": "^7.0.1",
"glob": "^7.1.3",
"husky": "^1.0.0-rc.8",
"mip2": "^1.5.2"
}
}
{
"name": "mip2-extensions-platform",
"version": "1.0.0",
"description": "MIP 2.0 站长组件",
"scripts": {
"lint": "eslint --ext .vue,.js .",
"validate": "sh tools/validate.sh",
"deploy:preview": "sh tools/build.sh",
"fix": "eslint --ext .vue,.js . --fix"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/mipengine/mip2-extensions-platform.git"
},
"keywords": [
"MIP"
],
"author": "MIP",
"license": "MIT",
"devDependencies": {
"babel-eslint": "^8.2.5",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jsdoc": "^3.7.1",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"eslint-plugin-vue": "^4.5.0",
"execa": "^0.11.0",
"fs-extra": "^7.0.1",
"glob": "^7.1.3",
"husky": "^1.3.1",
"mip2": "^1.5.2"
}
}
14 changes: 14 additions & 0 deletions sites/www.188soft.com/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
UTF-8
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{js,styl,html,json,vue}]
indent_size = 2
indent_style = space
[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions sites/www.188soft.com/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
39 changes: 39 additions & 0 deletions sites/www.188soft.com/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"parser": "vue-eslint-parser",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
"allowImportExportEverywhere": false
},
"extends": [
"standard",
"plugin:vue/recommended"
],
"plugins": [
"jsdoc"
],
"globals": {
"MIP": true
},
"env": {
"browser": true
},
"rules": {
"jsdoc/check-param-names": 1,
"jsdoc/check-tag-names": 1,
"jsdoc/check-types": 1,
"jsdoc/newline-after-description": 1,
"jsdoc/no-undefined-types": 1,
"jsdoc/require-description-complete-sentence": 0,
"jsdoc/require-example": 0,
"jsdoc/require-hyphen-before-param-description": 0,
"jsdoc/require-param": 1,
"jsdoc/require-param-description": 1,
"jsdoc/require-param-name": 1,
"jsdoc/require-param-type": 1,
"jsdoc/require-returns-description": 1,
"jsdoc/require-returns-type": 1,
"jsdoc/valid-types": 1,
"no-var": 2
}
}
8 changes: 8 additions & 0 deletions sites/www.188soft.com/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
dist/
.idea/
*.log
Thumbs.db
.DS_Store
*.swp
*.gz
Empty file.
45 changes: 45 additions & 0 deletions sites/www.188soft.com/components/mip-soft-jump/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# mip-soft-jump

| 标题 | 内容 |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 类型 |
| 支持布局 |
| 所需脚本 | [https://c.mipcdn.com/extensions/platform/v2/www.188soft.com/mip-soft-jump/mip-soft-jump.js](https://c.mipcdn.com/extensions/platform/v2/www.188soft.com/mip-soft-jump/mip-soft-jump.js) |

## 说明

判断用户使用是移动端还是非移动端,如果是非移动端访问m站时,页面进行跳转到www站

## 示例

示例说明

``` html
<!DOCTYPE html>
<html mip>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,user-scalable=no">
<title>MIP page</title>
<link rel="canonical" href="对应的原页面地址">
<link rel="stylesheet" href="https://c.mipcdn.com/static/v2/mip.css">
<style mip-custom>
/* 自定义样式 */

</style>
</head>

<body>
<div>
<mip-soft-jump></mip-soft-jump>
</div>
<script src="https://c.mipcdn.com/static/v2/mip.js"></script>
<script src="/mip-soft-jump/mip-soft-jump.js"></script>
</body>

</html>
```

## 属性
24 changes: 24 additions & 0 deletions sites/www.188soft.com/components/mip-soft-jump/example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html mip>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,user-scalable=no">
<title>MIP page</title>
<link rel="canonical" href="对应的原页面地址">
<link rel="stylesheet" href="https://c.mipcdn.com/static/v2/mip.css">
<style mip-custom>
/* 自定义样式 */

</style>
</head>

<body>
<div>
<mip-soft-jump></mip-soft-jump>
</div>
<script src="https://c.mipcdn.com/static/v2/mip.js"></script>
<script src="/mip-soft-jump/mip-soft-jump.js"></script>
</body>

</html>
6 changes: 6 additions & 0 deletions sites/www.188soft.com/components/mip-soft-jump/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mip-soft-jump {
.wrapper {
margin: 0 auto;
text-align: center;
}
}
77 changes: 77 additions & 0 deletions sites/www.188soft.com/components/mip-soft-jump/mip-soft-jump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* @file 188soft网站js判断非移动端访问M站,跳转到www站
* @author wangying ([email protected])
*/
import './index.less'

export default class MIPExample extends MIP.CustomElement {
connectedCallback () {
let urls = window.location.href
// 获取域名
let domain = urls.split('/')
if (domain[2]) {
domain = domain[2]
}
// 移动平台不跳,非移动平台就跳转
if (!(navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
let mprefix = null
let wprefix = null
if (domain === 'm.188soft.com') { // 188soft
mprefix = 'http://m.188soft.com'
wprefix = 'http://www.188soft.com'
let soft = urls.toString().split('soft/')[1]
let sort = urls.toString().split('sorts/')[1]
let info = urls.toString().split('info/')[1]
let list = null
if (sort !== 'game/' && sort !== '') {
list = '/sorts/' + sort
}
let softDetail = '/soft/' + soft
let infoDetail = '/info/' + info
if (urls === mprefix + list && sort !== '') { // 聚合页(列表)
getData(mprefix + list, wprefix + list)
window.location.href = wprefix + list
} else if (urls === mprefix + softDetail && soft !== '') { // 软件详情页
getData(mprefix + softDetail, wprefix + softDetail)
window.location.href = wprefix + softDetail
} else if (urls === mprefix + infoDetail && info !== '') { // 资讯情页
getData(mprefix + infoDetail, wprefix + infoDetail)
window.location.href = wprefix + infoDetail
}
switch (urls) {
case 'http://m.188soft.com/': // 首页
getData('http://m.188soft.com/', 'http://www.188soft.com/')
window.location.href = 'http://www.188soft.com/'
break
case 'http://m.188soft.com/new/': // 最近更新
getData('http://m.188soft.com/new/', 'http://www.188soft.com/new/')
window.location.href = 'http://www.188soft.com/new/'
break
case 'http://m.188soft.com/sorts/': // 软件频道页
getData('http://m.188soft.com/sorts/', 'http://www.188soft.com/sorts/')
window.location.href = 'http://www.188soft.com/sorts/'
break
case 'http://m.188soft.com/news/': // 资讯页
getData('http://m.188soft.com/news/', 'http://www.188soft.com/news/')
window.location.href = 'http://www.188soft.com/news/'
break
case 'http://m.188soft.com/sorts/game/': // 安卓手游频道页
getData('http://m.188soft.com/sorts/game/', 'http://www.188soft.com/sorts/game/')
window.location.href = 'http://www.188soft.com/sorts/game/'
break
default:
}
}
}

function getData (startUrl, endUrl) { // 跳转统计接口
fetch('https://mip.js.xzstatic.com/collect', {
method: 'POST',
body: 'startUrl=' + startUrl + '&endUrl=' + endUrl,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
}
}
}
26 changes: 26 additions & 0 deletions sites/www.188soft.com/example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html mip>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,user-scalable=no">
<title>MIP page</title>
<link rel="canonical" href="对应的原页面地址">
<link rel="stylesheet" href="https://c.mipcdn.com/static/v2/mip.css">
<style mip-custom>
/* 自定义样式 */
h2 {
margin: 50px auto;
text-align: center;
}
</style>
</head>
<body>
<div>
<h2>First MIP page</h2>
<h2>Add MIP components here</h2>
<mip-example></mip-example>
</div>
<script src="https://c.mipcdn.com/static/v2/mip.js"></script>
<script src="/mip-example/mip-example.js"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions sites/www.188soft.com/mip.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @file mip页面项目配置项
* @author
*/

module.exports = {
dev: {
/**
* 启动mip server调试的端口号
*
* @type {number}
*/
port: 8111,

/**
* 启用调试页面自动刷新
*
* @type {boolean}
*/
livereload: true,

/**
* server 启动自动打开页面,false 为关闭
* 如:
* autoopen: '/example/index.html'
*
* @type {string|boolean}
*/
autoopen: false
}
}
25 changes: 25 additions & 0 deletions sites/www.188soft.com/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "www.188soft.com",
"version": "0.0.1",
"description": "A MIP project",
"scripts": {
"dev": "mip2 dev",
"build": "mip2 build",
"lint": "npm run lint:js",
"lint:js": "eslint --ext .vue,.js .",
"fix": "npm run fix:js",
"fix:js": "eslint --ext .vue,.js . --fix"
},
"author": "[email protected]",
"dependencies": {},
"devDependencies": {
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jsdoc": "^3.7.1",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"eslint-plugin-vue": "^4.5.0"
}
}
Empty file.
Loading