#I1KQUK 开放地址首页展示优化,优化查看编辑页展示及url参数,无权限时不展示对应按钮

This commit is contained in:
暮光:城中城
2020-06-16 23:13:27 +08:00
parent 0451b9319c
commit 1abcc4f92e
40 changed files with 737 additions and 534 deletions

View File

@@ -2,8 +2,8 @@
ENV = 'development'
# base api
# VUE_APP_BASE_API = 'http://local.zyplayer.com:8083/zyplayer-doc-manage'
VUE_APP_BASE_API = 'http://doc.zyplayer.com/zyplayer-doc-manage'
VUE_APP_BASE_API = 'http://local.zyplayer.com:8083/zyplayer-doc-manage'
# VUE_APP_BASE_API = 'http://doc.zyplayer.com/zyplayer-doc-manage'
VUE_CLI_BABEL_TRANSPILE_MODULES = true

View File

@@ -63,14 +63,17 @@ export default {
return request({url: '/zyplayer-doc-wiki/page/zan/update', method: 'post', data: Qs.stringify(data)});
},
openPageDetail: data => {
return request({url: 'zyplayer-doc-wiki/open-api/page/detail', method: 'post', data: Qs.stringify(data)});
return request({url: '/zyplayer-doc-wiki/open-api/page/detail', method: 'post', data: Qs.stringify(data)});
},
openPageList: data => {
return request({url: 'zyplayer-doc-wiki/open-api/page/list', method: 'post', data: Qs.stringify(data)});
return request({url: '/zyplayer-doc-wiki/open-api/page/list', method: 'post', data: Qs.stringify(data)});
},
openSpaceInfo: data => {
return request({url: 'zyplayer-doc-wiki/open-api/space/info', method: 'post', data: Qs.stringify(data)});
return request({url: '/zyplayer-doc-wiki/open-api/space/info', method: 'post', data: Qs.stringify(data)});
},
openPageNews: data => {
return request({url: '/zyplayer-doc-wiki/open-api/page/news', method: 'post', data: Qs.stringify(data)});
},
xxxxxxxxxxxx: data => {
return request({url: 'update', method: 'post', data: Qs.stringify(data)});
},

View File

@@ -4,7 +4,7 @@
<el-aside v-show="leftCollapse">
<div style="padding: 10px;height: 100%;box-sizing: border-box;background: #fafafa;">
<div style="margin-bottom: 10px;">
<el-select v-model="choiceSpace" @change="spaceChangeEvents" filterable placeholder="选择空间" style="width: 100%;">
<el-select :value="choiceSpace" @change="spaceChangeEvents" filterable placeholder="选择空间" style="width: 100%;">
<el-option-group label="">
<el-option key="0" label="创建空间" value="0"></el-option>
<el-option key="-1" label="空间管理" value="-1"></el-option>
@@ -47,7 +47,8 @@
<el-main style="padding: 0;">
<router-view @loadPageList="loadPageList"
@changeExpandedKeys="changeWikiPageExpandedKeys"
@switchSpace="switchSpacePage">
@switchSpace="switchSpacePage"
:spaceId="choiceSpace">
</router-view>
</el-main>
</el-container>
@@ -166,11 +167,8 @@
{min: 2, max: 25, message: '长度在 2 到 25 个字符', trigger: 'blur'}
],
},
nowClickPath: {
id: '',
path: '',
},
// 依据目录树存储的map全局对象
nowPageId: '',
// 依据目录树存储的map全局对象
treePathDataMap: new Map(),
// 搜索的输入内容
searchKeywords: "",
@@ -183,9 +181,6 @@
}
},
computed: {
fullscreen () {
return this.$store.state.global.fullscreen;
}
},
mounted: function () {
this.loadSpaceList();
@@ -197,12 +192,8 @@
this.doGetPageList(param.parentId, param.node);
},
createWiki() {
if (this.nowClickPath.spaceId > 0) {
var param = {
spaceId: this.nowClickPath.spaceId,
parentId: this.nowClickPath.parentId, path: this.nowClickPath.path
};
this.$router.push({path: '/page/edit', query: param});
if (this.choiceSpace > 0) {
this.$router.push({path: '/page/edit', query: {parentId: this.nowPageId}});
} else {
this.$message.warning("请先选择或创建空间");
}
@@ -219,8 +210,8 @@
},
handleNodeClick(data) {
console.log("点击节点:", data);
this.nowClickPath = {spaceId: this.nowClickPath.spaceId, pageId: data.id, parentId: data.id, path: data.path};
this.$router.push({path: '/page/show', query: this.nowClickPath});
this.nowPageId = data.id;
this.$router.push({path: '/page/show', query: {pageId: data.id}});
},
handleNodeExpand(node) {
if (node.children.length > 0 && node.children[0].needLoad) {
@@ -249,7 +240,7 @@
return data.name.indexOf(value) !== -1;
},
showOpenSpace(space) {
let routeUrl = this.$router.resolve({path: '/page/openView', query: {space: space}});
let routeUrl = this.$router.resolve({path: '/page/share/home', query: {space: space}});
window.open(routeUrl.href, '_blank');
},
editSpaceInfo(row) {
@@ -273,22 +264,21 @@
},
spaceChangeEvents(data) {
if (data == 0) {
// 新建空间
this.newSpaceForm = {id: '', name: '', spaceExplain: '', treeLazyLoad: 0, openDoc: 0, uuid: '', type: 1};
this.choiceSpace = this.nowClickPath.spaceId;
this.newSpaceDialogVisible = true;
} else if (data == -1) {
// 使得选择的空间展示不变
this.choiceSpace = this.nowClickPath.spaceId;
// 管理空间
this.manageSpaceDialogVisible = true;
} else {
// 切换空间,重新初始化当前点击项,防止创建保存到之前点击的空间下去了
this.nowClickPath = {spaceId: data};
for (var i = 0; i < this.spaceList.length; i++) {
this.choiceSpace = data;
for (let i = 0; i < this.spaceList.length; i++) {
if (this.spaceList[i].id == data) {
this.nowSpaceShow = this.spaceList[i];
break;
}
}
this.nowPageId = '';
this.doGetPageList(null);
this.$router.push({path: '/home', query: {spaceId: data}});
}
@@ -296,18 +286,18 @@
loadSpaceList() {
pageApi.spaceList({}).then(json => {
this.spaceList = json.data || [];
var spaceOptions = [];
for (var i = 0; i < this.spaceList.length; i++) {
let spaceOptions = [];
for (let i = 0; i < this.spaceList.length; i++) {
spaceOptions.push({
label: this.spaceList[i].name, value: this.spaceList[i].id
});
}
this.spaceOptions = spaceOptions;
if (this.spaceList.length > 0) {
var spaceId = this.spaceList[0].id;
let spaceId = this.spaceList[0].id;
this.nowSpaceShow = this.spaceList[0];
this.nowClickPath = {spaceId: spaceId};
this.choiceSpace = spaceId;
this.nowPageId = '';
this.doGetPageList(null);
// TODO 在首页时跳转
try {
@@ -321,53 +311,30 @@
});
},
doGetPageList(parentId, node) {
var nodePath = "";
if (!!node) {
nodePath = node.nodePath || "/";
if (!nodePath.endsWith("/")) {
nodePath += "/";
}
} else {
nodePath = "/";
}
var param = {spaceId: this.nowClickPath.spaceId, parentId: parentId || 0};
let param = {spaceId: this.choiceSpace, parentId: parentId || 0};
if (this.nowSpaceShow.treeLazyLoad == 0) {
param.parentId = null;
}
pageApi.pageList(param).then(json => {
var result = json.data || [];
var pathIndex = [];
let result = json.data || [];
let pathIndex = [];
if (this.nowSpaceShow.treeLazyLoad == 0) {
pathIndex = result;
} else {
for (var i = 0; i < result.length; i++) {
var item = result[i];
for (let i = 0; i < result.length; i++) {
let item = result[i];
item.parentId = item.parentId || 0;
item.children = [{label: '', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
pathIndex.push(item);
}
}
this.createNodePath(pathIndex, nodePath);
if (parentId > 0) {
node.children = pathIndex;
} else {
this.wikiPageList = pathIndex;
//this.lastClickNode = {};
}
});
},
createNodePath(node, nodePath) {
if (!nodePath.endsWith("/")) {
nodePath += "/";
}
for (var i = 0; i < node.length; i++) {
var item = node[i];
item.nodePath = nodePath + item.name;
if (!!item.children && item.children.length > 0) {
this.createNodePath(item.children, item.nodePath);
}
}
},
userSettingDropdown(command) {
console.log("command:" + command);
if (command == 'userSignOut') {
@@ -390,7 +357,7 @@
onNewSpaceSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
var param = {
let param = {
id: this.newSpaceForm.id,
name: this.newSpaceForm.name,
type: this.newSpaceForm.type,
@@ -407,7 +374,6 @@
label: json.data.name, value: json.data.id
});
this.nowSpaceShow = json.data;
this.nowClickPath = {spaceId: json.data.id};
this.choiceSpace = json.data.id;
this.doGetPageList(null);
}
@@ -439,7 +405,6 @@
return;
}
this.choiceSpace = spaceId;
this.nowClickPath.spaceId = spaceId;
this.doGetPageList(null);
},
}

View File

@@ -1,244 +0,0 @@
<template>
<div>
<el-container style="height: 100%;">
<el-aside width="280px" style="height: 100%;background-color: #fafafa;" v-show="leftCollapse">
<div class="logo">{{nowSpaceShow.name}}</div>
<div style="padding: 0 10px 50px 10px;">
<el-input v-model="searchKeywords" @keyup.enter.native="searchByKeywords" placeholder="搜索文档" style="margin: 10px 0;">
<el-button slot="append" icon="el-icon-search" v-on:click="searchByKeywords"></el-button>
</el-input>
<el-tree :props="defaultProps" :data="wikiPageList" @node-click="handleNodeClick"
ref="wikiPageTree" :filter-node-method="filterPageNode" highlight-current
:expand-on-click-node="false" :default-expanded-keys="wikiPageExpandedKeys"
node-key="id"
style="background-color: #fafafa;">
</el-tree>
<!--请手下留情别删我(^)给我一个露脸的机会我长的不碍眼的-->
<div class="build-info">本文档使用<span @click="aboutDialogVisible = true">zyplayer-doc</span>构建</div>
</div>
</el-aside>
<el-container>
<el-main class="doc-body-box">
<el-row type="border-card" v-show="rightContentType == 0">
<div style="margin-top: 30px;color: #666; text-align: center; font-size: 30px;">欢迎使用在线文档</div>
<div style="margin-top: 30px;color: #666; text-align: center;">
{{nowSpaceShow.name}}
<span v-show="nowSpaceShow.spaceExplain && nowSpaceShow.spaceExplain.length > 0"> · {{nowSpaceShow.spaceExplain}}</span>
</div>
</el-row>
<el-row type="border-card" v-show="rightContentType == 1">
<i class="el-icon-menu icon-collapse" @click="leftCollapse = !leftCollapse"></i>
<div style="max-width: 950px;margin: 0 auto;">
<div class="wiki-title">{{wikiPage.name}}</div>
<div class="wiki-author">
<span v-show="!wikiPage.updateTime">创建时间{{wikiPage.createTime}}</span>
<span v-show="wikiPage.updateTime">最后修改{{wikiPage.updateTime}}</span>
</div>
<div class="wiki-files">
<el-table v-show="pageFileList.length > 0" :data="pageFileList" border style="width: 100%; margin-bottom: 5px;">
<el-table-column label="文件名">
<template slot-scope="scope">
<a target="_blank" :href="scope.row.fileUrl">{{scope.row.fileName}}</a>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" width="180px"></el-table-column>
<el-table-column prop="downloadNum" label="下载次数" width="80px"></el-table-column>
</el-table>
</div>
<div class="wiki-content w-e-text">
<div v-html="pageContent.content"></div>
</div>
</div>
</el-row>
</el-main>
</el-container>
</el-container>
<!--关于弹窗-->
<el-dialog title="关于zyplayer-doc-wiki" :visible.sync="aboutDialogVisible" width="600px">
<el-form>
<el-form-item label="项目地址:">
<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc">zyplayer-doc</a>
</el-form-item>
<el-form-item label="开发人员:">
<a target="_blank" href="http://zyplayer.com">暮光城中城</a>
</el-form-item>
<el-form-item label="">
欢迎加群讨论QQ群号466363173欢迎提交需求欢迎使用和加入开发
</el-form-item>
</el-form>
</el-dialog>
</div>
</template>
<script>
import pageApi from '../../common/api/page'
export default {
data() {
return {
leftCollapse: true,
aboutDialogVisible: false,
rightContentLoading: false,
rightContentType: 0,// 右侧显示类型0=欢迎页 1=文章内容 2=编辑或新增文章
pathIndex: [],
defaultProps: {
children: 'children',
label: 'name'
},
// 空间搜索相关
nowSpaceShow: {},
// 搜索的输入内容
searchKeywords: "",
lastClickNode: {},
// 页面展示相关
wikiPageList:[],
wikiPage: {},
wikiPageExpandedKeys: [],
pageContent: {},
pageFileList: [],
// 页面跳转相关
parentPath: {},
}
},
beforeRouteUpdate(to, from, next) {
this.initQueryParam(to);
next();
},
mounted: function () {
this.initQueryParam(this.$route);
this.getSpaceInfo();
this.doGetPageList(null);
},
methods: {
filterPageNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
handleNodeClick(data) {
this.rightContentType = 1;
if (this.lastClickNode.id == data.id) {
return;
}
console.log("点击节点:", data);
this.lastClickNode = data;
this.nowClickPath = {pageId: this.lastClickNode.id, space: this.parentPath.space};
this.$router.push({path: '/page/openView', query: this.nowClickPath});
},
loadPageDetail(pageId) {
this.rightContentType = 1;
let param = {pageId: pageId, space: this.parentPath.space};
pageApi.openPageDetail(param).then(json => {
let wikiPage = json.data.wikiPage || {};
wikiPage.selfZan = json.data.selfZan || 0;
this.wikiPage = wikiPage;
this.pageContent = json.data.pageContent || {};
this.pageFileList = json.data.fileList || [];
});
},
searchByKeywords() {
this.$refs.wikiPageTree.filter(this.searchKeywords);
},
doGetPageList() {
let nodePath = "/";
let param = {space: this.parentPath.space};
pageApi.openPageList(param).then(json => {
let pathIndex = json.data || [];
this.createNodePath(pathIndex, nodePath);
this.wikiPageList = pathIndex;
this.lastClickNode = {};
});
},
getSpaceInfo() {
let param = {space: this.parentPath.space};
pageApi.openSpaceInfo(param).then(json => {
this.nowSpaceShow = json.data;
});
},
createNodePath(node, nodePath) {
if (!nodePath.endsWith("/")) {
nodePath += "/";
}
for (let i = 0; i < node.length; i++) {
let item = node[i];
item.nodePath = nodePath + item.name;
if (!!item.children && item.children.length > 0) {
this.createNodePath(item.children, item.nodePath);
}
}
},
initQueryParam(to) {
this.parentPath = {space: to.query.space, pageId: to.query.pageId};
if (!!this.parentPath.pageId) {
this.loadPageDetail(this.parentPath.pageId);
}
},
}
};
</script>
<style scoped>
html,body,#app {margin: 0; padding: 0; height: 100%;}
pre{margin: 0;white-space: pre-wrap;font-size: 14px; font-family: auto;}
.el-menu {box-sizing: border-box;border-right: 0;margin-right: 3px;}
.el-header {background-color: #409EFF; color: #333; line-height: 40px; text-align: right;height: 40px !important;}
.doc-body-box{
overflow-x: hidden;overflow-y: auto;width: 100%;
padding: 10px;border-left: 1px solid #f1f1f1; box-sizing: border-box;
}
.el-tree{margin-right: 3px;}
.logo{
/*background: #409EFF; cursor: pointer;*/
border-bottom: 1px solid #f1f1f1;
overflow: hidden;white-space: nowrap;text-overflow: ellipsis; padding: 5px 10px;
width: 260px; height:40px;line-height:40px;font-size: 25px;color: #666;text-align: center;
}
.icon-collapse{float: left;font-size: 25px;color: #aaa;cursor: pointer;position: fixed;}
.icon-collapse:hover{color: #ccc;}
.wiki-title{font-size: 20px;text-align: center;}
.wiki-author{font-size: 14px;color: #888;padding: 20px 0;height: 40px;line-height: 40px;}
.wiki-content{font-size: 14px;}
.wiki-content.w-e-text{overflow-y: auto;}
.upload-page-file .el-upload-list{display: none;}
.is-link{color: #1e88e5;cursor: pointer;}
/*编辑框高度*/
#newPageContentDiv .w-e-text-container{height: 600px !important;}
/*评论*/
.comment-box .head{
float: left;background-color: #ccc;border-radius: 50%;margin-right: 10px;
width: 45px; height: 45px; line-height: 45px;text-align: center;color: #fff;
}
.build-info{
position: fixed;bottom: 0;left: 0;background: #fafafa;width: 280px;text-align: center;
padding: 5px 0;color: #aaa;font-size: 12px;
}
.build-info span{color: #4183c4;cursor: pointer;}
/* S-JSON展示的样式 */
pre.json {
display: block;
padding: 9.5px;
margin: 0 0 0 10px;
font-size: 12px;
line-height: 1.38461538;
color: #333;
word-break: break-all;
word-wrap: break-word;
background-color: #f5f5f5;
border: 1px solid #ccc;
border-radius: 4px;
}
pre.json .canvas{font:10pt georgia;background-color:#ececec;color:#000000;border:1px solid #cecece;}
pre.json .object-brace{color:#00aa00;font-weight:bold;}
pre.json .array-brace{color:#0033ff;font-weight:bold;}
pre.json .property-name{color:#cc0000;font-weight:bold;}
pre.json .string{color:#007777;}
pre.json .number{color:#aa00aa;}
pre.json .boolean{color:#0000ff;}
pre.json .function{color:#aa6633;text-decoration:initial;}
pre.json .null{color:#0000ff;}
pre.json .comma{color:#000000;font-weight:bold;}
pre.json .annotation{color:#aaa;}
pre img{cursor: pointer;}
/* E-JSON展示的样式 */
</style>

View File

@@ -0,0 +1,131 @@
<template>
<div style="height: 100%;">
<el-container>
<el-aside width="300px" style="background-color: #fafafa;" v-show="leftCollapse">
<div class="logo">{{nowSpaceShow.name}}</div>
<div style="padding: 10px;box-sizing: border-box;background: #fafafa;">
<el-input v-model="searchKeywords" @keyup.enter.native="searchByKeywords" placeholder="搜索文档" style="margin: 10px 0;">
<el-button slot="append" icon="el-icon-search" v-on:click="searchByKeywords"></el-button>
</el-input>
<el-tree :props="defaultProps" :data="wikiPageList" @node-click="handleNodeClick"
ref="wikiPageTree" :filter-node-method="filterPageNode" highlight-current
:expand-on-click-node="false" :default-expanded-keys="wikiPageExpandedKeys"
node-key="id"
style="background-color: #fafafa;padding-bottom: 30px;">
</el-tree>
<!--请手下留情别删我(^)给我一个露脸的机会我长的不碍眼的-->
<div class="build-info">本文档使用<span @click="aboutDialogVisible = true">zyplayer-doc</span>构建</div>
</div>
</el-aside>
<el-container>
<el-main class="doc-body-box">
<router-view></router-view>
</el-main>
</el-container>
</el-container>
<!--关于弹窗-->
<el-dialog title="关于zyplayer-doc-wiki" :visible.sync="aboutDialogVisible" width="600px">
<el-form>
<el-form-item label="项目地址:">
<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc">zyplayer-doc</a>
</el-form-item>
<el-form-item label="开发人员:">
<a target="_blank" href="http://zyplayer.com">暮光城中城</a>
</el-form-item>
<el-form-item label="">
欢迎加群讨论QQ群号466363173欢迎提交需求欢迎使用和加入开发
</el-form-item>
</el-form>
</el-dialog>
</div>
</template>
<script>
import pageApi from '../../common/api/page'
export default {
data() {
return {
leftCollapse: true,
aboutDialogVisible: false,
defaultProps: {
children: 'children',
label: 'name'
},
// 空间搜索相关
spaceUuid: '',
nowPageId: '',
nowSpaceShow: {},
// 搜索的输入内容
searchKeywords: "",
// 页面展示相关
wikiPageList:[],
wikiPageExpandedKeys: [],
}
},
mounted: function () {
this.spaceUuid = this.$route.query.space || '';
this.getSpaceInfo();
this.doGetPageList(null);
},
methods: {
filterPageNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
handleNodeClick(data) {
if (this.nowPageId == data.id) {
return;
}
console.log("点击节点:", data);
this.nowPageId = data.id;
this.$router.push({path: '/page/share/view', query: {pageId: data.id, space: this.spaceUuid}});
},
searchByKeywords() {
this.$refs.wikiPageTree.filter(this.searchKeywords);
},
doGetPageList() {
pageApi.openPageList({space: this.spaceUuid}).then(json => {
this.wikiPageList = json.data || [];
this.nowPageId = '';
});
},
getSpaceInfo() {
pageApi.openSpaceInfo({space: this.spaceUuid}).then(json => {
this.nowSpaceShow = json.data;
});
},
}
};
</script>
<style scoped>
html,body,#app {margin: 0; padding: 0; height: 100%;}
pre{margin: 0;white-space: pre-wrap;font-size: 14px; font-family: auto;}
.el-menu {box-sizing: border-box;border-right: 0;margin-right: 3px;}
.el-header {background-color: #409EFF; color: #333; line-height: 40px; text-align: right;height: 40px !important;}
.doc-body-box{
overflow-x: hidden;overflow-y: auto;width: 100%;
padding: 10px;border-left: 1px solid #f1f1f1; box-sizing: border-box;
}
.el-tree{margin-right: 3px;}
.logo{
/*background: #409EFF; cursor: pointer;*/
border-bottom: 1px solid #f1f1f1;
overflow: hidden;white-space: nowrap;text-overflow: ellipsis; padding: 5px 10px;
width: 260px; height:40px;line-height:40px;font-size: 25px;color: #666;text-align: center;
}
.icon-collapse{float: left;font-size: 25px;color: #aaa;cursor: pointer;position: fixed;}
.icon-collapse:hover{color: #ccc;}
/*评论*/
.comment-box .head{
float: left;background-color: #ccc;border-radius: 50%;margin-right: 10px;
width: 45px; height: 45px; line-height: 45px;text-align: center;color: #fff;
}
.build-info{
position: fixed;bottom: 0;left: 0;background: #fafafa;width: 240px;text-align: center;
padding: 5px 0;color: #aaa;font-size: 12px;
}
.build-info span{color: #4183c4;cursor: pointer;}
</style>

View File

@@ -22,7 +22,6 @@ router.beforeEach((to, from, next) => {
if (to.name) {
document.title = to.name;
}
store.commit('global/setFullscreen', !!to.meta.fullscreen);
next();
});

View File

@@ -1,5 +1,5 @@
import GlobalLayout from './components/layouts/GlobalLayout'
import OpenLayout from './components/layouts/OpenLayout'
import OpenLayout from './components/layouts/ShareLayout'
let routes = [
{path: '/', redirect: '/home'},
@@ -23,7 +23,8 @@ let routes = [
name: '页面管理',
component: OpenLayout,
children: [
{path: '/page/openView', name: 'WIKI-内容展示', component: () => import('@/views/page/OpenView')},
{path: '/page/share/home', name: 'WIKI-开放文档', component: () => import('@/views/page/share/Home')},
{path: '/page/share/view', name: 'WIKI-内容展示', component: () => import('@/views/page/share/View')},
]
}
];

View File

@@ -2,7 +2,6 @@ export default {
namespaced: true,
state: {
pageTabNameMap: {},
fullscreen: false,
},
getters: {
getPageTabNameMap(state) {
@@ -15,8 +14,5 @@ export default {
sameObj[item.key] = item.val;
state.pageTabNameMap = sameObj;
},
setFullscreen(state, val) {
state.fullscreen = val;
},
}
}

View File

@@ -1,11 +1,8 @@
<template>
<div style="padding: 10px;" class="page-edit-vue">
<el-row type="border-card">
<div style="margin-bottom: 10px;padding: 10px;" v-if="wikiPage.id > 0">
编辑{{parentPath.path}}
</div>
<div style="margin-bottom: 10px;padding: 10px;" v-else>
父级{{parentPath.path || '/'}} 
<div style="margin-bottom: 10px;padding: 10px;" v-if="!pageId">
父级{{parentWikiPage.name || '/'}} 
<el-tooltip class="item" content="在根目录创建文档">
<el-button type="text" @click="changeToRootPath" style="padding: 0 10px;">根目录</el-button>
</el-tooltip>
@@ -24,14 +21,19 @@
import pageApi from '../../common/api/page'
export default {
props: ['spaceId'],
data() {
return {
editor: {},
// 编辑相关
newPageTitle: "",
parentPath: {},
wikiPage: {},
parentWikiPage: {},
isUnlock: false,
// 页面ID有值代表编辑
pageId: '',
// 父级,有值代表在此父级新建文档
parentId: '',
};
},
destroyed: function () {
@@ -54,17 +56,15 @@
},
methods: {
changeToRootPath() {
this.parentPath = {spaceId: this.parentPath.spaceId};
// 没有父级,就是在根目录创建
this.parentId = '';
this.parentWikiPage = {};
},
unlockPage() {
// 防止各种事件重复调这个接口,只需要调一次就好了
if (this.isUnlock) {
return;
}
this.isUnlock = true;
var param = {pageId: this.parentPath.pageId};
pageApi.pageUnlock(param).then(() => {
});
if (this.isUnlock) return;
this.isUnlock = true;
pageApi.pageUnlock({pageId: this.pageId});
},
createWikiCancel() {
this.$confirm('确定要取消编辑吗?您编辑的内容将不会被保存哦~', '提示', {
@@ -77,37 +77,34 @@
});
},
createWikiSave(saveAfter) {
// 修改内容时强制不能修改父路径,只能在目录上拖动修改
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: this.parentPath.spaceId,
// 修改内容时强制不能修改父路径,只能在目录上拖动修改
let parentId = (this.pageId > 0) ? '' : this.parentId;
let param = {
spaceId: this.spaceId,
parentId: parentId,
id: this.wikiPage.id,
name: this.newPageTitle,
content: this.editor.txt.html(),
preview: preview,
preview: this.editor.txt.text(),
};
pageApi.updatePage(param).then(json => {
this.$message.success("保存成功!");
// 重新加载左侧列表,跳转到展示页面
this.$emit('loadPageList');
this.parentPath.pageId = json.data.id;
this.pageId = json.data.id;
if (saveAfter == 1) {
this.$router.push({path: '/page/show', query: this.parentPath});
this.$router.push({path: '/page/show', query: {pageId: this.pageId}});
} else {
this.loadPageDetail(this.parentPath.pageId);
this.loadPageDetail(this.pageId);
}
});
},
loadPageDetail(pageId) {
this.rightContentType = 1;
var param = {id: pageId};
pageApi.pageDetail(param).then(json => {
pageApi.pageDetail({id: pageId}).then(json => {
this.wikiPage = json.data.wikiPage || {};
this.pageContent = json.data.pageContent || {};
this.pageFileList = json.data.fileList || [];
@@ -116,6 +113,12 @@
this.editor.txt.html(this.pageContent.content || "");
});
},
loadParentPageDetail(pageId) {
if (!pageId) return;
pageApi.pageDetail({id: pageId}).then(json => {
this.parentWikiPage = json.data.wikiPage || {};
});
},
cleanPage() {
this.wikiPage = {};
this.pageContent = {};
@@ -126,18 +129,12 @@
}
},
initQueryParam(to) {
this.parentPath = {
spaceId: to.query.spaceId, pageId: to.query.pageId,
parentId: to.query.parentId, path: to.query.path
};
if (!!this.parentPath.pageId) {
this.loadPageDetail(this.parentPath.pageId);
} else {
this.cleanPage();
}
let param = {pageId: this.parentPath.pageId};
pageApi.pageLock(param).then(json => {
if (json.errCode !== 200) {
// pageId和parentId二选一传了pageId代表编辑页面否则代表新建页面
this.pageId = to.query.pageId;
this.parentId = to.query.parentId;
if (!!this.pageId) {
this.loadPageDetail(this.pageId);
pageApi.pageLock({pageId: this.pageId}).catch(json => {
let that = this;
this.$alert(json.errMsg || '未知错误', '错误', {
confirmButtonText: '确定',
@@ -145,8 +142,11 @@
that.$router.back();
}
});
}
});
});
} else {
this.loadParentPageDetail(this.parentId);
this.cleanPage();
}
},
initEditor() {
this.editor = new WangEditor('#newPageContentDiv');

View File

@@ -1,24 +0,0 @@
<template>
<div class="page-open-view-vue">
</div>
</template>
<script>
export default {
data() {
return {};
},
beforeRouteUpdate(to, from, next) {
},
mounted: function () {
},
methods: {}
}
</script>
<style>
</style>

View File

@@ -9,16 +9,17 @@
创建{{wikiPage.createUserName}} {{wikiPage.createTime}}  
<span v-show="wikiPage.updateUserName">修改{{wikiPage.updateUserName}} {{wikiPage.updateTime}}</span>
<div style="float: right;">
<el-upload class="upload-page-file" :action="uploadFileUrl"
<el-upload v-if="wikiPageAuth.canUploadFile==1"
class="upload-page-file" :action="uploadFileUrl"
:with-credentials="true"
:on-success="uploadFileSuccess" :on-error="uploadFileError"
name="files" show-file-list multiple :data="uploadFormData" :limit="999"
style="display: inline;margin-right: 10px;">
<el-button type="text" icon="el-icon-upload">上传附件</el-button>
</el-upload>
<el-button type="text" icon="el-icon-edit" v-on:click="editWiki">编辑</el-button>
<el-button type="text" icon="el-icon-setting" v-on:click="editWikiAuth">权限设置</el-button>
<el-button type="text" icon="el-icon-delete" v-on:click="deleteWikiPage">删除</el-button>
<el-button v-if="wikiPageAuth.canEdit==1" type="text" icon="el-icon-edit" @click="editWiki">编辑</el-button>
<el-button v-if="wikiPageAuth.canConfigAuth==1" type="text" icon="el-icon-setting" @click="editWikiAuth">权限设置</el-button>
<el-button v-if="wikiPageAuth.canDelete==1" type="text" icon="el-icon-delete" @click="deleteWikiPage">删除</el-button>
</div>
</div>
</div>
@@ -32,7 +33,7 @@
<el-table-column prop="createUserName" label="创建人"></el-table-column>
<el-table-column prop="createTime" label="创建时间" width="180px"></el-table-column>
<el-table-column prop="downloadNum" label="下载次数" width="80px"></el-table-column>
<el-table-column label="操作" width="100px">
<el-table-column label="操作" width="100px" v-if="wikiPageAuth.canUploadFile==1">
<template slot-scope="scope">
<el-button size="small" v-on:click="deletePageFile(scope.row)">删除</el-button>
</template>
@@ -146,6 +147,7 @@
return {
// 页面展示相关
wikiPage: {},
wikiPageAuth: {},
pageContent: {},
pageFileList: [],
selfUserId: 0,
@@ -173,22 +175,12 @@
},
mounted: function () {
this.initQueryParam(this.$route);
if (!!this.parentPath.pageId) {
// 延迟设置展开的目录edit比app先初始化
setTimeout(() => {
if (!!this.parentPath.spaceId) {
// 调用父方法切换选择的空间
this.$emit('switchSpace', this.parentPath.spaceId);
}
this.$emit('changeExpandedKeys', this.parentPath.pageId);
}, 500);
}
},
methods: {
editWiki() {
var param = {pageId: this.parentPath.pageId};
pageApi.pageLock(param).then(() => {
this.$router.push({path: '/page/edit', query: this.parentPath});
this.$router.push({path: '/page/edit', query: {pageId: this.parentPath.pageId}});
});
},
getSearchUserList(query) {
@@ -269,23 +261,32 @@
}).catch(()=>{});
},
loadPageDetail(pageId) {
this.rightContentType = 1;
var param = {id: pageId};
pageApi.pageDetail(param).then(json => {
var wikiPage = json.data.wikiPage || {};
wikiPage.selfZan = json.data.selfZan || 0;
let result = json.data || {};
var wikiPage = result.wikiPage || {};
wikiPage.selfZan = result.selfZan || 0;
this.wikiPage = wikiPage;
this.pageContent = json.data.pageContent || {};
this.pageFileList = json.data.fileList || [];
this.selfUserId = json.data.selfUserId || 0;
this.pageContent = result.pageContent || {};
this.pageFileList = result.fileList || [];
this.selfUserId = result.selfUserId || 0;
this.uploadFormData = {pageId: this.wikiPage.id};
this.parentPath.spaceId = wikiPage.spaceId;
this.wikiPageAuth = {
canEdit: result.canEdit,
canDelete: result.canDelete,
canUploadFile: result.canUploadFile,
canConfigAuth: result.canConfigAuth,
};
// 修改标题
document.title = wikiPage.name || '页面展示';
document.title = wikiPage.name || 'WIKI-内容展示';
// 修改最后点击的项,保证刷新后点击编辑能展示编辑的项
// if (!this.lastClickNode.id) {
// this.lastClickNode = {id: wikiPage.id, nodePath: wikiPage.name};
// }
// 调用父方法切换选择的空间
this.$emit('switchSpace', this.wikiPage.spaceId);
// 调用父方法展开目录树
this.$emit('changeExpandedKeys', pageId);
});
this.loadCommentList(pageId);
},
@@ -395,10 +396,7 @@
return color;
},
initQueryParam(to) {
this.parentPath = {
spaceId: to.query.spaceId, pageId: to.query.pageId,
parentId: to.query.parentId, path: to.query.path
};
this.parentPath = {pageId: to.query.pageId};
if (!!this.parentPath.pageId) {
this.loadPageDetail(this.parentPath.pageId);
}

View File

@@ -0,0 +1,106 @@
<template>
<div style="padding: 10px;" class="page-share-home-vue">
<div style="max-width: 800px;margin: 0 auto;">
<div v-if="spacePageNews.length <= 0" class="empty-news">暂无数据</div>
<div v-else class="line-box" v-for="item in spacePageNews">
<div class="line-title">
<span class="text-link">{{item.createUserName}}</span> 发布于 <span class="text-link">{{item.spaceName}}</span>
</div>
<div class="page-preview-box">
<div class="page-preview-title" v-on:click="showPageDetail(item)" v-html="item.pageTitle"></div>
<div class="page-preview-content" v-html="item.previewContent"></div>
<div>
<span><img src="../../../assets/img/zan.png" class="zan-img"> {{item.zanNum}} </span>
<span><i class="el-icon-view view-img"></i> {{item.viewNum}} </span>
<span>{{item.updateTime||item.createTime}}</span>
</div>
</div>
</div>
<div class="page-info-box">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:page-sizes="[20, 50, 100]"
:page-size="20"
:current-page="searchParam.pageNum"
layout="prev, pager, next, jumper, sizes, total"
:total="totalCount"
>
</el-pagination>
</div>
</div>
</div>
</template>
<script>
import pageApi from '../../../common/api/page'
export default {
data() {
return {
totalCount: 0,
searchParam: {
spaceId: '',
newsType: 1,
pageNum: 1,
pageSize: 20,
},
spacePageNews: [],
};
},
beforeRouteUpdate(to, from, next) {
this.initQueryParam(to);
next();
},
mounted: function () {
this.initQueryParam(this.$route);
},
methods: {
getSpacePageNews() {
pageApi.openPageNews(this.searchParam).then(json => {
this.spacePageNews = json.data || [];
this.totalCount = json.total;
});
},
handleSizeChange(val) {
this.searchParam.pageSize = val;
this.getSpacePageNews();
},
showPageDetail(row) {
this.nowClickPath = {space: row.space, pageId: row.pageId};
this.$router.push({path: '/page/share/view', query: this.nowClickPath});
},
handleCurrentChange(val) {
this.searchParam.pageNum = val;
this.getSpacePageNews();
},
initQueryParam(to) {
this.searchParam = {
space: to.query.space,
newsType: 1,
pageNum: 1,
pageSize: 20,
};
if (!!this.searchParam.space) {
this.getSpacePageNews();
}
},
}
}
</script>
<style>
.page-share-home-vue .empty-news{text-align: center;padding: 100px;}
.page-share-home-vue .text-link {
color: #444;
}
.page-share-home-vue .line-box{color: #666;border-bottom: 1px solid #eee;padding: 20px 0;}
.page-share-home-vue .line-title{font-size: 14px;}
.page-share-home-vue .page-preview-box{}
.page-share-home-vue .page-preview-title{cursor: pointer;font-size: 20px;margin: 10px 0 5px 0;color: #3a8ee6;}
.page-share-home-vue .page-preview-content{font-size: 16px;margin-bottom: 5px;}
.page-share-home-vue .zan-img{vertical-align: middle;margin-top: -3px;}
.page-share-home-vue .view-img{font-size: 16px;color: #666;}
.page-share-home-vue .page-info-box{text-align: right;margin: 20px 0 50px 0;}
</style>

View File

@@ -0,0 +1,84 @@
<template>
<div class="page-share-view-vue">
<el-row type="border-card">
<div style="max-width: 950px;margin: 0 auto;">
<div class="wiki-title">{{wikiPage.name}}</div>
<div class="wiki-author">
<span v-show="!wikiPage.updateTime">创建时间{{wikiPage.createTime}}</span>
<span v-show="wikiPage.updateTime">最后修改{{wikiPage.updateTime}}</span>
</div>
<div class="wiki-files">
<el-table v-show="pageFileList.length > 0" :data="pageFileList" border
style="width: 100%; margin-bottom: 5px;">
<el-table-column label="文件名">
<template slot-scope="scope">
<a target="_blank" :href="scope.row.fileUrl">{{scope.row.fileName}}</a>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" width="180px"></el-table-column>
<el-table-column prop="downloadNum" label="下载次数" width="80px"></el-table-column>
</el-table>
</div>
<div class="wiki-content w-e-text">
<div v-html="pageContent.content"></div>
</div>
</div>
</el-row>
</div>
</template>
<script>
import pageApi from '../../../common/api/page'
export default {
data() {
return {
spaceUuid: '',
nowPageId: '',
// 页面展示相关
wikiPage: {},
pageContent: {},
pageFileList: [],
};
},
beforeRouteUpdate(to, from, next) {
this.initQueryParam(to);
next();
},
mounted() {
this.initQueryParam(this.$route);
},
methods: {
loadPageDetail(pageId) {
let param = {pageId: pageId, space: this.spaceUuid};
pageApi.openPageDetail(param).then(json => {
let wikiPage = json.data.wikiPage || {};
wikiPage.selfZan = json.data.selfZan || 0;
this.wikiPage = wikiPage;
this.pageContent = json.data.pageContent || {};
this.pageFileList = json.data.fileList || [];
document.title = wikiPage.name || 'WIKI-内容展示';
});
},
initQueryParam(to) {
this.spaceUuid = to.query.space;
this.nowPageId = to.query.pageId;
if (!!this.nowPageId) {
this.loadPageDetail(this.nowPageId);
}
},
}
}
</script>
<style>
.page-share-view-vue .wiki-title{font-size: 20px;text-align: center;}
.page-share-view-vue .wiki-author{font-size: 14px;color: #888;padding: 20px 0;height: 40px;line-height: 40px;}
.page-share-view-vue .wiki-content{font-size: 14px;}
.page-share-view-vue .wiki-content.w-e-text{overflow-y: auto;}
.page-share-view-vue .upload-page-file .el-upload-list{display: none;}
.page-share-view-vue .is-link{color: #1e88e5;cursor: pointer;}
</style>