重构控制台首页

This commit is contained in:
暮光:城中城
2019-06-27 22:42:06 +08:00
parent 968bbb5f5a
commit f144e77035
53 changed files with 13353 additions and 24 deletions

View File

@@ -0,0 +1,39 @@
var URL = {
userLogin: '/login',
userLogout: '/logout',
getUserInfo: '/user/getUserInfo',
pageUpdate: '/zyplayer-doc-wiki/page/update',
pageChangeParent: '/zyplayer-doc-wiki/page/changeParent',
pageList: '/zyplayer-doc-wiki/page/list',
updatePage: '/zyplayer-doc-wiki/page/update',
pageDetail: '/zyplayer-doc-wiki/page/detail',
pageDelete: '/zyplayer-doc-wiki/page/delete',
pageNews: '/zyplayer-doc-wiki/page/news',
pageLock: '/zyplayer-doc-wiki/page/lock',
pageUnlock: '/zyplayer-doc-wiki/page/unlock',
spaceList: '/zyplayer-doc-wiki/space/list',
updateSpace: '/zyplayer-doc-wiki/space/update',
getPageUserAuthList: '/zyplayer-doc-wiki/page/auth/list',
assignPageUserAuth: '/zyplayer-doc-wiki/page/auth/assign',
updatePageFile: '/zyplayer-doc-wiki/page/file/update',
pageCommentList: '/zyplayer-doc-wiki/page/comment/list',
updatePageComment: '/zyplayer-doc-wiki/page/comment/update',
pageZanList: '/zyplayer-doc-wiki/page/zan/list',
updatePageZan: '/zyplayer-doc-wiki/page/zan/update',
commonUpload: '/zyplayer-doc-wiki/common/upload',
getUserBaseInfo: '/zyplayer-doc-wiki/common/user/base',
systemUpgradeInfo: '/system/info/upgrade',
};
var URL1 = {};
export default {
URL, URL1
};

View File

@@ -0,0 +1,52 @@
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
};

View File

@@ -0,0 +1,12 @@
const user = {
isLogin: true,
};
const vue = {};
const fullscreen = false;
export default {
vue,
user,
fullscreen,
}

View File

@@ -0,0 +1,110 @@
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) {
global.vue.$message('请先登录');
var href = encodeURIComponent(window.location.href);
window.location = apimix.apilist1.HOST + "/static/manage/login.html?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);
},
}

View File

@@ -0,0 +1,40 @@
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