!28 合并闭源版wiki相关逻辑,优化新建文档的显示问题

Merge pull request !28 from sh1yu/master
This commit is contained in:
暮光:城中城
2023-07-04 11:06:06 +00:00
committed by Gitee
3 changed files with 91 additions and 54 deletions

View File

@@ -24,15 +24,22 @@
</template>
</el-autocomplete>
<div style="margin-left: 10px;margin-bottom: 10px">
<span style="color:#898989;font-size:small;">空间目录
<el-dropdown style="float:right">
<el-icon >
<el-icon-plus/>
<span style="color:#898989;font-size:small;">空间目录
<el-dropdown trigger="click" style="float:right">
<el-icon style="margin-right: 5px">
<el-icon-plus />
</el-icon>
<template v-slot:dropdown>
<el-dropdown-menu>
<el-dropdown-item v-on:click="createWiki(1,true)">创建Html</el-dropdown-item>
<el-dropdown-item v-on:click="createWiki(2,true)">创建Markdown</el-dropdown-item>
<el-dropdown-item v-on:click="createWiki(1,true)">
<el-icon class="clickAddIcon" style="margin-right: 5px">
<svg width="1em" height="1em" viewBox="0 0 48 48" fill="none"><rect x="6" y="6" width="36" height="36" rx="3" fill="none" stroke="currentColor" stroke-width="4"></rect><path d="M14 16L18 32L24 19L30 32L34 16" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"></path></svg>
</el-icon>
创建富文本
</el-dropdown-item>
<el-dropdown-item v-on:click="createWiki(2,true)">
<el-icon class="clickAddIcon" style="margin-right: 5px"><el-icon-document/></el-icon>创建Markdown
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
@@ -55,24 +62,36 @@
@node-expand="handleNodeExpand"
@node-drop="handlePageDrop">
<template v-slot="{ node, data }">
<div class="page-tree-node">
<div class="page-tree-node" @mouseover="changeNodeOptionStatus(data,1)" @mouseleave="changeNodeOptionStatus(data,-1) ">
<el-tooltip :content="node.label" placement="top-start" :show-after="1000">
<span class="label">
<el-icon><el-icon-document/></el-icon>
<span class="el-dropdown-link">{{ node.label }}
<el-dropdown style="float:right">
<el-icon >
<el-icon-plus/>
</el-icon>
<template v-slot:dropdown>
<el-dropdown-menu>
<el-dropdown-item v-on:click="createWiki(2)">创建Markdown</el-dropdown-item>
<el-dropdown-item v-on:click="createWiki(1)">创建Html</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</span>
<span >
<el-icon v-if="data.editorType === 1" class="clickAddIcon" style="margin-right: 5px">
<svg width="1em" height="1em" viewBox="0 0 48 48" fill="none"><rect x="6" y="6" width="36" height="36" rx="3" fill="none" stroke="currentColor" stroke-width="4"></rect><path d="M14 16L18 32L24 19L30 32L34 16" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"></path></svg>
</el-icon>
<el-icon v-if="data.editorType === 2" class="clickAddIcon" style="margin-right: 5px"><el-icon-document/></el-icon>
<span >{{ node.label }}</span>
<span class="el-dropdown-link" @click="pageInfoLock()" >
<el-dropdown trigger="click" style="float:right" >
<el-icon v-show="changeNodeOptionStatus(data,0)" style="margin-right: 5px">
<el-icon-plus />
</el-icon>
<template v-slot:dropdown>
<el-dropdown-menu>
<el-dropdown-item v-on:click="createWiki(1)">
<el-icon class="clickAddIcon" style="margin-right: 5px">
<svg width="1em" height="1em" viewBox="0 0 48 48" fill="none"><rect x="6" y="6" width="36" height="36" rx="3" fill="none" stroke="currentColor" stroke-width="4"></rect><path d="M14 16L18 32L24 19L30 32L34 16" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"></path></svg>
</el-icon>
创建富文本
</el-dropdown-item>
<el-dropdown-item v-on:click="createWiki(2)">
<el-icon class="clickAddIcon" style="margin-right: 5px"><el-icon-document/></el-icon>创建Markdown
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</span>
</span>
</el-tooltip>
</div>
</template>
@@ -212,6 +231,9 @@ let userMessagePopVisible = ref(false);
let userMsgTotalCount = ref(0);
let userMsgParam = ref({sysType: 2, pageNum: 1, pageSize: 20,});
let rightAsideWidth = ref(300);
let optionStatus = ref(false);
let optionPageId = ref('');
let optionLock = ref(false);
onMounted(() => {
loadSpaceList()
@@ -222,6 +244,32 @@ const loadPageList = (param) => {
param = param || {}
doGetPageList(param.parentId, param.node)
}
const pageInfoLock = () => {
optionLock.value = true
}
const pageInfoUnlock = (keepLock) => {
console.log(optionLock.value)
if (optionLock.value === true){
if (!keepLock){
optionLock.value = false
}
return true
}
return false
}
const changeNodeOptionStatus = (param,type) => {
if (type > 0){
optionPageId.value = param.id
optionStatus.value = true
}
if (type < 0 ){
optionPageId.value = param.id
optionStatus.value = false
}
if (type === 0 && optionPageId.value === param.id && optionStatus.value){
return true
}
}
const turnLeftCollapse = () => {
leftCollapse.value = !leftCollapse.value
setTimeout(() => {
@@ -237,8 +285,10 @@ const turnLeftCollapse = () => {
nowPageId.value = 0
}
if (choiceSpace.value > 0) {
pageApi.updatePage({spaceId: choiceSpace.value,parentId: nowPageId.value,editorType:editorType,name:'未命名',content:'',preview:''})
pageApi.updatePage({spaceId: choiceSpace.value,parentId: nowPageId.value,editorType:editorType,name:'新建文档',content:'',preview:''})
.then((json) => {
doGetPageList(null)
ElMessage.success('创建成功')
router.push({
path: '/page/edit',
query: {parentId: nowPageId.value, pageId: json.data.id}
@@ -281,12 +331,18 @@ const searchByKeywordsNewPage = () => {
window.open(routeUrl.href, '_blank')
}
const handleNodeClick = (data) => {
// console.log('点击节点:', data, nowPageId.value)
//console.log('点击节点:', data, nowPageId.value)
if (pageInfoUnlock()){
return
}
nowPageId.value = data.id
router.push({path: '/page/show', query: {pageId: data.id}})
handleNodeExpand(data)
}
const handleNodeExpand = (node) => {
if (pageInfoUnlock(true)){
return
}
if (
node.children &&
node.children.length > 0 &&
@@ -297,6 +353,9 @@ const handleNodeExpand = (node) => {
}
}
const handlePageDrop = (draggingNode, dropNode, dropType, ev) => {
if (pageInfoUnlock(true)){
return
}
console.log('tree drop: ', draggingNode.data, dropNode.data, dropType)
// 'prev'、'inner'、'next'
// before、after、inner

View File

@@ -1,37 +1,19 @@
<template>
<div style="height: 100%" class="page-edit-vue">
<div style="box-sizing: border-box; background: #f5f5f5; overflow: hidden">
<div style="padding: 8px; font-size: 14px; background: #fff">
<div style="padding: 5px; font-size: 14px; background: #fff">
<el-row>
<el-col :span="16">
<template v-if="pageId">
<span>编辑方式</span>
<el-select v-model="wikiPageEdit.editorType" v-on:change="editorTypeChange" :disabled="!!pageId" size="small">
<el-option label="Markdown" :value="2"></el-option>
<el-option label="HTML" :value="1"></el-option>
</el-select>
</template>
<template v-else>
<span class="parent-name">父级{{ parentWikiPage.name || '/' }}</span>
<el-tooltip class="item" content="在根目录创建文档" v-if="parentId">
<el-link @click="changeToRootPath" type="primary" size="small" style="padding: 0 10px">根目录</el-link>
</el-tooltip>
<span style="margin-left: 50px">编辑方式</span>
<el-select v-model="wikiPageEdit.editorType" v-on:change="editorTypeChange" :disabled="!!pageId" size="small">
<el-option label="Markdown" :value="2"></el-option>
<el-option label="HTML" :value="1"></el-option>
</el-select>
</template>
<el-col :span="16" style="text-align: left">
<el-input v-if="wikiPageEdit.editorType===2" v-model="wikiPageEdit.pageTitle" :maxlength="40" placeholder="请输入标题" class="page-title-input" ></el-input>
</el-col>
<el-col :span="8" style="text-align: right">
<el-col :span="8" style="text-align: right;margin-top: 4px;">
<el-button type="primary" v-on:click="createWikiSave(1)" size="small" :icon="ElIconDocumentChecked">保存并查看</el-button>
<el-button type="success" v-on:click="createWikiSave(0)" size="small" :icon="ElIconCheck">仅保存</el-button>
<el-button v-on:click="createWikiCancel" size="small" :icon="ElIconBack">取消</el-button>
<el-button v-on:click="createWikiCancel" size="small" :icon="ElIconBack" style="margin-right: 5px">取消</el-button>
</el-col>
</el-row>
</div>
<div v-show="wikiPageEdit.editorType === 2" style="padding: 0 10px 10px 10px; background: #fff">
<el-input v-model="wikiPageEdit.pageTitle" :maxlength="40" placeholder="请输入标题" class="page-title-input"></el-input>
<mavonEditor
ref="mavonEditorRef"
v-model="markdownContent"
@@ -137,13 +119,6 @@ onMounted(() => {
that.unlockPage()
}
})
const changeToRootPath = () => {
// 没有父级,就是在根目录创建
parentId.value = ''
parentWikiPage.value = {}
}
const editorTypeChange = () => {
}
const unlockPage = () => {
// 防止各种事件重复调这个接口,只需要调一次就好了
if (isUnlock.value) return
@@ -385,6 +360,8 @@ const initEditor = () => {
.page-edit-vue .page-title-input {
padding-bottom: 10px;
margin-left: 5px;
width: 100%;
}
.page-edit-vue .markdown-body table {

View File

@@ -71,6 +71,7 @@ import {useStorePageData} from "@/store/pageData";
let storePage = useStorePageData();
let router = useRouter();
const editWiki = () => {
// 锁定页面并进入编辑页面
let param = {pageId: storePage.pageInfo.id};