fix(admin): 管理控制台界面使用element plus
This commit is contained in:
1 parent
6c47d0639c
commit
cdc8610ec1
45 files changed
+6258
-4639
No files matched your search
@@ -1,19 +1,26 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/AnnouncementsPage.vue
|
||||
* 公告管理独立页面:全宽表格列表 + 发布/编辑/详情居中弹窗。
|
||||
* 依赖:useAnnouncementsAdmin、AnnouncementFormModal、AnnouncementDetailModal、DeleteConfirmDialog。
|
||||
* 逻辑:路由 /admin/announcements 挂载本页;列表摘要截断,完整内容在详情弹窗查看。
|
||||
* 用途:公告管理列表。一张卡片里放标题、发布按钮和表格。
|
||||
* 依赖:AdminListPage、useAnnouncementsAdmin、useElementProvider、element-plus、公告表单和详情对话框。
|
||||
* 逻辑:路由 /admin/announcements。骨架用 AdminListPage。发布、编辑、查看仍由本页的两个对话框完成。删除用 Element 确认框。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Edit, Eye, Plus, Trash2 } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import { ElButton, ElConfigProvider, ElTable, ElTableColumn } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import type { AdminAnnouncementRow } from '@/features/admin/types/admin.types';
|
||||
import AnnouncementDetailModal from './components/AnnouncementDetailModal.vue';
|
||||
import AnnouncementFormModal from './components/AnnouncementFormModal.vue';
|
||||
import { useAnnouncementsAdmin } from './composables/useAnnouncementsAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
|
||||
const {
|
||||
announcements,
|
||||
@@ -23,8 +30,6 @@ const {
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDetailModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
@@ -34,98 +39,66 @@ const {
|
||||
editFromDetail,
|
||||
saveAnnouncement,
|
||||
deleteAnnouncementItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
truncateAnnouncementPreview,
|
||||
formatPublishedAt,
|
||||
} = useAnnouncementsAdmin();
|
||||
|
||||
/**
|
||||
* 打开编辑对话框。表格行类型较宽,这里收成公告行。
|
||||
* @param row - 当前表格行
|
||||
*/
|
||||
function editAnnouncement(row: AdminAnnouncementRow): void {
|
||||
openEditModal(row);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<AdminListPage :loading="isLoading">
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.announcement.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.announcement.subtitle') }}</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton type="primary" :icon="Plus" @click="openCreateModal">
|
||||
{{ t('admin.announcement.add') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.announcement.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.announcement.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
@click="openCreateModal"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
<span>{{ t('admin.announcement.add') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.announcement.headers.title') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-44">{{ t('admin.announcement.headers.publishedAt') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.announcement.headers.preview') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-36">{{ t('admin.announcement.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="announcements.length === 0">
|
||||
<td colspan="4" class="px-6 admin-table-empty">{{ t('admin.announcement.noData') }}</td>
|
||||
</tr>
|
||||
<tr v-for="ann in announcements" :key="ann.id" class="group">
|
||||
<td class="px-6 py-4">
|
||||
<div class="font-medium text-primary text-sm">{{ ann.title }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-muted whitespace-nowrap">
|
||||
{{ formatPublishedAt(ann.created_at) }}
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<p class="text-sm text-secondary truncate max-w-md" :title="ann.content">
|
||||
{{ truncateAnnouncementPreview(ann.content) }}
|
||||
</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex justify-end gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-blue-600 hover:bg-blue-50 rounded-lg transition-colors"
|
||||
:title="t('admin.announcement.actions.view')"
|
||||
@click="openDetailModal(ann)"
|
||||
>
|
||||
<Eye class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-indigo-600 hover:bg-indigo-50 rounded-lg transition-colors"
|
||||
:title="t('admin.announcement.actions.edit')"
|
||||
@click="openEditModal(ann)"
|
||||
>
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-red-600 hover:bg-red-50 rounded-lg transition-colors"
|
||||
:title="t('admin.announcement.actions.delete')"
|
||||
@click="deleteAnnouncementItem(ann.id)"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
<ElTable
|
||||
class="hx-admin-table"
|
||||
:data="announcements"
|
||||
row-key="id"
|
||||
:empty-text="t('admin.announcement.noData')"
|
||||
>
|
||||
<ElTableColumn prop="title" :label="t('admin.announcement.headers.title')" min-width="180" />
|
||||
<ElTableColumn :label="t('admin.announcement.headers.publishedAt')" min-width="180">
|
||||
<template #default="{ row }">{{ formatPublishedAt(row.created_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.announcement.headers.preview')" min-width="240">
|
||||
<template #default="{ row }">
|
||||
<p class="announcement-preview" :title="row.content">{{ truncateAnnouncementPreview(row.content) }}</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.announcement.headers.actions')" width="200" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openDetailModal(row as AdminAnnouncementRow)">
|
||||
{{ t('admin.announcement.actions.view') }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" @click="editAnnouncement(row as AdminAnnouncementRow)">
|
||||
{{ t('admin.announcement.actions.edit') }}
|
||||
</ElButton>
|
||||
<ElButton link type="danger" @click="deleteAnnouncementItem((row as AdminAnnouncementRow).id)">
|
||||
{{ t('admin.announcement.actions.delete') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</AdminListPage>
|
||||
|
||||
<AnnouncementFormModal
|
||||
:visible="showFormModal"
|
||||
@@ -134,19 +107,19 @@ onMounted(() => {
|
||||
@close="closeFormModal"
|
||||
@save="saveAnnouncement"
|
||||
/>
|
||||
|
||||
<AnnouncementDetailModal
|
||||
:visible="showDetailModal"
|
||||
:announcement="viewingAnnouncement"
|
||||
@close="closeDetailModal"
|
||||
@edit="editFromDetail"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@cancel="closeDeleteConfirm"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.announcement-preview {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
+52
-30
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/components/AnnouncementDetailModal.vue
|
||||
* 公告详情居中弹窗,展示完整标题、时间与正文。
|
||||
* 依赖:AdminAnnouncementRow、admin 通用 modal 样式。
|
||||
* 逻辑:AnnouncementsPage 列表「查看」打开;可跳转编辑或关闭。
|
||||
* 用途:只读展示公告标题、发布时间和正文。
|
||||
* 依赖:element-plus 对话框和描述列表、AdminAnnouncementRow。
|
||||
* 逻辑:AnnouncementsPage 点「查看」后传入。可关闭,或 emit edit 交给页面打开编辑框。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDescriptions, ElDescriptionsItem, ElDialog } from 'element-plus';
|
||||
import type { AdminAnnouncementRow } from '@/features/admin/types/admin.types';
|
||||
|
||||
defineProps<{
|
||||
@@ -25,34 +26,55 @@ const { t } = useI18n();
|
||||
* @param iso - 后端返回的 created_at
|
||||
* @returns 本地化日期时间字符串
|
||||
*/
|
||||
const formatDateTime = (iso: string): string => new Date(iso).toLocaleString();
|
||||
function formatDateTime(iso: string): string {
|
||||
return new Date(iso).toLocaleString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible && announcement" class="admin-modal-overlay animate-fade-in items-center">
|
||||
<div class="admin-modal-panel max-w-3xl max-h-[92vh] scale-100">
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-subtle">
|
||||
<h3 class="section-title">{{ t('admin.announcement.viewDetail') }}</h3>
|
||||
<p class="text-xs text-muted mt-2">{{ formatDateTime(announcement.created_at) }}</p>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 overflow-y-auto space-y-4">
|
||||
<div>
|
||||
<p class="text-xs font-semibold text-muted uppercase tracking-wider mb-1.5">
|
||||
{{ t('admin.announcement.fields.title') }}
|
||||
</p>
|
||||
<p class="text-base font-semibold text-primary">{{ announcement.title }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs font-semibold text-muted uppercase tracking-wider mb-1.5">
|
||||
{{ t('admin.announcement.fields.content') }}
|
||||
</p>
|
||||
<p class="text-sm text-secondary whitespace-pre-wrap leading-relaxed">{{ announcement.content }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-modal-footer">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.close') }}</button>
|
||||
<button type="button" class="btn-primary" @click="emit('edit')">{{ t('admin.edit') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible && !!announcement"
|
||||
:title="t('admin.announcement.viewDetail')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<template v-if="announcement">
|
||||
<p class="section-desc">{{ formatDateTime(announcement.created_at) }}</p>
|
||||
<ElDescriptions class="announcement-detail" :column="1" border>
|
||||
<ElDescriptionsItem :label="t('admin.announcement.fields.title')">
|
||||
{{ announcement.title }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.announcement.fields.content')">
|
||||
<p class="announcement-detail__content">{{ announcement.content }}</p>
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
</template>
|
||||
<template #footer>
|
||||
<ElButton @click="emit('close')">{{ t('admin.close') }}</ElButton>
|
||||
<ElButton type="primary" @click="emit('edit')">{{ t('admin.edit') }}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.announcement-detail {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.announcement-detail__content {
|
||||
white-space: pre-wrap;
|
||||
max-height: 50vh;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
+38
-34
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/components/AnnouncementFormModal.vue
|
||||
* 公告创建/编辑居中弹窗。
|
||||
* 依赖:AnnouncementFormState、admin 通用 modal 样式。
|
||||
* 逻辑:AnnouncementsPage 打开本组件;提交时 emit save,由 composable 调 API。
|
||||
* 用途:公告发布和编辑对话框。标题一行,正文多行。
|
||||
* 依赖:element-plus 对话框和表单、AnnouncementFormState。
|
||||
* 逻辑:AnnouncementsPage 打开本组件。提交时 emit save,由 composable 调接口。样式跟页面已引入的 Element 皮肤走。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog, ElForm, ElFormItem, ElInput } from 'element-plus';
|
||||
import type { AnnouncementFormState } from '@/features/admin/types/announcement.types';
|
||||
|
||||
defineProps<{
|
||||
@@ -20,38 +21,41 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay animate-fade-in items-center">
|
||||
<div class="admin-modal-panel max-w-2xl max-h-[92vh] scale-100">
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-subtle">
|
||||
<h3 class="section-title">
|
||||
{{ form.id ? t('admin.announcement.edit') : t('admin.announcement.add') }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 space-y-5 overflow-y-auto">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.announcement.fields.title') }}</label>
|
||||
<input v-model="form.title" type="text" class="input-field text-sm" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.announcement.fields.content') }}</label>
|
||||
<textarea v-model="form.content" rows="10" class="input-field text-sm resize-y min-h-[200px]" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-modal-footer">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>
|
||||
<button type="button" class="btn-primary disabled:opacity-70" :disabled="isSaving" @click="emit('save')">
|
||||
{{
|
||||
isSaving
|
||||
? t('admin.save') + '...'
|
||||
: form.id
|
||||
? t('admin.update')
|
||||
: t('admin.announcement.publish')
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="form.id ? t('admin.announcement.edit') : t('admin.announcement.add')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!isSaving"
|
||||
:show-close="!isSaving"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<ElForm label-position="top" :model="form" @submit.prevent="emit('save')">
|
||||
<ElFormItem :label="t('admin.announcement.fields.title')" required>
|
||||
<ElInput v-model="form.title" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.announcement.fields.content')" required>
|
||||
<ElInput v-model="form.content" type="textarea" :rows="8" />
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton :disabled="isSaving" @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" @click="emit('save')">
|
||||
{{ form.id ? t('admin.update') : t('admin.announcement.publish') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
+24
-53
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/composables/useAnnouncementsAdmin.ts
|
||||
* 公告管理:列表、发布/编辑弹窗、详情弹窗、删除。
|
||||
* 依赖:admin.api、announcement.types、useMessage。
|
||||
* 逻辑:AnnouncementsPage 调用本 composable 驱动表格与两个居中弹窗。
|
||||
* 依赖:admin.api、announcement.types、useMessage、element-plus 确认框。
|
||||
* 逻辑:AnnouncementsPage 调用本 composable 驱动表格与两个对话框。删除用 ElMessageBox。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import {
|
||||
createAnnouncement,
|
||||
deleteAnnouncement,
|
||||
@@ -33,10 +34,6 @@ export function useAnnouncementsAdmin() {
|
||||
const showFormModal = ref(false);
|
||||
const showDetailModal = ref(false);
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
/**
|
||||
* 拉取公告列表并写入 announcements。
|
||||
* @returns Promise<void>
|
||||
@@ -60,36 +57,6 @@ export function useAnnouncementsAdmin() {
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开删除确认对话框并绑定确认后的删除动作。
|
||||
* @param message - 确认文案
|
||||
* @param action - 用户确认后执行的异步删除逻辑
|
||||
*/
|
||||
const openDeleteConfirm = (message: string, action: () => Promise<void> | void): void => {
|
||||
deleteConfirmMessage.value = message;
|
||||
deleteConfirmAction = action;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
/** 关闭删除确认对话框并清空待执行动作。 */
|
||||
const closeDeleteConfirm = (): void => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmAction = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 执行删除确认对话框中绑定的删除动作。
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
const confirmDelete = async (): Promise<void> => {
|
||||
if (!deleteConfirmAction) return;
|
||||
try {
|
||||
await deleteConfirmAction();
|
||||
} finally {
|
||||
closeDeleteConfirm();
|
||||
}
|
||||
};
|
||||
|
||||
/** 打开「发布公告」弹窗并重置表单。 */
|
||||
const openCreateModal = (): void => {
|
||||
form.value = createEmptyAnnouncementForm();
|
||||
@@ -168,22 +135,30 @@ export function useAnnouncementsAdmin() {
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除指定公告,删除前弹出确认框。
|
||||
* 删除指定公告。先用 Element 确认框询问,取消则不请求。
|
||||
* 核心逻辑:MessageBox 取消时 reject,这里吞掉;确定后删除并刷新列表。
|
||||
* @param id - 公告主键
|
||||
*/
|
||||
const deleteAnnouncementItem = (id: number): void => {
|
||||
openDeleteConfirm(t('admin.announcement.confirmDelete'), async () => {
|
||||
try {
|
||||
await deleteAnnouncement(id);
|
||||
if (viewingAnnouncement.value?.id === id) {
|
||||
closeDetailModal();
|
||||
}
|
||||
await loadAnnouncements();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
const deleteAnnouncementItem = async (id: number): Promise<void> => {
|
||||
try {
|
||||
await ElMessageBox.confirm(t('admin.announcement.confirmDelete'), t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await deleteAnnouncement(id);
|
||||
if (viewingAnnouncement.value?.id === id) {
|
||||
closeDetailModal();
|
||||
}
|
||||
});
|
||||
await loadAnnouncements();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -201,8 +176,6 @@ export function useAnnouncementsAdmin() {
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDetailModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
@@ -212,8 +185,6 @@ export function useAnnouncementsAdmin() {
|
||||
editFromDetail,
|
||||
saveAnnouncement,
|
||||
deleteAnnouncementItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
truncateAnnouncementPreview,
|
||||
formatPublishedAt,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user