V1.2.0需求 4个页面新增及功能 待处理编辑器锚点定位、编辑器发布的文章UI优化、中英文翻译

This commit is contained in:
2025-07-25 16:39:37 +08:00
parent 9fa026f267
commit 22dad92ef9
27 changed files with 3374 additions and 1269 deletions

View File

@@ -1,33 +1,16 @@
<template>
<div class="announcements-container">
<div class="announcements-container" >
<!-- 主要内容区域 -->
<div class="main-content" v-loading="loading">
<div class="main-content" v-loading="announcementsLoading">
<!-- 页面标题 -->
<div class="page-header">
<div class="header-left">
<h1 class="page-title">{{ $t('home.announcements') || '公告中心' }}</h1>
</div>
<div class="header-actions">
<el-button-group>
<el-button
:type="viewMode === 'list' ? 'primary' : 'default'"
@click="switchMode('list')"
icon="el-icon-menu"
>
查看公告
</el-button>
<el-button
:type="viewMode === 'editor' ? 'primary' : 'default'"
@click="switchMode('editor')"
icon="el-icon-edit"
>
Markdown编辑器
</el-button>
</el-button-group>
</div>
</div>
<!-- Markdown 使用规则指南 -->
<div class="markdown-guide-section" v-if="showMarkdownGuide">
@@ -339,7 +322,7 @@ ___ (三个或更多下划线)</code></pre>
<h3 class="announcement-title">{{ announcement.title }}</h3>
<div class="announcement-meta">
<span class="announcement-date">{{ formatDate(announcement.createTime) }}</span>
<span class="announcement-type" v-if="announcement.type">{{ announcement.type }}</span>
<span class="announcement-type" v-if="announcement.type">{{handelType(announcement.type) }}</span>
</div>
<p class="announcement-summary" v-if="announcement.summary">
{{ announcement.summary }}
@@ -361,7 +344,7 @@ ___ (三个或更多下划线)</code></pre>
<!-- 分页信息和查看更多 -->
<div class="pagination-section" v-if="announcements.length > 0">
<div class="view-all-button">
<!-- <div class="view-all-button">
<el-button
type="text"
class="view-all-link"
@@ -370,25 +353,17 @@ ___ (三个或更多下划线)</code></pre>
{{ $t('home.viewAll') || '查看所有' }} {{ totalCount }} {{ $t('home.articles') || '篇文章' }}
</el-button>
<!-- 了解使用规则按钮 -->
<el-button
type="text"
class="markdown-guide-btn"
@click="toggleMarkdownGuide"
:icon="showMarkdownGuide ? 'el-icon-arrow-up' : 'el-icon-question'"
>
{{ showMarkdownGuide ? '隐藏' : '了解' }}Markdown使用规则
</el-button>
</div>
</div> -->
<!-- 分页组件 -->
<el-pagination
v-if="totalCount > pageSize"
<el-pagination
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
:current-page="currentPage"
:page-size="pageSize"
:page-sizes="[10, 50, 100, 400]"
:total="totalCount"
layout="prev, pager, next"
layout="total, sizes, prev, pager, next, jumper"
class="pagination"
/>
</div>
@@ -401,214 +376,11 @@ ___ (三个或更多下划线)</code></pre>
* 公告中心页面组件
* 提供公告列表展示、搜索、分页等功能
*/
import Index from './index.js'
export default {
name: 'Announcements',
data() {
return {
// 加载状态
loading: false,
// 搜索关键词
searchKeyword: '',
// 分页参数
currentPage: 1,
pageSize: 10,
totalCount: 275,
// 公告数据
announcements: [
{
id: 1,
title: 'ZEN挖矿服务即将结束',
summary: 'ZEN挖矿服务将于近期结束请及时调整您的挖矿设置。',
type: '重要通知',
createTime: '2025-01-20T10:00:00.000Z',
isTop: true
},
{
id: 2,
title: 'LKY即将减半',
summary: 'LKY币种将在近期进行减半操作请关注相关通知。',
type: '系统公告',
createTime: '2025-01-19T15:30:00.000Z',
isTop: false
},
{
id: 3,
title: 'PEP即将减产',
summary: 'PEP币种挖矿难度调整产量将有所减少。',
type: '市场动态',
createTime: '2025-01-18T09:15:00.000Z',
isTop: false
},
{
id: 4,
title: 'ETC+ZIL挖矿服务已结束',
summary: 'ETC+ZIL双挖服务已正式结束感谢您的支持。',
type: '服务通知',
createTime: '2025-01-17T14:45:00.000Z',
isTop: false
},
{
id: 5,
title: '有关2025年06月19日SCT池异常的说明',
summary: 'SCT矿池在指定时间出现异常情况现已修复并提供补偿方案。',
type: '故障说明',
createTime: '2025-01-16T11:20:00.000Z',
isTop: false
},
{
id: 6,
title: 'FB单挖矿池下线公告',
summary: 'FB单挖矿池将于本月底正式下线请及时转移算力。',
type: '下线通知',
createTime: '2025-01-15T16:10:00.000Z',
isTop: false
}
],
// 搜索防抖定时器
searchTimer: null,
mixins:[Index],
// Markdown 使用规则指南
showMarkdownGuide: false,
viewMode: 'list' // 'list' or 'editor'
}
},
mounted() {
this.loadAnnouncements();
},
methods: {
/**
* 加载公告数据
*/
async loadAnnouncements() {
this.loading = true;
try {
// 这里应该调用API获取公告数据
// const response = await this.$api.getAnnouncements({
// page: this.currentPage,
// pageSize: this.pageSize,
// keyword: this.searchKeyword
// });
// this.announcements = response.data;
// this.totalCount = response.total;
// 模拟API调用延迟
await new Promise(resolve => setTimeout(resolve, 500));
} catch (error) {
console.error('加载公告失败:', error);
this.$message.error(this.$t('announcements.loadError') || '加载公告失败');
} finally {
this.loading = false;
}
},
/**
* 处理搜索输入
*/
handleSearchInput() {
if (this.searchTimer) {
clearTimeout(this.searchTimer);
}
// 防抖处理500ms后执行搜索
this.searchTimer = setTimeout(() => {
this.handleSearch();
}, 500);
},
/**
* 执行搜索
*/
handleSearch() {
this.currentPage = 1;
this.loadAnnouncements();
},
/**
* 处理页码变化
*/
handleCurrentChange(page) {
this.currentPage = page;
this.loadAnnouncements();
},
/**
* 处理公告点击
*/
handleAnnouncementClick(announcement) {
// 跳转到公告详情页
this.$router.push({
name: 'AnnouncementDetail',
params: { id: announcement.id }
});
},
/**
* 查看所有公告
*/
handleViewAll() {
// 可以跳转到完整的公告列表页面或展开显示更多
this.pageSize = 20;
this.loadAnnouncements();
},
/**
* 切换Markdown使用规则指南的显示状态
*/
toggleMarkdownGuide() {
this.showMarkdownGuide = !this.showMarkdownGuide;
},
/**
* 切换视图模式 (list/editor)
*/
switchMode(mode) {
this.viewMode = mode;
// Markdown指南现在完全独立控制不与视图模式绑定
},
/**
* 返回首页
*/
goHome() {
this.$router.push('/');
},
/**
* 格式化日期
*/
formatDate(dateString) {
if (!dateString) return '';
const date = new Date(dateString);
const now = new Date();
const diffTime = now - date;
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
if (diffDays === 0) {
return '今天';
} else if (diffDays === 1) {
return '昨天';
} else if (diffDays < 7) {
return `${diffDays}天前`;
} else {
return date.toLocaleDateString('zh-CN');
}
}
},
beforeDestroy() {
// 清理定时器
if (this.searchTimer) {
clearTimeout(this.searchTimer);
}
}
}
</script>