V1.2.0需求 4个页面新增及功能 待处理编辑器锚点定位、编辑器发布的文章UI优化、中英文翻译
This commit is contained in:
@@ -0,0 +1,243 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user