parent
a3cb935c2e
commit
4b236bc289
@ -0,0 +1,17 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="utf-8"> |
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0"> |
||||||
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> |
||||||
|
<title>App下载</title> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<noscript> |
||||||
|
<strong>We're sorry but fly doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> |
||||||
|
</noscript> |
||||||
|
<div id="download"></div> |
||||||
|
<!-- built files will be auto injected --> |
||||||
|
</body> |
||||||
|
</html> |
@ -1,51 +1,16 @@ |
|||||||
import Vue from 'vue' |
import Vue from 'vue' |
||||||
import App from "@/App"; |
import Download from "@/Download.vue"; |
||||||
import router from "@/router"; |
import router from "@/router/download.js"; |
||||||
import ElementUI from 'element-ui' |
import ElementUI from 'element-ui' |
||||||
import 'element-ui/lib/theme-chalk/index.css' |
import 'element-ui/lib/theme-chalk/index.css' |
||||||
import Vuex from 'vuex' |
|
||||||
const qiniu = require('qiniu-js'); |
|
||||||
Vue.prototype.qiniu = qiniu; |
|
||||||
|
|
||||||
//使用vue-cookies
|
|
||||||
import VueCookies from 'vue-cookies' |
|
||||||
|
|
||||||
Vue.use(VueCookies); |
|
||||||
|
|
||||||
//导入全局的geetest.js
|
|
||||||
import './assets/gt' |
|
||||||
|
|
||||||
|
|
||||||
//导入store实例
|
|
||||||
import store from "./store"; |
|
||||||
|
|
||||||
//全局导航守卫
|
|
||||||
router.beforeEach((to, from, next) => { |
|
||||||
// ...
|
|
||||||
|
|
||||||
if (VueCookies.isKey('access_token')) { |
|
||||||
let user = { |
|
||||||
username: VueCookies.get('username'), |
|
||||||
shop_cart_num: VueCookies.get('shop_cart_num'), |
|
||||||
access_token: VueCookies.get('access_token'), |
|
||||||
avatar: VueCookies.get('avatar'), |
|
||||||
notice_num: VueCookies.get('notice_num') |
|
||||||
}; |
|
||||||
store.dispatch('getUser', user) |
|
||||||
} |
|
||||||
next() |
|
||||||
|
|
||||||
}); |
|
||||||
|
|
||||||
|
|
||||||
Vue.config.productionTip = false; |
Vue.config.productionTip = false; |
||||||
|
|
||||||
Vue.use(ElementUI); |
Vue.use(ElementUI); |
||||||
Vue.use(Vuex); |
|
||||||
|
|
||||||
|
|
||||||
new Vue({ |
new Vue({ |
||||||
render: h => h(App), |
render: h => h(Download), |
||||||
router, |
router, |
||||||
store, |
}).$mount('#download'); |
||||||
}).$mount('#app'); |
|
||||||
|
@ -0,0 +1,117 @@ |
|||||||
|
import Axios from 'axios' |
||||||
|
const https = require('https'); |
||||||
|
Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; |
||||||
|
Axios.defaults.withCredentials = true; |
||||||
|
Axios.defaults.httpsAgent = new https.Agent({ |
||||||
|
keepAlive: true |
||||||
|
}); |
||||||
|
|
||||||
|
// Axios.defaults.baseURL='';
|
||||||
|
const USERSEVER = 'https://fir.dvcloud.xin/api/v1/fir/server'; |
||||||
|
|
||||||
|
// const USERSEVER = 'http://192.168.1.112:8000/api/v1/fir/server';
|
||||||
|
|
||||||
|
|
||||||
|
function getData(url, params = {}, callBack) { |
||||||
|
|
||||||
|
|
||||||
|
var uri = ''; |
||||||
|
var keys = Object.keys(params); |
||||||
|
var values = Object.values(params); |
||||||
|
for (var i = 0; i < keys.length; i++) { |
||||||
|
var key = keys[i]; |
||||||
|
var value = values[i]; |
||||||
|
uri = uri + key + "=" + value; |
||||||
|
if (i < keys.length - 1) { |
||||||
|
uri = uri + "&" |
||||||
|
} |
||||||
|
} |
||||||
|
if (uri !== "") { |
||||||
|
uri = "?" + uri |
||||||
|
} |
||||||
|
url = url + uri; |
||||||
|
Axios |
||||||
|
.get(url, params) |
||||||
|
.then(function (response) { |
||||||
|
callBack(response.data); |
||||||
|
let x = ''; |
||||||
|
if (x !== '') { |
||||||
|
alert(x) |
||||||
|
} |
||||||
|
}) |
||||||
|
.catch(function (error) { |
||||||
|
|
||||||
|
if (error && error.response) { |
||||||
|
switch (error.response.status) { |
||||||
|
case 400: |
||||||
|
error.message = '请求错误(400)'; |
||||||
|
break; |
||||||
|
case 401: |
||||||
|
error.message = '未授权,请重新登录(401)'; |
||||||
|
break; |
||||||
|
case 403: |
||||||
|
error.message = '拒绝访问(403)'; |
||||||
|
break; |
||||||
|
case 404: |
||||||
|
error.message = '请求出错(404)'; |
||||||
|
break; |
||||||
|
case 408: |
||||||
|
error.message = '请求超时(408)'; |
||||||
|
break; |
||||||
|
case 500: |
||||||
|
error.message = '服务器错误(500)'; |
||||||
|
break; |
||||||
|
case 501: |
||||||
|
error.message = '服务未实现(501)'; |
||||||
|
break; |
||||||
|
case 502: |
||||||
|
error.message = '网络错误(502)'; |
||||||
|
break; |
||||||
|
case 503: |
||||||
|
error.message = '服务不可用(503)'; |
||||||
|
break; |
||||||
|
case 504: |
||||||
|
error.message = '网络超时(504)'; |
||||||
|
break; |
||||||
|
case 505: |
||||||
|
error.message = 'HTTP版本不受支持(505)'; |
||||||
|
break; |
||||||
|
default: |
||||||
|
error.message = `连接出错(${error.response.status})!`; |
||||||
|
} |
||||||
|
} else { |
||||||
|
error.message = '连接服务器失败!'; |
||||||
|
} |
||||||
|
if (error.message === 'Network Error') { |
||||||
|
alert('网络连接失败') |
||||||
|
} |
||||||
|
|
||||||
|
callBack(null); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**根据短链接获取应用信息 */ |
||||||
|
export function getShortAppinfo(callBack, params) { |
||||||
|
getData( |
||||||
|
USERSEVER + '/short/' + params.short , |
||||||
|
params, |
||||||
|
data => { |
||||||
|
callBack(data); |
||||||
|
}, |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/**获取下载的url */ |
||||||
|
export function getdownloadurl(callBack, params) { |
||||||
|
getData( |
||||||
|
USERSEVER + '/install/'+params.app_id , |
||||||
|
params.data, |
||||||
|
data => { |
||||||
|
callBack(data); |
||||||
|
}, |
||||||
|
); |
||||||
|
} |
||||||
|
|
@ -0,0 +1,26 @@ |
|||||||
|
import Vue from 'vue' |
||||||
|
//1.先导入
|
||||||
|
import VueRouter from 'vue-router' |
||||||
|
//2.一定先use 一下
|
||||||
|
Vue.use(VueRouter); |
||||||
|
|
||||||
|
// 解决push 同一个路由的错误
|
||||||
|
const originalPush = VueRouter.prototype.push; |
||||||
|
VueRouter.prototype.push = function push(location) { |
||||||
|
return originalPush.call(this, location).catch(err => err) |
||||||
|
}; |
||||||
|
|
||||||
|
import FirDownload from "@/components/FirDownload.vue"; |
||||||
|
const router = new VueRouter({ |
||||||
|
mode:'history', |
||||||
|
routes: [ |
||||||
|
{ |
||||||
|
path: '/:short', |
||||||
|
name: 'FirDownload', |
||||||
|
component: FirDownload |
||||||
|
} |
||||||
|
] |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
export default router; |
@ -0,0 +1,16 @@ |
|||||||
|
module.exports = { |
||||||
|
pages: { |
||||||
|
index: { |
||||||
|
entry: 'src/main.js', |
||||||
|
template: 'public/index.html', |
||||||
|
chunks:['chunk-vendors','chunk-common','index'] |
||||||
|
}, |
||||||
|
|
||||||
|
download: { |
||||||
|
entry: 'src/download.js', |
||||||
|
template: 'public/download.html', |
||||||
|
chunks:['chunk-vendors','chunk-common','download'] |
||||||
|
|
||||||
|
}, |
||||||
|
} |
||||||
|
}; |
Loading…
Reference in new issue