前端拆分为单独项目来维护开发
This commit is contained in:
17
zyplayer-doc-ui/wiki-ui/src/common/config/apilist.js
Normal file
17
zyplayer-doc-ui/wiki-ui/src/common/config/apilist.js
Normal file
@@ -0,0 +1,17 @@
|
||||
var URL = {
|
||||
userLogin: '/user/login',
|
||||
getUserInfo: '/user/getUserInfo',
|
||||
pageUpdate: '/zyplayer-doc-wiki/page/update',
|
||||
pageList: '/zyplayer-doc-wiki/page/list',
|
||||
spaceList: '/zyplayer-doc-wiki/space/list',
|
||||
};
|
||||
|
||||
var URL1 = {};
|
||||
|
||||
export default {
|
||||
URL, URL1
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
70
zyplayer-doc-ui/wiki-ui/src/common/config/apimix.js
Normal file
70
zyplayer-doc-ui/wiki-ui/src/common/config/apimix.js
Normal file
@@ -0,0 +1,70 @@
|
||||
import apilist from './apilist'
|
||||
|
||||
var href = window.location.href;
|
||||
var EVT = '';
|
||||
var _evt = function () {
|
||||
if (href.indexOf('https://') > -1) {
|
||||
// 测试环境
|
||||
if (href.indexOf('https://test') > -1 && href.indexOf('https://test.') == -1) {
|
||||
EVT = 'https://test';
|
||||
// dev环境
|
||||
} else if (href.indexOf('https://dev') > -1 && href.indexOf('https://dev.') == -1) {
|
||||
EVT = 'https://dev';
|
||||
} else {
|
||||
EVT = 'https://'
|
||||
}
|
||||
return EVT;
|
||||
} else {
|
||||
// 测试环境
|
||||
if (href.indexOf('http://test') > -1 && href.indexOf('http://test.') == -1) {
|
||||
EVT = 'http://test';
|
||||
// dev环境
|
||||
} else if (href.indexOf('http://dev') > -1 && href.indexOf('http://dev.') == -1) {
|
||||
EVT = 'http://dev';
|
||||
} else {
|
||||
EVT = 'http://'
|
||||
}
|
||||
return EVT;
|
||||
}
|
||||
};
|
||||
|
||||
var _fn = {
|
||||
href: href,
|
||||
HOST: EVT + 'local.zyplayer.com:8083/zyplayer-doc-manage', //这里设置接口域名
|
||||
HOST1: EVT + 'local.zyplayer.com:8083', //设置多个接口域名
|
||||
mixUrl: function (host, url) {
|
||||
var p;
|
||||
if (!host || !url || _fn.isEmptyObject(url)) {
|
||||
return;
|
||||
}
|
||||
url.EVT = _evt();
|
||||
for (p in url) {
|
||||
if (url[p].indexOf('http') == -1) {
|
||||
url[p] = url.EVT + 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
|
||||
};
|
||||
|
||||
12
zyplayer-doc-ui/wiki-ui/src/common/config/global.js
Normal file
12
zyplayer-doc-ui/wiki-ui/src/common/config/global.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const user = {
|
||||
isLogin: true,
|
||||
};
|
||||
const app = {};
|
||||
const fullscreen = false;
|
||||
|
||||
export default {
|
||||
app,
|
||||
user,
|
||||
fullscreen,
|
||||
}
|
||||
|
||||
51
zyplayer-doc-ui/wiki-ui/src/common/lib/common/common.js
Normal file
51
zyplayer-doc-ui/wiki-ui/src/common/lib/common/common.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import Qs from 'qs'
|
||||
import global from '../../config/global'
|
||||
|
||||
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.data.errCode == 400) {
|
||||
global.app.$message('请先登录');
|
||||
global.app.$router.push("/user/login");
|
||||
} else if (res.data.errCode == 402) {
|
||||
global.app.$router.push("/common/noAuth");
|
||||
} else if (res.data.errCode !== 200) {
|
||||
global.app.$message(res.data.errMsg || "未知错误");
|
||||
} else {
|
||||
if (typeof callback == 'function') {
|
||||
callback(res.data);
|
||||
}
|
||||
}
|
||||
},
|
||||
post: function (url, param, callback) {
|
||||
param = param || {};
|
||||
param.accessToken = this.getAccessToken();
|
||||
global.app.axios({
|
||||
method: "post",
|
||||
url: url,
|
||||
headers: {'Content-type': 'application/x-www-form-urlencoded'},
|
||||
data: Qs.stringify(param),
|
||||
}).then((res) => {
|
||||
console.log("ok", res);
|
||||
this.validateResult(res, callback);
|
||||
}).catch((res) => {
|
||||
console.log("error", res);
|
||||
this.validateResult(res);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
40
zyplayer-doc-ui/wiki-ui/src/common/lib/common/toast.js
Normal file
40
zyplayer-doc-ui/wiki-ui/src/common/lib/common/toast.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import global from '../../config/global'
|
||||
|
||||
/**
|
||||
* 提示工具类
|
||||
* @author
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
export default {
|
||||
notOpen: function () {
|
||||
global.app.$message({
|
||||
message: '该功能暂未开放,敬请期待!',
|
||||
type: 'warning',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
success: function (msg, time) {
|
||||
global.app.$message({
|
||||
message: msg,
|
||||
duration: time || 3000,
|
||||
type: 'success',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
warn: function (msg, time) {
|
||||
global.app.$message({
|
||||
message: msg,
|
||||
duration: time || 3000,
|
||||
type: 'warning',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
error: function (msg, time) {
|
||||
global.app.$message({
|
||||
message: msg,
|
||||
duration: time || 3000,
|
||||
type: 'error',
|
||||
showClose: true
|
||||
});
|
||||
},
|
||||
};
|
||||
4
zyplayer-doc-ui/wiki-ui/src/common/lib/jquery/jquery-3.1.0.min.js
vendored
Normal file
4
zyplayer-doc-ui/wiki-ui/src/common/lib/jquery/jquery-3.1.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
zyplayer-doc-ui/wiki-ui/src/common/lib/jquery/qrcode.min.js
vendored
Normal file
1
zyplayer-doc-ui/wiki-ui/src/common/lib/jquery/qrcode.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user