测试升级为vue3
This commit is contained in:
@@ -0,0 +1,562 @@
|
||||
<template>
|
||||
<div class="global-layout-vue">
|
||||
<el-container>
|
||||
<el-aside v-show="leftCollapse" :style="{ width: rightAsideWidth + 'px' }">
|
||||
<div style="padding: 10px;height: 100%;box-sizing: border-box;background: #fafafa;">
|
||||
<div style="margin-bottom: 10px">
|
||||
<el-select :model-value="choiceSpace" filterable placeholder="选择空间" style="width: 100%" @change="spaceChangeEvents">
|
||||
<el-option-group label="">
|
||||
<el-option key="0" label="创建空间" value="0"></el-option>
|
||||
<el-option key="-1" label="空间管理" value="-1"></el-option>
|
||||
</el-option-group>
|
||||
<el-option-group label="">
|
||||
<el-option v-for="item in spaceOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
|
||||
</el-option-group>
|
||||
</el-select>
|
||||
</div>
|
||||
<div align="center">
|
||||
<el-button :icon="ElIconPlus" style="width: 100%" v-on:click="createWiki">创建文档</el-button>
|
||||
</div>
|
||||
<el-autocomplete v-model="searchKeywords" :fetch-suggestions="doSearchByKeywords" placeholder="在当前空间搜索" popper-class="search-autocomplete" style="width: 100%; margin: 10px 0" @select="handleSearchKeywordsSelect">
|
||||
<template v-slot="{ item }">
|
||||
<div class="search-option-item">
|
||||
<div class="title">
|
||||
<span v-html="item.pageTitle || '-'"></span>
|
||||
</div>
|
||||
<span class="content" v-html="item.previewContent || '-'"></span>
|
||||
</div>
|
||||
</template>
|
||||
</el-autocomplete>
|
||||
<div class="wiki-page-tree-box">
|
||||
<el-tree
|
||||
ref="wikiPageTree"
|
||||
:current-node-key="nowPageId"
|
||||
:data="wikiPageList"
|
||||
:default-expanded-keys="wikiPageExpandedKeys"
|
||||
:expand-on-click-node="false"
|
||||
:filter-node-method="filterPageNode"
|
||||
:props="defaultProps"
|
||||
draggable
|
||||
highlight-current
|
||||
node-key="id"
|
||||
style="background-color: #fafafa"
|
||||
@node-click="handleNodeClick"
|
||||
@node-expand="handleNodeExpand"
|
||||
@node-drop="handlePageDrop"
|
||||
>
|
||||
<template v-slot="{ node, data }">
|
||||
<span style="font-size: 14px">
|
||||
<el-icon><el-icon-document/></el-icon>
|
||||
<span style="margin-left: 6px">{{ node.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
</div>
|
||||
</div>
|
||||
</el-aside>
|
||||
<RightResize v-show="leftCollapse" v-model:value="rightAsideWidth" @change="rightAsideWidthChange"></RightResize>
|
||||
<el-container>
|
||||
<el-header>
|
||||
<el-icon class="el-icon-s-fold">
|
||||
<el-icon-fold/>
|
||||
</el-icon>
|
||||
<el-icon class="el-icon-s-unfold">
|
||||
<el-icon-fold/>
|
||||
</el-icon>
|
||||
<span class="header-right-user-name">{{userSelfInfo.userName}}</span>
|
||||
<el-popover v-model="userMessagePopVisible" placement="bottom" trigger="click" width="600">
|
||||
<template v-slot:reference>
|
||||
<el-badge :is-dot="haveNotReadUserMessage" style="line-height: 20px; margin: 0 15px">
|
||||
<el-icon class="head-icon" style="margin-right: 0">
|
||||
<el-icon-bell/>
|
||||
</el-icon>
|
||||
</el-badge>
|
||||
</template>
|
||||
<div style="margin-bottom: 10px">
|
||||
<span style="font-size: 14px; font-weight: bold">通知</span>
|
||||
<el-link v-if="haveNotReadUserMessage" :icon="ElIconCheck" style="float: right" type="primary" v-on:click="readAllUserMessage">本页标记已读</el-link>
|
||||
</div>
|
||||
<div class="header-user-message">
|
||||
<el-table :data="userMessageList" border max-height="500" size="mini" style="width: 100%; margin-bottom: 5px">
|
||||
<el-table-column label="操作人" prop="operatorUserName" width="100px"></el-table-column>
|
||||
<el-table-column label="操作时间" prop="creationTime" width="140px"></el-table-column>
|
||||
<el-table-column label="内容">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.msgContent }}
|
||||
<!-- TODO-->
|
||||
<!-- <template v-slot:reference>-->
|
||||
<!-- <el-badge :is-dot="scope.row.msgStatus == 0" style="line-height: 10px; padding-right: 5px">-->
|
||||
<!-- <el-link type="primary" v-on:click="showUserMessage(scope.row)">查看</el-link>-->
|
||||
<!-- </el-badge>-->
|
||||
<!-- </template>-->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="page-info-box">
|
||||
<el-pagination
|
||||
:current-page="userMsgParam.pageNum"
|
||||
:page-size="userMsgParam.pageSize"
|
||||
:total="userMsgTotalCount"
|
||||
layout="prev, pager, next, total"
|
||||
@current-change="handleCurrentChange">
|
||||
</el-pagination>
|
||||
</div>
|
||||
</div>
|
||||
</el-popover>
|
||||
<el-dropdown trigger="click" @command="userSettingDropdown">
|
||||
<el-icon class="head-icon">
|
||||
<el-icon-setting/>
|
||||
</el-icon>
|
||||
<template v-slot:dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="console">控制台</el-dropdown-item>
|
||||
<el-dropdown-item command="aboutDoc">关于</el-dropdown-item>
|
||||
<el-dropdown-item command="userSignOut" divided>退出登录</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-header>
|
||||
<el-main style="padding: 0; border-left: 1px solid #dcdfe6">
|
||||
<router-view
|
||||
v-slot="{ Component }"
|
||||
:spaceId="choiceSpace"
|
||||
:spaceInfo="getSpaceInfo(choiceSpace)"
|
||||
@changeExpandedKeys="changeWikiPageExpandedKeys"
|
||||
@loadPageList="loadPageList"
|
||||
@loadSpace="loadSpaceList"
|
||||
@switchSpace="switchSpacePage">
|
||||
<component :is="Component"></component>
|
||||
</router-view>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</el-container>
|
||||
<create-space ref="createSpace" @success="loadSpaceList"></create-space>
|
||||
<about-dialog ref="aboutDialog"></about-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
Document as ElIconDocument,
|
||||
Fold as ElIconFold,
|
||||
Bell as ElIconBell,
|
||||
Setting as ElIconSetting,
|
||||
Plus as ElIconPlus,
|
||||
Check as ElIconCheck,
|
||||
} from '@element-plus/icons-vue'
|
||||
import userApi from '../../common/api/user'
|
||||
import pageApi from '../../common/api/page'
|
||||
import CreateSpace from '../space/CreateSpace'
|
||||
import RightResize from './RightResize.vue'
|
||||
import aboutDialog from '../../views/common/AboutDialog'
|
||||
import {useStoreDisplay} from '@/store/wikiDisplay.js'
|
||||
|
||||
const storeDisplay = useStoreDisplay()
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
leftCollapse: true,
|
||||
rightContentLoading: false,
|
||||
pathIndex: [],
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name',
|
||||
},
|
||||
// 空间搜索相关
|
||||
spaceOptions: [],
|
||||
spaceList: [],
|
||||
choiceSpace: '',
|
||||
nowSpaceShow: {},
|
||||
nowPageId: '',
|
||||
// 依据目录树存储的map全局对象
|
||||
treePathDataMap: new Map(),
|
||||
// 搜索的输入内容
|
||||
searchKeywords: '',
|
||||
// 页面展示相关
|
||||
wikiPageList: [],
|
||||
wikiPage: {},
|
||||
wikiPageExpandedKeys: [],
|
||||
userSelfInfo: {},
|
||||
userMessageList: [],
|
||||
haveNotReadUserMessage: false,
|
||||
userMessagePopVisible: false,
|
||||
userMsgTotalCount: 0,
|
||||
userMsgParam: {
|
||||
sysType: 2,
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
},
|
||||
rightAsideWidth: 300,
|
||||
ElIconPlus,
|
||||
ElIconCheck,
|
||||
}
|
||||
},
|
||||
components: {
|
||||
RightResize,
|
||||
'create-space': CreateSpace,
|
||||
'about-dialog': aboutDialog,
|
||||
ElIconDocument,
|
||||
ElIconFold,
|
||||
ElIconBell,
|
||||
ElIconSetting,
|
||||
},
|
||||
computed: {},
|
||||
mounted() {
|
||||
this.loadSpaceList()
|
||||
this.loadUserMessageList()
|
||||
this.getSelfUserInfo()
|
||||
},
|
||||
methods: {
|
||||
loadPageList(param) {
|
||||
param = param || {}
|
||||
this.doGetPageList(param.parentId, param.node)
|
||||
},
|
||||
turnLeftCollapse() {
|
||||
this.leftCollapse = !this.leftCollapse
|
||||
setTimeout(() => {
|
||||
if (this.leftCollapse) {
|
||||
this.rightAsideWidthChange(this.rightAsideWidth + 1)
|
||||
} else {
|
||||
this.rightAsideWidthChange(1)
|
||||
}
|
||||
}, 100)
|
||||
},
|
||||
createWiki() {
|
||||
if (this.choiceSpace > 0) {
|
||||
this.$router.push({
|
||||
path: '/page/edit',
|
||||
query: {parentId: this.nowPageId},
|
||||
})
|
||||
} else {
|
||||
this.$message.warning('请先选择或创建空间')
|
||||
}
|
||||
},
|
||||
changeWikiPageExpandedKeys(pageId) {
|
||||
// 展开没有触发子节点的加载,如果去加载子节点有还找不到当前的node,暂不展开
|
||||
// this.wikiPageExpandedKeys = [pageId];
|
||||
},
|
||||
doSearchByKeywords(queryString, callback) {
|
||||
if (!queryString || !queryString.trim()) {
|
||||
callback([])
|
||||
return
|
||||
}
|
||||
pageApi
|
||||
.pageNews({spaceId: this.choiceSpace, keywords: queryString})
|
||||
.then((json) => {
|
||||
let spacePageNews = json.data || []
|
||||
callback(spacePageNews)
|
||||
})
|
||||
},
|
||||
handleSearchKeywordsSelect(item) {
|
||||
this.searchKeywords = ''
|
||||
this.$router.push({path: '/page/show', query: {pageId: item.pageId}})
|
||||
},
|
||||
searchByKeywords() {
|
||||
this.$refs.wikiPageTree.filter(this.searchKeywords)
|
||||
},
|
||||
searchByKeywordsNewPage() {
|
||||
var routeUrl = this.$router.resolve({
|
||||
path: '/page/search',
|
||||
query: {keywords: this.searchKeywords},
|
||||
})
|
||||
window.open(routeUrl.href, '_blank')
|
||||
},
|
||||
handleNodeClick(data) {
|
||||
console.log('点击节点:', data, this.nowPageId)
|
||||
this.nowPageId = data.id
|
||||
this.$router.push({path: '/page/show', query: {pageId: data.id}})
|
||||
this.handleNodeExpand(data)
|
||||
},
|
||||
handleNodeExpand(node) {
|
||||
if (
|
||||
node.children &&
|
||||
node.children.length > 0 &&
|
||||
node.children[0].needLoad
|
||||
) {
|
||||
console.log('加载节点:', node)
|
||||
this.doGetPageList(node.id, node)
|
||||
}
|
||||
},
|
||||
handlePageDrop(draggingNode, dropNode, dropType, ev) {
|
||||
console.log('tree drop: ', draggingNode.data, dropNode.data, dropType)
|
||||
// 'prev'、'inner'、'next'
|
||||
// before、after、inner
|
||||
var param = {id: draggingNode.data.id, parentId: dropNode.data.parentId}
|
||||
if (dropType == 'inner') {
|
||||
param.parentId = dropNode.data.id
|
||||
} else if (dropType == 'before') {
|
||||
param.beforeSeq = dropNode.data.seqNo
|
||||
} else if (dropType == 'after') {
|
||||
param.afterSeq = dropNode.data.seqNo
|
||||
}
|
||||
pageApi.pageChangeParent(param).then((res) => {
|
||||
this.doGetPageList(null)
|
||||
})
|
||||
},
|
||||
loadUserMessageIfPopVisible() {
|
||||
if (!this.userMessagePopVisible) {
|
||||
this.loadUserMessageList()
|
||||
}
|
||||
},
|
||||
loadUserMessageList() {
|
||||
userApi.getUserMessageList(this.userMsgParam).then((res) => {
|
||||
this.userMessageList = res.data || []
|
||||
this.userMsgTotalCount = res.total || 0
|
||||
this.haveNotReadUserMessage =
|
||||
this.userMessageList.filter((item) => item.msgStatus == 0).length > 0
|
||||
})
|
||||
},
|
||||
showUserMessage(row) {
|
||||
if (row.msgStatus == 0) {
|
||||
userApi.readUserMessage({ids: row.id}).then(() => {
|
||||
this.loadUserMessageList()
|
||||
})
|
||||
}
|
||||
if (row.msgType >= 2 && row.msgType <= 12) {
|
||||
this.$router.push({path: '/page/show', query: {pageId: row.dataId}})
|
||||
this.userMessagePopVisible = false
|
||||
}
|
||||
},
|
||||
readAllUserMessage() {
|
||||
let msgIds = []
|
||||
this.userMessageList
|
||||
.filter((item) => item.msgStatus == 0)
|
||||
.forEach((item) => {
|
||||
msgIds.push(item.id)
|
||||
})
|
||||
if (msgIds.length <= 0) return
|
||||
userApi.readUserMessage({ids: msgIds.join(',')}).then(() => {
|
||||
this.$message.success('标记成功')
|
||||
this.loadUserMessageList()
|
||||
})
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.userMsgParam.pageNum = val
|
||||
this.loadUserMessageList()
|
||||
},
|
||||
filterPageNode(value, data) {
|
||||
if (!value || !data.name) return true
|
||||
// issues:I2CG72 忽略大小写
|
||||
let name = data.name.toLowerCase()
|
||||
return name.indexOf(value.toLowerCase()) !== -1
|
||||
},
|
||||
spaceChangeEvents(data) {
|
||||
if (data == 0) {
|
||||
// 新建空间
|
||||
this.$refs.createSpace.show()
|
||||
} else if (data == -1) {
|
||||
// 管理空间
|
||||
this.$router.push({path: '/space/manage'})
|
||||
} else {
|
||||
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}})
|
||||
}
|
||||
},
|
||||
loadSpaceList(spaceId) {
|
||||
pageApi.spaceList({}).then((json) => {
|
||||
this.spaceList = json.data || []
|
||||
let spaceOptions = []
|
||||
this.spaceList.forEach((item) =>
|
||||
spaceOptions.push({label: item.name, value: item.id})
|
||||
)
|
||||
this.spaceOptions = spaceOptions
|
||||
if (this.spaceList.length > 0) {
|
||||
let nowSpaceId = spaceId
|
||||
let nowSpaceShow = this.spaceList.find((item) => item.id == spaceId)
|
||||
if (!nowSpaceShow) {
|
||||
nowSpaceShow = this.spaceList[0]
|
||||
nowSpaceId = nowSpaceShow.id
|
||||
}
|
||||
this.nowSpaceShow = nowSpaceShow
|
||||
this.choiceSpace = nowSpaceId
|
||||
this.nowPageId = ''
|
||||
this.doGetPageList(null)
|
||||
// TODO 在首页时跳转
|
||||
try {
|
||||
if (this.$router.app._route.path == '/home') {
|
||||
this.$router.push({
|
||||
path: '/home',
|
||||
query: {spaceId: nowSpaceId},
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
doGetPageList(parentId, node) {
|
||||
let param = {spaceId: this.choiceSpace}
|
||||
pageApi.pageList(param).then((json) => {
|
||||
this.wikiPageList = json.data || []
|
||||
// 设置默认选中效果
|
||||
this.$nextTick(() => {
|
||||
this.nowPageId = this.$route.query.pageId
|
||||
if (this.nowPageId) {
|
||||
console.log('moern?')
|
||||
this.$refs['wikiPageTree'].setCurrentKey(this.nowPageId)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
userSettingDropdown(command) {
|
||||
console.log('command:' + command)
|
||||
if (command == 'userSignOut') {
|
||||
this.userSignOut()
|
||||
} else if (command == 'aboutDoc') {
|
||||
this.$refs.aboutDialog.show()
|
||||
} else if (command == 'myInfo') {
|
||||
this.$router.push({path: '/user/myInfo'})
|
||||
} else if (command == 'console') {
|
||||
window.open(process.env.VUE_APP_BASE_API, '_blank')
|
||||
} else {
|
||||
this.$message.warning('暂未开放')
|
||||
}
|
||||
},
|
||||
userSignOut() {
|
||||
userApi.userLogout().then(() => {
|
||||
location.reload()
|
||||
})
|
||||
},
|
||||
getSelfUserInfo() {
|
||||
userApi.getSelfUserInfo().then((json) => {
|
||||
this.userSelfInfo = json.data
|
||||
})
|
||||
},
|
||||
getSpaceInfo(spaceId) {
|
||||
for (let i = 0; i < this.spaceList.length; i++) {
|
||||
if (this.spaceList[i].id == spaceId) {
|
||||
return this.spaceList[i]
|
||||
}
|
||||
}
|
||||
return {}
|
||||
},
|
||||
switchSpacePage(spaceId) {
|
||||
spaceId = parseInt(spaceId)
|
||||
if (this.choiceSpace == spaceId) {
|
||||
return
|
||||
}
|
||||
this.choiceSpace = spaceId
|
||||
this.doGetPageList(null)
|
||||
},
|
||||
rightAsideWidthChange(width) {
|
||||
storeDisplay.viewMenuWidth = width
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.global-layout-vue {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#app,
|
||||
.el-container,
|
||||
.el-menu {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.el-header {
|
||||
background-color: #1d4e89 !important;
|
||||
}
|
||||
|
||||
.header-right-user-name {
|
||||
color: #fff;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.el-header {
|
||||
color: #333;
|
||||
line-height: 40px;
|
||||
text-align: right;
|
||||
height: 40px !important;
|
||||
}
|
||||
|
||||
.el-icon-fold {
|
||||
float: left;
|
||||
font-size: 25px;
|
||||
color: #aaa;
|
||||
margin-top: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.el-icon-fold:hover {
|
||||
color: #eee;
|
||||
}
|
||||
|
||||
.head-icon {
|
||||
margin-right: 15px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.header-user-message .page-info-box {
|
||||
text-align: right;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.upgrade-info {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
word-break: break-all;
|
||||
white-space: pre-wrap;
|
||||
line-height: 26px;
|
||||
}
|
||||
|
||||
.search-option-item {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.search-option-item .title {
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.search-option-item .content {
|
||||
font-size: 12px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.search-autocomplete {
|
||||
width: 600px !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.wiki-page-tree-box {
|
||||
overflow: auto;
|
||||
padding-bottom: 30px;
|
||||
|
||||
.el-tree-node {
|
||||
.el-tree-node__content {
|
||||
height: 35px;
|
||||
|
||||
.el-tree-node__label {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<van-collapse v-model:value="pageSelect">
|
||||
<template v-for="page in pageList">
|
||||
<div
|
||||
v-if="!page.children"
|
||||
@click="pageSelectChange(page.id)"
|
||||
class="van-cell van-cell--clickable"
|
||||
>
|
||||
{{ page.name }}
|
||||
</div>
|
||||
<van-collapse-item :name="page.id" v-else>
|
||||
<template v-slot:title>
|
||||
<span @click="pageSelectChange(page.id)">{{ page.name }}</span>
|
||||
</template>
|
||||
<page-tree
|
||||
:page-list="page.children"
|
||||
@pageChange="pageSelectChange"
|
||||
></page-tree>
|
||||
</van-collapse-item>
|
||||
</template>
|
||||
</van-collapse>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { $on, $off, $once, $emit } from '../../utils/gogocodeTransfer'
|
||||
export default {
|
||||
name: 'pageTree',
|
||||
data() {
|
||||
return {
|
||||
pageSelect: [],
|
||||
}
|
||||
},
|
||||
props: { pageList: Array },
|
||||
mounted() {},
|
||||
methods: {
|
||||
pageSelectChange(value) {
|
||||
$emit(this, 'pageChange', value)
|
||||
},
|
||||
},
|
||||
emits: ['pageChange'],
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,80 @@
|
||||
<template>
|
||||
<div ref="rightResize" class="right-resize">
|
||||
<i ref="rightResizeBar">...</i>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { $on, $off, $once, $emit } from '../../utils/gogocodeTransfer'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
rightAsideWidth: 300,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.dragChangeRightAsideWidth()
|
||||
},
|
||||
methods: {
|
||||
dragChangeRightAsideWidth() {
|
||||
// 保留this引用
|
||||
let resize = this.$refs.rightResize
|
||||
let resizeBar = this.$refs.rightResizeBar
|
||||
resize.onmousedown = (e) => {
|
||||
let startX = e.clientX
|
||||
// 颜色改变提醒
|
||||
resize.style.background = '#ccc'
|
||||
resizeBar.style.background = '#aaa'
|
||||
resize.left = resize.offsetLeft
|
||||
document.onmousemove = (e2) => {
|
||||
// 计算并应用位移量
|
||||
let endX = e2.clientX
|
||||
let moveLen = startX - endX
|
||||
if (
|
||||
(moveLen < 0 && this.rightAsideWidth < 600) ||
|
||||
(moveLen > 0 && this.rightAsideWidth > 300)
|
||||
) {
|
||||
startX = endX
|
||||
this.rightAsideWidth -= moveLen
|
||||
if (this.rightAsideWidth < 300) {
|
||||
this.rightAsideWidth = 300
|
||||
}
|
||||
$emit(this, 'update:value', this.rightAsideWidth)
|
||||
$emit(this, 'change', this.rightAsideWidth)
|
||||
}
|
||||
}
|
||||
document.onmouseup = () => {
|
||||
// 颜色恢复
|
||||
resize.style.background = '#fafafa'
|
||||
resizeBar.style.background = '#ccc'
|
||||
document.onmousemove = null
|
||||
document.onmouseup = null
|
||||
}
|
||||
return false
|
||||
}
|
||||
},
|
||||
},
|
||||
emits: ['update:value', 'change'],
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.right-resize {
|
||||
width: 5px;
|
||||
height: 100%;
|
||||
cursor: w-resize;
|
||||
background: #fafafa;
|
||||
}
|
||||
.right-resize i {
|
||||
margin-top: 300px;
|
||||
width: 5px;
|
||||
height: 35px;
|
||||
display: inline-block;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
line-height: 8px;
|
||||
border-radius: 5px;
|
||||
background: #ccc;
|
||||
color: #888;
|
||||
}
|
||||
</style>
|
||||
228
zyplayer-doc-ui/wiki-ui-2/src/components/layouts/ShareLayout.vue
Normal file
228
zyplayer-doc-ui/wiki-ui-2/src/components/layouts/ShareLayout.vue
Normal file
@@ -0,0 +1,228 @@
|
||||
<template>
|
||||
<div style="height: 100%">
|
||||
<el-container>
|
||||
<el-aside
|
||||
width="300px"
|
||||
style="background-color: #fafafa"
|
||||
:style="{ width: rightAsideWidth + 'px' }"
|
||||
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="searchByKeywords"
|
||||
placeholder="搜索文档"
|
||||
style="margin: 10px 0"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<el-button
|
||||
:icon="ElIconSearch"
|
||||
v-on:click="searchByKeywords"
|
||||
></el-button>
|
||||
</template>
|
||||
</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"
|
||||
>
|
||||
<template v-slot="{ node, data }">
|
||||
<span style="font-size: 14px">
|
||||
<el-icon><el-icon-document /></el-icon>
|
||||
<span>{{ node.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
<!--请手下留情,别删我(╥╯^╰╥),给我一个露脸的机会,我长的不碍眼的-->
|
||||
<div class="build-info">
|
||||
本文档使用<a
|
||||
target="_blank"
|
||||
href="https://gitee.com/zyplayer/zyplayer-doc"
|
||||
>zyplayer-doc</a
|
||||
>构建
|
||||
</div>
|
||||
</div>
|
||||
</el-aside>
|
||||
<RightResize
|
||||
v-model:value="rightAsideWidth"
|
||||
v-show="leftCollapse"
|
||||
></RightResize>
|
||||
<el-container>
|
||||
<el-main class="doc-body-box">
|
||||
<router-view></router-view>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</el-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
Document as ElIconDocument,
|
||||
Search as ElIconSearch,
|
||||
} from '@element-plus/icons-vue'
|
||||
import pageApi from '../../common/api/page'
|
||||
import RightResize from './RightResize.vue'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
leftCollapse: true,
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name',
|
||||
},
|
||||
// 空间搜索相关
|
||||
spaceUuid: '',
|
||||
nowPageId: '',
|
||||
nowSpaceShow: {},
|
||||
// 搜索的输入内容
|
||||
searchKeywords: '',
|
||||
// 页面展示相关
|
||||
wikiPageList: [],
|
||||
wikiPageExpandedKeys: [],
|
||||
rightAsideWidth: 300,
|
||||
ElIconSearch,
|
||||
}
|
||||
},
|
||||
components: {
|
||||
RightResize,
|
||||
ElIconDocument,
|
||||
},
|
||||
mounted: function () {
|
||||
this.spaceUuid = this.$route.query.space || ''
|
||||
this.getSpaceInfo()
|
||||
this.doGetPageList(null)
|
||||
},
|
||||
methods: {
|
||||
filterPageNode(value, data) {
|
||||
if (!value || !data.name) return true
|
||||
// issues:I2CG72 忽略大小写
|
||||
let name = data.name.toLowerCase()
|
||||
return name.indexOf(value.toLowerCase()) !== -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 {
|
||||
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 a {
|
||||
color: #4183c4;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,207 @@
|
||||
<template>
|
||||
<div class="share-mobile-layout">
|
||||
<van-popup
|
||||
v-model:value="popupShow"
|
||||
closeable
|
||||
position="left"
|
||||
class="popup-module"
|
||||
:style="{ height: '100%', width: '80%' }"
|
||||
>
|
||||
<div class="header">
|
||||
<van-nav-bar :title="nowSpaceShow.name"></van-nav-bar>
|
||||
</div>
|
||||
<div class="main">
|
||||
<page-tree
|
||||
:page-list="wikiPageList"
|
||||
@pageChange="pageSelectChange"
|
||||
></page-tree>
|
||||
<div class="build-info">
|
||||
本文档使用<a
|
||||
target="_blank"
|
||||
href="https://gitee.com/zyplayer/zyplayer-doc"
|
||||
>zyplayer-doc</a
|
||||
>构建
|
||||
</div>
|
||||
</div>
|
||||
</van-popup>
|
||||
<router-view @popupShow="popupShowChange"></router-view>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as Vue from 'vue'
|
||||
import pageApi from '../../common/api/page'
|
||||
import PageTree from './PageTree'
|
||||
import Vant from 'vant'
|
||||
import 'vant/lib/icon/index.css'
|
||||
import 'vant/lib/popup/index.css'
|
||||
import 'vant/lib/cell/index.css'
|
||||
import 'vant/lib/nav-bar/index.css'
|
||||
import 'vant/lib/collapse-item/index.css'
|
||||
window.$vueApp.use(Vant)
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name',
|
||||
},
|
||||
// 空间搜索相关
|
||||
spaceUuid: '',
|
||||
nowPageId: '',
|
||||
nowSpaceShow: {},
|
||||
// 搜索的输入内容
|
||||
searchKeywords: '',
|
||||
// 页面展示相关
|
||||
wikiPageList: [],
|
||||
wikiPageExpandedKeys: [],
|
||||
popupShow: false,
|
||||
pageSelect: [],
|
||||
}
|
||||
},
|
||||
components: {
|
||||
PageTree: PageTree,
|
||||
},
|
||||
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
|
||||
},
|
||||
pageSelectChange(value) {
|
||||
console.log('页面修改:' + value)
|
||||
this.popupShow = false
|
||||
this.$router.replace({
|
||||
path: '/page/share/mobile/view',
|
||||
query: { pageId: value, space: this.spaceUuid },
|
||||
})
|
||||
},
|
||||
popupShowChange(value) {
|
||||
this.popupShow = value
|
||||
console.log(this.pageSelect)
|
||||
},
|
||||
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%;
|
||||
}
|
||||
.share-mobile-layout {
|
||||
height: 100%;
|
||||
}
|
||||
.popup-module .header {
|
||||
width: 100%;
|
||||
height: 46px;
|
||||
}
|
||||
.popup-module .main {
|
||||
position: absolute;
|
||||
top: 46px;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
.popup-module .footer {
|
||||
width: 100%;
|
||||
height: 26px;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
}
|
||||
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 {
|
||||
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 {
|
||||
text-align: center;
|
||||
padding: 5px 0;
|
||||
color: #aaa;
|
||||
font-size: 12px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
.build-info a {
|
||||
color: #4183c4;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
200
zyplayer-doc-ui/wiki-ui-2/src/components/space/CreateSpace.vue
Normal file
200
zyplayer-doc-ui/wiki-ui-2/src/components/space/CreateSpace.vue
Normal file
@@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<div class="create-space-vue">
|
||||
<!--新建空间弹窗-->
|
||||
<el-dialog
|
||||
title="创建空间"
|
||||
v-model="newSpaceDialogVisible"
|
||||
width="600px"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
label-width="100px"
|
||||
:model="newSpaceForm"
|
||||
:rules="newSpaceFormRules"
|
||||
ref="newSpaceForm"
|
||||
>
|
||||
<el-form-item label="空间名:" prop="name">
|
||||
<el-input v-model="newSpaceForm.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="空间描述:" prop="spaceExplain">
|
||||
<el-input v-model="newSpaceForm.spaceExplain"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="空间开放:">
|
||||
<el-switch
|
||||
v-model="newSpaceForm.openDoc"
|
||||
inactive-text="需要登录"
|
||||
:inactive-value="0"
|
||||
active-text="开放访问"
|
||||
:active-value="1"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="空间类型:">
|
||||
<el-select
|
||||
v-model="newSpaceForm.type"
|
||||
filterable
|
||||
placeholder="选择类型"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option :key="1" label="公共空间" :value="1">
|
||||
<span style="float: left">公共空间</span>
|
||||
<span style="float: right; color: #8492a6; font-size: 13px"
|
||||
>属于公共,登录用户可访问、编辑</span
|
||||
>
|
||||
</el-option>
|
||||
<el-option :key="2" label="个人空间" :value="2">
|
||||
<span style="float: left">个人空间</span>
|
||||
<span style="float: right; color: #8492a6; font-size: 13px"
|
||||
>属于个人,所有登录用户可访问</span
|
||||
>
|
||||
</el-option>
|
||||
<el-option :key="3" label="隐私空间" :value="3">
|
||||
<span style="float: left">隐私空间</span>
|
||||
<span style="float: right; color: #8492a6; font-size: 13px"
|
||||
>属于个人,仅创建者可访问</span
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
v-if="newSpaceForm.id > 0"
|
||||
@click="onNewSpaceSubmit('newSpaceForm')"
|
||||
>保存修改</el-button
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
v-else
|
||||
@click="onNewSpaceSubmit('newSpaceForm')"
|
||||
>立即创建</el-button
|
||||
>
|
||||
<el-button @click="onNewSpaceCancel">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { $on, $off, $once, $emit } from '../../utils/gogocodeTransfer'
|
||||
import pageApi from '../../common/api/page'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
newSpaceDialogVisible: false,
|
||||
manageSpaceDialogVisible: false,
|
||||
newSpaceForm: {
|
||||
id: '',
|
||||
name: '',
|
||||
spaceExplain: '',
|
||||
treeLazyLoad: 0,
|
||||
openDoc: 0,
|
||||
uuid: '',
|
||||
type: 1,
|
||||
},
|
||||
newSpaceFormRules: {
|
||||
name: [
|
||||
{ required: true, message: '请输入空间名', trigger: 'blur' },
|
||||
{
|
||||
min: 2,
|
||||
max: 25,
|
||||
message: '长度在 2 到 25 个字符',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
editSpaceId: '',
|
||||
}
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
show(spaceId) {
|
||||
this.newSpaceForm = {
|
||||
id: '',
|
||||
name: '',
|
||||
spaceExplain: '',
|
||||
treeLazyLoad: 0,
|
||||
openDoc: 0,
|
||||
uuid: '',
|
||||
type: 1,
|
||||
}
|
||||
this.editSpaceId = spaceId || ''
|
||||
if (!!this.editSpaceId) {
|
||||
pageApi.spaceList({ id: this.editSpaceId }).then((json) => {
|
||||
let spaceList = json.data || []
|
||||
if (spaceList.length > 0) {
|
||||
this.newSpaceForm = spaceList[0]
|
||||
}
|
||||
})
|
||||
}
|
||||
this.newSpaceDialogVisible = true
|
||||
},
|
||||
onNewSpaceSubmit(formName) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
let param = {
|
||||
id: this.newSpaceForm.id,
|
||||
name: this.newSpaceForm.name,
|
||||
type: this.newSpaceForm.type,
|
||||
openDoc: this.newSpaceForm.openDoc,
|
||||
spaceExplain: this.newSpaceForm.spaceExplain,
|
||||
treeLazyLoad: this.newSpaceForm.treeLazyLoad,
|
||||
}
|
||||
pageApi.updateSpace(param).then((json) => {
|
||||
this.$message.success('创建成功')
|
||||
this.newSpaceDialogVisible = false
|
||||
$emit(this, 'success', json.data.id)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
onNewSpaceCancel() {
|
||||
this.newSpaceDialogVisible = false
|
||||
},
|
||||
},
|
||||
emits: ['success'],
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.create-space-vue .empty-news {
|
||||
text-align: center;
|
||||
padding: 100px;
|
||||
}
|
||||
.create-space-vue .text-link {
|
||||
color: #444;
|
||||
}
|
||||
.create-space-vue .line-box {
|
||||
color: #666;
|
||||
border-bottom: 1px solid #eee;
|
||||
padding: 20px 0;
|
||||
}
|
||||
.create-space-vue .line-title {
|
||||
font-size: 14px;
|
||||
}
|
||||
.create-space-vue .page-preview-box {
|
||||
}
|
||||
.create-space-vue .page-preview-title {
|
||||
font-size: 18px;
|
||||
margin: 10px 0 5px 0;
|
||||
color: #3a8ee6;
|
||||
cursor: pointer;
|
||||
}
|
||||
.create-space-vue .page-preview-content {
|
||||
font-size: 16px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.create-space-vue .zan-img {
|
||||
vertical-align: middle;
|
||||
margin-top: -3px;
|
||||
}
|
||||
.create-space-vue .view-img {
|
||||
font-size: 16px;
|
||||
color: #666;
|
||||
}
|
||||
.create-space-vue .page-info-box {
|
||||
text-align: right;
|
||||
margin: 20px 0 50px 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user