/** * 日志管理 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 []; } } };