改为使用vue-cli打包,修改所有的请求方式

This commit is contained in:
暮光:城中城
2020-05-29 22:38:25 +08:00
parent ba29b57a14
commit 13ddbc05ee
44 changed files with 7611 additions and 7970 deletions

View File

@@ -40,10 +40,7 @@
</template>
<script>
import toast from '../../common/lib/common/toast'
import global from '../../common/config/global'
var app;
import pageApi from '../../common/api/page'
export default {
data() {
@@ -65,14 +62,13 @@
},
mounted: function () {
this.initQueryParam(this.$route);
app = this;
},
methods: {
getSpacePageNews() {
this.common.post(this.apilist1.pageNews, this.searchParam, function (json) {
app.spacePageNews = json.data || [];
app.totalCount = json.total;
});
pageApi.pageNews(this.searchParam).then(json => {
this.spacePageNews = json.data || [];
this.totalCount = json.total;
});
},
handleSizeChange(val) {
this.searchParam.pageSize = val;

View File

@@ -20,18 +20,9 @@
</template>
<script>
import toast from '../../common/lib/common/toast'
import global from '../../common/config/global'
import WangEditor from 'wangeditor'
import pageApi from '../../common/api/page'
window.onunload = function () {
app.unlockPage();
};
window.onbeforeunload = function () {
app.unlockPage();
};
var app;
export default {
data() {
return {
@@ -51,13 +42,19 @@
next();
},
mounted: function () {
app = this;
this.initEditor();
this.initQueryParam(this.$route);
let that = this;
window.onunload = function () {
that.unlockPage();
};
window.onbeforeunload = function () {
that.unlockPage();
};
},
methods: {
changeToRootPath() {
app.parentPath = {spaceId: this.parentPath.spaceId};
this.parentPath = {spaceId: this.parentPath.spaceId};
},
unlockPage() {
// 防止各种事件重复调这个接口,只需要调一次就好了
@@ -65,8 +62,9 @@
return;
}
this.isUnlock = true;
var param = {pageId: app.parentPath.pageId};
this.common.post(this.apilist1.pageUnlock, param, function (json) {});
var param = {pageId: this.parentPath.pageId};
pageApi.pageUnlock(param).then(() => {
});
},
createWikiCancel() {
this.$confirm('确定要取消编辑吗?您编辑的内容将不会被保存哦~', '提示', {
@@ -74,57 +72,57 @@
cancelButtonText: '继续编辑',
type: 'warning'
}).then(() => {
app.unlockPage();
app.$router.back();
this.unlockPage();
this.$router.back();
});
},
createWikiSave(saveAfter) {
// 修改内容时强制不能修改父路径,只能在目录上拖动修改
var parentId = (this.wikiPage.id > 0) ? '' : app.parentPath.parentId;
if (this.common.isEmpty(app.newPageTitle)) {
toast.warn("标题不能为空");
var parentId = (this.wikiPage.id > 0) ? '' : this.parentPath.parentId;
if (!this.newPageTitle) {
this.$message.warning("标题不能为空");
return;
}
var preview = this.editor.txt.text();
var param = {
spaceId: app.parentPath.spaceId,
spaceId: this.parentPath.spaceId,
parentId: parentId,
id: app.wikiPage.id,
name: app.newPageTitle,
id: this.wikiPage.id,
name: this.newPageTitle,
content: this.editor.txt.html(),
preview: preview,
};
this.common.post(this.apilist1.updatePage, param, function (json) {
toast.success("保存成功!");
pageApi.updatePage(param).then(json => {
this.$message.success("保存成功!");
// 重新加载左侧列表,跳转到展示页面
global.vue.$app.doGetPageList(null);
app.parentPath.pageId = json.data.id;
this.$emit('loadPageList');
this.parentPath.pageId = json.data.id;
if (saveAfter == 1) {
app.$router.push({path: '/page/show', query: app.parentPath});
this.$router.push({path: '/page/show', query: this.parentPath});
} else {
app.loadPageDetail(app.parentPath.pageId);
this.loadPageDetail(this.parentPath.pageId);
}
});
},
loadPageDetail(pageId) {
app.rightContentType = 1;
this.rightContentType = 1;
var param = {id: pageId};
this.common.post(this.apilist1.pageDetail, param, function (json) {
app.wikiPage = json.data.wikiPage || {};
app.pageContent = json.data.pageContent || {};
app.pageFileList = json.data.fileList || [];
pageApi.pageDetail(param).then(json => {
this.wikiPage = json.data.wikiPage || {};
this.pageContent = json.data.pageContent || {};
this.pageFileList = json.data.fileList || [];
// 内容
app.newPageTitle = app.wikiPage.name;
app.editor.txt.html(app.pageContent.content || "");
this.newPageTitle = this.wikiPage.name;
this.editor.txt.html(this.pageContent.content || "");
});
},
cleanPage() {
app.wikiPage = {};
app.pageContent = {};
app.pageFileList = [];
app.newPageTitle = "";
if (!!app.editor.txt) {
app.editor.txt.html("");
this.wikiPage = {};
this.pageContent = {};
this.pageFileList = [];
this.newPageTitle = "";
if (!!this.editor.txt) {
this.editor.txt.html("");
}
},
initQueryParam(to) {
@@ -137,13 +135,14 @@
} else {
this.cleanPage();
}
var param = {pageId: app.parentPath.pageId};
this.common.postNonCheck(this.apilist1.pageLock, param, function (json) {
let param = {pageId: this.parentPath.pageId};
pageApi.pageLock(param).then(json => {
if (json.errCode !== 200) {
app.$alert(json.errMsg || '未知错误', '错误', {
let that = this;
this.$alert(json.errMsg || '未知错误', '错误', {
confirmButtonText: '确定',
callback: () => {
app.$router.back();
that.$router.back();
}
});
}
@@ -151,7 +150,7 @@
},
initEditor() {
this.editor = new WangEditor('#newPageContentDiv');
this.editor.customConfig.uploadImgServer = this.apilist1.HOST + '/zyplayer-doc-wiki/common/wangEditor/upload';
this.editor.customConfig.uploadImgServer = process.env.VUE_APP_BASE_API + '/zyplayer-doc-wiki/common/wangEditor/upload';
this.editor.customConfig.zIndex = 100;
this.editor.customConfig.uploadFileName = 'files';
this.editor.customConfig.uploadImgMaxLength = 1;

View File

@@ -1,4 +0,0 @@
<template>
<router-view></router-view>
</template>

View File

@@ -43,10 +43,7 @@
</template>
<script>
import toast from '../../common/lib/common/toast'
import global from '../../common/config/global'
var app;
import pageApi from '../../common/api/page'
export default {
data() {
@@ -68,13 +65,12 @@
},
mounted: function () {
this.initQueryParam(this.$route);
app = this;
},
methods: {
getSpacePageNews() {
this.common.post(this.apilist1.pageSearchByEs, this.searchParam, function (json) {
app.spacePageNews = json.data || [];
app.totalCount = json.total;
pageApi.pageSearchByEs(this.searchParam).then(json => {
this.spacePageNews = json.data || [];
this.totalCount = json.total;
});
},
handleSizeChange(val) {

View File

@@ -132,9 +132,9 @@
</template>
<script>
import toast from '../../common/lib/common/toast'
import global from '../../common/config/global'
var app;
import common from '../../common/lib/common'
import pageApi from '../../common/api/page'
import userApi from '../../common/api/user'
var page = {
colorArr: ["#67C23A", "#409EFF", "#E6A23C", "#F56C6C", "#909399", "#303133"],
userHeadColor: {},
@@ -168,24 +168,23 @@
next();
},
mounted: function () {
app = this;
this.initQueryParam(this.$route);
if (!!this.parentPath.pageId) {
// 延迟设置展开的目录edit比app先初始化
setTimeout(function () {
if (!!app.parentPath.spaceId) {
setTimeout(() => {
if (!!this.parentPath.spaceId) {
// 调用父方法切换选择的空间
global.vue.$app.switchSpacePage(app.parentPath.spaceId);
this.$emit('switchSpace', this.parentPath.spaceId);
}
global.vue.$app.changeWikiPageExpandedKeys(app.parentPath.pageId);
this.$emit('changeExpandedKeys', this.parentPath.pageId);
}, 500);
}
},
methods: {
editWiki() {
var param = {pageId: app.parentPath.pageId};
this.common.post(this.apilist1.pageLock, param, function (json) {
app.$router.push({path: '/page/edit', query: app.parentPath});
var param = {pageId: this.parentPath.pageId};
pageApi.pageLock(param).then(() => {
this.$router.push({path: '/page/edit', query: this.parentPath});
});
},
getSearchUserList(query) {
@@ -194,14 +193,14 @@
}
this.pageAuthUserLoading = true;
var param = {search: query};
this.common.post(this.apilist1.getUserBaseInfo, param, function (json) {
app.searchUserList = json.data || [];
app.pageAuthUserLoading = false;
userApi.getUserBaseInfo(param).then(json => {
this.searchUserList = json.data || [];
this.pageAuthUserLoading = false;
});
},
addPageAuthUser() {
if (this.pageAuthNewUser.length <= 0) {
toast.warn("请先选择用户");
this.$message.warning("请先选择用户");
return;
}
var userName = "";
@@ -224,22 +223,22 @@
this.pageAuthNewUser = "";
},
editWikiAuth() {
app.pageAuthNewUser = [];
app.pageAuthUserList = [];
var param = {pageId: app.wikiPage.id};
this.common.post(this.apilist1.getPageUserAuthList, param, function (json) {
app.pageAuthUserList = json.data || [];
app.pageAuthDialogVisible = true;
this.pageAuthNewUser = [];
this.pageAuthUserList = [];
var param = {pageId: this.wikiPage.id};
pageApi.getPageUserAuthList(param).then(json => {
this.pageAuthUserList = json.data || [];
this.pageAuthDialogVisible = true;
});
},
saveUserPageAuth() {
var param = {pageId: app.wikiPage.id, authList: JSON.stringify(app.pageAuthUserList)};
this.common.post(this.apilist1.assignPageUserAuth, param, function (json) {
toast.success("保存成功!");
var param = {pageId: this.wikiPage.id, authList: JSON.stringify(this.pageAuthUserList)};
pageApi.assignPageUserAuth(param).then(() => {
this.$message.success("保存成功!");
});
},
notOpen() {
toast.notOpen();
this.$message.warning("暂未开放");
},
deleteUserPageAuth(row) {
var pageAuthUserList = [];
@@ -257,63 +256,63 @@
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var param = {pageId: app.wikiPage.id};
this.common.post(this.apilist1.pageDelete, param, function (json) {
var param = {pageId: this.wikiPage.id};
pageApi.pageDelete(param).then(() => {
// 重新加载左侧列表,跳转到展示页面
global.vue.$app.doGetPageList(null);
app.$router.push({path: '/home', query: {spaceId: app.wikiPage.spaceId}});
this.$emit('loadPageList');
this.$router.push({path: '/home', query: {spaceId: this.wikiPage.spaceId}});
});
}).catch(()=>{});
},
loadPageDetail(pageId) {
app.rightContentType = 1;
this.rightContentType = 1;
var param = {id: pageId};
this.common.post(this.apilist1.pageDetail, param, function (json) {
pageApi.pageDetail(param).then(json => {
var wikiPage = json.data.wikiPage || {};
wikiPage.selfZan = json.data.selfZan || 0;
app.wikiPage = wikiPage;
app.pageContent = json.data.pageContent || {};
app.pageFileList = json.data.fileList || [];
app.uploadFormData = {pageId: app.wikiPage.id};
app.parentPath.spaceId = wikiPage.spaceId;
this.wikiPage = wikiPage;
this.pageContent = json.data.pageContent || {};
this.pageFileList = json.data.fileList || [];
this.uploadFormData = {pageId: this.wikiPage.id};
this.parentPath.spaceId = wikiPage.spaceId;
// 修改最后点击的项,保证刷新后点击编辑能展示编辑的项
// if (!app.lastClickNode.id) {
// app.lastClickNode = {id: wikiPage.id, nodePath: wikiPage.name};
// if (!this.lastClickNode.id) {
// this.lastClickNode = {id: wikiPage.id, nodePath: wikiPage.name};
// }
});
this.loadCommentList(pageId);
},
loadCommentList(pageId) {
app.commentList = [];
app.cancelCommentUser();
this.commentList = [];
this.cancelCommentUser();
var param = {pageId: pageId};
this.common.post(this.apilist1.pageCommentList, param, function (json) {
pageApi.pageCommentList(param).then(json => {
var commentList = json.data || [];
for (var i = 0; i < commentList.length; i++) {
commentList[i].color = app.getUserHeadBgColor(commentList[i].createUserId);
commentList[i].color = this.getUserHeadBgColor(commentList[i].createUserId);
var subCommentList = commentList[i].commentList || [];
for (var j = 0; j < subCommentList.length; j++) {
var subItem = subCommentList[j];
subItem.color = app.getUserHeadBgColor(subItem.createUserId);
subItem.color = this.getUserHeadBgColor(subItem.createUserId);
}
commentList[i].commentList = subCommentList;
}
app.commentList = commentList;
this.commentList = commentList;
});
},
zanPage(yn) {
var param = {yn: yn, pageId: app.wikiPage.id};
this.common.post(this.apilist1.updatePageZan, param, function (json) {
app.wikiPage.selfZan = yn;
app.wikiPage.zanNum = app.wikiPage.zanNum + (yn == 1 ? 1 : -1);
var param = {yn: yn, pageId: this.wikiPage.id};
pageApi.updatePageZan(param).then(() => {
this.wikiPage.selfZan = yn;
this.wikiPage.zanNum = this.wikiPage.zanNum + (yn == 1 ? 1 : -1);
});
},
showZanPageUser() {
app.zanUserDialogVisible = true;
app.zanUserList = [];
var param = {pageId: app.wikiPage.id};
this.common.post(this.apilist1.pageZanList, param, function (json) {
app.zanUserList = json.data;
this.zanUserDialogVisible = true;
this.zanUserList = [];
var param = {pageId: this.wikiPage.id};
pageApi.pageZanList(param).then(json => {
this.zanUserList = json.data;
});
},
recommentUser(id, index) {
@@ -323,28 +322,28 @@
this.recommentInfo = {};
},
submitPageComment() {
if (app.commentTextInput.length <= 0) {
toast.error("请输入评论内容");
if (this.commentTextInput.length <= 0) {
this.$message.error("请输入评论内容");
return;
}
var param = {
pageId: app.wikiPage.id, content: app.commentTextInput,
parentId: app.recommentInfo.id
pageId: this.wikiPage.id, content: this.commentTextInput,
parentId: this.recommentInfo.id
};
this.common.post(this.apilist1.updatePageComment, param, function (json) {
pageApi.updatePageComment(param).then(json => {
var data = json.data;
data.color = app.getUserHeadBgColor(data.createUserId);
app.commentTextInput = "";
app.commentList.push(data);
data.color = this.getUserHeadBgColor(data.createUserId);
this.commentTextInput = "";
this.commentList.push(data);
});
},
uploadFileError(err) {
toast.error("上传失败," + err);
this.$message.error("上传失败," + err);
},
uploadFileSuccess(response) {
this.common.validateResult({data: response}, function () {
app.pageFileList.push(response.data);
toast.success("上传成功!");
common.validateResult({data: response}).then(() => {
this.pageFileList.push(response.data);
this.$message.success("上传成功!");
});
},
deletePageFile(row) {
@@ -353,20 +352,20 @@
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var param = {id: row.id, delFlag: 1};
this.common.post(this.apilist1.updatePageFile, param, function (json) {
var pageFileList = [];
for (var i = 0; i < app.pageFileList.length; i++) {
if (app.pageFileList[i].id != row.id) {
pageFileList.push(app.pageFileList[i]);
let param = {id: row.id, delFlag: 1};
pageApi.updatePageFile(param).then(() => {
let pageFileList = [];
for (let i = 0; i < this.pageFileList.length; i++) {
if (this.pageFileList[i].id != row.id) {
pageFileList.push(this.pageFileList[i]);
}
}
app.pageFileList = pageFileList;
this.pageFileList = pageFileList;
});
});
},
getUserHeadBgColor(userId) {
var color = page.userHeadColor[userId];
let color = page.userHeadColor[userId];
if (!color) {
color = page.colorArr[Math.ceil(Math.random() * page.colorArr.length) - 1];
page.userHeadColor[userId] = color;

View File

@@ -1,17 +1,16 @@
<template>
<div style="padding-top: 50px;" class="user-login-vue">
<div style="padding-top: 50px;">
<el-form :model="loginParam" :rules="loginRules" ref="loginParam" label-position="left" label-width="0px"
class="demo-ruleForm login-container">
<h3 class="title">系统登录</h3>
<el-form-item>
<el-form-item prop="username">
<el-input type="text" v-model="loginParam.username" auto-complete="off" placeholder="账号" @keyup.enter="loginSubmit"></el-input>
</el-form-item>
<el-form-item>
<el-form-item prop="password">
<el-input type="password" v-model="loginParam.password" auto-complete="off" placeholder="密码" @keyup.enter="loginSubmit"></el-input>
</el-form-item>
<el-form-item style="width:100%;">
<el-button type="primary" style="width:100%;" @click.native.prevent="loginSubmit" :loading="logining">登录
</el-button>
<el-button type="primary" style="width:100%;" @click.native.prevent="loginSubmit" :loading="logining">登录</el-button>
<!--<el-button @click.native.prevent="handleReset2">重置</el-button>-->
</el-form-item>
</el-form>
@@ -19,6 +18,7 @@
</template>
<script>
import userApi from '../../common/api/user'
export default {
data() {
return {
@@ -44,14 +44,13 @@
},
methods: {
loginSubmit() {
var that = this;
this.$refs.loginParam.validate((valid) => {
if (!valid) return;
that.common.post(that.apilist1.userLogin, that.loginParam, function (json) {
if(!!that.redirect) {
location.href = decodeURIComponent(that.redirect);
userApi.userLogin(this.loginParam).then(() => {
if (!!this.redirect) {
location.href = decodeURIComponent(this.redirect);
} else {
that.$router.back();
this.$router.back();
}
});
});
@@ -61,7 +60,7 @@
</script>
<style>
.user-login-vue .login-container {
.login-container {
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-border-radius: 5px;
@@ -73,12 +72,14 @@
border: 1px solid #eaeaea;
box-shadow: 0 0 25px #cac6c6;
}
.user-login-vue .title {
.title {
margin: 0px auto 40px auto;
text-align: center;
color: #505458;
}
.user-login-vue .remember {
.remember {
margin: 0px 0px 35px 0px;
}

View File

@@ -1,9 +1,5 @@
<template>
<div class="user-my-info-vue">
<el-breadcrumb separator-class="el-icon-arrow-right" style="padding: 20px 10px;">
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
<el-breadcrumb-item>我的信息</el-breadcrumb-item>
</el-breadcrumb>
<div class="my-info-vue">
<div style="margin: 0 auto;max-width: 1000px;">
<el-card class="box-card">
<div slot="header" class="clearfix">我的信息</div>
@@ -21,7 +17,7 @@
</template>
<script>
var app;
import userApi from '../../common/api/user'
export default {
data() {
return {
@@ -29,13 +25,12 @@
};
},
mounted: function () {
app = this;
this.getUserInfo();
},
methods: {
getUserInfo() {
this.common.post(this.apilist1.getSelfUserInfo, this.searchParam, function (json) {
app.userInfo = json.data;
userApi.getSelfUserInfo().then(json => {
this.userInfo = json.data;
});
},
}
@@ -43,7 +38,7 @@
</script>
<style>
.user-my-info-vue{}
.user-my-info-vue .box-card{margin: 10px;}
.my-info-vue{}
.my-info-vue .box-card{margin: 10px;}
</style>

View File

@@ -1,4 +0,0 @@
<template>
<router-view></router-view>
</template>