Files
m2pool_web_frontend/mining-pool/src/views/announcements/index.js

243 lines
6.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { documentsList } from '../../api/documentManagement'
export default {
name: 'Announcements',
data() {
return {
// 加载状态
loading: false,
// 搜索关键词
searchKeyword: '',
// 分页参数
currentPage: 1,
totalCount: 0,
// 公告数据
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,
// Markdown 使用规则指南
showMarkdownGuide: false,
viewMode: 'list', // 'list' or 'editor'0
listParams:{
type:"3",
lang:this.$i18n.locale,
pageNum:1,
pageSize:10
},
announcementsLoading:false
}
},
mounted() {
try {
this.TypeList = JSON.parse(localStorage.getItem('TypeList'))
} catch (error) {
console.log(error);
}
// this.loadAnnouncements();
this.fetchAllList(this.listParams)
},
methods: {
async fetchAllList(params){
this.setLoading('announcementsLoading', true);
const res = await documentsList(params)
console.log(res,"res");
if (res.code === 200) {
this.announcements = res.rows
this.totalCount = res.total
}
this.setLoading('announcementsLoading', false);
},
/**
* 加载公告数据
*/
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;
},
/**
* 处理页码变化
*/
handleCurrentChange(page) {
this.currentPage = page;
this.listParams.pageNum = page
this.fetchAllList(this.listParams)
},
handleSizeChange(size){
this.listParams.pageNum = 1
this.currentPage = 1;
this.listParams.pageSize = size
this.fetchAllList(this.listParams)
},
/**
* 处理公告点击
*/
handleAnnouncementClick(announcement) {
console.log(announcement,"announcement");
let url = `/${this.$i18n.locale}/announcementDetails`
// 跳转到公告详情页
this.$router.push({
path:url,
query:{
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) {
try {
return `${dateString.split("T")[0]} ${dateString.split("T")[1]}`
} catch (error) {
return ''
}
},
handelType(type){
try {
let label = this.TypeList.find(item => item.value == type).label
return this.$t(label)
} catch (error) {
return ''
}
},
},
beforeDestroy() {
// 清理定时器
if (this.searchTimer) {
clearTimeout(this.searchTimer);
}
}
}