Files
autoAiWorkSys/app/mixins/logMixin.js
张成 e17d5610f5 1
2025-12-22 16:26:59 +08:00

49 lines
906 B
JavaScript

/**
* 日志管理 Mixin
* 直接使用 store 中的 log 状态
*/
export default {
methods: {
/**
* 添加日志
* @param {string} level - 日志级别: 'info', 'success', 'warn', 'error'
* @param {string} message - 日志消息
*/
addLog(level, message) {
if (this.$store) {
this.$store.dispatch('log/addLog', { level, message });
}
},
/**
* 清空日志
*/
clearLogs() {
if (this.$store) {
this.$store.dispatch('log/clearLogs');
}
},
/**
* 导出日志
*/
exportLogs() {
if (this.$store) {
this.$store.dispatch('log/exportLogs');
}
}
},
computed: {
/**
* 获取日志条目(从 store 获取)
*/
logEntries() {
if (this.$store) {
return this.$store.getters['log/logEntries'] || [];
}
return [];
}
}
};