控制台前端页面升级
This commit is contained in:
35
zyplayer-doc-ui/console-ui/src/common/api/console.js
Normal file
35
zyplayer-doc-ui/console-ui/src/common/api/console.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import Qs from 'qs'
|
||||
import request from './request'
|
||||
|
||||
export default {
|
||||
systemUpgradeInfo: data => {
|
||||
return request({url: '/system/info/upgrade', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
userLogin: data => {
|
||||
return request({url: '/login', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
userLogout: data => {
|
||||
return request({url: '/logout', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
getSelfUserInfo: data => {
|
||||
return request({url: '/user/info/selfInfo', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
getUserInfoList: data => {
|
||||
return request({url: '/user/info/list', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
updateUserInfo: data => {
|
||||
return request({url: '/user/info/update', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
deleteUserInfo: data => {
|
||||
return request({url: '/user/info/delete', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
userAuthList: data => {
|
||||
return request({url: '/user/info/auth/list', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
updateUserAuth: data => {
|
||||
return request({url: '/user/info/auth/update', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
resetPassword: data => {
|
||||
return request({url: '/user/info/resetPassword', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
};
|
||||
65
zyplayer-doc-ui/console-ui/src/common/api/request.js
Normal file
65
zyplayer-doc-ui/console-ui/src/common/api/request.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import axios from 'axios'
|
||||
import vue from '../../main'
|
||||
|
||||
const service = axios.create({
|
||||
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url process.env.APP_BASE_API
|
||||
timeout: 10000,
|
||||
headers: {'Content-type': 'application/x-www-form-urlencoded'},
|
||||
withCredentials: true
|
||||
});
|
||||
// 增加不需要验证结果的标记
|
||||
const noValidate = {
|
||||
"/zyplayer-doc-db/executor/execute": true,
|
||||
"/zyplayer-doc-db/datasource/test": true,
|
||||
};
|
||||
|
||||
service.interceptors.request.use(
|
||||
config => {
|
||||
config.needValidateResult = true;
|
||||
// 增加不需要验证结果的标记
|
||||
if (noValidate[config.url]) {
|
||||
config.needValidateResult = false;
|
||||
}
|
||||
return config
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
service.interceptors.response.use(
|
||||
response => {
|
||||
if (!!response.message) {
|
||||
vue.$message.error('请求错误:' + response.message);
|
||||
}else {
|
||||
if (!response.config.needValidateResult || response.data.errCode == 200) {
|
||||
return response.data;
|
||||
} else if (response.data.errCode == 400) {
|
||||
vue.$message.error('请先登录');
|
||||
let redirectUrl = '';
|
||||
let locationHref = window.location.href;
|
||||
if (locationHref.indexOf("?") >= 0) {
|
||||
let reg = new RegExp("(^|&)redirect=([^&]*)(&|$)", "i");
|
||||
let r = locationHref.substring(locationHref.indexOf("?") + 1).match(reg);
|
||||
if (r != null) {
|
||||
redirectUrl = unescape(r[2]);
|
||||
}
|
||||
}
|
||||
redirectUrl = redirectUrl || encodeURIComponent(window.location.href);
|
||||
vue.$router.push({path: '/user/login', query: {redirect: redirectUrl}});
|
||||
} else if (response.data.errCode == 402) {
|
||||
vue.$router.push("/common/noAuth");
|
||||
} else if (response.data.errCode !== 200) {
|
||||
vue.$message.error(response.data.errMsg || "未知错误");
|
||||
}
|
||||
}
|
||||
return Promise.reject('请求错误');
|
||||
},
|
||||
error => {
|
||||
console.log('err' + error);
|
||||
vue.$message.info('请求错误:' + error.message);
|
||||
return Promise.reject(error)
|
||||
}
|
||||
);
|
||||
export default service;
|
||||
@@ -1,23 +0,0 @@
|
||||
var URL = {
|
||||
userLogin: '/login',
|
||||
userLogout: '/logout',
|
||||
getSelfUserInfo: '/user/info/selfInfo',
|
||||
getUserInfoList: '/user/info/list',
|
||||
updateUserInfo: '/user/info/update',
|
||||
deleteUserInfo: '/user/info/delete',
|
||||
userAuthList: '/user/info/auth/list',
|
||||
updateUserAuth: '/user/info/auth/update',
|
||||
resetPassword: '/user/info/resetPassword',
|
||||
|
||||
systemUpgradeInfo: '/system/info/upgrade',
|
||||
};
|
||||
|
||||
var URL1 = {};
|
||||
|
||||
export default {
|
||||
URL, URL1
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
import apilist from './apilist'
|
||||
|
||||
var href = window.location.href;
|
||||
|
||||
var _fn = {
|
||||
href: href,
|
||||
// 本地启动时使用本地接口调试
|
||||
// HOST: 'http://local.zyplayer.com:8083/zyplayer-doc-manage',
|
||||
// HOST1: 'http://local.zyplayer.com:8083/zyplayer-doc-manage',
|
||||
// 也可以直接使用线上的服务调试
|
||||
// HOST: 'http://doc.zyplayer.com/zyplayer-doc-manage',
|
||||
// HOST1: 'http://doc.zyplayer.com/zyplayer-doc-manage',
|
||||
// 打包时使用下面这两行,文件就放在根目录下,所以当前路劲就好
|
||||
HOST: './',
|
||||
HOST1: './',
|
||||
|
||||
mixUrl: function (host, url) {
|
||||
var p;
|
||||
if (!host || !url || _fn.isEmptyObject(url)) {
|
||||
return;
|
||||
}
|
||||
url.HOST = host;
|
||||
for (p in url) {
|
||||
if (url[p].indexOf('http') == -1) {
|
||||
url[p] = host + url[p];
|
||||
}
|
||||
}
|
||||
return url;
|
||||
},
|
||||
//判断是否空对象
|
||||
isEmptyObject: function (obj) { //判断空对象
|
||||
if (typeof obj === "object" && !(obj instanceof Array)) {
|
||||
var hasProp = false;
|
||||
for (var prop in obj) {
|
||||
hasProp = true;
|
||||
break;
|
||||
}
|
||||
if (hasProp) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var apilist1 = _fn.mixUrl(_fn.HOST, apilist.URL);
|
||||
var apilist2 = _fn.mixUrl(_fn.HOST1, apilist.URL1);
|
||||
|
||||
export default {
|
||||
apilist1, apilist2
|
||||
};
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
const user = {
|
||||
isLogin: true,
|
||||
};
|
||||
const vue = {};
|
||||
const fullscreen = false;
|
||||
|
||||
export default {
|
||||
vue,
|
||||
user,
|
||||
fullscreen,
|
||||
}
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
import Qs from 'qs'
|
||||
import global from '../../config/global'
|
||||
import apimix from '../../config/apimix'
|
||||
|
||||
export default {
|
||||
data: {
|
||||
accessToken: '',
|
||||
},
|
||||
setAccessToken: function (token) {
|
||||
this.data.accessToken = token;
|
||||
},
|
||||
getAccessToken: function () {
|
||||
if (!this.data.accessToken) {
|
||||
var arr, reg = new RegExp("(^| )accessToken=([^;]*)(;|$)");
|
||||
if (arr = document.cookie.match(reg)) {
|
||||
this.data.accessToken = unescape(arr[2]);
|
||||
}
|
||||
}
|
||||
return this.data.accessToken;
|
||||
},
|
||||
validateResult: function (res, callback) {
|
||||
if (!!res.message) {
|
||||
global.vue.$message('请求错误:' + res.message);
|
||||
} else if (res.data.errCode == 400) {
|
||||
var href = encodeURIComponent(window.location.href);
|
||||
if (global.vue.$router.currentRoute.path != '/user/login') {
|
||||
global.vue.$message('请先登录');
|
||||
global.vue.$router.push({path: '/user/login', query: {redirect: href}});
|
||||
}
|
||||
} else if (res.data.errCode == 402) {
|
||||
global.vue.$router.push("/common/noAuth");
|
||||
} else if (res.data.errCode !== 200) {
|
||||
global.vue.$message(res.data.errMsg || "未知错误");
|
||||
} else {
|
||||
if (typeof callback == 'function') {
|
||||
callback(res.data);
|
||||
}
|
||||
}
|
||||
},
|
||||
post: function (url, param, callback) {
|
||||
param = param || {};
|
||||
param.accessToken = this.getAccessToken();
|
||||
global.vue.axios({
|
||||
method: "post",
|
||||
url: url,
|
||||
headers: {'Content-type': 'application/x-www-form-urlencoded'},
|
||||
data: Qs.stringify(param),
|
||||
withCredentials: true,
|
||||
}).then((res) => {
|
||||
console.log("ok", res);
|
||||
this.validateResult(res, callback);
|
||||
}).catch((res) => {
|
||||
console.log("error", res);
|
||||
this.validateResult(res);
|
||||
});
|
||||
},
|
||||
postNonCheck: function (url, param, callback) {
|
||||
param = param || {};
|
||||
param.accessToken = this.getAccessToken();
|
||||
global.vue.axios({
|
||||
method: "post",
|
||||
url: url,
|
||||
headers: {'Content-type': 'application/x-www-form-urlencoded'},
|
||||
data: Qs.stringify(param),
|
||||
withCredentials: true,
|
||||
}).then((res) => {
|
||||
console.log("ok", res);
|
||||
if (typeof callback == 'function') {
|
||||
callback(res.data);
|
||||
}
|
||||
}).catch((res) => {
|
||||
console.log("error", res);
|
||||
if (typeof callback == 'function') {
|
||||
callback(res.data);
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 返回不为空的字符串,为空返回def
|
||||
*/
|
||||
getNotEmptyStr(str, def) {
|
||||
if (isEmpty(str)) {
|
||||
return isEmpty(def) ? "" : def;
|
||||
}
|
||||
return str;
|
||||
},
|
||||
/**
|
||||
* 是否是空对象
|
||||
* @param obj
|
||||
* @returns
|
||||
*/
|
||||
isEmptyObject(obj) {
|
||||
return isEmpty(obj) || $.isEmptyObject(obj);
|
||||
},
|
||||
/**
|
||||
* 是否是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
isEmpty(str) {
|
||||
return (str == "" || str == null || str == undefined);
|
||||
},
|
||||
/**
|
||||
* 是否不是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
isNotEmpty(str) {
|
||||
return !isEmpty(str);
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import global from '../../config/global'
|
||||
|
||||
/**
|
||||
* 提示工具类
|
||||
* @author
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
export default {
|
||||
notOpen: function () {
|
||||
global.vue.$message({
|
||||
message: '该功能暂未开放,敬请期待!',
|
||||
type: 'warning',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
success: function (msg, time) {
|
||||
global.vue.$message({
|
||||
message: msg,
|
||||
duration: time || 3000,
|
||||
type: 'success',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
warn: function (msg, time) {
|
||||
global.vue.$message({
|
||||
message: msg,
|
||||
duration: time || 3000,
|
||||
type: 'warning',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
error: function (msg, time) {
|
||||
global.vue.$message({
|
||||
message: msg,
|
||||
duration: time || 3000,
|
||||
type: 'error',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user