Files
zyplayer-doc/zyplayer-doc-wiki/src/main/resources/doc-wiki.html
2019-03-04 23:20:40 +08:00

284 lines
9.4 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>wiki文档管理系统</title>
<link rel="shortcut icon" href="webjars/doc-wiki/img/wiki.ico"/>
<link rel="stylesheet" href="webjars/doc-wiki/css/element-ui.css">
<link rel="stylesheet" href="webjars/doc-wiki/css/doc-wiki.css" />
</head>
<body>
<div id="app">
<el-container style="height: 100%;">
<el-aside width="auto" style="height: 100%;">
<!--<div class="logo" @click="aboutDialogVisible = true">zyplayer-doc-wiki</div>-->
<div style="padding: 10px;">
<div align="center"><el-button type="primary" v-on:click="createWiki" icon="el-icon-plus" style="width: 100%;">创建文档</el-button></div>
<!--<el-row><el-switch v-model="isCollapse"></el-switch></el-row>-->
<el-input v-model="searchKeywords" 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" @node-click="handleNodeClick" :load="loadNodeChildren" lazy></el-tree>
</div>
</el-aside>
<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;">欢迎使用在线文档</div>
</el-row>
<el-row type="border-card" v-show="rightContentType == 1">
<div class="wiki-title">
<!--狗屎一样的代码如何重构wiki模块正在开发中这只是一个预览页面-->
{{wikiPage.name}}
<div style="float: right;">
<el-button type="text" icon="el-icon-edit" v-on:click="editWiki">编辑</el-button>
<el-button type="text" icon="el-icon-setting">访问权限</el-button>
</div>
</div>
<div class="wiki-author">
创建时间:{{wikiPage.createUserName}} {{wikiPage.createTime}}  最后修改:{{wikiPage.updateUserName}} {{wikiPage.updateTime}}
</div>
<div class="wiki-files">
<div style="margin-bottom: 5px; height: 40px;">
<div style="float: right;">
<!--:on-preview="handlePreview"-->
<!--:on-remove="handleRemove"-->
<!--:before-remove="beforeRemove"-->
<!--:on-exceed="handleExceed"-->
<el-upload
class="upload-demo"
action="zyplayer-doc-wiki/common/upload"
name="files"
show-file-list
multiple
:limit="3">
<el-button icon="el-icon-upload">上传附件</el-button>
</el-upload>
</div>
</div>
<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="createUserName" label="创建人"></el-table-column>
<el-table-column prop="createTime" label="创建时间"></el-table-column>
</el-table>
</div>
<div class="wiki-content">
<div v-html="pageContent.content"></div>
</div>
</el-row>
<el-row type="border-card" v-show="rightContentType == 2">
<div style="margin-bottom: 10px;">
父级:{{lastClickNode.nodePath || '/'}} 
<el-tooltip class="item" content="在根目录创建文档">
<el-button type="text" @click="lastClickNode={}" style="padding: 0 10px;">根目录</el-button>
</el-tooltip>
</div>
<el-input v-model="newPageTitle" placeholder="请输入标题"></el-input>
<div id="newPageContentDiv" style="margin: 10px 0;"></div>
<el-button type="primary" v-on:click="createWikiSave">保存</el-button>
<el-button v-on:click="createWikiCancel">取消</el-button>
</el-row>
</el-main>
</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>
</body>
<script type="text/javascript" src="webjars/doc-wiki/vue/vue.js"></script>
<script type="text/javascript" src="webjars/doc-wiki/js/element-ui.js"></script>
<!-- ajax 用到了jquery -->
<script type="text/javascript" src="webjars/doc-wiki/js/jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="webjars/doc-wiki/js/common.js"></script>
<script type="text/javascript" src="webjars/doc-wiki/js/toast.js"></script>
<script type="text/javascript" src="webjars/doc-wiki/js/formatjson.js"></script>
<script type="text/javascript" src="webjars/doc-wiki/js/doc-wiki-tree.js"></script>
<script type="text/javascript" src="webjars/doc-wiki/lib/wangEditor/wangEditor.js"></script>
<script>
var page = {
newPageContentEditor: '',
};
var app = new Vue({
el: '#app',
data() {
return {
isCollapse: false,
aboutDialogVisible: false,
rightContentLoading: false,
rightContentType: 0,// 右侧显示类型0=欢迎页 1=文章内容 2=编辑或新增文章
pathIndex: [],
defaultProps: {
children: 'children',
label: 'label',
isLeaf: 'leaf'
},
wikiPageList:[],
// 依据目录树存储的map全局对象
treePathDataMap: new Map(),
// 搜索的输入内容
searchKeywords: "",
lastClickNode: {},
newPageId: "",
newPageTitle: "",
// 页面展示相关
wikiPage: {},
pageContent: {},
pageFileList: [],
uploadFileList: [],
}
},
watch: {
},
mounted: function () {
//this.doGetPageList();
this.init();
},
methods: {
editWiki(){
this.rightContentType = 2;
this.newPageId = app.wikiPage.id;
this.newPageTitle = app.wikiPage.name;
page.newPageContentEditor.txt.html(app.pageContent.content || "");
},
createWiki(){
this.newPageId = "";
this.rightContentType = 2;
},
createWikiCancel(){
if (isEmpty(this.lastClickNode.label)) {
this.rightContentType = 0;
} else {
this.rightContentType = 1;
}
},
createWikiSave(){
var parentId = app.lastClickNode.id;
if (this.newPageId > 0) {
parentId = "";
}
var param = {
spaceId: 1,
id: this.newPageId,
name: app.newPageTitle,
parentId: parentId,
content: page.newPageContentEditor.txt.html()
};
ajaxTemp("zyplayer-doc-wiki/page/update", "post", "json", param, function (json) {
if (validateResult(json)) {
Toast.success("保存成功!");
this.loadPageDetail(json.data.id);
}
});
},
handleNodeClick(data) {
app.rightContentType = 1;
if (app.lastClickNode.id == data.id) {
return;
}
console.log("点击节点:", data);
app.lastClickNode = data;
this.loadPageDetail(app.lastClickNode.id);
},
loadPageDetail(pageId) {
app.rightContentType = 1;
var param = {id: pageId};
ajaxTemp("zyplayer-doc-wiki/page/detail", "post", "json", param, function (json) {
if (validateResult(json)) {
app.wikiPage = json.data.wikiPage || {};
app.pageContent = json.data.pageContent || {};
app.pageFileList = json.data.fileList || [];
}
});
},
searchByKeywords() {
app.pathIndex = createTreeViewByTreeWithMerge(app.dubboDocList, app.searchKeywords);
},
loadNodeChildren(node, resolve) {
if (node.level === 0) {
this.doGetPageList(null, node, resolve);
} else {
this.doGetPageList(node.data.id, node, resolve);
}
},
doGetPageList(parentId, node, resolve) {
var nodePath = "";
if (!!node.data) {
nodePath = node.data.nodePath || "/";
if (!nodePath.endsWith("/")) {
nodePath += "/";
}
} else {
nodePath = "/";
}
var param = {spaceId: 1, parentId: parentId};
ajaxTemp("zyplayer-doc-wiki/page/list", "post", "json", param, function (json) {
if (validateResult(json)) {
app.wikiPageList = json.data || [];
var pathIndex = [];
for (var i = 0; i < json.data.length; i++) {
var item = json.data[i];
pathIndex.push({
id: item.id,
label: item.name,
leaf: item.nodeType == 1,
nodePath: nodePath + item.name,
});
}
resolve(pathIndex);
}
});
},
init(){
var E = window.wangEditor;
page.newPageContentEditor = new E('#newPageContentDiv');
page.newPageContentEditor.customConfig.uploadImgServer = 'zyplayer-doc-wiki/common/upload';
page.newPageContentEditor.create();
}
}
});
</script>
<style>
html,body,#app {
margin: 0;
padding: 0;
height: 100%;
}
pre{margin: 0;}
.el-menu {
box-sizing: border-box;
border-right: 0;
margin-right: 3px;
}
.doc-body-box{
overflow-x: hidden;height: calc(100vh);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;
width: 100%; height:60px;line-height:60px;font-size: 25px;color: #fff;text-align: center;
}
.wiki-title{font-size: 20px;}
.wiki-author{font-size: 14px;padding: 10px 0;}
.wiki-content{font-size: 14px;}
</style>
</html>