hortimagic 1.0.7 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hortimagic.iife.js +2 -2
- package/dist/hortimagic.js +4 -4
- package/dist/hortimagic.txt +4 -4
- package/dist/hortimagic.user.js +4 -4
- package/package.json +4 -3
- package/src/apps/config-app.ts +132 -0
- package/src/apps/dialog-app.ts +62 -0
- package/src/apps/index.ts +5 -0
- package/src/apps/log-app.ts +251 -0
- package/src/apps/main-app.ts +72 -0
- package/src/apps/script-app.ts +225 -0
- package/src/components/hm-swipe-cell.ts +2 -2
- package/src/core/Emitter.ts +129 -0
- package/src/core/Message.ts +179 -0
- package/src/core/decoder.ts +207 -0
- package/src/core/elements-hooks.ts +168 -0
- package/src/core/encoder.ts +154 -0
- package/src/core/index.ts +10 -0
- package/src/core/log-tools.ts +69 -0
- package/src/core/script-tools.ts +121 -0
- package/src/core/socket-tools.ts +118 -0
- package/src/core/store.ts +149 -0
- package/src/core/tools.ts +318 -0
- package/src/easy-tools.ts +141 -0
- package/src/holders/dialog.ts +9 -0
- package/src/holders/index.ts +4 -0
- package/src/holders/menu.ts +20 -0
- package/src/holders/move-panel.ts +9 -0
- package/src/holders/notification.ts +9 -0
- package/src/main.ts +49 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { movePanelHolder } from '../holders/move-panel';
|
|
2
|
+
import { LitElement, html } from 'lit';
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
4
|
+
import *as script_tool from '../core/script-tools';
|
|
5
|
+
import { notice } from '../easy-tools';
|
|
6
|
+
import { HortimagicStore, saveStore, loadStore, reactive } from '../core/store';
|
|
7
|
+
// import { logger } from '../main';
|
|
8
|
+
|
|
9
|
+
const Tag = 'hm-script-app';
|
|
10
|
+
|
|
11
|
+
class HmScriptApp extends LitElement {
|
|
12
|
+
@property({ type: String })
|
|
13
|
+
scriptName = '';
|
|
14
|
+
@property({ type: String })
|
|
15
|
+
scriptUrl = '';
|
|
16
|
+
@property({ type: Boolean })
|
|
17
|
+
scriptEnable = true;
|
|
18
|
+
@property({ type: Boolean })
|
|
19
|
+
scriptIngected = false;
|
|
20
|
+
|
|
21
|
+
@property({ type: Boolean })
|
|
22
|
+
dialogOpen = false;
|
|
23
|
+
|
|
24
|
+
private isUpdate = false;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// 返回一个只读的快照
|
|
29
|
+
storeSnap = reactive.snapshot(HortimagicStore);
|
|
30
|
+
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
reactive.subscribe(HortimagicStore, () => {
|
|
34
|
+
this.storeSnap = reactive.snapshot(HortimagicStore);
|
|
35
|
+
this.requestUpdate();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
// <hm-button @hm-button-click="${() => {
|
|
39
|
+
// logger.debug(Tag, '镜像', this.storeSnap.scriptList);
|
|
40
|
+
// logger.debug(Tag, '存储对象', HortimagicStore.scriptList);
|
|
41
|
+
// }}">当前信息</hm-button>
|
|
42
|
+
|
|
43
|
+
render() {
|
|
44
|
+
return html`
|
|
45
|
+
<hm-dialog ?isopen="${this.dialogOpen}"
|
|
46
|
+
@hm-dialog-close="${() => {
|
|
47
|
+
this.dialogOpen = false;
|
|
48
|
+
}}"
|
|
49
|
+
@hm-dialog-confirm="${() => {
|
|
50
|
+
if (this.scriptName.trim() == "" || this.scriptUrl.trim() == "") {
|
|
51
|
+
notice.error(Tag, "请填写完整的脚本信息"); return;
|
|
52
|
+
}
|
|
53
|
+
// logger.debug(Tag, '要添加的脚本', `${this.scriptName}${this.scriptUrl}`);
|
|
54
|
+
this.scriptEnable = true;
|
|
55
|
+
this.scriptIngected = false;
|
|
56
|
+
let script = new script_tool.Script(this.scriptName, this.scriptUrl, this.scriptEnable);
|
|
57
|
+
let res = false;
|
|
58
|
+
if (this.isUpdate)
|
|
59
|
+
res = script_tool.updateScriptInList(script);
|
|
60
|
+
else
|
|
61
|
+
res = script_tool.addScriptToList(script);
|
|
62
|
+
if (res) {
|
|
63
|
+
notice.success(Tag, "脚本添加成功");
|
|
64
|
+
} else {
|
|
65
|
+
notice.error(Tag, "脚本添加失败");
|
|
66
|
+
}
|
|
67
|
+
/** 关闭修改标志 */
|
|
68
|
+
this.isUpdate = false;
|
|
69
|
+
this.dialogOpen = false;
|
|
70
|
+
this.storeSnap = reactive.snapshot(HortimagicStore);
|
|
71
|
+
/** 刷新渲染 */
|
|
72
|
+
// this.requestUpdate();
|
|
73
|
+
}}"
|
|
74
|
+
>
|
|
75
|
+
<h2>修改或添加脚本</h2>
|
|
76
|
+
<hm-input
|
|
77
|
+
label=" 脚本名称"
|
|
78
|
+
placeholder="请输入脚本名称"
|
|
79
|
+
value="${this.scriptName}"
|
|
80
|
+
@hm-input-change="${(e: CustomEvent) => { this.scriptName = e.detail.value; }}"
|
|
81
|
+
>
|
|
82
|
+
</hm-input>
|
|
83
|
+
<hm-input
|
|
84
|
+
label="脚本链接"
|
|
85
|
+
placeholder="请输入https的脚本链接"
|
|
86
|
+
value="${this.scriptUrl}"
|
|
87
|
+
@hm-input-change="${(e: CustomEvent) => { this.scriptUrl = e.detail.value; }}"
|
|
88
|
+
>
|
|
89
|
+
</hm-input>
|
|
90
|
+
|
|
91
|
+
</hm-dialog>
|
|
92
|
+
|
|
93
|
+
<hm-accordion>
|
|
94
|
+
<span slot="header"> 脚本列表 </span>
|
|
95
|
+
${this.storeSnap.scriptList.map((script) => {
|
|
96
|
+
return html`
|
|
97
|
+
<hm-swipe-cell>
|
|
98
|
+
<div slot="left-actions">
|
|
99
|
+
<hm-button
|
|
100
|
+
icon="delete"
|
|
101
|
+
@hm-button-click="${() => {
|
|
102
|
+
let res = script_tool.removeScriptFromList(script);
|
|
103
|
+
if (res) {
|
|
104
|
+
notice.success(Tag, "脚本删除成功");
|
|
105
|
+
} else {
|
|
106
|
+
notice.error(Tag, "脚本已经不在脚本列表中");
|
|
107
|
+
}
|
|
108
|
+
this.storeSnap = reactive.snapshot(HortimagicStore);
|
|
109
|
+
/** 刷新渲染 */
|
|
110
|
+
// this.requestUpdate();
|
|
111
|
+
}
|
|
112
|
+
}"
|
|
113
|
+
>删除</hm-button
|
|
114
|
+
>
|
|
115
|
+
</div>
|
|
116
|
+
<hm-cell title-name="${script.name}" descripthion="${script.url}">
|
|
117
|
+
<hm-switch
|
|
118
|
+
?checked="${script.enable}"
|
|
119
|
+
@hm-switch-change="${(e: CustomEvent) => {
|
|
120
|
+
let sc = new script_tool.Script(script.name, script.url, e.detail.checked);
|
|
121
|
+
let res = script_tool.updateScriptInList(sc);
|
|
122
|
+
if (res) {
|
|
123
|
+
notice.success(Tag, "脚本修改成功");
|
|
124
|
+
} else {
|
|
125
|
+
notice.error(Tag, "脚本修改失败");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}"
|
|
129
|
+
></hm-switch>
|
|
130
|
+
</hm-cell>
|
|
131
|
+
<div slot="right-actions">
|
|
132
|
+
<hm-button
|
|
133
|
+
icon="edit"
|
|
134
|
+
@hm-button-click="${() => {
|
|
135
|
+
this.scriptName = script.name;
|
|
136
|
+
this.scriptUrl = script.url;
|
|
137
|
+
this.scriptEnable = script.enable;
|
|
138
|
+
/** 打开修改标志位 */
|
|
139
|
+
this.isUpdate = true;
|
|
140
|
+
this.dialogOpen = true;
|
|
141
|
+
// script_tool.addScriptToList(script);
|
|
142
|
+
}
|
|
143
|
+
}"
|
|
144
|
+
>修改</hm-button
|
|
145
|
+
>
|
|
146
|
+
<hm-button
|
|
147
|
+
icon="run"
|
|
148
|
+
?enable="${!script_tool.ingectedUrlList.includes(script.url)}"
|
|
149
|
+
@hm-button-click="${() => {
|
|
150
|
+
let res = script_tool.ingecteScript(script);
|
|
151
|
+
if (res) {
|
|
152
|
+
notice.success(Tag, "脚本运行成功");
|
|
153
|
+
} else {
|
|
154
|
+
notice.error(Tag, "脚本运行失败,脚本已经在运行了");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}"
|
|
158
|
+
>运行</hm-button
|
|
159
|
+
>
|
|
160
|
+
</div>
|
|
161
|
+
</hm-swipe-cell>
|
|
162
|
+
` })
|
|
163
|
+
}
|
|
164
|
+
<div slot="footer">
|
|
165
|
+
<hm-button
|
|
166
|
+
icon="refresh"
|
|
167
|
+
@click="${() => {
|
|
168
|
+
loadStore();
|
|
169
|
+
this.storeSnap = reactive.snapshot(HortimagicStore);
|
|
170
|
+
/** 刷新渲染 */
|
|
171
|
+
// this.requestUpdate();
|
|
172
|
+
}}"
|
|
173
|
+
>
|
|
174
|
+
刷新
|
|
175
|
+
</hm-button>
|
|
176
|
+
<hm-button
|
|
177
|
+
icon="post-add"
|
|
178
|
+
@click="${() => {
|
|
179
|
+
this.dialogOpen = true;
|
|
180
|
+
}}"
|
|
181
|
+
>
|
|
182
|
+
添加
|
|
183
|
+
</hm-button>
|
|
184
|
+
<hm-button
|
|
185
|
+
icon="save"
|
|
186
|
+
@click="${() => {
|
|
187
|
+
saveStore();
|
|
188
|
+
}}">
|
|
189
|
+
保存
|
|
190
|
+
</hm-button>
|
|
191
|
+
</div>
|
|
192
|
+
</hm-accordion>`;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function initScriptApp() {
|
|
197
|
+
customElements.define('hm-script-app', HmScriptApp);
|
|
198
|
+
let panel = document.createElement('hm-move-panel');
|
|
199
|
+
panel.titleContent = '脚本管理';
|
|
200
|
+
panel.icon = 'js';
|
|
201
|
+
panel.leftButtonText = "读取"
|
|
202
|
+
panel.leftIcon = 'load';
|
|
203
|
+
panel.addEventListener('left-button-click', function () {
|
|
204
|
+
loadStore();
|
|
205
|
+
});
|
|
206
|
+
panel.rightButtonText = "保存"
|
|
207
|
+
panel.rightIcon = 'save';
|
|
208
|
+
panel.addEventListener('right-button-click', function () {
|
|
209
|
+
saveStore();
|
|
210
|
+
});
|
|
211
|
+
// panel.showMovePanel();
|
|
212
|
+
movePanelHolder.appendChild(panel);
|
|
213
|
+
let template = `<hm-script-app> </hm-script-app>
|
|
214
|
+
`;
|
|
215
|
+
panel.innerHTML = template;
|
|
216
|
+
let menuItem = document.createElement('hm-menu');
|
|
217
|
+
menuItem.content = "脚本管理";
|
|
218
|
+
menuItem.isMenuItem = true;
|
|
219
|
+
menuItem.icon = 'js';
|
|
220
|
+
|
|
221
|
+
menuItem.addEventListener('hm-menu-click', function () {
|
|
222
|
+
panel.putTopToggel();
|
|
223
|
+
});
|
|
224
|
+
return menuItem;
|
|
225
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement, css, html } from 'lit'
|
|
2
2
|
import { customElement, property, query } from 'lit/decorators.js'
|
|
3
|
-
import { logger } from '../core/log-tools';
|
|
3
|
+
// import { logger } from '../core/log-tools';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 滑动单元格组件
|
|
@@ -37,7 +37,7 @@ export class HmSwipeCell extends LitElement {
|
|
|
37
37
|
*/
|
|
38
38
|
@property()
|
|
39
39
|
rightButtonCallback = function () {
|
|
40
|
-
logger.log('cell', '点击了一下');
|
|
40
|
+
// logger.log('cell', '点击了一下');
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
@query('.slider') sliderElement!: HTMLElement;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 事件监听器类型定义,表示一个可以接收任意参数的函数
|
|
3
|
+
*/
|
|
4
|
+
type Listener = (...args: any[]) => void;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Emitter 类提供事件驱动的编程模式,允许对象间通过事件进行通信
|
|
8
|
+
* 支持事件监听、取消监听、一次性监听和事件触发功能
|
|
9
|
+
*/
|
|
10
|
+
export class Emitter {
|
|
11
|
+
/**
|
|
12
|
+
* 存储事件名称和对应监听器数组的映射
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
private events: { [key: string]: Listener[] } = {};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 为指定事件添加监听器
|
|
19
|
+
* @param eventName 事件名称
|
|
20
|
+
* @param listener 事件触发时要调用的回调函数
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const emitter = new Emitter();
|
|
24
|
+
* emitter.on('test', (data) => console.log('接收到数据:', data));
|
|
25
|
+
* emitter.emit('test', { message: 'Hello' }); // 输出: 接收到数据: { message: 'Hello' }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
on(eventName: string, listener: Listener): void {
|
|
29
|
+
if (!this.events[eventName]) this.events[eventName] = [];
|
|
30
|
+
this.events[eventName].push(listener);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 移除指定事件的监听器
|
|
35
|
+
* @param eventName 事件名称
|
|
36
|
+
* @param listener 要移除的监听器函数,如果未提供则移除该事件的所有监听器
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const emitter = new Emitter();
|
|
40
|
+
* const listener = (data) => console.log(data);
|
|
41
|
+
* emitter.on('test', listener);
|
|
42
|
+
* emitter.off('test', listener); // 移除特定监听器
|
|
43
|
+
* emitter.off('test'); // 移除所有 'test' 事件的监听器
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
off(eventName: string, listener?: Listener): void {
|
|
47
|
+
if (!this.events[eventName]) return;
|
|
48
|
+
if (listener) {
|
|
49
|
+
this.events[eventName] = this.events[eventName].filter(fn => fn !== listener);
|
|
50
|
+
} else {
|
|
51
|
+
delete this.events[eventName];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 为指定事件添加一次性监听器,监听器在第一次触发后将被移除
|
|
57
|
+
* @param eventName 事件名称
|
|
58
|
+
* @param listener 事件触发时要调用的回调函数,只执行一次
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const emitter = new Emitter();
|
|
62
|
+
* emitter.once('start', () => console.log('仅执行一次'));
|
|
63
|
+
* emitter.emit('start'); // 输出: 仅执行一次
|
|
64
|
+
* emitter.emit('start'); // 没有输出,因为监听器已被移除
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
once(eventName: string, listener: Listener): void {
|
|
68
|
+
const onceWrapper: Listener = (...args) => {
|
|
69
|
+
listener(...args);
|
|
70
|
+
this.off(eventName, onceWrapper);
|
|
71
|
+
};
|
|
72
|
+
this.on(eventName, onceWrapper);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 触发指定事件,并传递参数给监听器
|
|
77
|
+
* @param eventName 事件名称
|
|
78
|
+
* @param args 传递给监听器的参数
|
|
79
|
+
* @returns 如果至少有一个监听器被调用则返回 true,否则返回 false
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const emitter = new Emitter();
|
|
83
|
+
* emitter.on('greet', (name, age) => console.log(`你好 ${name}, 你 ${age} 岁了`));
|
|
84
|
+
* emitter.emit('greet', '小明', 25); // 输出: 你好 小明, 你 25 岁了
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
emit(eventName: string, ...args: any[]): boolean {
|
|
88
|
+
const listeners = this.events[eventName];
|
|
89
|
+
if (!listeners || listeners.length === 0) return false;
|
|
90
|
+
// 使用副本防止遍历时修改
|
|
91
|
+
[...listeners].forEach(fn => fn(...args));
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 以下是完整的使用示例
|
|
97
|
+
/*
|
|
98
|
+
// 示例1:基本事件监听和触发
|
|
99
|
+
const emitter = new Emitter();
|
|
100
|
+
|
|
101
|
+
// 监听事件
|
|
102
|
+
emitter.on('dataReceived', (data) => {
|
|
103
|
+
console.log('收到数据:', data);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// 触发事件
|
|
107
|
+
emitter.emit('dataReceived', { id: 1, value: 'example' }); // 输出: 收到数据: { id: 1, value: 'example' }
|
|
108
|
+
|
|
109
|
+
// 示例2:一次性事件监听
|
|
110
|
+
emitter.once('startup', () => {
|
|
111
|
+
console.log('系统启动了一次');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
emitter.emit('startup'); // 输出: 系统启动了一次
|
|
115
|
+
emitter.emit('startup'); // 无输出,因为once的监听器已被移除
|
|
116
|
+
|
|
117
|
+
// 示例3:移除监听器
|
|
118
|
+
const handler = (msg) => console.log('消息:', msg);
|
|
119
|
+
emitter.on('message', handler);
|
|
120
|
+
emitter.emit('message', '测试消息'); // 输出: 消息: 测试消息
|
|
121
|
+
|
|
122
|
+
emitter.off('message', handler); // 移除特定监听器
|
|
123
|
+
emitter.emit('message', '这不会被处理'); // 无输出
|
|
124
|
+
|
|
125
|
+
// 示例4:多个监听器
|
|
126
|
+
emitter.on('multiEvent', () => console.log('第一个监听器'));
|
|
127
|
+
emitter.on('multiEvent', () => console.log('第二个监听器'));
|
|
128
|
+
emitter.emit('multiEvent'); // 输出: 第一个监听器 和 第二个监听器
|
|
129
|
+
*/
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 公共消息类
|
|
3
|
+
* 用于表示公共频道中的消息
|
|
4
|
+
*/
|
|
5
|
+
class Public {
|
|
6
|
+
/** 时间戳 */
|
|
7
|
+
timeStamp: string = '';
|
|
8
|
+
/** 头像链接 */
|
|
9
|
+
headPortrait: string = '';
|
|
10
|
+
/** 名字 */
|
|
11
|
+
name: string = '';
|
|
12
|
+
/** 消息 */
|
|
13
|
+
message: string = '';
|
|
14
|
+
/** 消息气泡背景颜色 */
|
|
15
|
+
color: string = '';
|
|
16
|
+
/** 性别 */
|
|
17
|
+
gender: string = '';
|
|
18
|
+
/** 唯一标识 */
|
|
19
|
+
uid: string = '';
|
|
20
|
+
/** 称号 */
|
|
21
|
+
designation: string = '';
|
|
22
|
+
/** 消息UID */
|
|
23
|
+
messageUid: string = '';
|
|
24
|
+
/** 消息类别 */
|
|
25
|
+
// readonly messageClass = 'public';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 私聊消息类
|
|
30
|
+
* 用于表示私聊消息
|
|
31
|
+
*/
|
|
32
|
+
class Private {
|
|
33
|
+
/** 时间戳 */
|
|
34
|
+
timeStamp: string = '';
|
|
35
|
+
/** 头像链接 */
|
|
36
|
+
headPortrait: string = '';
|
|
37
|
+
/** 名字 */
|
|
38
|
+
name: string = '';
|
|
39
|
+
/** 消息 */
|
|
40
|
+
message: string = '';
|
|
41
|
+
/** 消息颜色 */
|
|
42
|
+
color: string = '';
|
|
43
|
+
/** 性别 */
|
|
44
|
+
gender: string = '';
|
|
45
|
+
/** 唯一标识UID */
|
|
46
|
+
uid: string = '';
|
|
47
|
+
/** 消息唯一标识 */
|
|
48
|
+
messageUid: string = '';
|
|
49
|
+
/** 消息类型 */
|
|
50
|
+
// readonly messageClass = 'private';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 隐藏消息类
|
|
55
|
+
* 用于表示隐藏类型的消息
|
|
56
|
+
*/
|
|
57
|
+
class Hidden {
|
|
58
|
+
/** 消息的标题,名字?主题 */
|
|
59
|
+
messageName: string = '';
|
|
60
|
+
/** 发送过来的唯一标识 */
|
|
61
|
+
uid: string = '';
|
|
62
|
+
/** 数据 */
|
|
63
|
+
data: string = '';
|
|
64
|
+
/** 消息类型 */
|
|
65
|
+
// readonly messageClass = 'hidden';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 弹幕消息类
|
|
70
|
+
* 用于表示弹幕类型的消息
|
|
71
|
+
*/
|
|
72
|
+
class Danmu {
|
|
73
|
+
/** 用户名 */
|
|
74
|
+
username: string = '';
|
|
75
|
+
/** 头像链接 */
|
|
76
|
+
avatar: string = '';
|
|
77
|
+
/** 消息 */
|
|
78
|
+
message: string = '';
|
|
79
|
+
/** 消息颜色 */
|
|
80
|
+
color: string = '';
|
|
81
|
+
/** 性别 */
|
|
82
|
+
gender: string = '';
|
|
83
|
+
/** 时间戳 */
|
|
84
|
+
timeStamp: string = '';
|
|
85
|
+
/** 唯一id */
|
|
86
|
+
uid: string = '';
|
|
87
|
+
/** 消息类型 */
|
|
88
|
+
// readonly messageClass = 'danmu';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 撤回消息类
|
|
93
|
+
* 用于表示撤回操作的消息
|
|
94
|
+
*/
|
|
95
|
+
class Withdrawn {
|
|
96
|
+
/** 可选的,撤回私聊对象窗口的UID */
|
|
97
|
+
privateUID: string = '';
|
|
98
|
+
/** 需要要撤回的气泡用户uid */
|
|
99
|
+
uid: string = '';
|
|
100
|
+
/** 消息唯一标识,一串随机数 */
|
|
101
|
+
messageUid: string = '';
|
|
102
|
+
/** 数据唯一标识,上面两个组合在一起 */
|
|
103
|
+
dataUid: string = '';
|
|
104
|
+
/** 消息类型 */
|
|
105
|
+
// readonly messageClass = 'withdrawn';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 系统消息类
|
|
110
|
+
* 用于表示系统通知类消息
|
|
111
|
+
*/
|
|
112
|
+
class System {
|
|
113
|
+
/** 消息列表 */
|
|
114
|
+
userMessageList: string[] = [];
|
|
115
|
+
/** 消息类型 */
|
|
116
|
+
// readonly messageClass = 'system';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 股票消息类
|
|
121
|
+
* 用于表示股票相关数据消息
|
|
122
|
+
*/
|
|
123
|
+
class Stock {
|
|
124
|
+
/**
|
|
125
|
+
* '*' 表示股价过低无法买股票
|
|
126
|
+
* '>' 表示卖出的股票超出数量
|
|
127
|
+
* '<' 表示余额不够
|
|
128
|
+
* 数字表示正常
|
|
129
|
+
*/
|
|
130
|
+
result: string = '';
|
|
131
|
+
/** 股价 */
|
|
132
|
+
stockPrice: number = NaN;
|
|
133
|
+
/** 总股数 */
|
|
134
|
+
totalStock: number = NaN;
|
|
135
|
+
/** 持股数 */
|
|
136
|
+
holdingAmount: number = NaN;
|
|
137
|
+
/** 总金 */
|
|
138
|
+
totalEquity: number = NaN;
|
|
139
|
+
/** 账户余额 */
|
|
140
|
+
balance: number = NaN;
|
|
141
|
+
/** 消息类型 */
|
|
142
|
+
// readonly messageClass = 'stock';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 未知消息类
|
|
147
|
+
* 用于表示无法识别的消息类型
|
|
148
|
+
*/
|
|
149
|
+
class Unkonw {
|
|
150
|
+
/** 未知消息的原型 */
|
|
151
|
+
message: string = '';
|
|
152
|
+
/** 消息类型 */
|
|
153
|
+
// readonly messageClass = 'unkonw';
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* 所有消息类型的联合类型
|
|
158
|
+
* 用于类型检查和类型安全
|
|
159
|
+
*/
|
|
160
|
+
export type MessageClass =
|
|
161
|
+
Public |
|
|
162
|
+
Private |
|
|
163
|
+
Hidden |
|
|
164
|
+
Danmu |
|
|
165
|
+
Withdrawn |
|
|
166
|
+
System |
|
|
167
|
+
Stock |
|
|
168
|
+
Unkonw;
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
Public,
|
|
172
|
+
Private,
|
|
173
|
+
Hidden,
|
|
174
|
+
Danmu,
|
|
175
|
+
Withdrawn,
|
|
176
|
+
System,
|
|
177
|
+
Stock,
|
|
178
|
+
Unkonw
|
|
179
|
+
};
|