2026-04-02 00:31:28 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { LeftOutlined } from "@ant-design/icons-vue";
|
|
|
|
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query";
|
|
|
|
|
import { message } from "ant-design-vue";
|
2026-04-07 09:19:03 +08:00
|
|
|
import { computed, ref, watch } from "vue";
|
2026-04-02 00:31:28 +08:00
|
|
|
import { useI18n } from "vue-i18n";
|
|
|
|
|
import { useRoute, useRouter } from "vue-router";
|
|
|
|
|
import { MilkdownProvider } from "@milkdown/vue";
|
|
|
|
|
|
|
|
|
|
import ArticleEditorCanvas from "@/components/ArticleEditorCanvas.vue";
|
2026-04-07 09:19:03 +08:00
|
|
|
import CoverPickerModal from "@/components/CoverPickerModal.vue";
|
2026-04-03 00:39:15 +08:00
|
|
|
import PublishArticleModal from "@/components/PublishArticleModal.vue";
|
2026-04-02 00:31:28 +08:00
|
|
|
import PublishPlatformSelector from "@/components/PublishPlatformSelector.vue";
|
2026-04-07 09:19:03 +08:00
|
|
|
import { articlesApi, mediaApi, resolveApiURL } from "@/lib/api";
|
|
|
|
|
import {
|
|
|
|
|
coverUploadRequired,
|
|
|
|
|
deriveCoverFileName,
|
|
|
|
|
} from "@/lib/cover-requirements";
|
2026-04-02 00:31:28 +08:00
|
|
|
import { formatError } from "@/lib/errors";
|
2026-04-06 15:41:49 +08:00
|
|
|
import {
|
|
|
|
|
buildPublishPlatformOptions,
|
|
|
|
|
normalizePublishPlatformIds,
|
|
|
|
|
} from "@/lib/publish-platforms";
|
2026-04-02 00:31:28 +08:00
|
|
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
|
const { t } = useI18n();
|
|
|
|
|
|
|
|
|
|
const articleId = computed(() => Number(route.params.id));
|
|
|
|
|
const title = ref("");
|
|
|
|
|
const markdown = ref("");
|
|
|
|
|
const initialTitle = ref("");
|
|
|
|
|
const initialMarkdown = ref("");
|
|
|
|
|
const publishPlatforms = ref<string[]>([]);
|
|
|
|
|
const initialPublishPlatforms = ref<string[]>([]);
|
2026-04-07 09:19:03 +08:00
|
|
|
const coverEnabled = ref(false);
|
|
|
|
|
const coverAssetUrl = ref("");
|
|
|
|
|
const coverFileName = ref("");
|
|
|
|
|
const initialCoverAssetUrl = ref("");
|
|
|
|
|
const coverPickerOpen = ref(false);
|
2026-04-02 00:31:28 +08:00
|
|
|
const leaveModalOpen = ref(false);
|
2026-04-03 00:39:15 +08:00
|
|
|
const publishModalOpen = ref(false);
|
2026-04-02 00:31:28 +08:00
|
|
|
|
|
|
|
|
const detailQuery = useQuery({
|
|
|
|
|
queryKey: computed(() => ["articles", "detail", articleId.value]),
|
|
|
|
|
enabled: computed(() => Number.isInteger(articleId.value) && articleId.value > 0),
|
|
|
|
|
queryFn: () => articlesApi.detail(articleId.value),
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-06 15:41:49 +08:00
|
|
|
const platformsQuery = useQuery({
|
|
|
|
|
queryKey: ["media", "platforms", "article-editor"],
|
|
|
|
|
queryFn: () => mediaApi.platforms(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const accountsQuery = useQuery({
|
|
|
|
|
queryKey: ["media", "platform-accounts", "article-editor"],
|
|
|
|
|
queryFn: () => mediaApi.accounts(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const publishPlatformOptions = computed(() =>
|
|
|
|
|
buildPublishPlatformOptions(platformsQuery.data.value ?? [], accountsQuery.data.value),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const publishPlatformsLoading = computed(
|
|
|
|
|
() => platformsQuery.isPending.value || accountsQuery.isPending.value,
|
|
|
|
|
);
|
|
|
|
|
|
2026-04-02 00:31:28 +08:00
|
|
|
watch(
|
|
|
|
|
() => detailQuery.data.value,
|
|
|
|
|
(detail) => {
|
|
|
|
|
if (!detail) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const nextTitle = detail.title ?? "";
|
|
|
|
|
const nextMarkdown = stripLeadingTitleHeading(nextTitle, detail.markdown_content ?? "");
|
|
|
|
|
|
|
|
|
|
title.value = nextTitle;
|
|
|
|
|
markdown.value = nextMarkdown;
|
|
|
|
|
initialTitle.value = nextTitle;
|
|
|
|
|
initialMarkdown.value = nextMarkdown;
|
2026-04-06 15:41:49 +08:00
|
|
|
publishPlatforms.value = normalizePublishPlatformIds(detail.platforms ?? []);
|
2026-04-02 00:31:28 +08:00
|
|
|
initialPublishPlatforms.value = [...publishPlatforms.value];
|
2026-04-07 09:19:03 +08:00
|
|
|
coverAssetUrl.value = resolveApiURL(detail.cover_asset_url);
|
|
|
|
|
coverFileName.value = deriveCoverFileName(coverAssetUrl.value);
|
|
|
|
|
initialCoverAssetUrl.value = coverAssetUrl.value;
|
|
|
|
|
coverEnabled.value = Boolean(coverAssetUrl.value);
|
2026-04-02 00:31:28 +08:00
|
|
|
},
|
|
|
|
|
{ immediate: true },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const detail = computed(() => detailQuery.data.value);
|
|
|
|
|
const editorLocked = computed(() => detail.value?.generate_status !== "completed");
|
2026-04-07 09:19:03 +08:00
|
|
|
const coverRequired = computed(() => coverUploadRequired(publishPlatforms.value));
|
|
|
|
|
const normalizedCoverValue = computed(() => {
|
|
|
|
|
if (!coverEnabled.value && !coverRequired.value) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return coverAssetUrl.value.trim();
|
|
|
|
|
});
|
2026-04-02 00:31:28 +08:00
|
|
|
const hasChanges = computed(
|
|
|
|
|
() =>
|
|
|
|
|
title.value.trim() !== initialTitle.value.trim() ||
|
|
|
|
|
markdown.value !== initialMarkdown.value ||
|
2026-04-07 09:19:03 +08:00
|
|
|
serializePlatformSelection(publishPlatforms.value) !== serializePlatformSelection(initialPublishPlatforms.value) ||
|
|
|
|
|
normalizedCoverValue.value !== initialCoverAssetUrl.value.trim(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
coverRequired,
|
|
|
|
|
(required) => {
|
|
|
|
|
if (required) {
|
|
|
|
|
coverEnabled.value = true;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true },
|
2026-04-02 00:31:28 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const saveMutation = useMutation({
|
|
|
|
|
mutationFn: () =>
|
|
|
|
|
articlesApi.update(articleId.value, {
|
|
|
|
|
title: title.value.trim(),
|
|
|
|
|
markdown_content: markdown.value,
|
2026-04-06 15:41:49 +08:00
|
|
|
platforms: normalizePublishPlatformIds(publishPlatforms.value),
|
2026-04-07 09:19:03 +08:00
|
|
|
cover_asset_url: normalizedCoverValue.value,
|
2026-04-02 00:31:28 +08:00
|
|
|
}),
|
|
|
|
|
onSuccess: async (data) => {
|
|
|
|
|
message.success(t("article.editor.messages.saved"));
|
|
|
|
|
title.value = data.title ?? "";
|
|
|
|
|
markdown.value = data.markdown_content ?? "";
|
|
|
|
|
initialTitle.value = title.value;
|
|
|
|
|
initialMarkdown.value = markdown.value;
|
2026-04-06 15:41:49 +08:00
|
|
|
publishPlatforms.value = normalizePublishPlatformIds(data.platforms ?? []);
|
2026-04-02 00:31:28 +08:00
|
|
|
initialPublishPlatforms.value = [...publishPlatforms.value];
|
2026-04-07 09:19:03 +08:00
|
|
|
coverAssetUrl.value = resolveApiURL(data.cover_asset_url);
|
|
|
|
|
coverFileName.value = deriveCoverFileName(coverAssetUrl.value);
|
|
|
|
|
initialCoverAssetUrl.value = coverAssetUrl.value;
|
|
|
|
|
coverEnabled.value = coverRequired.value || Boolean(coverAssetUrl.value);
|
2026-04-02 00:31:28 +08:00
|
|
|
await Promise.all([
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ["articles"] }),
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ["workspace"] }),
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ["templates"] }),
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ["articles", "detail", articleId.value] }),
|
2026-04-13 16:08:12 +08:00
|
|
|
queryClient.invalidateQueries({ queryKey: ["articles", "detail", articleId.value, "publish-modal"] }),
|
2026-04-02 00:31:28 +08:00
|
|
|
]);
|
|
|
|
|
},
|
|
|
|
|
onError: (error) => {
|
|
|
|
|
message.error(formatError(error));
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const saveDisabled = computed(
|
|
|
|
|
() => editorLocked.value || saveMutation.isPending.value || title.value.trim() === "" || !hasChanges.value,
|
|
|
|
|
);
|
|
|
|
|
const leaveSaveDisabled = computed(
|
|
|
|
|
() => editorLocked.value || saveMutation.isPending.value || title.value.trim() === "",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
async function saveArticle(): Promise<boolean> {
|
|
|
|
|
if (leaveSaveDisabled.value || !hasChanges.value) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await saveMutation.mutateAsync();
|
|
|
|
|
return true;
|
|
|
|
|
} catch {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function handleSave(): Promise<void> {
|
|
|
|
|
if (saveDisabled.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await saveArticle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function handlePublish(): Promise<void> {
|
|
|
|
|
if (editorLocked.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hasChanges.value && !saveMutation.isPending.value) {
|
|
|
|
|
try {
|
|
|
|
|
await saveMutation.mutateAsync();
|
|
|
|
|
} catch {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-03 00:39:15 +08:00
|
|
|
publishModalOpen.value = true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-05 22:10:05 +08:00
|
|
|
async function uploadEditorImage(file: File): Promise<string> {
|
|
|
|
|
const result = await articlesApi.uploadImage(articleId.value, file);
|
|
|
|
|
return result.url;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-07 09:19:03 +08:00
|
|
|
function handleCoverPicked(payload: { url: string; fileName: string }): void {
|
|
|
|
|
coverAssetUrl.value = payload.url;
|
|
|
|
|
coverFileName.value = payload.fileName;
|
|
|
|
|
coverEnabled.value = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleRemoveCover(): void {
|
|
|
|
|
coverAssetUrl.value = "";
|
|
|
|
|
coverFileName.value = "";
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-03 00:39:15 +08:00
|
|
|
async function handlePublished(): Promise<void> {
|
|
|
|
|
await Promise.all([
|
|
|
|
|
detailQuery.refetch(),
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ["articles"] }),
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ["workspace"] }),
|
|
|
|
|
]);
|
2026-04-02 00:31:28 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-06 22:18:55 +08:00
|
|
|
const isFreeCreateEmpty = computed(
|
|
|
|
|
() =>
|
|
|
|
|
detail.value?.source_type === "free_create" &&
|
|
|
|
|
title.value.trim() === "" &&
|
|
|
|
|
markdown.value.trim() === "",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const isFreeCreateInitiallyEmpty = computed(
|
|
|
|
|
() =>
|
|
|
|
|
detail.value?.source_type === "free_create" &&
|
|
|
|
|
initialTitle.value.trim() === "" &&
|
|
|
|
|
initialMarkdown.value.trim() === "",
|
|
|
|
|
);
|
|
|
|
|
|
2026-04-02 00:31:28 +08:00
|
|
|
function handleBack(): void {
|
|
|
|
|
if (saveMutation.isPending.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-06 22:18:55 +08:00
|
|
|
if (isFreeCreateEmpty.value) {
|
|
|
|
|
void cleanupEmptyFreeCreate();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-02 00:31:28 +08:00
|
|
|
if (hasChanges.value) {
|
|
|
|
|
leaveModalOpen.value = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
navigateBack();
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-06 22:18:55 +08:00
|
|
|
async function cleanupEmptyFreeCreate(): Promise<void> {
|
|
|
|
|
try {
|
|
|
|
|
await articlesApi.remove(articleId.value);
|
|
|
|
|
await Promise.all([
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ["articles"] }),
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ["workspace"] }),
|
|
|
|
|
]);
|
|
|
|
|
} catch {
|
|
|
|
|
// ignore cleanup errors
|
|
|
|
|
}
|
|
|
|
|
navigateBack();
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-02 00:31:28 +08:00
|
|
|
function navigateBack(): void {
|
|
|
|
|
if (window.history.length > 1) {
|
|
|
|
|
void router.back();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void router.push("/articles/templates");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleStay(): void {
|
|
|
|
|
leaveModalOpen.value = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleDiscardLeave(): void {
|
|
|
|
|
leaveModalOpen.value = false;
|
2026-04-06 22:18:55 +08:00
|
|
|
if (isFreeCreateInitiallyEmpty.value) {
|
|
|
|
|
void cleanupEmptyFreeCreate();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-04-02 00:31:28 +08:00
|
|
|
navigateBack();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function handleSaveAndLeave(): Promise<void> {
|
|
|
|
|
const saved = await saveArticle();
|
|
|
|
|
if (!saved) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
leaveModalOpen.value = false;
|
|
|
|
|
navigateBack();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function stripLeadingTitleHeading(titleValue: string, markdownValue: string): string {
|
|
|
|
|
const normalizedTitle = titleValue.trim();
|
|
|
|
|
if (!normalizedTitle) {
|
|
|
|
|
return markdownValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const normalizedMarkdown = markdownValue.replace(/^\uFEFF/, "");
|
|
|
|
|
const match = normalizedMarkdown.match(/^#\s+(.+?)\s*(\r?\n|$)/);
|
|
|
|
|
if (!match) {
|
|
|
|
|
return markdownValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (match[1].trim() !== normalizedTitle) {
|
|
|
|
|
return markdownValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return normalizedMarkdown.slice(match[0].length).replace(/^\s*\r?\n/, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function serializePlatformSelection(platformIds: string[]): string {
|
2026-04-06 15:41:49 +08:00
|
|
|
return normalizePublishPlatformIds(platformIds)
|
2026-04-02 00:31:28 +08:00
|
|
|
.sort()
|
|
|
|
|
.join(",");
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="article-editor-view">
|
|
|
|
|
<header class="article-editor-view__topbar">
|
|
|
|
|
<button class="article-editor-view__back" type="button" @click="handleBack">
|
|
|
|
|
<LeftOutlined />
|
|
|
|
|
<span>{{ t("common.back") }}</span>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<div class="article-editor-view__actions">
|
|
|
|
|
<a-button :disabled="saveDisabled" :loading="saveMutation.isPending.value" @click="handleSave">
|
|
|
|
|
{{ t("common.save") }}
|
|
|
|
|
</a-button>
|
|
|
|
|
<a-button type="primary" :disabled="editorLocked" @click="handlePublish">
|
|
|
|
|
{{ t("article.editor.publish") }}
|
|
|
|
|
</a-button>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<div v-if="detailQuery.isPending.value" class="article-editor-view__loading">
|
|
|
|
|
<a-skeleton active :paragraph="{ rows: 14 }" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<template v-else-if="detail">
|
|
|
|
|
<a-alert
|
|
|
|
|
v-if="editorLocked"
|
|
|
|
|
class="article-editor-view__alert"
|
|
|
|
|
type="info"
|
|
|
|
|
show-icon
|
|
|
|
|
:message="t('article.editor.messages.locked')"
|
|
|
|
|
/>
|
|
|
|
|
<div class="article-editor-view__layout">
|
|
|
|
|
<section class="article-editor-view__main">
|
|
|
|
|
<MilkdownProvider>
|
|
|
|
|
<ArticleEditorCanvas
|
|
|
|
|
:key="String(articleId)"
|
2026-04-06 22:18:55 +08:00
|
|
|
:article-id="articleId"
|
2026-04-02 00:31:28 +08:00
|
|
|
v-model:title="title"
|
|
|
|
|
v-model="markdown"
|
|
|
|
|
:disabled="editorLocked"
|
2026-04-05 22:10:05 +08:00
|
|
|
:upload-image="uploadEditorImage"
|
2026-04-02 00:31:28 +08:00
|
|
|
/>
|
|
|
|
|
</MilkdownProvider>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<aside class="article-editor-view__rail">
|
|
|
|
|
<section class="article-editor-view__card">
|
|
|
|
|
<h3>{{ t("article.editor.platformsTitle") }}</h3>
|
|
|
|
|
<p>{{ t("article.editor.platformsHint") }}</p>
|
2026-04-06 15:41:49 +08:00
|
|
|
<a-skeleton
|
|
|
|
|
v-if="publishPlatformsLoading"
|
|
|
|
|
active
|
|
|
|
|
:title="false"
|
|
|
|
|
:paragraph="{ rows: 4 }"
|
|
|
|
|
/>
|
2026-04-02 00:31:28 +08:00
|
|
|
<PublishPlatformSelector
|
2026-04-06 15:41:49 +08:00
|
|
|
v-else
|
2026-04-02 00:31:28 +08:00
|
|
|
v-model="publishPlatforms"
|
|
|
|
|
class="article-editor-view__platforms"
|
2026-04-06 15:41:49 +08:00
|
|
|
:platforms="publishPlatformOptions"
|
2026-04-02 00:31:28 +08:00
|
|
|
:disabled="editorLocked"
|
|
|
|
|
/>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class="article-editor-view__card">
|
|
|
|
|
<div class="article-editor-view__card-head">
|
|
|
|
|
<div>
|
|
|
|
|
<h3>{{ t("article.editor.coverTitle") }}</h3>
|
2026-04-07 09:19:03 +08:00
|
|
|
<p>{{ coverRequired ? t("article.editor.coverRequired") : t("article.editor.coverHint") }}</p>
|
2026-04-02 00:31:28 +08:00
|
|
|
</div>
|
2026-04-07 09:19:03 +08:00
|
|
|
<a-switch
|
|
|
|
|
v-model:checked="coverEnabled"
|
|
|
|
|
:disabled="coverRequired"
|
|
|
|
|
/>
|
2026-04-02 00:31:28 +08:00
|
|
|
</div>
|
|
|
|
|
|
2026-04-07 09:19:03 +08:00
|
|
|
<div
|
|
|
|
|
v-if="coverEnabled || coverRequired"
|
|
|
|
|
class="article-editor-view__cover-panel"
|
2026-04-02 00:31:28 +08:00
|
|
|
>
|
2026-04-07 09:19:03 +08:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="article-editor-view__cover-dropzone"
|
|
|
|
|
@click="coverPickerOpen = true"
|
|
|
|
|
>
|
|
|
|
|
<template v-if="coverAssetUrl">
|
|
|
|
|
<img :src="coverAssetUrl" alt="cover preview" />
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<span class="article-editor-view__cover-plus">+</span>
|
|
|
|
|
<span>{{ t("article.editor.coverUpload") }}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-else class="article-editor-view__cover-off">
|
|
|
|
|
{{ t("article.editor.coverOff") }}
|
|
|
|
|
</div>
|
2026-04-02 00:31:28 +08:00
|
|
|
</section>
|
|
|
|
|
</aside>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<a-empty v-else :description="t('common.noData')" />
|
|
|
|
|
|
|
|
|
|
<a-modal
|
|
|
|
|
:open="leaveModalOpen"
|
|
|
|
|
:title="t('article.editor.leaveConfirm.title')"
|
|
|
|
|
:closable="false"
|
|
|
|
|
:mask-closable="false"
|
|
|
|
|
@cancel="handleStay"
|
|
|
|
|
>
|
|
|
|
|
<p class="article-editor-view__leave-copy">
|
|
|
|
|
{{ t("article.editor.leaveConfirm.description") }}
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
<a-button @click="handleStay">
|
|
|
|
|
{{ t("common.cancel") }}
|
|
|
|
|
</a-button>
|
|
|
|
|
<a-button @click="handleDiscardLeave">
|
|
|
|
|
{{ t("article.editor.leaveConfirm.discard") }}
|
|
|
|
|
</a-button>
|
|
|
|
|
<a-button
|
|
|
|
|
type="primary"
|
|
|
|
|
:loading="saveMutation.isPending.value"
|
|
|
|
|
:disabled="leaveSaveDisabled"
|
|
|
|
|
@click="handleSaveAndLeave"
|
|
|
|
|
>
|
|
|
|
|
{{ t("article.editor.leaveConfirm.saveAndLeave") }}
|
|
|
|
|
</a-button>
|
|
|
|
|
</template>
|
|
|
|
|
</a-modal>
|
2026-04-03 00:39:15 +08:00
|
|
|
|
|
|
|
|
<PublishArticleModal
|
|
|
|
|
v-model:open="publishModalOpen"
|
|
|
|
|
:article-id="detail?.id ?? null"
|
|
|
|
|
@published="handlePublished"
|
|
|
|
|
/>
|
2026-04-07 09:19:03 +08:00
|
|
|
|
|
|
|
|
<CoverPickerModal
|
|
|
|
|
v-model:open="coverPickerOpen"
|
|
|
|
|
:article-id="detail?.id ?? null"
|
|
|
|
|
:platform-ids="publishPlatforms"
|
|
|
|
|
:current-url="coverAssetUrl"
|
|
|
|
|
:current-file-name="coverFileName"
|
|
|
|
|
@confirmed="handleCoverPicked"
|
|
|
|
|
/>
|
2026-04-02 00:31:28 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.article-editor-view {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 18px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__topbar {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
gap: 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__back {
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
padding: 0;
|
|
|
|
|
border: 0;
|
|
|
|
|
background: transparent;
|
|
|
|
|
color: #111827;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__back :deep(.anticon) {
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
width: 36px;
|
|
|
|
|
height: 36px;
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
background: rgba(255, 255, 255, 0.82);
|
|
|
|
|
border: 1px solid rgba(144, 157, 181, 0.24);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__actions {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__main {
|
|
|
|
|
height: calc(100vh - 180px);
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
background: rgba(255, 255, 255, 0.88);
|
|
|
|
|
border: 1px solid rgba(216, 225, 237, 0.9);
|
|
|
|
|
border-radius: 28px;
|
|
|
|
|
box-shadow: 0 18px 40px rgba(15, 23, 42, 0.05);
|
|
|
|
|
backdrop-filter: blur(14px);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__loading,
|
|
|
|
|
.article-editor-view__card {
|
|
|
|
|
padding: 24px;
|
|
|
|
|
background: rgba(255, 255, 255, 0.88);
|
|
|
|
|
border: 1px solid rgba(216, 225, 237, 0.9);
|
|
|
|
|
border-radius: 28px;
|
|
|
|
|
box-shadow: 0 18px 40px rgba(15, 23, 42, 0.05);
|
|
|
|
|
backdrop-filter: blur(14px);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__alert {
|
|
|
|
|
border-radius: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__leave-copy {
|
|
|
|
|
margin: 0;
|
|
|
|
|
color: #475467;
|
|
|
|
|
line-height: 1.75;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__layout {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: minmax(0, 1fr) 360px;
|
|
|
|
|
gap: 18px;
|
|
|
|
|
align-items: start;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__main {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 18px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__card h3 {
|
|
|
|
|
margin: 0;
|
|
|
|
|
color: #101828;
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__rail {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 18px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__card p {
|
|
|
|
|
margin: 6px 0 0;
|
|
|
|
|
color: #667085;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
line-height: 1.7;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__platforms {
|
|
|
|
|
margin-top: 18px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__card-head {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-07 09:19:03 +08:00
|
|
|
.article-editor-view__cover-panel {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: 156px minmax(0, 1fr);
|
|
|
|
|
gap: 16px;
|
|
|
|
|
margin-top: 18px;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-02 00:31:28 +08:00
|
|
|
.article-editor-view__cover-dropzone {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
gap: 8px;
|
2026-04-07 09:19:03 +08:00
|
|
|
min-height: 116px;
|
|
|
|
|
padding: 0;
|
2026-04-02 00:31:28 +08:00
|
|
|
border: 1px dashed #d3dceb;
|
|
|
|
|
border-radius: 20px;
|
|
|
|
|
background:
|
|
|
|
|
radial-gradient(circle at top, rgba(70, 102, 255, 0.08), transparent 45%),
|
|
|
|
|
#fbfcff;
|
|
|
|
|
color: #475467;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__cover-dropzone img {
|
|
|
|
|
width: 100%;
|
2026-04-07 09:19:03 +08:00
|
|
|
height: 116px;
|
2026-04-02 00:31:28 +08:00
|
|
|
object-fit: cover;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-07 09:19:03 +08:00
|
|
|
.article-editor-view__cover-info {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__cover-actions {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__cover-file,
|
|
|
|
|
.article-editor-view__cover-off {
|
|
|
|
|
color: #667085;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
line-height: 1.7;
|
2026-04-02 00:31:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__cover-plus {
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
width: 44px;
|
|
|
|
|
height: 44px;
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
background: #eef4ff;
|
|
|
|
|
color: #355dff;
|
|
|
|
|
font-size: 28px;
|
|
|
|
|
line-height: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: 1200px) {
|
|
|
|
|
.article-editor-view__layout {
|
|
|
|
|
grid-template-columns: 1fr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__rail {
|
|
|
|
|
order: -1;
|
|
|
|
|
}
|
2026-04-07 09:19:03 +08:00
|
|
|
|
|
|
|
|
.article-editor-view__cover-panel {
|
|
|
|
|
grid-template-columns: 1fr;
|
|
|
|
|
}
|
2026-04-02 00:31:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: 768px) {
|
|
|
|
|
.article-editor-view__topbar {
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: stretch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__actions {
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.article-editor-view__actions :deep(.ant-btn) {
|
|
|
|
|
flex: 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|