fix(notice): 修改管理控制台公告布局,并在首页滚动显示
This commit is contained in:
1 parent
ced7fbe085
commit
d4f629106f
18 files changed
+737
-105
No files matched your search
@@ -1688,6 +1688,27 @@ def create_announcement():
|
||||
db.session.commit()
|
||||
return (jsonify({'message': 'Created', 'id': ann.id}), 201)
|
||||
|
||||
@user_bp.route('/announcements/<int:id>', methods=['PUT'])
|
||||
def update_announcement(id):
|
||||
"""
|
||||
更新公告(仅管理员)。
|
||||
|
||||
核心逻辑:校验 title/content 非空后更新 Announcement 记录。
|
||||
"""
|
||||
user = _get_current_user()
|
||||
if not user or user.role != 'admin':
|
||||
raise ForbiddenError('Unauthorized')
|
||||
data = request.get_json() or {}
|
||||
if not data.get('title') or not data.get('content'):
|
||||
raise ValidationError('Missing fields')
|
||||
ann = db.session.get(Announcement, id)
|
||||
if not ann:
|
||||
raise NotFoundError('Not found')
|
||||
ann.title = data['title']
|
||||
ann.content = data['content']
|
||||
db.session.commit()
|
||||
return jsonify({'message': 'Updated'})
|
||||
|
||||
@user_bp.route('/announcements/<int:id>', methods=['DELETE'])
|
||||
def delete_announcement(id):
|
||||
user = _get_current_user()
|
||||
|
||||
@@ -167,6 +167,8 @@ export const unbindAdminWecomUser = (userId: number) =>
|
||||
export const listAnnouncements = () => requestJson<any[]>('/api/user/announcements', auth());
|
||||
export const createAnnouncement = (payload: Record<string, unknown>) =>
|
||||
requestJson('/api/user/announcements', { method: 'POST', ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const updateAnnouncement = (id: number, payload: Record<string, unknown>) =>
|
||||
requestJson(`/api/user/announcements/${id}`, { method: 'PUT', ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const deleteAnnouncement = (id: number) =>
|
||||
requestJson(`/api/user/announcements/${id}`, { method: 'DELETE', ...auth() });
|
||||
|
||||
|
||||
@@ -1,28 +1,43 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/AnnouncementsPage.vue
|
||||
* 公告管理独立页面。路由:/admin/announcements
|
||||
* 公告管理独立页面:全宽表格列表 + 发布/编辑/详情居中弹窗。
|
||||
* 依赖:useAnnouncementsAdmin、AnnouncementFormModal、AnnouncementDetailModal、DeleteConfirmDialog。
|
||||
* 逻辑:路由 /admin/announcements 挂载本页;列表摘要截断,完整内容在详情弹窗查看。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Trash2 } from 'lucide-vue-next';
|
||||
import { Edit, Eye, Plus, Trash2 } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import AnnouncementDetailModal from './components/AnnouncementDetailModal.vue';
|
||||
import AnnouncementFormModal from './components/AnnouncementFormModal.vue';
|
||||
import { useAnnouncementsAdmin } from './composables/useAnnouncementsAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
announcements,
|
||||
newAnnouncement,
|
||||
form,
|
||||
viewingAnnouncement,
|
||||
isLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDetailModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
publishAnnouncement,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
openDetailModal,
|
||||
closeFormModal,
|
||||
closeDetailModal,
|
||||
editFromDetail,
|
||||
saveAnnouncement,
|
||||
deleteAnnouncementItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
truncateAnnouncementPreview,
|
||||
formatPublishedAt,
|
||||
} = useAnnouncementsAdmin();
|
||||
|
||||
onMounted(() => {
|
||||
@@ -31,72 +46,102 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="section-gap animate-fade-in-up">
|
||||
<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>
|
||||
|
||||
<template v-else>
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.announcement.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.announcement.subtitle') }}</p>
|
||||
<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="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
<div class="lg:col-span-1 card p-6 shadow-sm h-fit">
|
||||
<h3 class="font-bold text-primary mb-4">{{ t('admin.announcement.add') }}</h3>
|
||||
<div class="space-y-4">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.announcement.fields.title') }}</label>
|
||||
<input v-model="newAnnouncement.title" 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="newAnnouncement.content" rows="6" class="input-field text-sm" />
|
||||
</div>
|
||||
<div class="flex justify-end pt-2">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary btn-sm disabled:opacity-50"
|
||||
:disabled="isSaving"
|
||||
@click="publishAnnouncement"
|
||||
>
|
||||
{{ isSaving ? t('admin.save') + '...' : t('admin.announcement.publish') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="lg:col-span-2 card shadow-sm overflow-hidden">
|
||||
<div v-if="announcements.length === 0" class="p-8 text-center text-muted">
|
||||
{{ t('admin.announcement.noData') }}
|
||||
</div>
|
||||
<div v-else class="divide-y divide-subtle">
|
||||
<div
|
||||
v-for="ann in announcements"
|
||||
:key="ann.id"
|
||||
class="p-5 hover-surface-soft transition-colors"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<h4 class="font-semibold text-primary truncate">{{ ann.title }}</h4>
|
||||
<p class="text-xs text-muted mt-1">{{ new Date(ann.created_at).toLocaleString() }}</p>
|
||||
<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>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-red-600 hover:bg-red-50 rounded-lg transition-colors"
|
||||
@click="deleteAnnouncementItem(ann.id)"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-sm text-secondary mt-2 whitespace-pre-wrap">{{ ann.content }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<AnnouncementFormModal
|
||||
:visible="showFormModal"
|
||||
:form="form"
|
||||
:is-saving="isSaving"
|
||||
@close="closeFormModal"
|
||||
@save="saveAnnouncement"
|
||||
/>
|
||||
|
||||
<AnnouncementDetailModal
|
||||
:visible="showDetailModal"
|
||||
:announcement="viewingAnnouncement"
|
||||
@close="closeDetailModal"
|
||||
@edit="editFromDetail"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/components/AnnouncementDetailModal.vue
|
||||
* 公告详情居中弹窗,展示完整标题、时间与正文。
|
||||
* 依赖:AdminAnnouncementRow、admin 通用 modal 样式。
|
||||
* 逻辑:AnnouncementsPage 列表「查看」打开;可跳转编辑或关闭。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { AdminAnnouncementRow } from '@/features/admin/types/admin.types';
|
||||
|
||||
defineProps<{
|
||||
visible: boolean;
|
||||
announcement: AdminAnnouncementRow | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
edit: [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 将 ISO 时间格式化为本地可读字符串。
|
||||
* @param iso - 后端返回的 created_at
|
||||
* @returns 本地化日期时间字符串
|
||||
*/
|
||||
const formatDateTime = (iso: string): string => new Date(iso).toLocaleString();
|
||||
</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>
|
||||
</template>
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/components/AnnouncementFormModal.vue
|
||||
* 公告创建/编辑居中弹窗。
|
||||
* 依赖:AnnouncementFormState、admin 通用 modal 样式。
|
||||
* 逻辑:AnnouncementsPage 打开本组件;提交时 emit save,由 composable 调 API。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { AnnouncementFormState } from '@/features/admin/types/announcement.types';
|
||||
|
||||
defineProps<{
|
||||
visible: boolean;
|
||||
form: AnnouncementFormState;
|
||||
isSaving: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
save: [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
</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>
|
||||
</template>
|
||||
+123
-12
@@ -1,14 +1,23 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/composables/useAnnouncementsAdmin.ts
|
||||
* 公告管理:列表、发布、删除。
|
||||
* 公告管理:列表、发布/编辑弹窗、详情弹窗、删除。
|
||||
* 依赖:admin.api、announcement.types、useMessage。
|
||||
* 逻辑:AnnouncementsPage 调用本 composable 驱动表格与两个居中弹窗。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { createAnnouncement, deleteAnnouncement, listAnnouncements } from '@/features/admin/api/admin.api';
|
||||
import {
|
||||
createAnnouncement,
|
||||
deleteAnnouncement,
|
||||
listAnnouncements,
|
||||
updateAnnouncement,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { AdminAnnouncementRow } from '@/features/admin/types/admin.types';
|
||||
import {
|
||||
announcementRowToForm,
|
||||
createEmptyAnnouncementForm,
|
||||
truncateAnnouncementPreview,
|
||||
type AnnouncementFormState,
|
||||
} from '@/features/admin/types/announcement.types';
|
||||
|
||||
@@ -17,14 +26,21 @@ export function useAnnouncementsAdmin() {
|
||||
const msg = useMessage();
|
||||
|
||||
const announcements = ref<AdminAnnouncementRow[]>([]);
|
||||
const newAnnouncement = ref<AnnouncementFormState>(createEmptyAnnouncementForm());
|
||||
const form = ref<AnnouncementFormState>(createEmptyAnnouncementForm());
|
||||
const viewingAnnouncement = ref<AdminAnnouncementRow | null>(null);
|
||||
const isLoading = ref(true);
|
||||
const isSaving = ref(false);
|
||||
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>
|
||||
*/
|
||||
const loadAnnouncements = async (): Promise<void> => {
|
||||
try {
|
||||
announcements.value = await listAnnouncements();
|
||||
@@ -34,23 +50,37 @@ export function useAnnouncementsAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 页面初始化:加载公告列表并结束 loading。
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
const loadAll = async (): Promise<void> => {
|
||||
isLoading.value = true;
|
||||
await loadAnnouncements();
|
||||
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 {
|
||||
@@ -60,18 +90,74 @@ export function useAnnouncementsAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
const publishAnnouncement = async (): Promise<void> => {
|
||||
if (!newAnnouncement.value.title.trim() || !newAnnouncement.value.content.trim()) {
|
||||
/** 打开「发布公告」弹窗并重置表单。 */
|
||||
const openCreateModal = (): void => {
|
||||
form.value = createEmptyAnnouncementForm();
|
||||
showFormModal.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开「编辑公告」弹窗并回填选中行数据。
|
||||
* @param row - 待编辑的公告行
|
||||
*/
|
||||
const openEditModal = (row: AdminAnnouncementRow): void => {
|
||||
form.value = announcementRowToForm(row);
|
||||
showDetailModal.value = false;
|
||||
showFormModal.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开公告详情弹窗。
|
||||
* @param row - 待查看的公告行
|
||||
*/
|
||||
const openDetailModal = (row: AdminAnnouncementRow): void => {
|
||||
viewingAnnouncement.value = row;
|
||||
showDetailModal.value = true;
|
||||
};
|
||||
|
||||
/** 关闭创建/编辑弹窗。 */
|
||||
const closeFormModal = (): void => {
|
||||
showFormModal.value = false;
|
||||
form.value = createEmptyAnnouncementForm();
|
||||
};
|
||||
|
||||
/** 关闭详情弹窗。 */
|
||||
const closeDetailModal = (): void => {
|
||||
showDetailModal.value = false;
|
||||
viewingAnnouncement.value = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 从详情弹窗跳转至编辑弹窗。
|
||||
* 核心逻辑:关闭详情弹窗,用当前 viewingAnnouncement 回填编辑表单。
|
||||
*/
|
||||
const editFromDetail = (): void => {
|
||||
if (!viewingAnnouncement.value) return;
|
||||
openEditModal(viewingAnnouncement.value);
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存公告:有 id 则更新,否则新建。
|
||||
* 核心逻辑:校验必填 → 调 create/update API → 刷新列表并关闭弹窗。
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
const saveAnnouncement = async (): Promise<void> => {
|
||||
if (!form.value.title.trim() || !form.value.content.trim()) {
|
||||
msg.warning(t('admin.announcement.msg.fillAll'));
|
||||
return;
|
||||
}
|
||||
isSaving.value = true;
|
||||
try {
|
||||
await createAnnouncement({
|
||||
title: newAnnouncement.value.title.trim(),
|
||||
content: newAnnouncement.value.content.trim(),
|
||||
});
|
||||
newAnnouncement.value = createEmptyAnnouncementForm();
|
||||
const payload = {
|
||||
title: form.value.title.trim(),
|
||||
content: form.value.content.trim(),
|
||||
};
|
||||
if (form.value.id) {
|
||||
await updateAnnouncement(form.value.id, payload);
|
||||
} else {
|
||||
await createAnnouncement(payload);
|
||||
}
|
||||
closeFormModal();
|
||||
await loadAnnouncements();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -81,10 +167,17 @@ export function useAnnouncementsAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除指定公告,删除前弹出确认框。
|
||||
* @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);
|
||||
@@ -93,17 +186,35 @@ export function useAnnouncementsAdmin() {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 格式化公告发布时间为本地字符串。
|
||||
* @param iso - 后端 created_at
|
||||
* @returns 本地化日期时间
|
||||
*/
|
||||
const formatPublishedAt = (iso: string): string => new Date(iso).toLocaleString();
|
||||
|
||||
return {
|
||||
announcements,
|
||||
newAnnouncement,
|
||||
form,
|
||||
viewingAnnouncement,
|
||||
isLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDetailModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
publishAnnouncement,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
openDetailModal,
|
||||
closeFormModal,
|
||||
closeDetailModal,
|
||||
editFromDetail,
|
||||
saveAnnouncement,
|
||||
deleteAnnouncementItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
truncateAnnouncementPreview,
|
||||
formatPublishedAt,
|
||||
};
|
||||
}
|
||||
@@ -1,14 +1,54 @@
|
||||
/**
|
||||
* features/admin/types/announcement.types.ts
|
||||
* 公告管理表单类型。
|
||||
* 公告管理表单与展示类型。
|
||||
* 依赖:AdminAnnouncementRow(admin.types)。
|
||||
* 逻辑:AnnouncementsPage / useAnnouncementsAdmin 用于创建与编辑弹窗表单。
|
||||
*/
|
||||
|
||||
export interface AnnouncementFormState {
|
||||
id?: number;
|
||||
title: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建空白公告表单,用于「发布公告」弹窗初始状态。
|
||||
* @returns 无 id 的空表单对象
|
||||
*/
|
||||
export const createEmptyAnnouncementForm = (): AnnouncementFormState => ({
|
||||
title: '',
|
||||
content: '',
|
||||
});
|
||||
|
||||
/**
|
||||
* 将列表行转为编辑表单,供「编辑公告」弹窗回填。
|
||||
* @param row - 公告列表行
|
||||
* @returns 含 id 的表单对象
|
||||
*/
|
||||
export const announcementRowToForm = (row: {
|
||||
id: number;
|
||||
title: string;
|
||||
content: string;
|
||||
}): AnnouncementFormState => ({
|
||||
id: row.id,
|
||||
title: row.title,
|
||||
content: row.content,
|
||||
});
|
||||
|
||||
/** 列表摘要截断默认最大字符数 */
|
||||
export const ANNOUNCEMENT_PREVIEW_MAX_LENGTH = 60;
|
||||
|
||||
/**
|
||||
* 将公告正文截断为一行摘要,供表格预览列展示。
|
||||
* @param content - 公告正文
|
||||
* @param maxLength - 最大字符数,默认 60
|
||||
* @returns 截断后的摘要(去除换行)
|
||||
*/
|
||||
export const truncateAnnouncementPreview = (
|
||||
content: string,
|
||||
maxLength = ANNOUNCEMENT_PREVIEW_MAX_LENGTH,
|
||||
): string => {
|
||||
const normalized = content.replace(/\s+/g, ' ').trim();
|
||||
if (normalized.length <= maxLength) return normalized;
|
||||
return `${normalized.slice(0, maxLength)}…`;
|
||||
};
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { Bot, Megaphone } from 'lucide-vue-next';
|
||||
import AnnouncementCardCarousel from '@/shared/components/AnnouncementCardCarousel.vue';
|
||||
import { LOGIN_KEY } from '../composables/login.context';
|
||||
|
||||
const lk = inject(LOGIN_KEY)! as any;
|
||||
@@ -37,25 +38,18 @@ const lk = inject(LOGIN_KEY)! as any;
|
||||
{{ $t('landing.hero.subtitle') }}
|
||||
</p>
|
||||
|
||||
<div v-if="lk.announcements.length > 0" class="bg-white/70 backdrop-blur-sm rounded-2xl border border-default p-6 shadow-sm">
|
||||
<h3 class="text-sm font-bold text-slate-950 mb-4 flex items-center gap-2">
|
||||
<div v-if="lk.announcements.length > 0" class="bg-white/75 backdrop-blur-md rounded-2xl border border-white/60 p-5 shadow-sm">
|
||||
<h3 class="text-sm font-bold text-slate-900 mb-3 flex items-center gap-2">
|
||||
<Megaphone class="w-4 h-4 text-brand-600" />
|
||||
{{ $t('login.announcements') }}
|
||||
</h3>
|
||||
<div class="space-y-3">
|
||||
<div
|
||||
v-for="ann in lk.announcements.slice(0, 3)"
|
||||
:key="ann.id"
|
||||
class="group cursor-pointer hover:bg-white/50 p-2 rounded-lg transition-colors"
|
||||
@click="lk.openAnnouncement(ann)"
|
||||
>
|
||||
<div class="flex justify-between items-start gap-2">
|
||||
<h4 class="text-sm font-semibold text-primary group-hover:text-brand-800 line-clamp-1">{{ ann.title }}</h4>
|
||||
<span class="text-[10px] text-muted whitespace-nowrap">{{ new Date(ann.created_at).toLocaleDateString() }}</span>
|
||||
</div>
|
||||
<p class="text-xs text-secondary line-clamp-2 mt-1">{{ ann.content }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<AnnouncementCardCarousel
|
||||
:announcements="lk.announcements"
|
||||
variant="login"
|
||||
:auto-play="lk.announcements.length > 1"
|
||||
:auto-play-interval="8000"
|
||||
@select="lk.openAnnouncement"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
LayoutGrid, Star, GripVertical, Plus, Trash2, Edit, ExternalLink,
|
||||
Bot, Megaphone, ChevronDown, ChevronUp,
|
||||
} from 'lucide-vue-next';
|
||||
import AnnouncementCardCarousel from '@/shared/components/AnnouncementCardCarousel.vue';
|
||||
import { WORKSPACE_KEY } from '../composables/workspace.context';
|
||||
|
||||
const ws = inject(WORKSPACE_KEY)! as any;
|
||||
@@ -57,19 +58,14 @@ const ws = inject(WORKSPACE_KEY)! as any;
|
||||
<!-- Content: Announcements -->
|
||||
<div v-if="section.id === 'announcements'">
|
||||
<div v-if="ws.announcements.length === 0" class="text-muted text-sm italic py-8 text-center bg-surface-soft rounded-xl border border-dashed border-default">{{ $t('workspace.announcements.noData') }}</div>
|
||||
<div v-else class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
|
||||
<div
|
||||
v-for="ann in ws.announcements"
|
||||
:key="ann.id"
|
||||
class="group border border-default rounded-2xl bg-surface p-5 hover:border-emerald-300 hover:shadow-md transition-all cursor-pointer"
|
||||
@click="ws.openAnnouncement(ann)"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3 mb-2">
|
||||
<h4 class="font-bold text-primary line-clamp-2 group-hover:text-emerald-700 transition-colors">{{ ann.title }}</h4>
|
||||
<span class="text-[10px] font-semibold text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded-full whitespace-nowrap">{{ new Date(ann.created_at).toLocaleDateString() }}</span>
|
||||
</div>
|
||||
<p class="text-sm text-secondary line-clamp-3">{{ ann.content }}</p>
|
||||
</div>
|
||||
<div v-else class="max-w-2xl">
|
||||
<AnnouncementCardCarousel
|
||||
:announcements="ws.announcements"
|
||||
variant="workspace"
|
||||
:auto-play="ws.announcements.length > 1"
|
||||
:auto-play-interval="8000"
|
||||
@select="ws.openAnnouncement"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -212,6 +212,8 @@
|
||||
"title": "Announcement Management",
|
||||
"subtitle": "Publish company announcements for all users",
|
||||
"add": "Publish Announcement",
|
||||
"edit": "Edit Announcement",
|
||||
"viewDetail": "Announcement Details",
|
||||
"publish": "Publish",
|
||||
"noData": "No announcements yet",
|
||||
"confirmDelete": "Are you sure to delete this announcement?",
|
||||
@@ -219,6 +221,17 @@
|
||||
"title": "Title",
|
||||
"content": "Content"
|
||||
},
|
||||
"headers": {
|
||||
"title": "Title",
|
||||
"publishedAt": "Published At",
|
||||
"preview": "Preview",
|
||||
"actions": "Actions"
|
||||
},
|
||||
"actions": {
|
||||
"view": "View",
|
||||
"edit": "Edit",
|
||||
"delete": "Delete"
|
||||
},
|
||||
"msg": {
|
||||
"fillAll": "Please fill all fields"
|
||||
}
|
||||
|
||||
@@ -41,7 +41,12 @@
|
||||
},
|
||||
"announcements": {
|
||||
"title": "Company Announcements",
|
||||
"noData": "No announcements yet."
|
||||
"noData": "No announcements yet.",
|
||||
"prev": "Previous",
|
||||
"next": "Next",
|
||||
"viewDetail": "Click to view details",
|
||||
"goTo": "Announcement {index}",
|
||||
"currentOf": "{current} of {total}"
|
||||
},
|
||||
"favorites": "Favorites",
|
||||
"myAgents": "My Agents",
|
||||
|
||||
@@ -212,6 +212,8 @@
|
||||
"title": "การจัดการประกาศ",
|
||||
"subtitle": "เผยแพร่ข่าวสารบริษัทให้ผู้ใช้ทุกคน",
|
||||
"add": "เผยแพร่ประกาศ",
|
||||
"edit": "แก้ไขประกาศ",
|
||||
"viewDetail": "รายละเอียดประกาศ",
|
||||
"publish": "เผยแพร่",
|
||||
"noData": "ยังไม่มีประกาศ",
|
||||
"confirmDelete": "คุณแน่ใจหรือไม่ว่าต้องการลบประกาศนี้?",
|
||||
@@ -219,6 +221,17 @@
|
||||
"title": "หัวข้อ",
|
||||
"content": "เนื้อหา"
|
||||
},
|
||||
"headers": {
|
||||
"title": "หัวข้อ",
|
||||
"publishedAt": "เวลาเผยแพร่",
|
||||
"preview": "สรุปเนื้อหา",
|
||||
"actions": "การดำเนินการ"
|
||||
},
|
||||
"actions": {
|
||||
"view": "ดู",
|
||||
"edit": "แก้ไข",
|
||||
"delete": "ลบ"
|
||||
},
|
||||
"msg": {
|
||||
"fillAll": "กรุณากรอกข้อมูลให้ครบถ้วน"
|
||||
}
|
||||
|
||||
@@ -41,7 +41,12 @@
|
||||
},
|
||||
"announcements": {
|
||||
"title": "ประกาศบริษัท",
|
||||
"noData": "ยังไม่มีประกาศ"
|
||||
"noData": "ยังไม่มีประกาศ",
|
||||
"prev": "ก่อนหน้า",
|
||||
"next": "ถัดไป",
|
||||
"viewDetail": "คลิกเพื่อดูรายละเอียด",
|
||||
"goTo": "ประกาศที่ {index}",
|
||||
"currentOf": "{current} จาก {total}"
|
||||
},
|
||||
"favorites": "รายการโปรด",
|
||||
"myAgents": "ตัวแทนของฉัน",
|
||||
|
||||
@@ -213,6 +213,8 @@
|
||||
"title": "公告管理",
|
||||
"subtitle": "面向全体用户发布公司资讯",
|
||||
"add": "发布公告",
|
||||
"edit": "编辑公告",
|
||||
"viewDetail": "公告详情",
|
||||
"publish": "发布",
|
||||
"noData": "暂无公告",
|
||||
"confirmDelete": "确认删除该公告吗?",
|
||||
@@ -220,6 +222,17 @@
|
||||
"title": "标题",
|
||||
"content": "内容"
|
||||
},
|
||||
"headers": {
|
||||
"title": "标题",
|
||||
"publishedAt": "发布时间",
|
||||
"preview": "内容摘要",
|
||||
"actions": "操作"
|
||||
},
|
||||
"actions": {
|
||||
"view": "查看",
|
||||
"edit": "编辑",
|
||||
"delete": "删除"
|
||||
},
|
||||
"msg": {
|
||||
"fillAll": "请填写所有必填项"
|
||||
}
|
||||
|
||||
@@ -41,7 +41,12 @@
|
||||
},
|
||||
"announcements": {
|
||||
"title": "公司公告",
|
||||
"noData": "暂无公告"
|
||||
"noData": "暂无公告",
|
||||
"prev": "上一条",
|
||||
"next": "下一条",
|
||||
"viewDetail": "点击查看详情",
|
||||
"goTo": "第 {index} 条公告",
|
||||
"currentOf": "第 {current} 条,共 {total} 条"
|
||||
},
|
||||
"favorites": "收藏应用",
|
||||
"myAgents": "我的应用",
|
||||
|
||||
@@ -212,6 +212,8 @@
|
||||
"title": "公告管理",
|
||||
"subtitle": "面向全體用戶發布公司資訊",
|
||||
"add": "發布公告",
|
||||
"edit": "編輯公告",
|
||||
"viewDetail": "公告詳情",
|
||||
"publish": "發布",
|
||||
"noData": "暫無公告",
|
||||
"confirmDelete": "確認刪除該公告嗎?",
|
||||
@@ -219,6 +221,17 @@
|
||||
"title": "標題",
|
||||
"content": "內容"
|
||||
},
|
||||
"headers": {
|
||||
"title": "標題",
|
||||
"publishedAt": "發布時間",
|
||||
"preview": "內容摘要",
|
||||
"actions": "操作"
|
||||
},
|
||||
"actions": {
|
||||
"view": "查看",
|
||||
"edit": "編輯",
|
||||
"delete": "刪除"
|
||||
},
|
||||
"msg": {
|
||||
"fillAll": "請填寫所有必填項"
|
||||
}
|
||||
|
||||
@@ -41,7 +41,12 @@
|
||||
},
|
||||
"announcements": {
|
||||
"title": "公司公告",
|
||||
"noData": "暫無公告"
|
||||
"noData": "暫無公告",
|
||||
"prev": "上一條",
|
||||
"next": "下一條",
|
||||
"viewDetail": "點擊查看詳情",
|
||||
"goTo": "第 {index} 則公告",
|
||||
"currentOf": "第 {current} 則,共 {total} 則"
|
||||
},
|
||||
"favorites": "收藏應用",
|
||||
"myAgents": "我的應用",
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
/**
|
||||
* shared/components/AnnouncementCardCarousel.vue
|
||||
* 公告横向滑动走马灯:每次仅展示一条,无层叠侧卡。
|
||||
* 依赖:WorkspaceAnnouncement、lucide-vue-next、truncateAnnouncementPreview。
|
||||
* 逻辑:LoginPage / HomePage 传入公告列表;点击卡片 emit select 打开详情弹窗。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ChevronLeft, ChevronRight } from 'lucide-vue-next';
|
||||
import { truncateAnnouncementPreview } from '@/features/admin/types/announcement.types';
|
||||
import type { WorkspaceAnnouncement } from '@/features/workspace/types/workspace.types';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
announcements: WorkspaceAnnouncement[];
|
||||
/** 视觉主题:login 融入登录页毛玻璃区,workspace 工作台卡片风格 */
|
||||
variant?: 'login' | 'workspace';
|
||||
autoPlay?: boolean;
|
||||
autoPlayInterval?: number;
|
||||
}>(),
|
||||
{
|
||||
variant: 'login',
|
||||
autoPlay: false,
|
||||
autoPlayInterval: 6000,
|
||||
},
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
select: [WorkspaceAnnouncement];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const currentIndex = ref(0);
|
||||
let autoPlayTimer: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
const total = computed(() => props.announcements.length);
|
||||
const hasMultiple = computed(() => total.value > 1);
|
||||
const activeAnnouncement = computed(() => props.announcements[currentIndex.value] ?? null);
|
||||
const trackStyle = computed(() => ({
|
||||
transform: `translateX(-${currentIndex.value * 100}%)`,
|
||||
}));
|
||||
|
||||
/**
|
||||
* 将索引归一化到 [0, length) 区间,支持首尾循环。
|
||||
* @param index - 原始索引
|
||||
* @returns 合法索引
|
||||
*/
|
||||
const normalizeIndex = (index: number): number => {
|
||||
if (total.value <= 0) return 0;
|
||||
return ((index % total.value) + total.value) % total.value;
|
||||
};
|
||||
|
||||
/** 切换到上一条公告。 */
|
||||
const goPrev = (): void => {
|
||||
if (!hasMultiple.value) return;
|
||||
currentIndex.value = normalizeIndex(currentIndex.value - 1);
|
||||
};
|
||||
|
||||
/** 切换到下一条公告。 */
|
||||
const goNext = (): void => {
|
||||
if (!hasMultiple.value) return;
|
||||
currentIndex.value = normalizeIndex(currentIndex.value + 1);
|
||||
};
|
||||
|
||||
/**
|
||||
* 跳转到指定索引。
|
||||
* @param index - 目标索引
|
||||
*/
|
||||
const goTo = (index: number): void => {
|
||||
if (index < 0 || index >= total.value) return;
|
||||
currentIndex.value = index;
|
||||
};
|
||||
|
||||
/**
|
||||
* 点击当前公告卡片,打开详情弹窗。
|
||||
* @param ann - 被点击公告
|
||||
*/
|
||||
const openDetail = (ann: WorkspaceAnnouncement): void => {
|
||||
emit('select', ann);
|
||||
};
|
||||
|
||||
/**
|
||||
* 格式化公告日期为本地化短日期。
|
||||
* @param iso - created_at
|
||||
*/
|
||||
const formatDate = (iso: string): string => new Date(iso).toLocaleDateString();
|
||||
|
||||
/** 启动自动轮播定时器。 */
|
||||
const startAutoPlay = (): void => {
|
||||
stopAutoPlay();
|
||||
if (!props.autoPlay || !hasMultiple.value) return;
|
||||
autoPlayTimer = setInterval(goNext, props.autoPlayInterval);
|
||||
};
|
||||
|
||||
/** 停止自动轮播定时器。 */
|
||||
const stopAutoPlay = (): void => {
|
||||
if (autoPlayTimer) {
|
||||
clearInterval(autoPlayTimer);
|
||||
autoPlayTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => [props.announcements, props.autoPlay, props.autoPlayInterval] as const,
|
||||
() => {
|
||||
currentIndex.value = normalizeIndex(currentIndex.value);
|
||||
if (currentIndex.value >= total.value) {
|
||||
currentIndex.value = 0;
|
||||
}
|
||||
startAutoPlay();
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopAutoPlay();
|
||||
});
|
||||
|
||||
const panelClass = computed(() =>
|
||||
props.variant === 'workspace'
|
||||
? 'rounded-2xl border border-emerald-100 bg-gradient-to-br from-white to-emerald-50/40'
|
||||
: 'rounded-xl',
|
||||
);
|
||||
|
||||
const accentTextClass = computed(() =>
|
||||
props.variant === 'workspace' ? 'text-emerald-600' : 'text-brand-600',
|
||||
);
|
||||
|
||||
const dateBadgeClass = computed(() =>
|
||||
props.variant === 'workspace'
|
||||
? 'text-emerald-700 bg-emerald-50'
|
||||
: 'text-muted bg-slate-100/80',
|
||||
);
|
||||
|
||||
const dotActiveClass = computed(() =>
|
||||
props.variant === 'workspace' ? 'bg-emerald-500' : 'bg-brand-600',
|
||||
);
|
||||
|
||||
const navBtnClass = computed(() =>
|
||||
props.variant === 'workspace'
|
||||
? 'hover:bg-emerald-50 hover:text-emerald-700 disabled:hover:bg-transparent'
|
||||
: 'hover:bg-white/80 hover:text-brand-700 disabled:hover:bg-transparent',
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="w-full"
|
||||
@mouseenter="stopAutoPlay"
|
||||
@mouseleave="startAutoPlay"
|
||||
>
|
||||
<div class="overflow-hidden" :class="panelClass">
|
||||
<div
|
||||
class="flex transition-transform duration-500 ease-out"
|
||||
:style="trackStyle"
|
||||
>
|
||||
<article
|
||||
v-for="ann in announcements"
|
||||
:key="ann.id"
|
||||
class="w-full shrink-0 cursor-pointer group px-1 py-1 sm:px-2 sm:py-2"
|
||||
@click="openDetail(ann)"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3 mb-2">
|
||||
<h4
|
||||
class="text-sm font-semibold text-primary line-clamp-1 transition-colors"
|
||||
:class="variant === 'workspace' ? 'group-hover:text-emerald-700' : 'group-hover:text-brand-700'"
|
||||
>
|
||||
{{ ann.title }}
|
||||
</h4>
|
||||
<time
|
||||
class="text-[10px] font-medium px-2 py-0.5 rounded-full whitespace-nowrap shrink-0"
|
||||
:class="dateBadgeClass"
|
||||
:datetime="ann.created_at"
|
||||
>
|
||||
{{ formatDate(ann.created_at) }}
|
||||
</time>
|
||||
</div>
|
||||
<p class="text-xs sm:text-sm text-secondary line-clamp-3 leading-relaxed min-h-[3.75rem]">
|
||||
{{ truncateAnnouncementPreview(ann.content, 100) }}
|
||||
</p>
|
||||
<p class="mt-2.5 text-xs font-medium transition-colors" :class="accentTextClass">
|
||||
{{ t('workspace.announcements.viewDetail') }} →
|
||||
</p>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="hasMultiple"
|
||||
class="mt-3 flex items-center justify-between gap-3"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 rounded-lg text-muted transition-colors disabled:opacity-30"
|
||||
:class="navBtnClass"
|
||||
:aria-label="t('workspace.announcements.prev')"
|
||||
@click="goPrev"
|
||||
>
|
||||
<ChevronLeft class="w-4 h-4" />
|
||||
</button>
|
||||
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<button
|
||||
v-for="(_, index) in announcements"
|
||||
:key="index"
|
||||
type="button"
|
||||
class="h-1.5 rounded-full transition-all duration-300"
|
||||
:class="index === currentIndex ? `${dotActiveClass} w-5` : 'w-1.5 bg-slate-300 hover:bg-slate-400'"
|
||||
:aria-label="t('workspace.announcements.goTo', { index: index + 1 })"
|
||||
@click="goTo(index)"
|
||||
/>
|
||||
</div>
|
||||
<span class="text-[11px] text-muted tabular-nums whitespace-nowrap">
|
||||
{{ t('workspace.announcements.currentOf', { current: currentIndex + 1, total }) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 rounded-lg text-muted transition-colors"
|
||||
:class="navBtnClass"
|
||||
:aria-label="t('workspace.announcements.next')"
|
||||
@click="goNext"
|
||||
>
|
||||
<ChevronRight class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p v-if="activeAnnouncement && hasMultiple" class="sr-only">
|
||||
{{ activeAnnouncement.title }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user