Update .gitignore and add files

This commit is contained in:
jrhlh
2025-07-17 23:13:04 +08:00
commit 39cedd4073
257 changed files with 34603 additions and 0 deletions

View File

@ -0,0 +1,37 @@
// utils/event-bus.js - 改进事件总线以管理全局状态
class GlobalState {
constructor() {
this.threshold = 35; // 默认阈值
this.listeners = new Map();
}
// 注册事件监听
on(event, callback) {
if (!this.listeners.has(event)) {
this.listeners.set(event, []);
}
this.listeners.get(event).push(callback);
}
// 触发事件
emit(event, data) {
if (this.listeners.has(event)) {
this.listeners.get(event).forEach(callback => callback(data));
}
}
// 设置全局阈值
setThreshold(threshold) {
this.threshold = threshold;
this.emit('thresholdUpdated', threshold);
}
// 获取全局阈值
getThreshold() {
return this.threshold;
}
}
// 创建全局状态实例
const globalState = new GlobalState();
export default globalState;