Skip to content

Commit c96a6ad

Browse files
committed
内置产品文档优化
1 parent 980ca2b commit c96a6ad

File tree

5 files changed

+60
-43
lines changed

5 files changed

+60
-43
lines changed

web/src/apps/workspace/module/managementPlatform/component/library/menu.vue

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
footer-hide
2121
>
2222
<Form
23-
ref="groupForm"
24-
:model="groupForm"
23+
ref="catalogForm"
24+
:model="catalogForm"
2525
:label-width="100"
2626
:rules="groupRule"
2727
v-show="modalType === 'catalog'"
2828
>
2929
<FormItem label="目录名称" prop="title">
3030
<Input
3131
type="text"
32-
v-model="groupForm.title"
32+
v-model="catalogForm.title"
3333
placeholder="请输入目录名称"
3434
style="width: 300px"
3535
></Input>
@@ -99,7 +99,7 @@ export default {
9999
modalVisible: false,
100100
modalTitle: "",
101101
submitLoading: false,
102-
groupForm: {
102+
catalogForm: {
103103
parentId: -1, // 第一级目录父id为-1
104104
title: "",
105105
description: "",
@@ -182,7 +182,7 @@ export default {
182182
let matched = false;
183183
for (let i=0,len=nodes.length; i<len; i++) {
184184
let item = {};
185-
if (nodes[i].id == catalogId) {
185+
if (!nodes[i].isLeaf && nodes[i].id == catalogId) {
186186
item = {
187187
...nodes[i],
188188
loaded: true,
@@ -199,7 +199,7 @@ export default {
199199
})
200200
}
201201
matched = true;
202-
} else if (!matched && nodes[i].children && nodes[i].children.length) {
202+
} else if (!matched && !nodes[i].isLeaf && nodes[i].children && nodes[i].children.length) {
203203
item = {
204204
...nodes[i],
205205
children: this.mergeTree(nodes[i].children, catalogId, children)
@@ -216,13 +216,13 @@ export default {
216216
let matched = false;
217217
for (let i=0,len=nodes.length; i<len; i++) {
218218
let item = {};
219-
if (nodes[i].id == node.id) {
219+
if (!nodes[i].isLeaf && nodes[i].id == node.id) {
220220
item = {
221221
...nodes[i],
222222
opened: !nodes[i].opened
223223
}
224224
matched = true;
225-
} else if (!matched && nodes[i].children && nodes[i].children.length) {
225+
} else if (!matched && !nodes[i].isLeaf && nodes[i].children && nodes[i].children.length) {
226226
item = {
227227
...nodes[i],
228228
children: this.handleToggle(nodes[i].children, node)
@@ -239,13 +239,13 @@ export default {
239239
let matched = false;
240240
for (let i=0,len=nodes.length; i<len; i++) {
241241
let item = {};
242-
if (nodes[i].id == node.id) {
242+
if (!nodes[i].isLeaf && nodes[i].id == node.id) {
243243
item = {
244244
...nodes[i],
245245
loading: true
246246
}
247247
matched = true;
248-
} else if (!matched && nodes[i].children && nodes[i].children.length) {
248+
} else if (!matched && !nodes[i].isLeaf && nodes[i].children && nodes[i].children.length) {
249249
item = {
250250
...nodes[i],
251251
children: this.handleLoading(nodes[i].children, node)
@@ -301,7 +301,7 @@ export default {
301301
type: "catalog",
302302
op: "修改",
303303
});
304-
this.groupForm = {
304+
this.catalogForm = {
305305
id: node.id,
306306
title: node.title || "",
307307
description: node.description || "",
@@ -362,11 +362,10 @@ export default {
362362
handleModalOk() {
363363
const modalType = this.modalType;
364364
if (modalType === "catalog") {
365-
this.$refs["groupForm"].validate((valid) => {
365+
this.$refs["catalogForm"].validate((valid) => {
366366
if (valid) {
367367
this.submitLoading = true;
368-
console.log('add', this.groupForm)
369-
SaveCatalog(this.groupForm).then((res) => {
368+
SaveCatalog(this.catalogForm).then((res) => {
370369
this.submitLoading = false;
371370
this.handleModalCancel();
372371
this.initTree();
@@ -412,11 +411,11 @@ export default {
412411
},
413412
resetForm() {
414413
if (this.modalType === "catalog") {
415-
this.groupForm = {
414+
this.catalogForm = {
416415
parentId: -1,
417416
title: "",
418417
};
419-
this.$refs["groupForm"].resetFields();
418+
this.$refs["catalogForm"].resetFields();
420419
} else {
421420
this.contentForm = {
422421
type: "",

web/src/dss/module/footer/guide.vue

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<library-detail :doc="currentDoc" v-show="currentMode == 'detail'" @on-chapter-click="changeToLibraryDetail" />
7979
<library-search :doc="currentDoc" v-show="currentMode == 'search'" @on-chapter-click="changeToLibraryDetail" @on-page-change="changeSearchPage" />
8080
<library-home v-show="currentMode == 'home'" @on-chapter-click="changeToLibraryDetail" />
81+
<Spin size="large" fix v-if="loading"></Spin>
8182
</div>
8283

8384
<div class="guide-footer">
@@ -126,6 +127,7 @@ export default {
126127
currentDoc: {}, // history当前坐标的数据
127128
keyword: '', // document搜索
128129
pageSize: 10,
130+
loading: false,
129131
130132
selectedImg: "",
131133
modalImg: false,
@@ -249,16 +251,21 @@ export default {
249251
}
250252
},
251253
changeToLibrarySearch() {
254+
if (!this.keyword || !this.keyword.trim()) {
255+
return;
256+
}
252257
this.currentMode = "search";
253-
if (this.lastHistory.mode == "search" && this.lastHistory.data.keyword == this.keyword) {
258+
if (this.lastHistory.mode == "search" && this.lastHistory.data.keyword == this.keyword.trim()) {
254259
// 最后一条历史记录是search且keyword没有变化,不处理
255260
} else {
256261
// history队列a b c d e, 如果当前在c,此时有元素进入队列,那么d e会被remove
257262
this.history = this.history.slice(0, this.currentIndex + 1).concat({ mode: "search", data: { keyword: this.keyword } });
258263
this.currentIndex = this.currentIndex + 1;
259-
QueryChapter({keyword: this.keyword, pageNow: 1, pageSize: this.pageSize}).then((res) => {
264+
this.loading = true;
265+
QueryChapter({keyword: this.keyword.trim(), pageNow: 1, pageSize: this.pageSize}).then((res) => {
260266
const data = this.formatSearchResult(res);
261267
this.currentDoc = data;
268+
this.loading = false;
262269
// 更新history
263270
this.history = this.history.map((item, index) => {
264271
if (index == this.currentIndex) {
@@ -274,10 +281,12 @@ export default {
274281
}
275282
},
276283
changeSearchPage(page) {
284+
this.loading = true;
277285
// search分页不更新history,只更新当前doc
278-
QueryChapter({keyword: this.keyword, pageNow: page, pageSize: this.pageSize}).then((res) => {
286+
QueryChapter({keyword: this.keyword.trim(), pageNow: page, pageSize: this.pageSize}).then((res) => {
279287
const data = this.formatSearchResult(res);
280288
this.currentDoc = data;
289+
this.loading = false;
281290
});
282291
},
283292
formatSearchResult(res) {
@@ -287,10 +296,10 @@ export default {
287296
...item,
288297
id: item.id,
289298
title: item.title,
290-
desc: (item.contentHtml || "").replace(/\<\w\>/g, "").replace(/\<[/]\w\>/g, "").substr(0, 100)
299+
desc: (item.contentHtml || "").replace(/<[^>]+>/gim, "").substr(0, 100), // 替换html标签
291300
}
292301
}),
293-
keyword: this.keyword,
302+
keyword: this.keyword.trim(),
294303
total: res.total
295304
};
296305
},
@@ -484,6 +493,7 @@ export default {
484493
}
485494
}
486495
.guide-body {
496+
position: relative;
487497
height: calc(100% - 96px);
488498
padding-bottom: 48px;
489499
overflow-x: hidden;

web/src/dss/module/footer/libraryDetail.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div class="library-detail" >
33
<div class="library-detail-title">{{ doc.title }}</div>
4+
<div class="library-detail-time">更新时间:{{ doc.updateTime }}</div>
45
<div class="library-detail-content" ref="libraryDetail">
56
<p v-html="doc.contentHtml"></p>
67
</div>
@@ -55,6 +56,11 @@ export default {
5556
font-size: 20px;
5657
@include font-color(#333, $dark-workspace-title-color);
5758
}
59+
.library-detail-time {
60+
margin: 15px;
61+
font-size: 12px;
62+
@include font-color(#999, $dark-workspace-title-color);
63+
}
5864
.library-detail-content {
5965
padding: 0 15px 15px;
6066
@include font-color(#666, $dark-text-color);

web/src/dss/module/footer/libraryHome.vue

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default {
6464
},
6565
refreshTree(catalogId) {
6666
GetCatalogById(catalogId).then((data) => {
67-
const childrenCatalog = data.result ? (data.result.childrenCatalog || []).map(i => { return {...i, type: "catalog", isLeaf: false, canAdd: true }}) : []
67+
const childrenCatalog = data.result ? (data.result.childrenCatalog || []).map(i => { return {...i, type: "catalog", isLeaf: false }}) : []
6868
const childrenChapter = data.result ? (data.result.childrenChapter || []).map(i => { return {...i, type: "chapter", isLeaf: true }}) : []
6969
const children = childrenCatalog.concat(childrenChapter);
7070
this.nodes = this.mergeTree(this.nodes, catalogId, children);
@@ -75,24 +75,17 @@ export default {
7575
let matched = false;
7676
for (let i=0,len=nodes.length; i<len; i++) {
7777
let item = {};
78-
if (nodes[i].id == catalogId) {
78+
if (!nodes[i].isLeaf && nodes[i].id == catalogId) {
7979
item = {
8080
...nodes[i],
8181
loaded: true,
8282
loading: false,
8383
opened: true,
8484
isLeaf: false,
85-
children: children.map(c => {
86-
return {
87-
...c,
88-
id: c.id,
89-
title: c.title,
90-
isLeaf: true,
91-
}
92-
})
85+
children: children
9386
}
9487
matched = true;
95-
} else if (!matched && nodes[i].children && nodes[i].children.length) {
88+
} else if (!matched && !nodes[i].isLeaf && nodes[i].children && nodes[i].children.length) {
9689
item = {
9790
...nodes[i],
9891
children: this.mergeTree(nodes[i].children, catalogId, children)
@@ -109,13 +102,13 @@ export default {
109102
let matched = false;
110103
for (let i=0,len=nodes.length; i<len; i++) {
111104
let item = {};
112-
if (nodes[i].id == node.id) {
105+
if (!nodes[i].isLeaf && nodes[i].id == node.id) {
113106
item = {
114107
...nodes[i],
115108
opened: !nodes[i].opened
116109
}
117110
matched = true;
118-
} else if (!matched && nodes[i].children && nodes[i].children.length) {
111+
} else if (!matched && !nodes[i].isLeaf && nodes[i].children && nodes[i].children.length) {
119112
item = {
120113
...nodes[i],
121114
children: this.handleToggle(nodes[i].children, node)
@@ -132,13 +125,13 @@ export default {
132125
let matched = false;
133126
for (let i=0,len=nodes.length; i<len; i++) {
134127
let item = {};
135-
if (nodes[i].id == node.id) {
128+
if (!nodes[i].isLeaf && nodes[i].id == node.id) {
136129
item = {
137130
...nodes[i],
138131
loading: true
139132
}
140133
matched = true;
141-
} else if (!matched && nodes[i].children && nodes[i].children.length) {
134+
} else if (!matched && !nodes[i].isLeaf && nodes[i].children && nodes[i].children.length) {
142135
item = {
143136
...nodes[i],
144137
children: this.handleLoading(nodes[i].children, node)

web/src/dss/module/footer/librarySearch.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<template>
22
<div class="library-search">
3-
<div class="library-search-list" v-for="item in doc.list" :key="item.id" @click="showChapter(item)">
4-
<div class="search-item-title">{{ item.title }}</div>
5-
<div class="search-item-desc">{{ item.desc }}</div>
6-
</div>
7-
<div class="library-search-page">
8-
<Page :total="doc.total" show-total @on-change="changePage"></Page>
9-
</div>
3+
<template v-if="doc.list && doc.list.length">
4+
<div class="library-search-list" v-for="item in doc.list" :key="item.id" @click="showChapter(item)">
5+
<div class="search-item-title">{{ item.title }}</div>
6+
<div class="search-item-desc">{{ item.desc }}</div>
7+
</div>
8+
<div class="library-search-page">
9+
<Page :total="doc.total" show-total @on-change="changePage"></Page>
10+
</div>
11+
</template>
12+
<div class="library-search-empty" v-else>没有找到您期望的内容</div>
1013
</div>
1114
</template>
1215
<script>
@@ -59,5 +62,11 @@ export default {
5962
.library-search-page {
6063
margin: 12px 15px;
6164
}
65+
.library-search-empty {
66+
text-align: center;
67+
margin: 80px 0;
68+
font-size: 16px;
69+
@include font-color(#333, $dark-text-color);
70+
}
6271
}
6372
</style>

0 commit comments

Comments
 (0)