tj
2025-06-05 bba272999cc546f65781bf3d20245a3f819af67f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* eslint-disable class-methods-use-this */
import { post, get, put } from '@/lin/plugin/axios'
import Config from '../../config'
import Sse from '../util/sse'
 
export default class Notify {
  url = null
 
  events = null
 
  sse = null
 
  constructor(url) {
    this.url = url
  }
 
  async getEvents() {
    const res = await get('cms/notify/events')
    this.events = res.events
  }
 
  async initSse() {
    await this.getEvents()
    this.sse = new Sse(Config.baseUrl + this.url, this.events)
  }
 
  /**
   * 创建events
   * @param {number} group_id
   * @param {Array} events
   */
  // eslint-disable-next-line camelcase
  async createEvents(group_id, events) {
    const res = await post('cms/notify/events', { group_id, events })
    return res
  }
 
  /**
   * 更新events
   * @param {number} group_id
   * @param {Array} events
   */
  // eslint-disable-next-line camelcase
  async updateEvents(group_id, events) {
    const res = await put('cms/notify/events', { group_id, events })
    return res
  }
}