Skip to content

Commit 16b8864

Browse files
committed
Format code and adjust import/link formatting
Apply code-style and minor cleanup across several files: reformat multi-line imports and function signatures in contentExporter.ts and JsonImport.vue, break long template/component attributes into multiple lines, and standardize trailing semicolons. Update MarkdownImport.vue and WordImport.vue to point attachment links to the console attachment settings (tab=attachment) instead of user settings. Also minor UI template tidy-ups (inline button spacing, multiline icon components with tooltips) and a small status object initialization fix. These are mostly non-functional formatting and UX link adjustments.
1 parent 41c8d55 commit 16b8864

5 files changed

Lines changed: 53 additions & 22 deletions

File tree

ui/src/class/contentExporter.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { downloadContent, downloadContentWithImages } from '@/utils';
22
import { processHTMLLinks } from '@/utils/content';
33
import { downloadImageAsBlob, extractImageReferencesFromContent } from '@/utils/image';
4-
import { consoleApiClient, type ContentWrapper, type Post, type PostRequest } from '@halo-dev/api-client';
4+
import {
5+
consoleApiClient,
6+
type ContentWrapper,
7+
type Post,
8+
type PostRequest,
9+
} from '@halo-dev/api-client';
510
import { Toast } from '@halo-dev/components';
611
import { cloneDeep } from 'es-toolkit';
712
import { ConverterFactory } from './converterFactory';
@@ -255,7 +260,10 @@ export class ContentExporter {
255260
}
256261

257262
if (postRequest.content.content) {
258-
for (const imagePath of extractImageReferencesFromContent(postRequest.content.content, 'html')) {
263+
for (const imagePath of extractImageReferencesFromContent(
264+
postRequest.content.content,
265+
'html'
266+
)) {
259267
imageReferences.add(imagePath);
260268
}
261269
}

ui/src/components/PostExportDropdownItem.vue

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ async function onSubmit(data: ExportForm) {
5151
}
5252
5353
const imageExportModeHelp = computed(() => {
54-
if(exportType.value === 'json') {
54+
if (exportType.value === 'json') {
5555
return 'JSON 导出包含图片时仅支持文件模式,文章数据和图片会一起打包为 ZIP 文件';
5656
}
5757
return imageExportMode.value === 'file'
5858
? '导出为文件时,图片会以附件的形式导出,与文章压缩在一起'
59-
: '导出为内嵌时,图片会以 Base64 的形式嵌入到导出文件中'
59+
: '导出为内嵌时,图片会以 Base64 的形式嵌入到导出文件中';
6060
});
6161
6262
const exportTypeHelp = computed(() => {
63-
if(exportType.value === 'json') {
63+
if (exportType.value === 'json') {
6464
return '导出之后可以在工具 -> 文章导入 -> JSON 导入选项卡中导入文章,也可以在另外的 Halo 站点中导入';
6565
}
66-
})
66+
});
6767
</script>
6868
<template>
6969
<VDropdownItem @click="display = true">导出</VDropdownItem>
@@ -82,7 +82,14 @@ const exportTypeHelp = computed(() => {
8282
name="post-export-form"
8383
@submit="onSubmit"
8484
>
85-
<FormKit v-model="exportType" label="导出格式" type="select" name="type" :options="exportTypeOptions" :help="exportTypeHelp" />
85+
<FormKit
86+
v-model="exportType"
87+
label="导出格式"
88+
type="select"
89+
name="type"
90+
:options="exportTypeOptions"
91+
:help="exportTypeHelp"
92+
/>
8693
<FormKit v-if="value.type !== 'pdf'" label="包含图片" type="checkbox" name="includeImages" />
8794
<FormKit
8895
v-if="value.type !== 'pdf' && value.includeImages"

ui/src/views/tabs/JsonImport.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ async function resolveAttachment(
298298
return await uploadCache.get(cacheKey);
299299
}
300300
301-
function findMatchingImageSource(imagePath: string, imageSources: ImageSource[]): ImageSource | undefined {
301+
function findMatchingImageSource(
302+
imagePath: string,
303+
imageSources: ImageSource[]
304+
): ImageSource | undefined {
302305
const normalizedImagePath = normalizePath(imagePath);
303306
const imageFileName = normalizedImagePath.split('/').pop() || normalizedImagePath;
304307
@@ -362,7 +365,7 @@ function preparePostRequestForImport(postRequest: PostRequest): PostRequest {
362365
// TODO: Support categories and tags
363366
postRequest.post.spec.categories = [];
364367
postRequest.post.spec.tags = [];
365-
postRequest.post.status = {}
368+
postRequest.post.status = {};
366369
367370
return postRequest;
368371
}
@@ -406,7 +409,9 @@ const showAlert = useSessionStorage('plugin:content-tools:json-import-alert', tr
406409
<li>如果 ZIP 已经提前解压,可以额外选择图片文件夹作为图片来源。</li>
407410
<li>
408411
图片会上传到管理端附件配置中的存储策略,请提前在
409-
<a class=":uno: text-gray-900 hover:text-gray-600" href="/console/settings?tab=attachment"
412+
<a
413+
class=":uno: text-gray-900 hover:text-gray-600"
414+
href="/console/settings?tab=attachment"
410415
>附件配置</a
411416
>
412417
中设置。
@@ -522,7 +527,10 @@ const showAlert = useSessionStorage('plugin:content-tools:json-import-alert', tr
522527
v-else-if="task.status === 'rejected'"
523528
class=":uno: inline-flex items-center gap-2"
524529
>
525-
<MingcuteCloseCircleLine v-tooltip="task.error?.toString()" class=":uno: text-red-500" />
530+
<MingcuteCloseCircleLine
531+
v-tooltip="task.error?.toString()"
532+
class=":uno: text-red-500"
533+
/>
526534
<VButton size="sm" :disabled="isBusy" @click="retry(task.id)"> 重试 </VButton>
527535
</div>
528536
<MingcuteTimeLine v-else class=":uno: text-gray-500" />

ui/src/views/tabs/MarkdownImport.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,11 @@ const showAlert = useSessionStorage('plugin:content-tools:markdown-import-alert'
282282
文件和图片的文件夹。
283283
</li>
284284
<li>
285-
图片会上传到与个人中心关联的存储策略,请提前在
286-
<a class=":uno: text-gray-900 hover:text-gray-600" href="/console/settings?tab=user"
287-
>用户设置</a
285+
图片会上传到管理端附件配置中的存储策略,请提前在
286+
<a
287+
class=":uno: text-gray-900 hover:text-gray-600"
288+
href="/console/settings?tab=attachment"
289+
>附件配置</a
288290
>
289291
中设置。
290292
</li>
@@ -423,7 +425,10 @@ const showAlert = useSessionStorage('plugin:content-tools:markdown-import-alert'
423425
v-else-if="task.status === 'rejected'"
424426
class=":uno: inline-flex items-center gap-2"
425427
>
426-
<MingcuteCloseCircleLine v-tooltip="task.error?.toString()" class=":uno: text-red-500" />
428+
<MingcuteCloseCircleLine
429+
v-tooltip="task.error?.toString()"
430+
class=":uno: text-red-500"
431+
/>
427432
<VButton size="sm" :disabled="isBusy" @click="retry(task.id)"> 重试 </VButton>
428433
</div>
429434
<MingcuteTimeLine v-else class=":uno: text-gray-500" />

ui/src/views/tabs/WordImport.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,11 @@ const showAlert = useSessionStorage('plugin:content-tools:word-import-alert', tr
226226
<li>由于 Word 文件的复杂性,可能无法完美解析内容格式,建议导入之后自行调整。</li>
227227
<li>支持同时导入 Word 文件中的图片资源,其他资源暂不支持。</li>
228228
<li>
229-
图片会上传到与个人中心关联的存储策略,请提前在
230-
<a class=":uno: text-gray-900 hover:text-gray-600" href="/console/settings?tab=user"
231-
>用户设置</a
229+
图片会上传到管理端附件配置中的存储策略,请提前在
230+
<a
231+
class=":uno: text-gray-900 hover:text-gray-600"
232+
href="/console/settings?tab=attachment"
233+
>附件配置</a
232234
>
233235
中设置。
234236
</li>
@@ -239,9 +241,7 @@ const showAlert = useSessionStorage('plugin:content-tools:word-import-alert', tr
239241
<VSpace>
240242
<VButton :disabled="isBusy" @click="fileInput?.click()">选择 Word 文档</VButton>
241243
<VButton :disabled="isBusy" @click="folderInput?.click()">选择 Word 文档文件夹</VButton>
242-
<VButton v-if="tasks.length > 0" :disabled="isBusy" @click="clear">
243-
清空文件
244-
</VButton>
244+
<VButton v-if="tasks.length > 0" :disabled="isBusy" @click="clear"> 清空文件 </VButton>
245245

246246
<input
247247
ref="fileInput"
@@ -350,7 +350,10 @@ const showAlert = useSessionStorage('plugin:content-tools:word-import-alert', tr
350350
v-else-if="task.status === 'rejected'"
351351
class=":uno: inline-flex items-center gap-2"
352352
>
353-
<MingcuteCloseCircleLine v-tooltip="task.error?.toString()" class=":uno: text-red-500" />
353+
<MingcuteCloseCircleLine
354+
v-tooltip="task.error?.toString()"
355+
class=":uno: text-red-500"
356+
/>
354357
<VButton size="sm" :disabled="isBusy" @click="retry(task.id)"> 重试 </VButton>
355358
</div>
356359
<MingcuteTimeLine v-else class=":uno: text-gray-500" />

0 commit comments

Comments
 (0)