--------去掉对es的支持和依赖,默认去掉对hive的包依赖,maven依赖关系优化,页面位置调整,增加build.bat的支持,支持jar直接启动,去掉历史遗留的无用前端代码,依赖的maven包升级--------

This commit is contained in:
暮光:城中城
2021-11-17 22:31:46 +08:00
parent 5bdf1ec0c6
commit 085b76f4b4
200 changed files with 1412 additions and 56618 deletions

View File

@@ -2,6 +2,7 @@ package com.zyplayer.doc.wiki.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.dozermapper.core.Mapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zyplayer.doc.core.json.DocResponseJson;
@@ -21,7 +22,6 @@ import com.zyplayer.doc.wiki.controller.vo.WikiPageContentVo;
import com.zyplayer.doc.wiki.controller.vo.WikiPageVo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.dozer.Mapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;

View File

@@ -88,11 +88,6 @@ public class WikiPageAuthController {
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
userAuthList.add(userAuth);
}
if (Objects.equals(authVo.getCommentPage(), 1)) {
Long authId = authInfoMap.get(WikiAuthType.COMMENT_PAGE.getName());
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
userAuthList.add(userAuth);
}
if (Objects.equals(authVo.getDeletePage(), 1)) {
Long authId = authInfoMap.get(WikiAuthType.DELETE_PAGE.getName());
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
@@ -160,7 +155,6 @@ public class WikiPageAuthController {
Set<String> authNameSet = value.stream().map(auth -> authInfoMap.get(auth.getAuthId())).collect(Collectors.toSet());
UserPageAuthVo authVo = new UserPageAuthVo();
authVo.setEditPage(this.haveAuth(authNameSet, WikiAuthType.EDIT_PAGE));
authVo.setCommentPage(this.haveAuth(authNameSet, WikiAuthType.COMMENT_PAGE));
authVo.setDeletePage(this.haveAuth(authNameSet, WikiAuthType.DELETE_PAGE));
authVo.setPageFileUpload(this.haveAuth(authNameSet, WikiAuthType.PAGE_FILE_UPLOAD));
authVo.setPageFileDelete(this.haveAuth(authNameSet, WikiAuthType.PAGE_FILE_DELETE));

View File

@@ -18,7 +18,6 @@ import com.zyplayer.doc.data.service.manage.WikiPageService;
import com.zyplayer.doc.data.service.manage.WikiSpaceService;
import com.zyplayer.doc.wiki.controller.vo.WikiPageCommentVo;
import com.zyplayer.doc.wiki.framework.consts.SpaceType;
import org.dozer.Mapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
@@ -28,9 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 文档控制器
@@ -52,8 +49,6 @@ public class WikiPageCommentController {
WikiPageService wikiPageService;
@Resource
UserMessageService userMessageService;
@Resource
Mapper mapper;
@PostMapping("/list")
public ResponseJson<List<WikiPageCommentVo>> list(WikiPageComment pageComment) {

View File

@@ -17,9 +17,6 @@ import com.zyplayer.doc.data.repository.manage.param.SearchByEsParam;
import com.zyplayer.doc.data.repository.manage.vo.SpaceNewsVo;
import com.zyplayer.doc.data.repository.support.consts.UserMsgSysType;
import com.zyplayer.doc.data.repository.support.consts.UserMsgType;
import com.zyplayer.doc.data.service.elasticsearch.entity.EsWikiPage;
import com.zyplayer.doc.data.service.elasticsearch.service.EsWikiPageService;
import com.zyplayer.doc.data.service.elasticsearch.support.EsPage;
import com.zyplayer.doc.data.service.manage.*;
import com.zyplayer.doc.data.utils.CachePrefix;
import com.zyplayer.doc.data.utils.CacheUtil;
@@ -30,12 +27,9 @@ import com.zyplayer.doc.wiki.service.common.WikiPageAuthService;
import com.zyplayer.doc.wiki.service.git.GitService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.dozer.Mapper;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import com.github.dozermapper.core.Mapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -78,8 +72,6 @@ public class WikiPageController {
GitService gitService;
@Resource
Mapper mapper;
@Autowired(required = false)
EsWikiPageService esWikiPageService;
@PostMapping("/list")
public ResponseJson<List<WikiPageVo>> list(WikiPage wikiPage) {
@@ -289,16 +281,6 @@ public class WikiPageController {
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPage.getId(), wikiPage.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_CREATE);
userMessageService.addWikiMessage(userMessage);
}
// 保存到es
if (esWikiPageService.isOpen()) {
WikiPage wikiPageSel = wikiPageService.getById(wikiPage.getId());
EsWikiPage esWikiPage = mapper.map(wikiPageSel, EsWikiPage.class);
esWikiPage.setContent(content);
esWikiPage.setPreview(preview);
esWikiPageService.upsert(esWikiPage);
} else {
logger.warn("未开启elasticsearch服务建议开启");
}
try {
// 提交历史版本记录
gitService.commitAndAddHistory(wikiPage.getId(), content);
@@ -337,50 +319,8 @@ public class WikiPageController {
@PostMapping("/searchByEs")
public ResponseJson<Object> searchByEs(SearchByEsParam param) {
if (esWikiPageService.isOpen()) {
Map<Long, WikiSpace> wikiSpaceMap = this.getCanVisitWikiSpace(param.getSpaceId());
if (wikiSpaceMap.isEmpty()) {
return DocResponseJson.ok();
}
String[] fields = {
"id", "preview", "createTime", "updateTime", "createUserId", "createUserName",
"updateUserId", "updateUserName", "spaceId", "name", "zanNum", "viewNum",
};
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
if (StringUtils.isNotBlank(param.getKeywords())) {
boolQueryBuilder.must(QueryBuilders.multiMatchQuery(param.getKeywords(), "name", "preview"));
}
boolQueryBuilder.must(QueryBuilders.termQuery("delFlag", "0"));
boolQueryBuilder.must(QueryBuilders.termsQuery("spaceId", wikiSpaceMap.keySet().toArray()));
EsPage<EsWikiPage> wikiPageEsPage = esWikiPageService.getDataByQuery(boolQueryBuilder, fields, param.getStartIndex(), param.getPageSize());
if (wikiPageEsPage == null || wikiPageEsPage.getTotal() == null) {
return DocResponseJson.ok();
}
// 组装数据
List<EsWikiPage> esWikiPageList = wikiPageEsPage.getData();
List<SpaceNewsVo> pageVoList = new LinkedList<>();
esWikiPageList.forEach(val -> {
String preview = val.getPreview();
if (preview != null && preview.length() > 200) {
preview = preview.substring(0, 200);
}
SpaceNewsVo spaceNewsVo = mapper.map(val, SpaceNewsVo.class);
spaceNewsVo.setSpaceName(wikiSpaceMap.get(val.getSpaceId()).getName());
spaceNewsVo.setPreviewContent(preview);
spaceNewsVo.setPageTitle(val.getName());
spaceNewsVo.setPageId(val.getId());
pageVoList.add(spaceNewsVo);
});
// 组装数据返回
PageInfo<SpaceNewsVo> pageInfo = new PageInfo<>();
pageInfo.setTotal(wikiPageEsPage.getTotal());
pageInfo.setList(pageVoList);
return DocResponseJson.ok(pageInfo);
} else {
logger.warn("未开启elasticsearch服务使用数据库查询匹配建议开启");
param.setNewsType(1);
return this.news(param);
}
param.setNewsType(1);
return this.news(param);
}
@PostMapping("/news")

View File

@@ -1,6 +1,7 @@
package com.zyplayer.doc.wiki.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import com.zyplayer.doc.core.annotation.AuthMan;
import com.zyplayer.doc.core.json.DocResponseJson;
@@ -158,7 +159,7 @@ public class WikiPageFileController {
if (!newFile.exists() && !newFile.mkdirs()) {
return DocResponseJson.warn("创建文件夹失败");
}
String simpleUUID = RandomUtil.simpleUUID();
String simpleUUID = IdUtil.simpleUUID();
path += simpleUUID + fileSuffix;
newFile = new File(path);
try {

View File

@@ -1,6 +1,6 @@
package com.zyplayer.doc.wiki.controller;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -23,7 +23,7 @@ import com.zyplayer.doc.wiki.controller.vo.UserSpaceAuthVo;
import com.zyplayer.doc.wiki.controller.vo.WikiSpaceVo;
import com.zyplayer.doc.wiki.framework.consts.WikiAuthType;
import org.apache.commons.collections.CollectionUtils;
import org.dozer.Mapper;
import com.github.dozermapper.core.Mapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
@@ -104,7 +104,7 @@ public class WikiSpaceController {
wikiSpace.setEditType(null);
wikiSpaceService.updateById(wikiSpace);
} else {
wikiSpace.setUuid(RandomUtil.simpleUUID());
wikiSpace.setUuid(IdUtil.simpleUUID());
wikiSpace.setCreateTime(new Date());
wikiSpace.setCreateUserId(currentUser.getUserId());
wikiSpace.setCreateUserName(currentUser.getUsername());
@@ -188,7 +188,6 @@ public class WikiSpaceController {
for (UserSpaceAuthVo authVo : authVoList) {
List<UserGroupAuth> userAuthList = new LinkedList<>();
this.createUserAuth(userAuthList, authVo.getEditPage(), spaceId, WikiAuthType.EDIT_PAGE, authVo.getGroupId());
this.createUserAuth(userAuthList, authVo.getCommentPage(), spaceId, WikiAuthType.COMMENT_PAGE, authVo.getGroupId());
this.createUserAuth(userAuthList, authVo.getDeletePage(), spaceId, WikiAuthType.DELETE_PAGE, authVo.getGroupId());
this.createUserAuth(userAuthList, authVo.getPageFileUpload(), spaceId, WikiAuthType.PAGE_FILE_UPLOAD, authVo.getGroupId());
this.createUserAuth(userAuthList, authVo.getPageFileDelete(), spaceId, WikiAuthType.PAGE_FILE_DELETE, authVo.getGroupId());
@@ -224,7 +223,6 @@ public class WikiSpaceController {
Set<Integer> authNameSet = value.stream().map(UserGroupAuth::getAuthType).collect(Collectors.toSet());
UserSpaceAuthVo authVo = new UserSpaceAuthVo();
authVo.setEditPage(this.haveAuth(authNameSet, WikiAuthType.EDIT_PAGE));
authVo.setCommentPage(this.haveAuth(authNameSet, WikiAuthType.COMMENT_PAGE));
authVo.setDeletePage(this.haveAuth(authNameSet, WikiAuthType.DELETE_PAGE));
authVo.setPageFileUpload(this.haveAuth(authNameSet, WikiAuthType.PAGE_FILE_UPLOAD));
authVo.setPageFileDelete(this.haveAuth(authNameSet, WikiAuthType.PAGE_FILE_DELETE));

View File

@@ -1,841 +0,0 @@
<!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" />
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>wiki文档管理系统</title>
</head>
<body>
<div id="app">
<el-container style="height: 100%;">
<el-aside width="auto" style="height: 100%;background-color: #fafafa;">
<div style="padding: 10px;" v-show="leftCollapse">
<div style="margin-bottom: 10px;">
<el-select v-model="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>
</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 v-on:click="createWiki" icon="el-icon-plus" style="width: 100%;">创建文档</el-button>
</div>
<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"
@node-expand="handleNodeExpand" draggable @node-drop="handlePageDrop"
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>
</el-aside>
<el-container>
<el-header>
<!--<el-switch v-model="isCollapse" ></el-switch>-->
<i class="el-icon-menu icon-collapse" @click="leftCollapse = !leftCollapse;"></i>
<!--<div class="logo" @click="aboutDialogVisible = true">zyplayer-doc-wiki</div>-->
<el-dropdown @command="userSettingDropdown" trigger="click">
<i class="el-icon-setting" style="margin-right: 15px; font-size: 16px;cursor: pointer;color: #fff;"> </i>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="aboutDoc">关于</el-dropdown-item>
<el-dropdown-item command="" divided>我的资料</el-dropdown-item>
<el-dropdown-item command="userSignOut">退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-header>
<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">
<div class="wiki-title">
{{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" v-on:click="editWikiAuth">访问权限</el-button>
<el-button type="text" icon="el-icon-delete" v-on:click="deleteWikiPage">删除</el-button>
</div>
</div>
<div class="wiki-author">
<span>创建:{{wikiPage.createUserName}} {{wikiPage.createTime}}  <span v-show="wikiPage.updateUserName">修改:{{wikiPage.updateUserName}} {{wikiPage.updateTime}}</span></span>
<div style="float: right;">
<el-upload class="upload-page-file" action="zyplayer-doc-wiki/common/upload"
:on-success="uploadFileSuccess" :on-error="uploadFileError"
name="files" show-file-list multiple :data="uploadFormData" :limit="999">
<el-button icon="el-icon-upload">上传附件</el-button>
</el-upload>
</div>
</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="createUserName" label="创建人"></el-table-column>
<el-table-column prop="createTime" label="创建时间"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button size="small" v-on:click="deletePageFile(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="wiki-content w-e-text">
<div v-html="pageContent.content"></div>
</div>
<div style="margin-top: 40px; font-size: 14px;">
<span style="vertical-align: top;" class="is-link">
<span v-show="wikiPage.selfZan == 0" v-on:click="zanPage(1)"><img src="webjars/doc-wiki/img/zan.png" style="vertical-align: middle;"></span>
<span v-show="wikiPage.selfZan == 1" v-on:click="zanPage(0)"><img src="webjars/doc-wiki/img/zan.png" style="vertical-align: middle;transform: rotateX(180deg);"></span>
</span>
<span style="margin-left: 10px;vertical-align: top;">
<span v-if="wikiPage.selfZan == 0 && wikiPage.zanNum <= 0">成为第一个赞同者</span>
<span v-else-if="wikiPage.selfZan == 0 && wikiPage.zanNum > 0"><span class="is-link" v-on:click="showZanPageUser">{{wikiPage.zanNum}}人</span>赞了它</span>
<span v-else-if="wikiPage.selfZan == 1 && wikiPage.zanNum <= 1">我赞了它</span>
<span v-else-if="wikiPage.selfZan == 1 && wikiPage.zanNum > 1"><span class="is-link" v-on:click="showZanPageUser">我和{{wikiPage.zanNum-1}}个其他人</span>赞了它</span>
</span>
</div>
<div v-show="commentList.length > 0" class="comment-box" style="margin-top: 20px;">
<div style="border-bottom: 1px solid #67C23A;padding-bottom: 10px;">评论列表:</div>
<div v-for="(comment,index) in commentList" :key="comment.id" :data-id="comment.id" :data-index="index" style="border-bottom: 1px solid #eee;padding: 10px;">
<div>
<div :style="'background-color: '+comment.color" class="head">{{comment.createUserName.substr(0,1)}}</div>
</div>
<div style="padding-left: 55px;">
{{comment.createUserName}}
<span style="color: #888;font-size: 13px;padding-left: 10px;">{{comment.createTime}}</span>
<span style="color: #888;font-size: 13px;margin-left: 10px;cursor: pointer;" @click="recommentUser(comment.id, index)">回复</span>
</div>
<pre style="padding: 10px 0 0 55px;">{{comment.content}}</pre>
<div v-for="(commentSub,indexSub) in comment.commentList" :key="commentSub.id" :data-id="commentSub.id" :data-index="indexSub" style="border-bottom: 1px solid #eee;padding: 10px;margin-left: 40px;">
<div>
<div :style="'background-color: '+commentSub.color" class="head">{{commentSub.createUserName.substr(0,1)}}</div>
</div>
<div style="padding-left: 55px;">
{{commentSub.createUserName}}
<span style="color: #888;font-size: 13px;padding-left: 10px;">{{commentSub.createTime}}</span>
</div>
<pre style="padding: 10px 0 0 55px;">{{commentSub.content}}</pre>
</div>
</div>
</div>
<div style="margin: 20px 0 50px 0;">
<el-input type="textarea" v-model="commentTextInput" :rows="5" :placeholder="recommentInfo.placeholder || '请输入评论内容'"></el-input>
<div align="right" style="margin-top: 5px;">
<el-button type="primary" v-on:click="submitPageComment">提交评论</el-button>
<el-button v-on:click="cancelCommentUser" v-show="recommentInfo.id > 0">取消回复</el-button>
</div>
</div>
</el-row>
<el-row type="border-card" v-show="rightContentType == 2">
<div style="margin-bottom: 10px;padding: 10px;" v-if="newPageId > 0">
编辑:{{lastClickNode.nodePath}}
</div>
<div style="margin-bottom: 10px;padding: 10px;" v-else>
父级:{{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-container>
<!--新建空间弹窗-->
<el-dialog title="创建空间" :visible.sync="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-switch v-model="newSpaceForm.treeLazyLoad" 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>
<!--管理空间弹窗-->
<el-dialog title="管理空间" :visible.sync="manageSpaceDialogVisible" :close-on-click-modal="false" width="80%">
<el-table :data="spaceList" border style="width: 100%; margin-bottom: 5px;" max-height="500">
<el-table-column prop="id" label="ID" width="60"></el-table-column>
<el-table-column prop="name" label="名字"></el-table-column>
<el-table-column prop="spaceExplain" label="说明"></el-table-column>
<el-table-column label="开放地址">
<template slot-scope="scope">
<a target="_blank" :href="'open-wiki.html?space='+scope.row.uuid" v-if="scope.row.openDoc == 1">{{scope.row.name}}</a>
<span v-else>暂未开放</span>
</template>
</el-table-column>
<el-table-column prop="createUserName" label="创建人"></el-table-column>
<el-table-column prop="createTime" label="创建时间"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button size="small" type="primary" v-on:click="editSpaceInfo(scope.row)">编辑</el-button>
<el-button size="small" type="danger" v-on:click="deleteSpaceInfo(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
<!--点赞人员弹窗-->
<el-dialog title="赞了它的人" :visible.sync="zanUserDialogVisible" width="600px">
<el-table :data="zanUserList" border :show-header="false" style="width: 100%; margin-bottom: 5px;">
<el-table-column prop="createUserName" label="用户"></el-table-column>
<el-table-column prop="createTime" label="时间"></el-table-column>
</el-table>
</el-dialog>
<!--关于弹窗-->
<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>
<template v-if="upgradeInfo.lastVersion">
<el-form-item label="当前版本:">{{upgradeInfo.nowVersion}}</el-form-item>
<el-form-item label="最新版本:">{{upgradeInfo.lastVersion}}</el-form-item>
<el-form-item label="升级地址:">
<a target="_blank" :href="upgradeInfo.upgradeUrl">{{upgradeInfo.upgradeUrl}}</a>
</el-form-item>
<el-form-item label="升级内容:">{{upgradeInfo.upgradeContent}}</el-form-item>
</template>
<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>
<div id="app"></div>
<script type="text/javascript" src="doc-wiki-manifest.js?e1c7e2dd98859acffb35"></script><script type="text/javascript" src="doc-wiki-vendor.js?c3f4b5470f256874619d"></script><script type="text/javascript" src="doc-wiki-index.js?0ffc50a80edd79017a70"></script></body>
<script>
var page = {
newPageContentEditor: '',
colorArr: ["#67C23A", "#409EFF", "#E6A23C", "#F56C6C", "#909399", "#303133"],
userHeadColor: {},
};
var app = new Vue({
el: '#app',
data() {
return {
leftCollapse: true,
aboutDialogVisible: false,
rightContentLoading: false,
rightContentType: 0,// 右侧显示类型0=欢迎页 1=文章内容 2=编辑或新增文章
pathIndex: [],
defaultProps: {
children: 'children',
label: 'name'
},
// 空间搜索相关
spaceOptions: [],
spaceList:[],
choiceSpace: "",
nowSpaceId: '',
nowSpaceShow: {},
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'}
],
},
// 依据目录树存储的map全局对象
treePathDataMap: new Map(),
// 搜索的输入内容
searchKeywords: "",
lastClickNode: {},
// 编辑相关
newPageId: "",
newPageTitle: "",
// 页面展示相关
wikiPageList:[],
wikiPage: {},
wikiPageExpandedKeys: [],
pageContent: {},
pageFileList: [],
uploadFileList: [],
uploadFormData: {pageId: 0},
zanUserDialogVisible: false,
zanUserList: [],
// 评论相关
commentTextInput: "",
commentList: [],
recommentInfo: {},
// 页面跳转相关
initOver: false,
doNotPushState: false,
urlParamPageId: 0,
urlParam: {},
// 升级信息
upgradeInfo: {},
}
},
watch: {
urlParamPageId: function (newVal, oldVal) {
if (!this.initOver) return;
var oldPageId = oldVal || 0;
console.log(app.doNotPushState, newVal, oldVal);
if (!newVal) {
app.rightContentType = 0;
} else if (newVal !== oldPageId) {
this.wikiPageExpandedKeys = [newVal];
this.loadPageDetail(newVal);
if (!app.doNotPushState) {
this.urlParam.pageId = newVal;
var params = urlToParam(this.urlParam).slice(1);
window.history.pushState(null, null, '?' + params);
}
}
app.doNotPushState = false;
}
},
mounted: function () {
this.init();
this.loadSpaceList();
this.checkSystemUpgrade();
this.initOver = true;
},
methods: {
filterPageNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
editSpaceInfo(row) {
app.newSpaceForm = {
id: row.id, name: row.name, spaceExplain: row.spaceExplain,
treeLazyLoad: row.treeLazyLoad, openDoc: row.openDoc, type: row.type
};
app.newSpaceDialogVisible = true;
},
deleteSpaceInfo(row) {
this.$confirm('确定要删除此空间及下面的所有文档吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var param = {id: row.id, delFlag: 1};
ajaxTemp("zyplayer-doc-wiki/space/update", "post", "json", param, function (json) {
if (validateResult(json)) {
app.loadSpaceList();
}
});
});
},
handlePageDrop(draggingNode, dropNode, dropType, ev) {
//console.log('tree drop: ', draggingNode.data, dropNode.data, dropType);
// 'prev'、'inner'、'next'
var param = {id: draggingNode.data.id, parentId: dropNode.data.parentId};
if (dropType == 'inner') {
param.parentId = dropNode.data.id;
}
ajaxTemp("zyplayer-doc-wiki/page/update", "post", "json", param, function (json) {
if (validateResult(json)) {
app.doGetPageList(null);
}
});
},
onNewSpaceCancel() {
this.newSpaceDialogVisible = false;
},
userSettingDropdown(command) {
console.log("command:" + command);
if (command == 'userSignOut') {
this.userSignOut();
} else if (command == 'aboutDoc') {
app.aboutDialogVisible = true;
} else {
Toast.notOpen();
}
},
userSignOut() {
ajaxTemp("logout", "post", "json", {}, function () {
}, function () {
}, function () {
location.reload();
});
},
onNewSpaceSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
var param = {
id: app.newSpaceForm.id,
name: app.newSpaceForm.name,
type: app.newSpaceForm.type,
openDoc: app.newSpaceForm.openDoc,
spaceExplain: app.newSpaceForm.spaceExplain,
treeLazyLoad: app.newSpaceForm.treeLazyLoad,
};
ajaxTemp("zyplayer-doc-wiki/space/update", "post", "json", param, function (json) {
if (validateResult(json)) {
if (param.id > 0) {
app.loadSpaceList();
} else {
app.spaceList.push(json.data);
app.spaceOptions.push({
label: json.data.name, value: json.data.id
});
app.nowSpaceId = json.data.id;
app.nowSpaceShow = json.data;
app.choiceSpace = app.nowSpaceId;
app.rightContentType = 0;
app.doGetPageList(null);
}
app.newSpaceForm = {id: '', name: '', spaceExplain: '', treeLazyLoad: 0, openDoc: 0, uuid: '', type: 1};
app.newSpaceDialogVisible = false;
}
});
}
});
},
zanPage(yn) {
var param = {yn: yn, pageId: app.wikiPage.id};
ajaxTemp("zyplayer-doc-wiki/page/zan/update", "post", "json", param, function (json) {
if (validateResult(json)) {
app.wikiPage.selfZan = yn;
app.wikiPage.zanNum = app.wikiPage.zanNum + (yn == 1 ? 1 : -1);
}
});
},
showZanPageUser() {
app.zanUserDialogVisible = true;
app.zanUserList = [];
var param = {pageId: app.wikiPage.id};
ajaxTemp("zyplayer-doc-wiki/page/zan/list", "post", "json", param, function (json) {
if (validateResult(json)) {
app.zanUserList = json.data;
}
});
},
recommentUser(id, index) {
this.recommentInfo = {id: id, index: index, placeholder: '回复' + (index + 1) + '楼'};
},
cancelCommentUser() {
this.recommentInfo = {};
},
submitPageComment() {
var param = {
pageId: app.wikiPage.id, content: app.commentTextInput,
parentId: app.recommentInfo.id
};
ajaxTemp("zyplayer-doc-wiki/page/comment/update", "post", "json", param, function (json) {
if (validateResult(json)) {
var data = json.data;
data.color = app.getUserHeadBgColor(data.createUserId);
app.commentTextInput = "";
app.commentList.push(data);
}
});
},
uploadFileError(err) {
Toast.success("上传失败," + err);
},
uploadFileSuccess(response) {
if (validateResult(response)) {
app.pageFileList.push(response.data);
Toast.success("上传成功!");
}
},
deletePageFile(row) {
this.$confirm('确定要删除此文件吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var param = {id: row.id, delFlag: 1};
ajaxTemp("zyplayer-doc-wiki/page/file/update", "post", "json", param, function (json) {
if (validateResult(json)) {
var pageFileList = [];
for (var i = 0; i < app.pageFileList.length; i++) {
if (app.pageFileList[i].id != row.id) {
pageFileList.push(app.pageFileList[i]);
}
}
app.pageFileList = pageFileList;
}
});
});
},
editWikiAuth() {
Toast.notOpen();
},
notOpen() {
Toast.notOpen();
},
deleteWikiPage() {
this.$confirm('确定要删除此页面吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var param = {id: app.wikiPage.id, delFlag: 1};
ajaxTemp("zyplayer-doc-wiki/page/update", "post", "json", param, function (json) {
if (validateResult(json)) {
app.rightContentType = 0;
app.wikiPage = {};
app.doGetPageList(null);
}
});
});
},
editWiki() {
this.rightContentType = 2;
this.newPageId = app.wikiPage.id;
this.newPageTitle = app.wikiPage.name;
page.newPageContentEditor.txt.html(app.pageContent.content || "");
},
createWiki() {
if (app.nowSpaceId > 0) {
this.newPageId = "";
this.newPageTitle = "";
page.newPageContentEditor.txt.html("");
this.rightContentType = 2;
} else {
Toast.warn("请先选择或创建空间");
}
},
createWikiCancel() {
this.$confirm('确定要取消编辑吗?您编辑的内容将不会被保存哦~', '提示', {
confirmButtonText: '确定',
cancelButtonText: '继续编辑',
type: 'warning'
}).then(() => {
if (isEmpty(this.lastClickNode.name)) {
this.rightContentType = 0;
} else {
this.rightContentType = 1;
}
});
},
createWikiSave() {
var parentId = app.lastClickNode.id;
if (this.newPageId > 0) {
parentId = "";
}
if (isEmpty(app.newPageTitle)) {
Toast.warn("标题不能为空");
return;
}
var param = {
spaceId: app.nowSpaceId,
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("保存成功!");
app.urlParamPageId = json.data.id;
app.loadPageDetail(json.data.id);
app.doGetPageList(null);
}
});
},
handleNodeClick(data) {
app.rightContentType = 1;
if (app.lastClickNode.id == data.id) {
return;
}
console.log("点击节点:", data);
app.lastClickNode = data;
app.urlParamPageId = app.lastClickNode.id;
},
handleNodeExpand(node) {
if (node.children.length > 0 && node.children[0].needLoad) {
console.log("加载节点:", node);
app.doGetPageList(node.id, node);
}
},
spaceChangeEvents(data) {
if (data == 0) {
app.newSpaceForm = {id: '', name: '', spaceExplain: '', treeLazyLoad: 0, openDoc: 0, uuid: '', type: 1};
app.choiceSpace = app.nowSpaceId;
app.newSpaceDialogVisible = true;
} else if (data == -1) {
app.choiceSpace = app.nowSpaceId;
app.manageSpaceDialogVisible = true;
} else {
app.nowSpaceId = data;
app.rightContentType = 0;
for (var i = 0; i < app.spaceList.length; i++) {
if (app.spaceList[i].id == data) {
app.nowSpaceShow = app.spaceList[i];
break;
}
}
app.doGetPageList(null);
}
},
loadSpaceList() {
ajaxTemp("zyplayer-doc-wiki/space/list", "post", "json", {}, function (json) {
if (validateResult(json)) {
app.spaceList = json.data || [];
var spaceOptions = [];
for (var i = 0; i < app.spaceList.length; i++) {
spaceOptions.push({
label: app.spaceList[i].name, value: app.spaceList[i].id
});
}
app.spaceOptions = spaceOptions;
if (app.spaceList.length > 0) {
app.nowSpaceId = app.spaceList[0].id;
app.nowSpaceShow = app.spaceList[0];
app.choiceSpace = app.nowSpaceId;
app.doGetPageList(null);
}
}
});
},
loadPageDetail(pageId) {
app.rightContentType = 1;
var param = {id: pageId};
ajaxTemp("zyplayer-doc-wiki/page/detail", "post", "json", param, function (json) {
if (validateResult(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};
// 修改最后点击的项,保证刷新后点击编辑能展示编辑的项
if (!app.lastClickNode.id) {
app.lastClickNode = {id: wikiPage.id, nodePath: wikiPage.name};
}
}
});
this.loadCommentList(pageId);
},
loadCommentList(pageId) {
app.commentList = [];
app.cancelCommentUser();
var param = {pageId: pageId};
ajaxTemp("zyplayer-doc-wiki/page/comment/list", "post", "json", param, function (json) {
if (validateResult(json)) {
var commentList = json.data || [];
for (var i = 0; i < commentList.length; i++) {
commentList[i].color = app.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);
}
commentList[i].commentList = subCommentList;
}
app.commentList = commentList;
}
});
},
getUserHeadBgColor(userId) {
var color = page.userHeadColor[userId];
if (!color) {
color = page.colorArr[Math.ceil(Math.random() * page.colorArr.length) - 1];
page.userHeadColor[userId] = color;
}
return color;
},
searchByKeywords() {
this.$refs.wikiPageTree.filter(app.searchKeywords);
},
doGetPageList(parentId, node) {
var nodePath = "";
if (!!node) {
nodePath = node.nodePath || "/";
if (!nodePath.endsWith("/")) {
nodePath += "/";
}
} else {
nodePath = "/";
}
var param = {spaceId: this.nowSpaceId, parentId: parentId || 0};
if (app.nowSpaceShow.treeLazyLoad == 0) {
param.parentId = null;
}
ajaxTemp("zyplayer-doc-wiki/page/list", "post", "json", param, function (json) {
if (validateResult(json)) {
var result = json.data || [];
var pathIndex = [];
if (app.nowSpaceShow.treeLazyLoad == 0) {
pathIndex = result;
} else {
for (var i = 0; i < result.length; i++) {
var item = result[i];
item.parentId = item.parentId || 0;
item.children = [{label: '', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
pathIndex.push(item);
}
}
app.createNodePath(pathIndex, nodePath);
if (parentId > 0) {
node.children = pathIndex;
} else {
app.wikiPageList = pathIndex;
//app.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);
}
}
},
checkSystemUpgrade() {
ajaxTemp("system/info/upgrade", "post", "json", {}, function (json) {
if (json.errCode == 200 && !!json.data) {
app.upgradeInfo = json.data;
console.log("zyplayer-doc发现新版本"
+ "\n升级地址" + json.data.upgradeUrl
+ "\n当前版本" + json.data.nowVersion
+ "\n最新版本" + json.data.lastVersion
+ "\n升级内容" + json.data.upgradeContent
);
}
});
},
createUrlParam() {
var url = document.location.toString();
var urlParam = {};
if (url.indexOf("?") >= 0) {
for (var key in this.urlParam) {
if (key != 'pageId') {
urlParam[key] = this.urlParam[key];
}
}
var params = url.split("?")[1];
var paramArr = params.split("&");
for (var i = 0; i < paramArr.length; i++) {
if (paramArr[i].indexOf("=") > 0) {
var param = paramArr[i].split("=");
urlParam[param[0]] = param[1];
}
}
if (!!urlParam.pageId) {
this.urlParamPageId = parseInt(urlParam.pageId);
} else {
this.urlParamPageId = 0;
this.lastClickNode = {};
}
}
this.urlParam = urlParam;
},
init(){
page.newPageContentEditor = new window.wangEditor('#newPageContentDiv');
page.newPageContentEditor.customConfig.uploadImgServer = 'zyplayer-doc-wiki/common/wangEditor/upload';
page.newPageContentEditor.customConfig.zIndex = 100;
page.newPageContentEditor.customConfig.uploadFileName = 'files';
page.newPageContentEditor.customConfig.uploadImgMaxLength = 1;
page.newPageContentEditor.customConfig.pasteFilterStyle = false;
page.newPageContentEditor.create();
this.createUrlParam();
window.addEventListener("popstate", function (e) {
app.doNotPushState = true;
app.createUrlParam();
}, false);
}
}
});
</script>
<style>
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;
width: 100%; height:40px;line-height:40px;font-size: 25px;color: #fff;text-align: center;
}
.icon-collapse{float: left;font-size: 25px;color: #aaa;margin-top: 8px;cursor: pointer;}
.icon-collapse:hover{color: #eee;}
.wiki-title{font-size: 20px;}
.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;
}
</style>
</html>

View File

@@ -1,341 +0,0 @@
<!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="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"
@node-expand="handleNodeExpand"
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>
</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: '',
colorArr: ["#67C23A", "#409EFF", "#E6A23C", "#F56C6C", "#909399", "#303133"],
userHeadColor: {},
};
var app = new Vue({
el: '#app',
data() {
return {
leftCollapse: true,
aboutDialogVisible: false,
rightContentLoading: false,
rightContentType: 0,// 右侧显示类型0=欢迎页 1=文章内容 2=编辑或新增文章
pathIndex: [],
defaultProps: {
children: 'children',
label: 'name'
},
// 空间搜索相关
spaceOptions: [],
spaceList:[],
choiceSpace: "",
nowSpaceId: '',
nowSpaceShow: {},
newSpaceDialogVisible: false,
manageSpaceDialogVisible: false,
newSpaceForm: {id: '', name: '', spaceExplain: '', treeLazyLoad: 0},
newSpaceFormRules: {
name: [
{required: true, message: '请输入空间名', trigger: 'blur'},
{min: 2, max: 25, message: '长度在 2 到 25 个字符', trigger: 'blur'}
],
},
// 依据目录树存储的map全局对象
treePathDataMap: new Map(),
// 搜索的输入内容
searchKeywords: "",
lastClickNode: {},
// 编辑相关
newPageId: "",
newPageTitle: "",
// 页面展示相关
wikiPageList:[],
wikiPage: {},
wikiPageExpandedKeys: [],
pageContent: {},
pageFileList: [],
uploadFileList: [],
uploadFormData: {pageId: 0},
zanUserDialogVisible: false,
zanUserList: [],
// 评论相关
commentTextInput: "",
commentList: [],
recommentInfo: {},
// 页面跳转相关
initOver: false,
doNotPushState: false,
urlParamPageId: 0,
urlParam: {},
}
},
watch: {
urlParamPageId: function (newVal, oldVal) {
if (!this.initOver) return;
var oldPageId = oldVal || 0;
console.log(app.doNotPushState, newVal, oldVal);
if (!newVal) {
app.rightContentType = 0;
} else if (newVal !== oldPageId) {
this.wikiPageExpandedKeys = [newVal];
this.loadPageDetail(newVal);
if (!app.doNotPushState) {
this.urlParam.pageId = newVal;
var params = urlToParam(this.urlParam).slice(1);
window.history.pushState(null, null, '?' + params);
}
}
app.doNotPushState = false;
}
},
mounted: function () {
this.init();
this.getSpaceInfo();
this.doGetPageList(null);
this.initOver = true;
},
methods: {
filterPageNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
notOpen() {
Toast.notOpen();
},
handleNodeClick(data) {
app.rightContentType = 1;
if (app.lastClickNode.id == data.id) {
return;
}
console.log("点击节点:", data);
app.lastClickNode = data;
app.urlParamPageId = app.lastClickNode.id;
},
handleNodeExpand(node) {
if (node.children.length > 0 && node.children[0].needLoad) {
console.log("加载节点:", node);
app.doGetPageList(node.id, node);
}
},
loadPageDetail(pageId) {
app.rightContentType = 1;
var param = {pageId: pageId, space: this.urlParam.space};
ajaxTemp("zyplayer-doc-wiki/open-api/page/detail", "post", "json", param, function (json) {
if (validateResult(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};
}
});
},
getUserHeadBgColor(userId) {
var color = page.userHeadColor[userId];
if (!color) {
color = page.colorArr[Math.ceil(Math.random() * page.colorArr.length) - 1];
page.userHeadColor[userId] = color;
}
return color;
},
searchByKeywords() {
this.$refs.wikiPageTree.filter(app.searchKeywords);
},
doGetPageList() {
var nodePath = "/";
var param = {space: this.urlParam.space};
ajaxTemp("zyplayer-doc-wiki/open-api/page/list", "post", "json", param, function (json) {
if (validateResult(json)) {
var pathIndex = json.data || [];
app.createNodePath(pathIndex, nodePath);
app.wikiPageList = pathIndex;
app.lastClickNode = {};
}
});
},
getSpaceInfo() {
var param = {space: this.urlParam.space};
ajaxTemp("zyplayer-doc-wiki/open-api/space/info", "post", "json", param, function (json) {
if (validateResult(json)) {
app.nowSpaceShow = json.data;
}
});
},
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);
}
}
},
createUrlParam() {
var url = document.location.toString();
var urlParam = {};
if (url.indexOf("?") >= 0) {
for (var key in this.urlParam) {
if (key != 'pageId') {
urlParam[key] = this.urlParam[key];
}
}
var params = url.split("?")[1];
var paramArr = params.split("&");
for (var i = 0; i < paramArr.length; i++) {
if (paramArr[i].indexOf("=") > 0) {
var param = paramArr[i].split("=");
urlParam[param[0]] = param[1];
}
}
if (!!urlParam.pageId) {
this.urlParamPageId = parseInt(urlParam.pageId);
} else {
this.urlParamPageId = 0;
this.lastClickNode = {};
}
}
this.urlParam = urlParam;
},
init(){
page.newPageContentEditor = new window.wangEditor('#newPageContentDiv');
page.newPageContentEditor.customConfig.uploadImgServer = 'zyplayer-doc-wiki/common/upload';
page.newPageContentEditor.customConfig.zIndex = 100;
page.newPageContentEditor.customConfig.pasteFilterStyle = false;
page.newPageContentEditor.create();
this.createUrlParam();
window.addEventListener("popstate", function (e) {
app.doNotPushState = true;
app.createUrlParam();
}, false);
}
}
});
</script>
<style>
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;}
</style>
</html>

View File

@@ -1,29 +0,0 @@
/* 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:italic;}
pre.json .null{color:#0000ff;}
pre.json .comma{color:#000000;font-weight:bold;}
pre.json .annotation{color:#aaa;}
pre img{cursor: pointer;}
/* E-JSON展示的样式 */

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 B

View File

@@ -1,341 +0,0 @@
/**
* 一些公用方法
* @author 暮光:城中城
* @since 2017年5月7日
*/
function serialize(value) {
if (typeof value === 'string') {
return value;
}
return JSON.stringify(value);
}
function deserialize(value) {
if (typeof value !== 'string' || isEmpty(value)) {
return value;
}
try {
return JSON.parse(value);
} catch (e) {
try {
return eval('(' + value + ')');// 处理变态的单双引号共存字符串
} catch (e) {
return value || undefined;
}
}
}
function validateResult(result) {
if (result.errCode == 200) {
return true;
} else if (result.errCode == 400) {
var href = encodeURIComponent(window.location.href);
window.location = "static/manage/login.html?redirect=" + href;
} else {
Toast.error(result.errMsg);
}
return false;
}
function urlToParam(param, key, encode) {
if (param == null) return '';
var paramStr = '';
var t = typeof (param);
if (t == 'string' || t == 'number' || t == 'boolean') {
paramStr += '&' + key + '=' + ((encode == null || encode) ? encodeURIComponent(param) : param);
} else {
for (var i in param) {
var k = key == null ? i : key + (param instanceof Array ? '[' + i + ']' : '.' + i);
paramStr += urlToParam(param[i], k, encode);
}
}
return paramStr;
}
function getNowDate() {
var date = new Date();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + "-" + month + "-" + strDate;
return currentdate;
}
function getNowTime() {
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
if (hours >= 1 && hours <= 9) {
hours = "0" + hours;
}
if (minutes >= 0 && minutes <= 9) {
minutes = "0" + minutes;
}
if (seconds >= 0 && seconds <= 9) {
seconds = "0" + seconds;
}
var currentdate = hours + ":" + minutes + ":" + seconds;
return currentdate;
}
function getNowDateTime() {
var currentdate = getNowDate() + " " + getNowTime();
return currentdate;
}
/**
* 返回不为空的字符串为空返回def
*/
function getNotEmptyStr(str, def) {
if (isEmpty(str)) {
return isEmpty(def) ? "" : def;
}
return str;
}
/**
* 是否是空对象
* @param obj
* @returns
*/
function isEmptyObject(obj){
return isEmpty(obj) || $.isEmptyObject(obj);
}
/**
* 是否是空字符串
* @param str
* @returns
*/
function isEmpty(str){
return (str == "" || str == null || str == undefined);
}
/**
* 是否不是空字符串
* @param str
* @returns
*/
function isNotEmpty(str){
return !isEmpty(str);
}
/**
* 数组转字符串,使用空格分隔
* @param array
* @returns
*/
function arrToString(array){
var temStr = "";
if(isEmpty(array)){
return temStr;
}
array.forEach(function(e){
if(isNotEmpty(temStr)) {
temStr += " ";
}
temStr += e;
});
return temStr;
}
/**
* 数组array中是否包含str字符串
* @param array
* @param str
* @returns
*/
function haveString(array, str){
if(isEmpty(array)) {
return false;
}
for (var i = 0; i < array.length; i++) {
if(array[i] == str) {
return true;
}
}
return false;
}
/**
* 直接返回对象的第一个属性
* @param data
* @returns
*/
function getObjectFirstAttribute(data) {
for ( var key in data) {
return data[key];
}
}
/**
* 如果对象只有一个属性则返回第一个属性否则返回null
* @param data
* @returns
*/
function getObjectFirstAttributeIfOnly(data) {
var len = 0, value = "";
for ( var key in data) {
if (++len > 1) {
return null;
}
value = data[key];
}
return value;
}
/**
* ajax处理事件模板
*
* @url 后台处理的url即action
* @dataSentType 数据发送的方式有postget方式
* @dataReceiveType 数据接收格式有html json text等
* @paramsStr 传入后台的参数
* @successFunction ajax成功后执行的函数名 ajaxTemp("", "GET", "html", {}, function(){},
* function(){}, "");
*/
function ajaxTemp(url, dataSentType, dataReceiveType, paramsStr, successFunction, errorFunction, completeFunction, id) {
$.ajax({
url : url, // 后台处理程序
sync : false,
type : dataSentType, // 数据发送方式
dataType : dataReceiveType, // 接受数据格式
traditional: true,
data : eval(paramsStr),
contentType : "application/x-www-form-urlencoded; charset=UTF-8",
success : function(msg) {
if (msg.errCode == 400) {
var href = encodeURIComponent(window.location.href);
window.location = "static/manage/login.html?redirect=" + href;
} else {
if (typeof successFunction == "function") {
successFunction(msg, id);
}
}
},
beforeSend : function() {
},
complete: function (msg) {
if (msg.responseText.startWith("<!doctype html>")) {
if (msg.responseText.indexOf("THIS_IS_LOGIN_PAGE_FLAG") > 0) {
app.$confirm('操作失败,登录已失效,请登陆后重试', '提示', {
confirmButtonText: '去登陆',
cancelButtonText: '知道了',
type: 'warning'
}).then(() => {
window.open("static/manage/login.html");
});
return;
}
}
if (typeof completeFunction == "function") {
completeFunction(msg, id);
}
},
error : function(msg) {
if(typeof errorFunction == "function") {
errorFunction(msg,id);
}
}
});
}
function postWithFile(url, paramsStr, successFunction, errorFunction, completeFunction, id) {
$.ajax({
url: url, // 后台处理程序
sync: false,
type: "POST", // 数据发送方式
dataType: "JSON", // 接受数据格式
data: eval(paramsStr),
processData: false,
contentType: false,
success: function (msg) {
if (typeof successFunction == "function") {
successFunction(msg, id);
}
},
beforeSend: function () {
},
complete: function (msg) {
if (typeof completeFunction == "function") {
completeFunction(msg, id);
}
},
error: function (msg) {
if (typeof errorFunction == "function") {
errorFunction(msg, id);
}
}
});
}
/**
* 获取cookie
* @param name
* @returns
*/
function getCookie(name) {
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg)){
return unescape(arr[2]);
}
return null;
}
/**
* 字符串格式化
*/
String.prototype.format = function(args) {
if (arguments.length > 0) {
var result = this;
if (arguments.length == 1 && typeof (args) == "object") {
for ( var key in args) {
var reg = new RegExp("({" + key + "})", "g");
result = result.replace(reg, args[key]);
}
} else {
for (var i = 0; i < arguments.length; i++) {
if (arguments[i] == undefined) {
return "";
} else {
var reg = new RegExp("({[" + i + "]})", "g");
result = result.replace(reg, arguments[i]);
}
}
}
return result;
} else {
return this;
}
};
String.prototype.endWith = function(str) {
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
return false;
}
return (this.substring(this.length - str.length) == str);
};
String.prototype.startWith = function(str) {
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
return false;
}
return (this.substr(0, str.length) == str);
};
/**
* 获取父窗口的exports
* @returns
*/
function getExport(){
return window.parent.window.exports;
}

View File

@@ -1,131 +0,0 @@
/**
* 以树形方式生成并展示:
* /api
* /data
* /getDateList
* post
* get
* @author 暮光:城中城
* @since 2018年5月26日
*/
/**
* 把原始的json字符串转换成对象列表的方式方便后续使用
* @param json swagger的原始对象
* @returns
*/
function createTreeViewByTree(json, keywords) {
var pathIndex = [];
if (isEmptyObject(json)) {
return;
}
//console.log(paths);
var lastId = "";
for (var i = 0; i < json.length; i++) {
var interface = json[i].interface;
//console.log(key, paths[key]);
if (!findInPathsValue(json[i], keywords)) {
continue;
}
if (json[i].nodeList.length <= 0) {
continue;
}
var methods = json[i].nodeList[0].methods;
for (var j = 0; j < methods.length; j++) {
var interfaceTemp = interface + "." + methods[j];
var keyArr = interfaceTemp.split(".");
var nowPathObj = null;
keyArr.forEach(function(val, index) {
//console.log(val, index);
if(isEmpty(val) && index == 0) {
return;
}
var nowPath = val;
if (nowPathObj == null) {
nowPathObj = findNode(pathIndex, nowPath);
if (nowPathObj == null) {
nowPathObj = {
id: pathIndex.length,
label: nowPath, children: []
};
pathIndex.push(nowPathObj);
}
lastId = nowPathObj.id;
nowPathObj = nowPathObj.children;
} else {
var tempPathObj = findNode(nowPathObj, nowPath);
if(tempPathObj == null) {
tempPathObj = {
id: lastId + "." + nowPathObj.length,
label: nowPath, children: []
};
nowPathObj.push(tempPathObj);
}
lastId = tempPathObj.id;
nowPathObj = tempPathObj.children;
if (index == keyArr.length - 1) {
var tempPath = interfaceTemp;
tempPathObj.children = null;
tempPathObj.method = methods[j];
tempPathObj.interface = tempPath;
app.treePathDataMap.set(tempPath, json[i]);
}
}
});
}
}
// console.log(pathIndex);
return pathIndex;
}
function createTreeViewByTreeWithMerge(json, keywords) {
var pathIndex = createTreeViewByTree(json, keywords);
mergeNode(pathIndex);
return pathIndex;
}
/**
* 查找node节点
*/
function findNode(arr, service){
for (var i = 0; i < arr.length; i++) {
if(arr[i].label == service) {
return arr[i];
}
}
return null;
}
/**
* 多层级合并
*/
function mergeNode(node) {
for (var i = 0; i < node.length; i++) {
var tempNode = node[i];
if (tempNode.children == null
|| tempNode.children[0].children == null
|| tempNode.children[0].children[0].children == null) {
continue;
}
if (tempNode.children.length == 1) {
tempNode.label = tempNode.label + "." + tempNode.children[0].label;
tempNode.children = tempNode.children[0].children;
i--;
}
mergeNode(tempNode.children);
}
}
function findInPathsValue(pathsValue, keywords) {
if (isEmpty(keywords)) {
return true;
}
keywords = keywords.toLowerCase();
// 找路径和说明里面包含关键字的
var interface = pathsValue.interface;
if (isNotEmpty(interface) && interface.toLowerCase().indexOf(keywords) >= 0) {
return true;
}
return false;
}

File diff suppressed because one or more lines are too long

View File

@@ -1,125 +0,0 @@
/**
* 将对象处理成json格式化和着色的html
* @author 暮光:城中城
* @since 2017年5月7日
*/
var Formatjson = {
// 需要在对象或列表后面添加注释的对象,例:{userList: "用户列表"}
// 那么在名字为userList的对象或列表后面都会加上“用户列表” 这个注释
annotationObject: {},
tabStr: " ",
isArray: function(obj) {
return obj && typeof obj === 'object' && typeof obj.length === 'number'
&& !(obj.propertyIsEnumerable('length'));
},
processObjectToHtmlPre: function(obj, indent, addComma, isArray, isPropertyContent, showAnnotation) {
var htmlStr = this.processObject(obj, "", indent, addComma, isArray, isPropertyContent, showAnnotation);
htmlStr = '<pre class="json">' + htmlStr + '</pre>';
return htmlStr;
},
processObject: function(obj, keyName, indent, addComma, isArray, isPropertyContent, showAnnotation) {
var html = "";
var comma = (addComma) ? "<span class='comma'>,</span> " : "";
var type = typeof obj;
if (this.isArray(obj)) {
if (obj.length == 0) {
html += this.getRow(indent, "<span class='array-brace'>[ ]</span>" + comma, isPropertyContent);
} else {
var clpsHtml = '<span><img class="option-img" src="webjars/doc-wiki/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
var annotation = '';
if(showAnnotation && isNotEmpty(keyName) && isNotEmpty(this.annotationObject[keyName])) {
annotation = '<span class="annotation">// '+this.annotationObject[keyName]+'</span>';
}
html += this.getRow(indent, "<span class='array-brace'>[</span>"+clpsHtml+annotation, isPropertyContent);
for (var i = 0; i < obj.length; i++) {
html += this.processObject(obj[i], "", indent + 1, i < (obj.length - 1), true, false, showAnnotation);
}
clpsHtml = "</span>";
html += this.getRow(indent, clpsHtml + "<span class='array-brace'>]</span>" + comma);
}
} else if (type == 'object' && obj == null) {
html += this.formatLiteral("null", "", comma, indent, isArray, "null");
} else if (type == 'object') {
var numProps = 0;
for ( var prop in obj) {
numProps++;
}
if (numProps == 0) {
html += this.getRow(indent, "<span class='object-brace'>{ }</span>" + comma, isPropertyContent);
} else {
var clpsHtml = '<span><img class="option-img" src="webjars/doc-wiki/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
var annotation = '';
if(showAnnotation && isNotEmpty(keyName) && isNotEmpty(this.annotationObject[keyName])) {
annotation = '<span class="annotation">// '+this.annotationObject[keyName]+'</span>';
}
html += this.getRow(indent, "<span class='object-brace'>{</span>"+clpsHtml+annotation, isPropertyContent);
var j = 0;
for ( var prop in obj) {
var processStr = '<span class="property-name">"' + prop + '"</span>: ' + this.processObject(obj[prop], prop, indent + 1, ++j < numProps, false, true, showAnnotation);
html += this.getRow(indent + 1, processStr);
}
clpsHtml = "</span>";
html += this.getRow(indent, clpsHtml + "<span class='object-brace'>}</span>" + comma);
}
} else if (type == 'number') {
html += this.formatLiteral(obj, "", comma, indent, isArray, "number");
} else if (type == 'boolean') {
html += this.formatLiteral(obj, "", comma, indent, isArray, "boolean");
} else if (type == 'function') {
obj = this.formatFunction(indent, obj);
html += this.formatLiteral(obj, "", comma, indent, isArray, "function");
} else if (type == 'undefined') {
html += this.formatLiteral("undefined", "", comma, indent, isArray, "null");
} else {
html += this.formatLiteral(obj, "\"", comma, indent, isArray, "string");
}
return html;
},
expImgClicked: function(img){
var container = img.parentNode.nextSibling;
if(!container) return;
var disp = "none";
var src = "webjars/doc-wiki/img/collapsed.png";
if(container.style.display == "none"){
disp = "inline";
src = "webjars/doc-wiki/img/expanded.png";
}
container.style.display = disp;
img.src = src;
},
formatLiteral: function(literal, quote, comma, indent, isArray, style) {
if (typeof literal == 'string') {
literal = literal.split("<").join("&lt;").split(">").join("&gt;");
}
var str = "<span class='" + style + "'>" + quote + literal + quote + comma + "</span>";
if (isArray) {
str = this.getRow(indent, str);
}
return str;
},
formatFunction: function(indent, obj) {
var tabs = "";
for (var i = 0; i < indent; i++) {
tabs += this.tabStr;
}
var funcStrArray = obj.toString().split("\n");
var str = "";
for (var i = 0; i < funcStrArray.length; i++) {
str += ((i == 0) ? "" : tabs) + funcStrArray[i] + "\n";
}
return str;
},
getRow: function(indent, data, isPropertyContent) {
var tabs = "";
for (var i = 0; i < indent && !isPropertyContent; i++) {
tabs += this.tabStr;
}
if (data != null && data.length > 0 && data.charAt(data.length - 1) != "\n") {
data = data + "\n";
}
return tabs + data;
}
}

File diff suppressed because one or more lines are too long

View File

@@ -1,38 +0,0 @@
/**
* 提示工具类
* @author 暮光:城中城
* @since 2017年5月7日
*/
var Toast = {
notOpen: function () {
app.$message({
message: '该功能暂未开放,敬请期待!',
type: 'warning',
showClose: true
});
},
success: function (msg, time) {
app.$message({
message: msg,
duration: time || 3000,
type: 'success',
showClose: true
});
},
warn: function (msg, time) {
app.$message({
message: msg,
duration: time || 3000,
type: 'warning',
showClose: true
});
},
error: function (msg, time) {
app.$message({
message: msg,
duration: time || 3000,
type: 'error',
showClose: true
});
},
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,140 +0,0 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>测试</title>
<link rel="shortcut icon" href="../doc-wiki/img/wiki.ico"/>
<link rel="stylesheet" href="../doc-wiki/css/element-ui.css">
<link rel="stylesheet" href="../doc-wiki/css/doc-wiki.css" />
</head>
<body>
<div id="app">
<el-form :model="ruleFormData" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="活动名称" prop="name">
<el-input v-model="ruleFormData.name"></el-input>
</el-form-item>
<el-form-item label="活动区域" prop="region">
<el-select v-model="ruleForm.region" placeholder="请选择活动区域">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
</el-select>
</el-form-item>
<el-form-item label="活动时间" required>
<el-col :span="11">
<el-form-item prop="date1">
<el-date-picker type="date" placeholder="选择日期" v-model="ruleForm.date1" style="width: 100%;"></el-date-picker>
</el-form-item>
</el-col>
<el-col class="line" :span="2">-</el-col>
<el-col :span="11">
<el-form-item prop="date2">
<el-time-picker type="fixed-time" placeholder="选择时间" v-model="ruleForm.date2" style="width: 100%;"></el-time-picker>
</el-form-item>
</el-col>
</el-form-item>
<el-form-item label="即时配送" prop="delivery">
<el-switch v-model="ruleForm.delivery"></el-switch>
</el-form-item>
<el-form-item label="活动性质" prop="type">
<el-checkbox-group v-model="ruleForm.type">
<el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
<el-checkbox label="地推活动" name="type"></el-checkbox>
<el-checkbox label="线下主题活动" name="type"></el-checkbox>
<el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="特殊资源" prop="resource">
<el-radio-group v-model="ruleForm.resource">
<el-radio label="线上品牌商赞助"></el-radio>
<el-radio label="线下场地免费"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="活动形式" prop="desc">
<el-input type="textarea" v-model="ruleForm.desc"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
<el-button @click="resetForm('ruleForm')">重置</el-button>
</el-form-item>
</el-form>
</div>
</body>
<script type="text/javascript" src="../doc-wiki/vue/vue.js"></script>
<script type="text/javascript" src="../doc-wiki/js/element-ui.js"></script>
<!-- ajax 用到了jquery -->
<script type="text/javascript" src="../doc-wiki/js/jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="../doc-wiki/js/common.js"></script>
<script type="text/javascript" src="../doc-wiki/js/toast.js"></script>
<script type="text/javascript" src="../doc-wiki/js/formatjson.js"></script>
<script type="text/javascript" src="../doc-wiki/js/doc-wiki-tree.js"></script>
<script type="text/javascript" src="../doc-wiki/lib/wangEditor/wangEditor.js"></script>
<script>
var app = new Vue({
el: '#app',
data() {
return {
ruleFormData: {
name: '',
region: '',
date1: '',
date2: '',
delivery: false,
type: [],
resource: '',
desc: ''
},
rules: {
name: [
{ required: true, message: '请输入活动名称', trigger: 'blur' },
{ min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
],
region: [
{ required: true, message: '请选择活动区域', trigger: 'change' }
],
date1: [
{ type: 'date', required: true, message: '请选择日期', trigger: 'change' }
],
date2: [
{ type: 'date', required: true, message: '请选择时间', trigger: 'change' }
],
type: [
{ type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
],
resource: [
{ required: true, message: '请选择活动资源', trigger: 'change' }
],
desc: [
{ required: true, message: '请填写活动形式', trigger: 'blur' }
]
}
}
},
watch: {
},
mounted: function () {
},
methods: {
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
alert('submit!');
} else {
console.log('error submit!!');
return false;
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
}
}
});
</script>
<style>
</style>
</html>