vue2-client 1.22.19 → 1.22.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.his +19 -19
- package/.env.message +19 -19
- package/.history/.eslintrc_20260521171150.js +74 -0
- package/.history/.eslintrc_20260521171213.js +74 -0
- package/.history/src/base-client/components/common/HIS/HAddNativeForm/HAddNativeForm_20260601154443.vue +726 -0
- package/.history/src/base-client/components/common/HIS/HAddNativeForm/HAddNativeForm_20260601154700.vue +478 -0
- package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260512175435.vue +706 -0
- package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260512175450.vue +694 -0
- package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260611152602.vue +755 -0
- package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513145941.vue +524 -0
- package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513153133.vue +731 -0
- package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513160316.vue +525 -0
- package/.history/src/base-client/components/common/HIS/HForm/HForm_20260601144150.vue +1046 -0
- package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260310142713.vue +512 -0
- package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260310145118.vue +511 -0
- package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260311094834.vue +696 -0
- package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260320143028.vue +693 -0
- package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260409101450.vue +677 -0
- package/.history/src/base-client/components/common/HIS/HTab/HTab_20260625173703.vue +767 -0
- package/.history/src/base-client/components/common/HIS/HTab/HTab_20260626112425.vue +803 -0
- package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513140637.vue +1455 -0
- package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513140935.vue +1441 -0
- package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513150818.vue +1441 -0
- package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513153119.vue +1442 -0
- package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513153126.vue +1486 -0
- package/.history/src/base-client/components/common/XForm/XFormItem_20260513140854.vue +1607 -0
- package/.history/src/base-client/components/common/XMarkdownViewer/XMarkdownViewer_20260519140403.vue +643 -0
- package/.history/src/base-client/components/common/XMarkdownViewer/XMarkdownViewer_20260519140829.vue +628 -0
- package/.history/src/base-client/components/common/XMarkdownViewer/demo_20260519142824.vue +104 -0
- package/.history/src/base-client/components/common/XMarkdownViewer/demo_20260519143155.vue +102 -0
- package/.history/src/base-client/components/common/XReportGrid/XReport_20260309171231.vue +1241 -0
- package/.history/src/base-client/components/common/XReportGrid/XReport_20260309171441.vue +1223 -0
- package/.history/src/base-client/components/his/HAi/HAi_20260612174826.vue +472 -0
- package/.history/src/base-client/components/his/HAi/HAi_20260612175839.vue +538 -0
- package/.history/src/base-client/components/his/HAi/HAi_20260615103331.vue +650 -0
- package/.history/src/base-client/components/his/HAi/HAi_20260618140214.vue +1396 -0
- package/.history/src/base-client/components/his/HAi/HAi_20260618140556.vue +1396 -0
- package/.history/src/base-client/components/his/XHDescriptions/XHDescriptions_20260424134504.vue +1469 -0
- package/.history/src/base-client/components/his/XSidebar/XSidebar_20260610171133.vue +788 -0
- package/.history/src/base-client/components/his/XSidebar/XSidebar_20260610171151.vue +780 -0
- package/.history/src/base-client/components/his/XTransfer/XTransfer_20260511170841.vue +585 -0
- package/.history/src/base-client/components/his/XTransfer/XTransfer_20260511171138.vue +787 -0
- package/.history/src/base-client/components/his/XTransfer/XTransfer_20260512141830.vue +739 -0
- package/.history/src/components/STable/index_20260409155138.js +806 -0
- package/.history/src/components/STable/index_20260409155218.js +814 -0
- package/.history/src/expression/core/Expression_20260305164427.js +1371 -0
- package/.history/src/expression/core/Expression_20260305170258.js +1358 -0
- package/.history/src/expression/core/Program_20260305111830.js +944 -0
- package/.history/src/expression/core/Program_20260305112041.js +931 -0
- package/.history/src/logic/LogicRunner_20260304154306.js +170 -0
- package/.history/src/logic/LogicRunner_20260304155553.js +112 -0
- package/.history/src/logic/LogicRunner_20260305105834.js +112 -0
- package/.history/src/logic/LogicRunner_20260305112718.js +129 -0
- package/.history/src/logic/LogicRunner_20260305182436.js +133 -0
- package/.history/src/logic/LogicRunner_20260306151301.js +213 -0
- package/.history/src/logic/LogicRunner_20260306152419.js +213 -0
- package/.history/src/logic/plugins/common/DateTools_20260305154159.js +61 -0
- package/.history/src/logic/plugins/common/DateTools_20260305154217.js +44 -0
- package/.history/src/logic/plugins/common/DateTools_20260305161014.js +44 -0
- package/.history/src/logic/plugins/common/HttpTools_20260305164352.js +80 -0
- package/.history/src/logic/plugins/common/HttpTools_20260305170258.js +75 -0
- package/.history/src/logic/plugins/common/HttpTools_20260305171634.js +75 -0
- package/.history/src/logic/plugins/common/HttpTools_20260306152419.js +72 -0
- package/.history/src/services/api/restTools_20260427142149.js +245 -0
- package/.history/src/services/api/restTools_20260427142853.js +230 -0
- package/.history/src/services/api/restTools_20260519135558.js +230 -0
- package/.history/src/services/api/restTools_20260519140825.js +230 -0
- package/.history/src/services/api/restTools_20260519151223.js +230 -0
- package/.history/src/utils/indexedDB_20260306150918.js +593 -0
- package/.history/src/utils/indexedDB_20260306151301.js +586 -0
- package/.idea/af-vue2-client.iml +4 -7
- package/.idea/codeStyles/Project.xml +62 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +6 -0
- package/CHANGELOG.md +837 -837
- package/package.json +117 -117
- package/preview-input-box.html +180 -0
- package/src/base-client/components/common/HIS/HForm/HForm.vue +1186 -1186
- package/src/base-client/components/common/HIS/HTab/HTab.vue +790 -757
- package/src/base-client/components/common/ImagePreviewModal/index.js +3 -3
- package/src/base-client/components/common/XMarkdownViewer/demo.vue +102 -102
- package/src/base-client/components/his/HAi/HAi.vue +159 -30
- package/src/base-client/components/his/XTransfer/index.md +327 -327
- package/src/components/MarkdownEditor/demo.vue +300 -300
- package/src/components/MarkdownEditor/index.vue +590 -590
- package/src/router/async/router.map.js +141 -141
- package/src/services/api/restTools.js +1 -1
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
|
@@ -1,300 +1,300 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="article-edit">
|
|
3
|
-
<a-card>
|
|
4
|
-
<template #title>
|
|
5
|
-
<div class="card-header">
|
|
6
|
-
<span>📝 {{ isEdit ? '编辑文章' : '新建文章' }}</span>
|
|
7
|
-
<span class="article-id" v-if="isEdit">ID: {{ articleId }}</span>
|
|
8
|
-
</div>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<!-- 文章信息 -->
|
|
12
|
-
<a-form layout="vertical">
|
|
13
|
-
<a-form-item label="标题">
|
|
14
|
-
<a-input
|
|
15
|
-
v-model="form.title"
|
|
16
|
-
placeholder="请输入文章标题"
|
|
17
|
-
size="large"
|
|
18
|
-
/>
|
|
19
|
-
</a-form-item>
|
|
20
|
-
|
|
21
|
-
<a-form-item label="分类">
|
|
22
|
-
<a-select
|
|
23
|
-
v-model="form.category"
|
|
24
|
-
placeholder="请选择分类"
|
|
25
|
-
style="width: 200px"
|
|
26
|
-
>
|
|
27
|
-
<a-select-option value="tech">技术</a-select-option>
|
|
28
|
-
<a-select-option value="life">生活</a-select-option>
|
|
29
|
-
<a-select-option value="travel">旅行</a-select-option>
|
|
30
|
-
</a-select>
|
|
31
|
-
</a-form-item>
|
|
32
|
-
</a-form>
|
|
33
|
-
|
|
34
|
-
<!-- Markdown 编辑器 -->
|
|
35
|
-
<div class="editor-container">
|
|
36
|
-
<MarkdownEditor
|
|
37
|
-
ref="editor"
|
|
38
|
-
v-model="form.content"
|
|
39
|
-
:serviceName="serviceName"
|
|
40
|
-
:imgPrefix="imgPrefix"
|
|
41
|
-
:height="editorHeight"
|
|
42
|
-
@upload-success="handleUploadSuccess"
|
|
43
|
-
@change="handleContentChange"
|
|
44
|
-
/>
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
<!-- 底部操作栏 -->
|
|
48
|
-
<div class="action-bar">
|
|
49
|
-
<a-space>
|
|
50
|
-
<a-button @click="handlePreview">预览</a-button>
|
|
51
|
-
<a-button type="primary" @click="handleSubmit" :loading="submitting">
|
|
52
|
-
{{ isEdit ? '更新' : '发布' }}
|
|
53
|
-
</a-button>
|
|
54
|
-
</a-space>
|
|
55
|
-
<span class="info-text">
|
|
56
|
-
共 {{ form.content.length }} 字符
|
|
57
|
-
</span>
|
|
58
|
-
</div>
|
|
59
|
-
</a-card>
|
|
60
|
-
|
|
61
|
-
<!-- ===== 预览弹窗(固定高度滚动) ===== -->
|
|
62
|
-
<a-modal
|
|
63
|
-
v-model="previewVisible"
|
|
64
|
-
title="文章预览"
|
|
65
|
-
width="800px"
|
|
66
|
-
:footer="null"
|
|
67
|
-
:bodyStyle="{ padding: '0', height: '600px' }"
|
|
68
|
-
>
|
|
69
|
-
<div class="preview-container">
|
|
70
|
-
<div class="preview-content" v-html="previewHtml"></div>
|
|
71
|
-
</div>
|
|
72
|
-
</a-modal>
|
|
73
|
-
</div>
|
|
74
|
-
</template>
|
|
75
|
-
|
|
76
|
-
<script>
|
|
77
|
-
import MarkdownEditor from '
|
|
78
|
-
|
|
79
|
-
export default {
|
|
80
|
-
name: 'ArticleEdit',
|
|
81
|
-
components: { MarkdownEditor },
|
|
82
|
-
|
|
83
|
-
data() {
|
|
84
|
-
return {
|
|
85
|
-
articleId: this.$route.params.id || null,
|
|
86
|
-
isEdit: !!this.$route.params.id,
|
|
87
|
-
submitting: false,
|
|
88
|
-
previewVisible: false,
|
|
89
|
-
previewHtml: '',
|
|
90
|
-
|
|
91
|
-
// 编辑器高度
|
|
92
|
-
editorHeight: '600px',
|
|
93
|
-
|
|
94
|
-
// 上传配置
|
|
95
|
-
serviceName: 'af-revenue',
|
|
96
|
-
imgPrefix: process.env.VUE_APP_IMG_PREFIX || '',
|
|
97
|
-
|
|
98
|
-
form: {
|
|
99
|
-
title: '',
|
|
100
|
-
category: 'tech',
|
|
101
|
-
content: '# 开始写作\n\n在这里编写你的文章内容...'
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
mounted() {
|
|
107
|
-
if (this.isEdit) {
|
|
108
|
-
this.loadArticle()
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
methods: {
|
|
113
|
-
async loadArticle() {
|
|
114
|
-
try {
|
|
115
|
-
const { data } = await this.$axios.get(`/api/article/${this.articleId}`)
|
|
116
|
-
this.form = data
|
|
117
|
-
} catch (error) {
|
|
118
|
-
console.error('加载文章失败:', error)
|
|
119
|
-
this.$message.error('加载文章失败')
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
handleUploadSuccess({ pos, file, relativePath, response }) {
|
|
124
|
-
console.log('图片上传成功:', {
|
|
125
|
-
pos,
|
|
126
|
-
fileName: file.name,
|
|
127
|
-
relativePath,
|
|
128
|
-
response
|
|
129
|
-
})
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
handleContentChange({ value, render }) {
|
|
133
|
-
this.form.content = value
|
|
134
|
-
this.previewHtml = render
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
handlePreview() {
|
|
138
|
-
this.previewHtml = this.$refs.editor.getHtml()
|
|
139
|
-
this.previewVisible = true
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
async handleSubmit() {
|
|
143
|
-
if (!this.form.title.trim()) {
|
|
144
|
-
this.$message.warning('请输入文章标题')
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (!this.form.content.trim()) {
|
|
149
|
-
this.$message.warning('请输入文章内容')
|
|
150
|
-
return
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
this.submitting = true
|
|
154
|
-
try {
|
|
155
|
-
const api = this.isEdit
|
|
156
|
-
? `/api/article/${this.articleId}`
|
|
157
|
-
: '/api/article'
|
|
158
|
-
const method = this.isEdit ? 'put' : 'post'
|
|
159
|
-
|
|
160
|
-
await this.$axios[method](api, this.form)
|
|
161
|
-
this.$message.success(this.isEdit ? '更新成功' : '发布成功')
|
|
162
|
-
|
|
163
|
-
setTimeout(() => {
|
|
164
|
-
this.$router.push('/articles')
|
|
165
|
-
}, 1000)
|
|
166
|
-
|
|
167
|
-
} catch (error) {
|
|
168
|
-
console.error('提交失败:', error)
|
|
169
|
-
this.$message.error('提交失败,请重试')
|
|
170
|
-
} finally {
|
|
171
|
-
this.submitting = false
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
goBack() {
|
|
176
|
-
this.$router.go(-1)
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
</script>
|
|
181
|
-
|
|
182
|
-
<style scoped>
|
|
183
|
-
.article-edit {
|
|
184
|
-
padding: 24px;
|
|
185
|
-
max-width: 1400px;
|
|
186
|
-
margin: 0 auto;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.card-header {
|
|
190
|
-
display: flex;
|
|
191
|
-
justify-content: space-between;
|
|
192
|
-
align-items: center;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
.article-id {
|
|
196
|
-
color: #999;
|
|
197
|
-
font-size: 14px;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.editor-container {
|
|
201
|
-
height: 600px;
|
|
202
|
-
margin: 16px 0;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.action-bar {
|
|
206
|
-
display: flex;
|
|
207
|
-
justify-content: space-between;
|
|
208
|
-
align-items: center;
|
|
209
|
-
padding-top: 16px;
|
|
210
|
-
border-top: 1px solid #f0f0f0;
|
|
211
|
-
margin-top: 16px;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.info-text {
|
|
215
|
-
color: #999;
|
|
216
|
-
font-size: 14px;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/* ===== 预览容器 - 固定高度滚动 ===== */
|
|
220
|
-
.preview-container {
|
|
221
|
-
height: 600px;
|
|
222
|
-
overflow: hidden;
|
|
223
|
-
position: relative;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.preview-content {
|
|
227
|
-
height: 100%;
|
|
228
|
-
padding: 20px 24px;
|
|
229
|
-
overflow-y: auto;
|
|
230
|
-
word-wrap: break-word;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/* 预览内容样式 */
|
|
234
|
-
.preview-content img {
|
|
235
|
-
max-width: 100%;
|
|
236
|
-
height: auto;
|
|
237
|
-
display: block;
|
|
238
|
-
margin: 12px 0;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.preview-content h1 {
|
|
242
|
-
font-size: 28px;
|
|
243
|
-
margin: 24px 0 16px;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.preview-content h2 {
|
|
247
|
-
font-size: 22px;
|
|
248
|
-
margin: 20px 0 12px;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
.preview-content pre {
|
|
252
|
-
background: #f6f8fa;
|
|
253
|
-
padding: 16px;
|
|
254
|
-
border-radius: 8px;
|
|
255
|
-
overflow-x: auto;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.preview-content code {
|
|
259
|
-
background: #f6f8fa;
|
|
260
|
-
padding: 2px 6px;
|
|
261
|
-
border-radius: 4px;
|
|
262
|
-
font-family: 'Courier New', monospace;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.preview-content table {
|
|
266
|
-
width: 100%;
|
|
267
|
-
border-collapse: collapse;
|
|
268
|
-
margin: 12px 0;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
.preview-content th,
|
|
272
|
-
.preview-content td {
|
|
273
|
-
border: 1px solid #e8e8e8;
|
|
274
|
-
padding: 8px 12px;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
.preview-content th {
|
|
278
|
-
background: #f5f7fa;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/* 滚动条样式 */
|
|
282
|
-
.preview-content::-webkit-scrollbar {
|
|
283
|
-
width: 6px;
|
|
284
|
-
height: 6px;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.preview-content::-webkit-scrollbar-track {
|
|
288
|
-
background: #f1f1f1;
|
|
289
|
-
border-radius: 3px;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
.preview-content::-webkit-scrollbar-thumb {
|
|
293
|
-
background: #c1c1c1;
|
|
294
|
-
border-radius: 3px;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
.preview-content::-webkit-scrollbar-thumb:hover {
|
|
298
|
-
background: #a8a8a8;
|
|
299
|
-
}
|
|
300
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="article-edit">
|
|
3
|
+
<a-card>
|
|
4
|
+
<template #title>
|
|
5
|
+
<div class="card-header">
|
|
6
|
+
<span>📝 {{ isEdit ? '编辑文章' : '新建文章' }}</span>
|
|
7
|
+
<span class="article-id" v-if="isEdit">ID: {{ articleId }}</span>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<!-- 文章信息 -->
|
|
12
|
+
<a-form layout="vertical">
|
|
13
|
+
<a-form-item label="标题">
|
|
14
|
+
<a-input
|
|
15
|
+
v-model="form.title"
|
|
16
|
+
placeholder="请输入文章标题"
|
|
17
|
+
size="large"
|
|
18
|
+
/>
|
|
19
|
+
</a-form-item>
|
|
20
|
+
|
|
21
|
+
<a-form-item label="分类">
|
|
22
|
+
<a-select
|
|
23
|
+
v-model="form.category"
|
|
24
|
+
placeholder="请选择分类"
|
|
25
|
+
style="width: 200px"
|
|
26
|
+
>
|
|
27
|
+
<a-select-option value="tech">技术</a-select-option>
|
|
28
|
+
<a-select-option value="life">生活</a-select-option>
|
|
29
|
+
<a-select-option value="travel">旅行</a-select-option>
|
|
30
|
+
</a-select>
|
|
31
|
+
</a-form-item>
|
|
32
|
+
</a-form>
|
|
33
|
+
|
|
34
|
+
<!-- Markdown 编辑器 -->
|
|
35
|
+
<div class="editor-container">
|
|
36
|
+
<MarkdownEditor
|
|
37
|
+
ref="editor"
|
|
38
|
+
v-model="form.content"
|
|
39
|
+
:serviceName="serviceName"
|
|
40
|
+
:imgPrefix="imgPrefix"
|
|
41
|
+
:height="editorHeight"
|
|
42
|
+
@upload-success="handleUploadSuccess"
|
|
43
|
+
@change="handleContentChange"
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<!-- 底部操作栏 -->
|
|
48
|
+
<div class="action-bar">
|
|
49
|
+
<a-space>
|
|
50
|
+
<a-button @click="handlePreview">预览</a-button>
|
|
51
|
+
<a-button type="primary" @click="handleSubmit" :loading="submitting">
|
|
52
|
+
{{ isEdit ? '更新' : '发布' }}
|
|
53
|
+
</a-button>
|
|
54
|
+
</a-space>
|
|
55
|
+
<span class="info-text">
|
|
56
|
+
共 {{ form.content.length }} 字符
|
|
57
|
+
</span>
|
|
58
|
+
</div>
|
|
59
|
+
</a-card>
|
|
60
|
+
|
|
61
|
+
<!-- ===== 预览弹窗(固定高度滚动) ===== -->
|
|
62
|
+
<a-modal
|
|
63
|
+
v-model="previewVisible"
|
|
64
|
+
title="文章预览"
|
|
65
|
+
width="800px"
|
|
66
|
+
:footer="null"
|
|
67
|
+
:bodyStyle="{ padding: '0', height: '600px' }"
|
|
68
|
+
>
|
|
69
|
+
<div class="preview-container">
|
|
70
|
+
<div class="preview-content" v-html="previewHtml"></div>
|
|
71
|
+
</div>
|
|
72
|
+
</a-modal>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<script>
|
|
77
|
+
import MarkdownEditor from '@vue2-client/components/MarkdownEditor'
|
|
78
|
+
|
|
79
|
+
export default {
|
|
80
|
+
name: 'ArticleEdit',
|
|
81
|
+
components: { MarkdownEditor },
|
|
82
|
+
|
|
83
|
+
data() {
|
|
84
|
+
return {
|
|
85
|
+
articleId: this.$route.params.id || null,
|
|
86
|
+
isEdit: !!this.$route.params.id,
|
|
87
|
+
submitting: false,
|
|
88
|
+
previewVisible: false,
|
|
89
|
+
previewHtml: '',
|
|
90
|
+
|
|
91
|
+
// 编辑器高度
|
|
92
|
+
editorHeight: '600px',
|
|
93
|
+
|
|
94
|
+
// 上传配置
|
|
95
|
+
serviceName: 'af-revenue',
|
|
96
|
+
imgPrefix: process.env.VUE_APP_IMG_PREFIX || '',
|
|
97
|
+
|
|
98
|
+
form: {
|
|
99
|
+
title: '',
|
|
100
|
+
category: 'tech',
|
|
101
|
+
content: '# 开始写作\n\n在这里编写你的文章内容...'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
mounted() {
|
|
107
|
+
if (this.isEdit) {
|
|
108
|
+
this.loadArticle()
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
methods: {
|
|
113
|
+
async loadArticle() {
|
|
114
|
+
try {
|
|
115
|
+
const { data } = await this.$axios.get(`/api/article/${this.articleId}`)
|
|
116
|
+
this.form = data
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.error('加载文章失败:', error)
|
|
119
|
+
this.$message.error('加载文章失败')
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
handleUploadSuccess({ pos, file, relativePath, response }) {
|
|
124
|
+
console.log('图片上传成功:', {
|
|
125
|
+
pos,
|
|
126
|
+
fileName: file.name,
|
|
127
|
+
relativePath,
|
|
128
|
+
response
|
|
129
|
+
})
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
handleContentChange({ value, render }) {
|
|
133
|
+
this.form.content = value
|
|
134
|
+
this.previewHtml = render
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
handlePreview() {
|
|
138
|
+
this.previewHtml = this.$refs.editor.getHtml()
|
|
139
|
+
this.previewVisible = true
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
async handleSubmit() {
|
|
143
|
+
if (!this.form.title.trim()) {
|
|
144
|
+
this.$message.warning('请输入文章标题')
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!this.form.content.trim()) {
|
|
149
|
+
this.$message.warning('请输入文章内容')
|
|
150
|
+
return
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
this.submitting = true
|
|
154
|
+
try {
|
|
155
|
+
const api = this.isEdit
|
|
156
|
+
? `/api/article/${this.articleId}`
|
|
157
|
+
: '/api/article'
|
|
158
|
+
const method = this.isEdit ? 'put' : 'post'
|
|
159
|
+
|
|
160
|
+
await this.$axios[method](api, this.form)
|
|
161
|
+
this.$message.success(this.isEdit ? '更新成功' : '发布成功')
|
|
162
|
+
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
this.$router.push('/articles')
|
|
165
|
+
}, 1000)
|
|
166
|
+
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.error('提交失败:', error)
|
|
169
|
+
this.$message.error('提交失败,请重试')
|
|
170
|
+
} finally {
|
|
171
|
+
this.submitting = false
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
goBack() {
|
|
176
|
+
this.$router.go(-1)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
</script>
|
|
181
|
+
|
|
182
|
+
<style scoped>
|
|
183
|
+
.article-edit {
|
|
184
|
+
padding: 24px;
|
|
185
|
+
max-width: 1400px;
|
|
186
|
+
margin: 0 auto;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.card-header {
|
|
190
|
+
display: flex;
|
|
191
|
+
justify-content: space-between;
|
|
192
|
+
align-items: center;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.article-id {
|
|
196
|
+
color: #999;
|
|
197
|
+
font-size: 14px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.editor-container {
|
|
201
|
+
height: 600px;
|
|
202
|
+
margin: 16px 0;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.action-bar {
|
|
206
|
+
display: flex;
|
|
207
|
+
justify-content: space-between;
|
|
208
|
+
align-items: center;
|
|
209
|
+
padding-top: 16px;
|
|
210
|
+
border-top: 1px solid #f0f0f0;
|
|
211
|
+
margin-top: 16px;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.info-text {
|
|
215
|
+
color: #999;
|
|
216
|
+
font-size: 14px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/* ===== 预览容器 - 固定高度滚动 ===== */
|
|
220
|
+
.preview-container {
|
|
221
|
+
height: 600px;
|
|
222
|
+
overflow: hidden;
|
|
223
|
+
position: relative;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.preview-content {
|
|
227
|
+
height: 100%;
|
|
228
|
+
padding: 20px 24px;
|
|
229
|
+
overflow-y: auto;
|
|
230
|
+
word-wrap: break-word;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* 预览内容样式 */
|
|
234
|
+
.preview-content img {
|
|
235
|
+
max-width: 100%;
|
|
236
|
+
height: auto;
|
|
237
|
+
display: block;
|
|
238
|
+
margin: 12px 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.preview-content h1 {
|
|
242
|
+
font-size: 28px;
|
|
243
|
+
margin: 24px 0 16px;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.preview-content h2 {
|
|
247
|
+
font-size: 22px;
|
|
248
|
+
margin: 20px 0 12px;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.preview-content pre {
|
|
252
|
+
background: #f6f8fa;
|
|
253
|
+
padding: 16px;
|
|
254
|
+
border-radius: 8px;
|
|
255
|
+
overflow-x: auto;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.preview-content code {
|
|
259
|
+
background: #f6f8fa;
|
|
260
|
+
padding: 2px 6px;
|
|
261
|
+
border-radius: 4px;
|
|
262
|
+
font-family: 'Courier New', monospace;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.preview-content table {
|
|
266
|
+
width: 100%;
|
|
267
|
+
border-collapse: collapse;
|
|
268
|
+
margin: 12px 0;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.preview-content th,
|
|
272
|
+
.preview-content td {
|
|
273
|
+
border: 1px solid #e8e8e8;
|
|
274
|
+
padding: 8px 12px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.preview-content th {
|
|
278
|
+
background: #f5f7fa;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/* 滚动条样式 */
|
|
282
|
+
.preview-content::-webkit-scrollbar {
|
|
283
|
+
width: 6px;
|
|
284
|
+
height: 6px;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.preview-content::-webkit-scrollbar-track {
|
|
288
|
+
background: #f1f1f1;
|
|
289
|
+
border-radius: 3px;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.preview-content::-webkit-scrollbar-thumb {
|
|
293
|
+
background: #c1c1c1;
|
|
294
|
+
border-radius: 3px;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.preview-content::-webkit-scrollbar-thumb:hover {
|
|
298
|
+
background: #a8a8a8;
|
|
299
|
+
}
|
|
300
|
+
</style>
|