import { defineComponent, ref, reactive, resolveComponent, mergeProps, withCtx, createTextVNode, unref, createVNode, toDisplayString, isRef, createBlock, createCommentVNode, openBlock, Fragment, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrRenderComponent, ssrInterpolate, ssrRenderAttr } from 'vue/server-renderer';
import { PlusOutlined, ReloadOutlined } from '@ant-design/icons-vue';
import { message } from 'ant-design-vue';
import { p as pageAppArticle, u as updateAppArticle, r as removeAppArticle, a as addAppArticle } from './index-DLTWNMRy.mjs';
import { u as uploadFile } from './index-SD8M3klL.mjs';
import { a as _export_sfc, c as useHead } from './server.mjs';
import './request-BIxQh2im.mjs';
import '../nitro/nitro.mjs';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:url';
import 'better-sqlite3';
import 'vue-router';
import '@babel/runtime/helpers/esm/extends';
import 'stylis';
import 'dayjs';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'unhead/server';
import 'devalue';
import 'unhead/plugins';
import 'unhead/utils';
const ANNOUNCE_MODEL = "announcement";
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "announcements",
__ssrInlineRender: true,
setup(__props) {
useHead({ title: "公告管理 - 平台管理" });
const loading = ref(false);
const imageUploading = ref(false);
const announcements2 = ref([]);
const filterStatus = ref(void 0);
const searchKeyword = ref("");
const totalCount = ref(0);
const publishedCount = ref(0);
const recommendCount = ref(0);
const pagination = reactive({ current: 1, pageSize: 20, total: 0, showSizeChanger: true, showQuickJumper: true });
const columns = [
{ title: "公告信息", key: "info", width: 420 },
{ title: "状态", key: "status", width: 100 },
{ title: "阅读量", key: "views", width: 100 },
{ title: "置顶", key: "recommend", width: 80 },
{ title: "发布时间", key: "createTime", width: 120 },
{ title: "操作", key: "action", width: 170 }
];
const showFormModal = ref(false);
const saving = ref(false);
const editing = ref(null);
const formData = reactive({ title: "", overview: "", content: "", status: 0, image: "" });
const formPin = ref(false);
const showPreviewModal = ref(false);
const previewData = ref(null);
const showImagePreview = ref(false);
const previewImageUrl = ref("");
async function loadAnnouncements() {
loading.value = true;
try {
const res = await pageAppArticle({
page: pagination.current,
limit: pagination.pageSize,
model: ANNOUNCE_MODEL,
status: filterStatus.value,
keywords: searchKeyword.value || void 0
});
announcements2.value = res?.list || [];
pagination.total = res?.count || 0;
loadStats();
} catch {
message.error("加载公告列表失败");
} finally {
loading.value = false;
}
}
async function loadStats() {
try {
const [allRes, pubRes, pinRes] = await Promise.allSettled([
pageAppArticle({ page: 1, limit: 1, model: ANNOUNCE_MODEL }),
pageAppArticle({ page: 1, limit: 1, model: ANNOUNCE_MODEL, status: 0 }),
pageAppArticle({ page: 1, limit: 1, model: ANNOUNCE_MODEL, recommend: 1 })
]);
totalCount.value = allRes.status === "fulfilled" ? allRes.value?.count || 0 : 0;
publishedCount.value = pubRes.status === "fulfilled" ? pubRes.value?.count || 0 : 0;
recommendCount.value = pinRes.status === "fulfilled" ? pinRes.value?.count || 0 : 0;
} catch {
}
}
function handleSearch() {
pagination.current = 1;
loadAnnouncements();
}
function handleTableChange(pag) {
pagination.current = pag.current;
pagination.pageSize = pag.pageSize;
loadAnnouncements();
}
function resetForm() {
Object.assign(formData, {
articleId: void 0,
title: "",
overview: "",
content: "",
status: 0,
image: ""
});
formPin.value = false;
}
function handleCreate() {
editing.value = null;
resetForm();
showFormModal.value = true;
}
function handleEdit(record) {
editing.value = record;
Object.assign(formData, {
articleId: record.articleId,
title: record.title || "",
overview: record.overview || "",
content: record.content || "",
status: record.status ?? 0,
image: record.image || ""
});
formPin.value = !!record.recommend;
showFormModal.value = true;
}
function handleView(record) {
previewData.value = record;
showPreviewModal.value = true;
}
async function handleSave() {
if (!formData.title?.trim()) {
message.warning("请输入公告标题");
return;
}
if (!formData.content?.trim()) {
message.warning("请输入公告内容");
return;
}
saving.value = true;
try {
const data = {
...formData,
model: ANNOUNCE_MODEL,
recommend: formPin.value ? 1 : 0
};
if (editing.value?.articleId) {
await updateAppArticle(data);
message.success("公告已更新");
} else {
await addAppArticle(data);
message.success("公告已发布");
}
showFormModal.value = false;
loadAnnouncements();
} catch (e) {
message.error(e?.message || "保存失败");
} finally {
saving.value = false;
}
}
async function handleDelete(record) {
try {
await removeAppArticle(record.articleId);
message.success("公告已删除");
loadAnnouncements();
} catch (e) {
message.error(e?.message || "删除失败");
}
}
async function handleTogglePin(record, val) {
try {
await updateAppArticle({ articleId: record.articleId, recommend: val ? 1 : 0 });
message.success(val ? "已置顶" : "已取消置顶");
loadAnnouncements();
} catch (e) {
message.error(e?.message || "操作失败");
}
}
function beforeImageUpload(file) {
if (!file.type.startsWith("image/")) {
message.error("只能上传图片文件");
return false;
}
if (file.size > 5 * 1024 * 1024) {
message.error("图片大小不能超过 5MB");
return false;
}
return true;
}
async function handleCoverUpload(option) {
const rawFile = option.file;
if (!rawFile) return;
imageUploading.value = true;
try {
const record = await uploadFile(rawFile);
const url = (record?.url || record?.downloadUrl || "").trim();
if (!url) throw new Error("上传成功但未返回图片地址");
formData.image = url;
option.onSuccess?.(record, rawFile);
message.success("封面上传成功");
} catch (e) {
option.onError?.(e);
message.error(e instanceof Error ? e.message : "封面上传失败");
} finally {
imageUploading.value = false;
}
}
function handleRemoveCover() {
formData.image = "";
}
function handlePreviewImage(url) {
if (!url) return;
previewImageUrl.value = url;
showImagePreview.value = true;
}
return (_ctx, _push, _parent, _attrs) => {
const _component_a_space = resolveComponent("a-space");
const _component_a_button = resolveComponent("a-button");
const _component_a_row = resolveComponent("a-row");
const _component_a_col = resolveComponent("a-col");
const _component_a_select = resolveComponent("a-select");
const _component_a_select_option = resolveComponent("a-select-option");
const _component_a_input_search = resolveComponent("a-input-search");
const _component_a_table = resolveComponent("a-table");
const _component_a_tag = resolveComponent("a-tag");
const _component_a_switch = resolveComponent("a-switch");
const _component_a_popconfirm = resolveComponent("a-popconfirm");
const _component_a_modal = resolveComponent("a-modal");
const _component_a_form = resolveComponent("a-form");
const _component_a_form_item = resolveComponent("a-form-item");
const _component_a_input = resolveComponent("a-input");
const _component_a_upload = resolveComponent("a-upload");
const _component_a_textarea = resolveComponent("a-textarea");
const _component_a_divider = resolveComponent("a-divider");
_push(`
`);
_push(ssrRenderComponent(_component_a_row, {
gutter: [16, 16],
class: "mb-6"
}, {
default: withCtx((_, _push2, _parent2, _scopeId) => {
if (_push2) {
_push2(ssrRenderComponent(_component_a_col, {
xs: 12,
md: 8
}, {
default: withCtx((_2, _push3, _parent3, _scopeId2) => {
if (_push3) {
_push3(`
📢
${ssrInterpolate(unref(totalCount))}
全部公告
`);
} else {
return [
createVNode("div", { class: "stat-card blue" }, [
createVNode("div", { class: "stat-icon" }, "📢"),
createVNode("div", { class: "stat-info" }, [
createVNode("div", { class: "stat-value" }, toDisplayString(unref(totalCount)), 1),
createVNode("div", { class: "stat-label" }, "全部公告")
])
])
];
}
}),
_: 1
}, _parent2, _scopeId));
_push2(ssrRenderComponent(_component_a_col, {
xs: 12,
md: 8
}, {
default: withCtx((_2, _push3, _parent3, _scopeId2) => {
if (_push3) {
_push3(`
✅
${ssrInterpolate(unref(publishedCount))}
已发布
`);
} else {
return [
createVNode("div", { class: "stat-card green" }, [
createVNode("div", { class: "stat-icon" }, "✅"),
createVNode("div", { class: "stat-info" }, [
createVNode("div", { class: "stat-value" }, toDisplayString(unref(publishedCount)), 1),
createVNode("div", { class: "stat-label" }, "已发布")
])
])
];
}
}),
_: 1
}, _parent2, _scopeId));
_push2(ssrRenderComponent(_component_a_col, {
xs: 12,
md: 8
}, {
default: withCtx((_2, _push3, _parent3, _scopeId2) => {
if (_push3) {
_push3(`
⭐
${ssrInterpolate(unref(recommendCount))}
置顶公告
`);
} else {
return [
createVNode("div", { class: "stat-card orange" }, [
createVNode("div", { class: "stat-icon" }, "⭐"),
createVNode("div", { class: "stat-info" }, [
createVNode("div", { class: "stat-value" }, toDisplayString(unref(recommendCount)), 1),
createVNode("div", { class: "stat-label" }, "置顶公告")
])
])
];
}
}),
_: 1
}, _parent2, _scopeId));
} else {
return [
createVNode(_component_a_col, {
xs: 12,
md: 8
}, {
default: withCtx(() => [
createVNode("div", { class: "stat-card blue" }, [
createVNode("div", { class: "stat-icon" }, "📢"),
createVNode("div", { class: "stat-info" }, [
createVNode("div", { class: "stat-value" }, toDisplayString(unref(totalCount)), 1),
createVNode("div", { class: "stat-label" }, "全部公告")
])
])
]),
_: 1
}),
createVNode(_component_a_col, {
xs: 12,
md: 8
}, {
default: withCtx(() => [
createVNode("div", { class: "stat-card green" }, [
createVNode("div", { class: "stat-icon" }, "✅"),
createVNode("div", { class: "stat-info" }, [
createVNode("div", { class: "stat-value" }, toDisplayString(unref(publishedCount)), 1),
createVNode("div", { class: "stat-label" }, "已发布")
])
])
]),
_: 1
}),
createVNode(_component_a_col, {
xs: 12,
md: 8
}, {
default: withCtx(() => [
createVNode("div", { class: "stat-card orange" }, [
createVNode("div", { class: "stat-icon" }, "⭐"),
createVNode("div", { class: "stat-info" }, [
createVNode("div", { class: "stat-value" }, toDisplayString(unref(recommendCount)), 1),
createVNode("div", { class: "stat-label" }, "置顶公告")
])
])
]),
_: 1
})
];
}
}),
_: 1
}, _parent));
_push(`
`);
_push(ssrRenderComponent(_component_a_table, {
columns,
"data-source": unref(announcements2),
loading: unref(loading),
pagination: unref(pagination),
"row-key": "articleId",
onChange: handleTableChange,
size: "middle"
}, {
bodyCell: withCtx(({ column, record }, _push2, _parent2, _scopeId) => {
if (_push2) {
if (column.key === "info") {
_push2(`
`);
if (record.image) {
_push2(`
![]()
`);
} else {
_push2(`
📢
`);
}
_push2(`
`);
if (record.recommend) {
_push2(`📌 置顶`);
} else {
_push2(``);
}
_push2(` ${ssrInterpolate(record.title)}
${ssrInterpolate(record.overview || "暂无摘要")}
`);
} else {
_push2(``);
}
if (column.key === "status") {
_push2(ssrRenderComponent(_component_a_tag, {
color: record.status === 0 ? "success" : "default"
}, {
default: withCtx((_, _push3, _parent3, _scopeId2) => {
if (_push3) {
_push3(`${ssrInterpolate(record.status === 0 ? "已发布" : "草稿")}`);
} else {
return [
createTextVNode(toDisplayString(record.status === 0 ? "已发布" : "草稿"), 1)
];
}
}),
_: 2
}, _parent2, _scopeId));
} else {
_push2(``);
}
if (column.key === "views") {
_push2(`
👁 ${ssrInterpolate(record.actualViews || 0)}`);
} else {
_push2(``);
}
if (column.key === "recommend") {
_push2(ssrRenderComponent(_component_a_switch, {
checked: !!record.recommend,
size: "small",
onChange: (val) => handleTogglePin(record, val)
}, null, _parent2, _scopeId));
} else {
_push2(``);
}
if (column.key === "createTime") {
_push2(`
${ssrInterpolate(record.createTime?.substring(0, 10) || "-")}`);
} else {
_push2(``);
}
if (column.key === "action") {
_push2(ssrRenderComponent(_component_a_space, null, {
default: withCtx((_, _push3, _parent3, _scopeId2) => {
if (_push3) {
_push3(ssrRenderComponent(_component_a_button, {
type: "link",
size: "small",
onClick: ($event) => handleView(record)
}, {
default: withCtx((_2, _push4, _parent4, _scopeId3) => {
if (_push4) {
_push4(`预览`);
} else {
return [
createTextVNode("预览")
];
}
}),
_: 2
}, _parent3, _scopeId2));
_push3(ssrRenderComponent(_component_a_button, {
type: "link",
size: "small",
onClick: ($event) => handleEdit(record)
}, {
default: withCtx((_2, _push4, _parent4, _scopeId3) => {
if (_push4) {
_push4(`编辑`);
} else {
return [
createTextVNode("编辑")
];
}
}),
_: 2
}, _parent3, _scopeId2));
_push3(ssrRenderComponent(_component_a_popconfirm, {
title: "确认删除此公告?",
onConfirm: ($event) => handleDelete(record)
}, {
default: withCtx((_2, _push4, _parent4, _scopeId3) => {
if (_push4) {
_push4(ssrRenderComponent(_component_a_button, {
type: "link",
size: "small",
danger: ""
}, {
default: withCtx((_3, _push5, _parent5, _scopeId4) => {
if (_push5) {
_push5(`删除`);
} else {
return [
createTextVNode("删除")
];
}
}),
_: 2
}, _parent4, _scopeId3));
} else {
return [
createVNode(_component_a_button, {
type: "link",
size: "small",
danger: ""
}, {
default: withCtx(() => [
createTextVNode("删除")
]),
_: 1
})
];
}
}),
_: 2
}, _parent3, _scopeId2));
} else {
return [
createVNode(_component_a_button, {
type: "link",
size: "small",
onClick: ($event) => handleView(record)
}, {
default: withCtx(() => [
createTextVNode("预览")
]),
_: 1
}, 8, ["onClick"]),
createVNode(_component_a_button, {
type: "link",
size: "small",
onClick: ($event) => handleEdit(record)
}, {
default: withCtx(() => [
createTextVNode("编辑")
]),
_: 1
}, 8, ["onClick"]),
createVNode(_component_a_popconfirm, {
title: "确认删除此公告?",
onConfirm: ($event) => handleDelete(record)
}, {
default: withCtx(() => [
createVNode(_component_a_button, {
type: "link",
size: "small",
danger: ""
}, {
default: withCtx(() => [
createTextVNode("删除")
]),
_: 1
})
]),
_: 1
}, 8, ["onConfirm"])
];
}
}),
_: 2
}, _parent2, _scopeId));
} else {
_push2(``);
}
} else {
return [
column.key === "info" ? (openBlock(), createBlock("div", {
key: 0,
class: "ann-info-cell"
}, [
record.image ? (openBlock(), createBlock("img", {
key: 0,
src: record.image,
class: "ann-thumb"
}, null, 8, ["src"])) : (openBlock(), createBlock("div", {
key: 1,
class: "ann-thumb-empty"
}, "📢")),
createVNode("div", { class: "ann-info-text" }, [
createVNode("div", { class: "ann-title" }, [
record.recommend ? (openBlock(), createBlock("span", {
key: 0,
class: "pin-badge"
}, "📌 置顶")) : createCommentVNode("", true),
createTextVNode(" " + toDisplayString(record.title), 1)
]),
createVNode("div", { class: "ann-overview" }, toDisplayString(record.overview || "暂无摘要"), 1)
])
])) : createCommentVNode("", true),
column.key === "status" ? (openBlock(), createBlock(_component_a_tag, {
key: 1,
color: record.status === 0 ? "success" : "default"
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(record.status === 0 ? "已发布" : "草稿"), 1)
]),
_: 2
}, 1032, ["color"])) : createCommentVNode("", true),
column.key === "views" ? (openBlock(), createBlock("span", {
key: 2,
class: "text-sm text-gray"
}, "👁 " + toDisplayString(record.actualViews || 0), 1)) : createCommentVNode("", true),
column.key === "recommend" ? (openBlock(), createBlock(_component_a_switch, {
key: 3,
checked: !!record.recommend,
size: "small",
onChange: (val) => handleTogglePin(record, val)
}, null, 8, ["checked", "onChange"])) : createCommentVNode("", true),
column.key === "createTime" ? (openBlock(), createBlock("span", {
key: 4,
class: "text-sm text-gray"
}, toDisplayString(record.createTime?.substring(0, 10) || "-"), 1)) : createCommentVNode("", true),
column.key === "action" ? (openBlock(), createBlock(_component_a_space, { key: 5 }, {
default: withCtx(() => [
createVNode(_component_a_button, {
type: "link",
size: "small",
onClick: ($event) => handleView(record)
}, {
default: withCtx(() => [
createTextVNode("预览")
]),
_: 1
}, 8, ["onClick"]),
createVNode(_component_a_button, {
type: "link",
size: "small",
onClick: ($event) => handleEdit(record)
}, {
default: withCtx(() => [
createTextVNode("编辑")
]),
_: 1
}, 8, ["onClick"]),
createVNode(_component_a_popconfirm, {
title: "确认删除此公告?",
onConfirm: ($event) => handleDelete(record)
}, {
default: withCtx(() => [
createVNode(_component_a_button, {
type: "link",
size: "small",
danger: ""
}, {
default: withCtx(() => [
createTextVNode("删除")
]),
_: 1
})
]),
_: 1
}, 8, ["onConfirm"])
]),
_: 2
}, 1024)) : createCommentVNode("", true)
];
}
}),
_: 1
}, _parent));
_push(`
`);
_push(ssrRenderComponent(_component_a_modal, {
open: unref(showFormModal),
"onUpdate:open": ($event) => isRef(showFormModal) ? showFormModal.value = $event : null,
title: unref(editing)?.articleId ? "编辑公告" : "发布公告",
width: "760px",
"confirm-loading": unref(saving),
onOk: handleSave,
onCancel: ($event) => showFormModal.value = false
}, {
default: withCtx((_, _push2, _parent2, _scopeId) => {
if (_push2) {
_push2(ssrRenderComponent(_component_a_form, {
model: unref(formData),
layout: "vertical"
}, {
default: withCtx((_2, _push3, _parent3, _scopeId2) => {
if (_push3) {
_push3(ssrRenderComponent(_component_a_form_item, {
label: "公告标题",
required: ""
}, {
default: withCtx((_3, _push4, _parent4, _scopeId3) => {
if (_push4) {
_push4(ssrRenderComponent(_component_a_input, {
value: unref(formData).title,
"onUpdate:value": ($event) => unref(formData).title = $event,
placeholder: "请输入公告标题",
maxlength: 200,
"show-count": ""
}, null, _parent4, _scopeId3));
} else {
return [
createVNode(_component_a_input, {
value: unref(formData).title,
"onUpdate:value": ($event) => unref(formData).title = $event,
placeholder: "请输入公告标题",
maxlength: 200,
"show-count": ""
}, null, 8, ["value", "onUpdate:value"])
];
}
}),
_: 1
}, _parent3, _scopeId2));
_push3(ssrRenderComponent(_component_a_form_item, { label: "封面图" }, {
default: withCtx((_3, _push4, _parent4, _scopeId3) => {
if (_push4) {
_push4(`
`);
if (unref(formData).image) {
_push4(`
![]()
`);
_push4(ssrRenderComponent(_component_a_button, {
size: "small",
onClick: ($event) => handlePreviewImage(unref(formData).image)
}, {
default: withCtx((_4, _push5, _parent5, _scopeId4) => {
if (_push5) {
_push5(`预览`);
} else {
return [
createTextVNode("预览")
];
}
}),
_: 1
}, _parent4, _scopeId3));
_push4(ssrRenderComponent(_component_a_button, {
size: "small",
danger: "",
onClick: handleRemoveCover
}, {
default: withCtx((_4, _push5, _parent5, _scopeId4) => {
if (_push5) {
_push5(`移除`);
} else {
return [
createTextVNode("移除")
];
}
}),
_: 1
}, _parent4, _scopeId3));
_push4(`
`);
} else {
_push4(``);
}
_push4(ssrRenderComponent(_component_a_upload, {
accept: "image/*",
"show-upload-list": false,
"before-upload": beforeImageUpload,
"custom-request": handleCoverUpload
}, {
default: withCtx((_4, _push5, _parent5, _scopeId4) => {
if (_push5) {
_push5(ssrRenderComponent(_component_a_button, { loading: unref(imageUploading) }, {
default: withCtx((_5, _push6, _parent6, _scopeId5) => {
if (_push6) {
_push6(`上传封面`);
} else {
return [
createTextVNode("上传封面")
];
}
}),
_: 1
}, _parent5, _scopeId4));
} else {
return [
createVNode(_component_a_button, { loading: unref(imageUploading) }, {
default: withCtx(() => [
createTextVNode("上传封面")
]),
_: 1
}, 8, ["loading"])
];
}
}),
_: 1
}, _parent4, _scopeId3));
_push4(`
支持 jpg/png/webp,适合公告 banner 场景,单张不超过 5MB
`);
} else {
return [
createVNode("div", { class: "cover-upload-wrap" }, [
unref(formData).image ? (openBlock(), createBlock("div", {
key: 0,
class: "cover-preview-card"
}, [
createVNode("img", {
src: unref(formData).image,
class: "cover-preview-image"
}, null, 8, ["src"]),
createVNode("div", { class: "cover-preview-actions" }, [
createVNode(_component_a_button, {
size: "small",
onClick: ($event) => handlePreviewImage(unref(formData).image)
}, {
default: withCtx(() => [
createTextVNode("预览")
]),
_: 1
}, 8, ["onClick"]),
createVNode(_component_a_button, {
size: "small",
danger: "",
onClick: handleRemoveCover
}, {
default: withCtx(() => [
createTextVNode("移除")
]),
_: 1
})
])
])) : createCommentVNode("", true),
createVNode(_component_a_upload, {
accept: "image/*",
"show-upload-list": false,
"before-upload": beforeImageUpload,
"custom-request": handleCoverUpload
}, {
default: withCtx(() => [
createVNode(_component_a_button, { loading: unref(imageUploading) }, {
default: withCtx(() => [
createTextVNode("上传封面")
]),
_: 1
}, 8, ["loading"])
]),
_: 1
}),
createVNode("div", { class: "field-hint" }, "支持 jpg/png/webp,适合公告 banner 场景,单张不超过 5MB")
])
];
}
}),
_: 1
}, _parent3, _scopeId2));
_push3(ssrRenderComponent(_component_a_form_item, { label: "公告摘要" }, {
default: withCtx((_3, _push4, _parent4, _scopeId3) => {
if (_push4) {
_push4(ssrRenderComponent(_component_a_textarea, {
value: unref(formData).overview,
"onUpdate:value": ($event) => unref(formData).overview = $event,
rows: 2,
placeholder: "简短描述公告内容",
maxlength: 300,
"show-count": ""
}, null, _parent4, _scopeId3));
} else {
return [
createVNode(_component_a_textarea, {
value: unref(formData).overview,
"onUpdate:value": ($event) => unref(formData).overview = $event,
rows: 2,
placeholder: "简短描述公告内容",
maxlength: 300,
"show-count": ""
}, null, 8, ["value", "onUpdate:value"])
];
}
}),
_: 1
}, _parent3, _scopeId2));
_push3(ssrRenderComponent(_component_a_form_item, {
label: "公告内容",
required: ""
}, {
default: withCtx((_3, _push4, _parent4, _scopeId3) => {
if (_push4) {
_push4(ssrRenderComponent(_component_a_textarea, {
value: unref(formData).content,
"onUpdate:value": ($event) => unref(formData).content = $event,
rows: 10,
placeholder: "公告正文内容..."
}, null, _parent4, _scopeId3));
} else {
return [
createVNode(_component_a_textarea, {
value: unref(formData).content,
"onUpdate:value": ($event) => unref(formData).content = $event,
rows: 10,
placeholder: "公告正文内容..."
}, null, 8, ["value", "onUpdate:value"])
];
}
}),
_: 1
}, _parent3, _scopeId2));
_push3(ssrRenderComponent(_component_a_row, { gutter: 16 }, {
default: withCtx((_3, _push4, _parent4, _scopeId3) => {
if (_push4) {
_push4(ssrRenderComponent(_component_a_col, { span: 12 }, {
default: withCtx((_4, _push5, _parent5, _scopeId4) => {
if (_push5) {
_push5(ssrRenderComponent(_component_a_form_item, { label: "状态" }, {
default: withCtx((_5, _push6, _parent6, _scopeId5) => {
if (_push6) {
_push6(ssrRenderComponent(_component_a_select, {
value: unref(formData).status,
"onUpdate:value": ($event) => unref(formData).status = $event
}, {
default: withCtx((_6, _push7, _parent7, _scopeId6) => {
if (_push7) {
_push7(ssrRenderComponent(_component_a_select_option, { value: 0 }, {
default: withCtx((_7, _push8, _parent8, _scopeId7) => {
if (_push8) {
_push8(`立即发布`);
} else {
return [
createTextVNode("立即发布")
];
}
}),
_: 1
}, _parent7, _scopeId6));
_push7(ssrRenderComponent(_component_a_select_option, { value: 1 }, {
default: withCtx((_7, _push8, _parent8, _scopeId7) => {
if (_push8) {
_push8(`保存为草稿`);
} else {
return [
createTextVNode("保存为草稿")
];
}
}),
_: 1
}, _parent7, _scopeId6));
} else {
return [
createVNode(_component_a_select_option, { value: 0 }, {
default: withCtx(() => [
createTextVNode("立即发布")
]),
_: 1
}),
createVNode(_component_a_select_option, { value: 1 }, {
default: withCtx(() => [
createTextVNode("保存为草稿")
]),
_: 1
})
];
}
}),
_: 1
}, _parent6, _scopeId5));
} else {
return [
createVNode(_component_a_select, {
value: unref(formData).status,
"onUpdate:value": ($event) => unref(formData).status = $event
}, {
default: withCtx(() => [
createVNode(_component_a_select_option, { value: 0 }, {
default: withCtx(() => [
createTextVNode("立即发布")
]),
_: 1
}),
createVNode(_component_a_select_option, { value: 1 }, {
default: withCtx(() => [
createTextVNode("保存为草稿")
]),
_: 1
})
]),
_: 1
}, 8, ["value", "onUpdate:value"])
];
}
}),
_: 1
}, _parent5, _scopeId4));
} else {
return [
createVNode(_component_a_form_item, { label: "状态" }, {
default: withCtx(() => [
createVNode(_component_a_select, {
value: unref(formData).status,
"onUpdate:value": ($event) => unref(formData).status = $event
}, {
default: withCtx(() => [
createVNode(_component_a_select_option, { value: 0 }, {
default: withCtx(() => [
createTextVNode("立即发布")
]),
_: 1
}),
createVNode(_component_a_select_option, { value: 1 }, {
default: withCtx(() => [
createTextVNode("保存为草稿")
]),
_: 1
})
]),
_: 1
}, 8, ["value", "onUpdate:value"])
]),
_: 1
})
];
}
}),
_: 1
}, _parent4, _scopeId3));
_push4(ssrRenderComponent(_component_a_col, { span: 12 }, {
default: withCtx((_4, _push5, _parent5, _scopeId4) => {
if (_push5) {
_push5(ssrRenderComponent(_component_a_form_item, { label: "是否置顶" }, {
default: withCtx((_5, _push6, _parent6, _scopeId5) => {
if (_push6) {
_push6(ssrRenderComponent(_component_a_switch, {
checked: unref(formPin),
"onUpdate:checked": ($event) => isRef(formPin) ? formPin.value = $event : null
}, null, _parent6, _scopeId5));
_push6(`
置顶公告将优先展示在列表顶部`);
} else {
return [
createVNode(_component_a_switch, {
checked: unref(formPin),
"onUpdate:checked": ($event) => isRef(formPin) ? formPin.value = $event : null
}, null, 8, ["checked", "onUpdate:checked"]),
createVNode("span", { class: "switch-tip" }, "置顶公告将优先展示在列表顶部")
];
}
}),
_: 1
}, _parent5, _scopeId4));
} else {
return [
createVNode(_component_a_form_item, { label: "是否置顶" }, {
default: withCtx(() => [
createVNode(_component_a_switch, {
checked: unref(formPin),
"onUpdate:checked": ($event) => isRef(formPin) ? formPin.value = $event : null
}, null, 8, ["checked", "onUpdate:checked"]),
createVNode("span", { class: "switch-tip" }, "置顶公告将优先展示在列表顶部")
]),
_: 1
})
];
}
}),
_: 1
}, _parent4, _scopeId3));
} else {
return [
createVNode(_component_a_col, { span: 12 }, {
default: withCtx(() => [
createVNode(_component_a_form_item, { label: "状态" }, {
default: withCtx(() => [
createVNode(_component_a_select, {
value: unref(formData).status,
"onUpdate:value": ($event) => unref(formData).status = $event
}, {
default: withCtx(() => [
createVNode(_component_a_select_option, { value: 0 }, {
default: withCtx(() => [
createTextVNode("立即发布")
]),
_: 1
}),
createVNode(_component_a_select_option, { value: 1 }, {
default: withCtx(() => [
createTextVNode("保存为草稿")
]),
_: 1
})
]),
_: 1
}, 8, ["value", "onUpdate:value"])
]),
_: 1
})
]),
_: 1
}),
createVNode(_component_a_col, { span: 12 }, {
default: withCtx(() => [
createVNode(_component_a_form_item, { label: "是否置顶" }, {
default: withCtx(() => [
createVNode(_component_a_switch, {
checked: unref(formPin),
"onUpdate:checked": ($event) => isRef(formPin) ? formPin.value = $event : null
}, null, 8, ["checked", "onUpdate:checked"]),
createVNode("span", { class: "switch-tip" }, "置顶公告将优先展示在列表顶部")
]),
_: 1
})
]),
_: 1
})
];
}
}),
_: 1
}, _parent3, _scopeId2));
} else {
return [
createVNode(_component_a_form_item, {
label: "公告标题",
required: ""
}, {
default: withCtx(() => [
createVNode(_component_a_input, {
value: unref(formData).title,
"onUpdate:value": ($event) => unref(formData).title = $event,
placeholder: "请输入公告标题",
maxlength: 200,
"show-count": ""
}, null, 8, ["value", "onUpdate:value"])
]),
_: 1
}),
createVNode(_component_a_form_item, { label: "封面图" }, {
default: withCtx(() => [
createVNode("div", { class: "cover-upload-wrap" }, [
unref(formData).image ? (openBlock(), createBlock("div", {
key: 0,
class: "cover-preview-card"
}, [
createVNode("img", {
src: unref(formData).image,
class: "cover-preview-image"
}, null, 8, ["src"]),
createVNode("div", { class: "cover-preview-actions" }, [
createVNode(_component_a_button, {
size: "small",
onClick: ($event) => handlePreviewImage(unref(formData).image)
}, {
default: withCtx(() => [
createTextVNode("预览")
]),
_: 1
}, 8, ["onClick"]),
createVNode(_component_a_button, {
size: "small",
danger: "",
onClick: handleRemoveCover
}, {
default: withCtx(() => [
createTextVNode("移除")
]),
_: 1
})
])
])) : createCommentVNode("", true),
createVNode(_component_a_upload, {
accept: "image/*",
"show-upload-list": false,
"before-upload": beforeImageUpload,
"custom-request": handleCoverUpload
}, {
default: withCtx(() => [
createVNode(_component_a_button, { loading: unref(imageUploading) }, {
default: withCtx(() => [
createTextVNode("上传封面")
]),
_: 1
}, 8, ["loading"])
]),
_: 1
}),
createVNode("div", { class: "field-hint" }, "支持 jpg/png/webp,适合公告 banner 场景,单张不超过 5MB")
])
]),
_: 1
}),
createVNode(_component_a_form_item, { label: "公告摘要" }, {
default: withCtx(() => [
createVNode(_component_a_textarea, {
value: unref(formData).overview,
"onUpdate:value": ($event) => unref(formData).overview = $event,
rows: 2,
placeholder: "简短描述公告内容",
maxlength: 300,
"show-count": ""
}, null, 8, ["value", "onUpdate:value"])
]),
_: 1
}),
createVNode(_component_a_form_item, {
label: "公告内容",
required: ""
}, {
default: withCtx(() => [
createVNode(_component_a_textarea, {
value: unref(formData).content,
"onUpdate:value": ($event) => unref(formData).content = $event,
rows: 10,
placeholder: "公告正文内容..."
}, null, 8, ["value", "onUpdate:value"])
]),
_: 1
}),
createVNode(_component_a_row, { gutter: 16 }, {
default: withCtx(() => [
createVNode(_component_a_col, { span: 12 }, {
default: withCtx(() => [
createVNode(_component_a_form_item, { label: "状态" }, {
default: withCtx(() => [
createVNode(_component_a_select, {
value: unref(formData).status,
"onUpdate:value": ($event) => unref(formData).status = $event
}, {
default: withCtx(() => [
createVNode(_component_a_select_option, { value: 0 }, {
default: withCtx(() => [
createTextVNode("立即发布")
]),
_: 1
}),
createVNode(_component_a_select_option, { value: 1 }, {
default: withCtx(() => [
createTextVNode("保存为草稿")
]),
_: 1
})
]),
_: 1
}, 8, ["value", "onUpdate:value"])
]),
_: 1
})
]),
_: 1
}),
createVNode(_component_a_col, { span: 12 }, {
default: withCtx(() => [
createVNode(_component_a_form_item, { label: "是否置顶" }, {
default: withCtx(() => [
createVNode(_component_a_switch, {
checked: unref(formPin),
"onUpdate:checked": ($event) => isRef(formPin) ? formPin.value = $event : null
}, null, 8, ["checked", "onUpdate:checked"]),
createVNode("span", { class: "switch-tip" }, "置顶公告将优先展示在列表顶部")
]),
_: 1
})
]),
_: 1
})
]),
_: 1
})
];
}
}),
_: 1
}, _parent2, _scopeId));
} else {
return [
createVNode(_component_a_form, {
model: unref(formData),
layout: "vertical"
}, {
default: withCtx(() => [
createVNode(_component_a_form_item, {
label: "公告标题",
required: ""
}, {
default: withCtx(() => [
createVNode(_component_a_input, {
value: unref(formData).title,
"onUpdate:value": ($event) => unref(formData).title = $event,
placeholder: "请输入公告标题",
maxlength: 200,
"show-count": ""
}, null, 8, ["value", "onUpdate:value"])
]),
_: 1
}),
createVNode(_component_a_form_item, { label: "封面图" }, {
default: withCtx(() => [
createVNode("div", { class: "cover-upload-wrap" }, [
unref(formData).image ? (openBlock(), createBlock("div", {
key: 0,
class: "cover-preview-card"
}, [
createVNode("img", {
src: unref(formData).image,
class: "cover-preview-image"
}, null, 8, ["src"]),
createVNode("div", { class: "cover-preview-actions" }, [
createVNode(_component_a_button, {
size: "small",
onClick: ($event) => handlePreviewImage(unref(formData).image)
}, {
default: withCtx(() => [
createTextVNode("预览")
]),
_: 1
}, 8, ["onClick"]),
createVNode(_component_a_button, {
size: "small",
danger: "",
onClick: handleRemoveCover
}, {
default: withCtx(() => [
createTextVNode("移除")
]),
_: 1
})
])
])) : createCommentVNode("", true),
createVNode(_component_a_upload, {
accept: "image/*",
"show-upload-list": false,
"before-upload": beforeImageUpload,
"custom-request": handleCoverUpload
}, {
default: withCtx(() => [
createVNode(_component_a_button, { loading: unref(imageUploading) }, {
default: withCtx(() => [
createTextVNode("上传封面")
]),
_: 1
}, 8, ["loading"])
]),
_: 1
}),
createVNode("div", { class: "field-hint" }, "支持 jpg/png/webp,适合公告 banner 场景,单张不超过 5MB")
])
]),
_: 1
}),
createVNode(_component_a_form_item, { label: "公告摘要" }, {
default: withCtx(() => [
createVNode(_component_a_textarea, {
value: unref(formData).overview,
"onUpdate:value": ($event) => unref(formData).overview = $event,
rows: 2,
placeholder: "简短描述公告内容",
maxlength: 300,
"show-count": ""
}, null, 8, ["value", "onUpdate:value"])
]),
_: 1
}),
createVNode(_component_a_form_item, {
label: "公告内容",
required: ""
}, {
default: withCtx(() => [
createVNode(_component_a_textarea, {
value: unref(formData).content,
"onUpdate:value": ($event) => unref(formData).content = $event,
rows: 10,
placeholder: "公告正文内容..."
}, null, 8, ["value", "onUpdate:value"])
]),
_: 1
}),
createVNode(_component_a_row, { gutter: 16 }, {
default: withCtx(() => [
createVNode(_component_a_col, { span: 12 }, {
default: withCtx(() => [
createVNode(_component_a_form_item, { label: "状态" }, {
default: withCtx(() => [
createVNode(_component_a_select, {
value: unref(formData).status,
"onUpdate:value": ($event) => unref(formData).status = $event
}, {
default: withCtx(() => [
createVNode(_component_a_select_option, { value: 0 }, {
default: withCtx(() => [
createTextVNode("立即发布")
]),
_: 1
}),
createVNode(_component_a_select_option, { value: 1 }, {
default: withCtx(() => [
createTextVNode("保存为草稿")
]),
_: 1
})
]),
_: 1
}, 8, ["value", "onUpdate:value"])
]),
_: 1
})
]),
_: 1
}),
createVNode(_component_a_col, { span: 12 }, {
default: withCtx(() => [
createVNode(_component_a_form_item, { label: "是否置顶" }, {
default: withCtx(() => [
createVNode(_component_a_switch, {
checked: unref(formPin),
"onUpdate:checked": ($event) => isRef(formPin) ? formPin.value = $event : null
}, null, 8, ["checked", "onUpdate:checked"]),
createVNode("span", { class: "switch-tip" }, "置顶公告将优先展示在列表顶部")
]),
_: 1
})
]),
_: 1
})
]),
_: 1
})
]),
_: 1
}, 8, ["model"])
];
}
}),
_: 1
}, _parent));
_push(ssrRenderComponent(_component_a_modal, {
open: unref(showPreviewModal),
"onUpdate:open": ($event) => isRef(showPreviewModal) ? showPreviewModal.value = $event : null,
title: unref(previewData)?.title || "公告预览",
width: "760px",
footer: null
}, {
default: withCtx((_, _push2, _parent2, _scopeId) => {
if (_push2) {
if (unref(previewData)) {
_push2(`
发布时间:${ssrInterpolate(unref(previewData).createTime?.substring(0, 16) || "-")}`);
if (unref(previewData).recommend) {
_push2(ssrRenderComponent(_component_a_tag, { color: "orange" }, {
default: withCtx((_2, _push3, _parent3, _scopeId2) => {
if (_push3) {
_push3(`置顶`);
} else {
return [
createTextVNode("置顶")
];
}
}),
_: 1
}, _parent2, _scopeId));
} else {
_push2(``);
}
_push2(ssrRenderComponent(_component_a_tag, {
color: unref(previewData).status === 0 ? "success" : "default"
}, {
default: withCtx((_2, _push3, _parent3, _scopeId2) => {
if (_push3) {
_push3(`${ssrInterpolate(unref(previewData).status === 0 ? "已发布" : "草稿")}`);
} else {
return [
createTextVNode(toDisplayString(unref(previewData).status === 0 ? "已发布" : "草稿"), 1)
];
}
}),
_: 1
}, _parent2, _scopeId));
_push2(`
`);
if (unref(previewData).image) {
_push2(`
`);
} else {
_push2(``);
}
if (unref(previewData).overview) {
_push2(`
${ssrInterpolate(unref(previewData).overview)}
`);
} else {
_push2(``);
}
_push2(ssrRenderComponent(_component_a_divider, null, null, _parent2, _scopeId));
_push2(`
${(unref(previewData).content || unref(previewData).overview || "暂无内容") ?? ""}
`);
} else {
_push2(``);
}
} else {
return [
unref(previewData) ? (openBlock(), createBlock(Fragment, { key: 0 }, [
createVNode("div", { class: "preview-meta" }, [
createVNode("span", { class: "text-sm text-gray" }, "发布时间:" + toDisplayString(unref(previewData).createTime?.substring(0, 16) || "-"), 1),
unref(previewData).recommend ? (openBlock(), createBlock(_component_a_tag, {
key: 0,
color: "orange"
}, {
default: withCtx(() => [
createTextVNode("置顶")
]),
_: 1
})) : createCommentVNode("", true),
createVNode(_component_a_tag, {
color: unref(previewData).status === 0 ? "success" : "default"
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(unref(previewData).status === 0 ? "已发布" : "草稿"), 1)
]),
_: 1
}, 8, ["color"])
]),
unref(previewData).image ? (openBlock(), createBlock("div", {
key: 0,
class: "preview-cover-wrap"
}, [
createVNode("img", {
src: unref(previewData).image,
class: "preview-cover"
}, null, 8, ["src"])
])) : createCommentVNode("", true),
unref(previewData).overview ? (openBlock(), createBlock("div", {
key: 1,
class: "preview-summary"
}, toDisplayString(unref(previewData).overview), 1)) : createCommentVNode("", true),
createVNode(_component_a_divider),
createVNode("div", {
class: "preview-content",
innerHTML: unref(previewData).content || unref(previewData).overview || "暂无内容"
}, null, 8, ["innerHTML"])
], 64)) : createCommentVNode("", true)
];
}
}),
_: 1
}, _parent));
_push(ssrRenderComponent(_component_a_modal, {
open: unref(showImagePreview),
"onUpdate:open": ($event) => isRef(showImagePreview) ? showImagePreview.value = $event : null,
title: "封面预览",
footer: null,
width: "640px"
}, {
default: withCtx((_, _push2, _parent2, _scopeId) => {
if (_push2) {
if (unref(previewImageUrl)) {
_push2(`
![]()
`);
} else {
_push2(``);
}
} else {
return [
unref(previewImageUrl) ? (openBlock(), createBlock("img", {
key: 0,
src: unref(previewImageUrl),
class: "image-preview-modal"
}, null, 8, ["src"])) : createCommentVNode("", true)
];
}
}),
_: 1
}, _parent));
_push(`
`);
};
}
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/admin/announcements.vue");
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const announcements = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-6454b5e2"]]);
export { announcements as default };
//# sourceMappingURL=announcements-BflH5AKP.mjs.map