hortimagic 1.1.0 → 1.1.2
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 +47 -15
- package/dist/hortimagic.js +49 -17
- package/dist/hortimagic.txt +49 -17
- package/dist/hortimagic.user.js +49 -17
- package/package.json +4 -3
- package/src/apps/config-app.ts +172 -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 +151 -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,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 基于组件等组成的工具
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { notificationHolder } from "./holders/notification";
|
|
6
|
+
import { dialogApp } from "./apps/dialog-app";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 消失通知函数
|
|
10
|
+
* @example
|
|
11
|
+
* ```javascript
|
|
12
|
+
* // 显示成功通知
|
|
13
|
+
* hortimagic.easy_tools.notice.success('操作成功', '您的操作已成功完成');
|
|
14
|
+
*
|
|
15
|
+
* // 显示警告通知
|
|
16
|
+
* hortimagic.easy_tools.notice.warning('警告', '请注意检查输入信息', 5000);
|
|
17
|
+
*
|
|
18
|
+
* // 显示错误通知
|
|
19
|
+
* hortimagic.easy_tools.notice.error('错误', '操作失败,请重试');
|
|
20
|
+
*
|
|
21
|
+
* // 显示普通通知
|
|
22
|
+
* hortimagic.easy_tools.notice.normal('提示', '这是一条普通提示信息');
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export const notice = {
|
|
26
|
+
/**
|
|
27
|
+
* 显示成功通知
|
|
28
|
+
* 创建并显示一个成功状态的通知组件
|
|
29
|
+
* @param title - 通知的标题文本
|
|
30
|
+
* @param content - 通知的内容文本
|
|
31
|
+
* @param displayTime - 通知显示的时间(毫秒),默认为3000毫秒
|
|
32
|
+
* @returns 无返回值
|
|
33
|
+
*/
|
|
34
|
+
success(title: string, content: string, displayTime: number = 3000) {
|
|
35
|
+
let notice = document.createElement('hm-notification');
|
|
36
|
+
notice.title = title;
|
|
37
|
+
notice.content = content;
|
|
38
|
+
notice.displayTime = displayTime;
|
|
39
|
+
notice.backgroundColor = 'rgba(57, 231, 34, 0.7)';
|
|
40
|
+
notice.color = 'rgb(255,255,255)';
|
|
41
|
+
notificationHolder.append(notice);
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* 显示警告通知
|
|
45
|
+
* 创建并显示一个警告状态的通知组件
|
|
46
|
+
* @param title - 通知的标题文本
|
|
47
|
+
* @param content - 通知的内容文本
|
|
48
|
+
* @param displayTime - 通知显示的时间(毫秒),默认为3000毫秒
|
|
49
|
+
* @returns 无返回值
|
|
50
|
+
*/
|
|
51
|
+
warning(title: string, content: string, displayTime: number = 3000) {
|
|
52
|
+
let notice = document.createElement('hm-notification');
|
|
53
|
+
notice.title = title;
|
|
54
|
+
notice.content = content;
|
|
55
|
+
notice.displayTime = displayTime;
|
|
56
|
+
notice.backgroundColor = 'rgba(255,193,7,0.7)';
|
|
57
|
+
notice.color = 'rgb(255,255,255)';
|
|
58
|
+
notificationHolder.append(notice);
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* 显示错误通知
|
|
62
|
+
* 创建并显示一个错误状态的通知组件
|
|
63
|
+
* @param title - 通知的标题文本
|
|
64
|
+
* @param content - 通知的内容文本
|
|
65
|
+
* @param displayTime - 通知显示的时间(毫秒),默认为3000毫秒
|
|
66
|
+
* @returns 无返回值
|
|
67
|
+
*/
|
|
68
|
+
error(title: string, content: string, displayTime: number = 3000) {
|
|
69
|
+
let notice = document.createElement('hm-notification');
|
|
70
|
+
notice.title = title;
|
|
71
|
+
notice.content = content;
|
|
72
|
+
notice.displayTime = displayTime;
|
|
73
|
+
notice.backgroundColor = 'rgba(255,0,0,0.7)';
|
|
74
|
+
notice.color = 'rgb(255,255,255)';
|
|
75
|
+
notificationHolder.append(notice);
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* 显示普通通知
|
|
79
|
+
* 创建并显示一个普通状态的通知组件
|
|
80
|
+
* @param title - 通知的标题文本
|
|
81
|
+
* @param content - 通知的内容文本
|
|
82
|
+
* @param displayTime - 通知显示的时间(毫秒),默认为3000毫秒
|
|
83
|
+
* @returns 无返回值
|
|
84
|
+
*/
|
|
85
|
+
normal(title: string, content: string, displayTime: number = 3000) {
|
|
86
|
+
let notice = document.createElement('hm-notification');
|
|
87
|
+
notice.title = title;
|
|
88
|
+
notice.content = content;
|
|
89
|
+
notice.displayTime = displayTime;
|
|
90
|
+
notice.backgroundColor = 'rgba(33,33,33,0.7)';
|
|
91
|
+
notice.color = 'rgb(255,255,255)';
|
|
92
|
+
notificationHolder.append(notice);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 确认弹窗函数
|
|
97
|
+
* @param message 消息提示
|
|
98
|
+
* @param confirmCallback 选择确认时的回调函数
|
|
99
|
+
* @param cancelCallback 选择取消时的回调函数
|
|
100
|
+
* @param closeCallback 关闭弹窗时的回调函数
|
|
101
|
+
* @example ```javascript
|
|
102
|
+
* hortimagic.easy_tools.confirm('hhhhhhhhhhhhhh',()=>{console.log('qqqqqqqqqqq')},()=>{console.log('cccccccccccc')})
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export function confirm(message: string, confirmCallback?: Function, cancelCallback?: Function, closeCallback?: Function) {
|
|
106
|
+
dialogApp.message = message;
|
|
107
|
+
if (confirmCallback)
|
|
108
|
+
dialogApp.confirmCallback = confirmCallback;
|
|
109
|
+
else
|
|
110
|
+
dialogApp.confirmCallback = null;
|
|
111
|
+
if (cancelCallback)
|
|
112
|
+
dialogApp.cancelCallback = cancelCallback;
|
|
113
|
+
else
|
|
114
|
+
dialogApp.cancelCallback = null;
|
|
115
|
+
if (closeCallback)
|
|
116
|
+
dialogApp.closeCallback = closeCallback;
|
|
117
|
+
else
|
|
118
|
+
dialogApp.closeCallback = null;
|
|
119
|
+
dialogApp.dialogOpen = true;
|
|
120
|
+
console.debug('弹窗已打开', dialogApp)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 简单快速工具集
|
|
125
|
+
* @example
|
|
126
|
+
* ```javascript
|
|
127
|
+
* // 显示不同类型的通知
|
|
128
|
+
* hortimagic.easy_tools.notice.success('操作成功', '您的操作已成功完成');
|
|
129
|
+
* hortimagic.easy_tools.notice.warning('警告', '请注意检查输入信息', 5000);
|
|
130
|
+
* hortimagic.easy_tools.notice.error('错误', '操作失败,请重试');
|
|
131
|
+
* hortimagic.easy_tools.notice.normal('提示', '这是一条普通提示信息');
|
|
132
|
+
*
|
|
133
|
+
* // 显示确认对话框
|
|
134
|
+
* hortimagic.easy_tools.confirm(
|
|
135
|
+
* '您确定要执行此操作吗?',
|
|
136
|
+
* () => { console.log('用户点击了确认'); },
|
|
137
|
+
* () => { console.log('用户点击了取消'); },
|
|
138
|
+
* () => { console.log('对话框已关闭'); }
|
|
139
|
+
* );
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** 弹窗容器 */
|
|
2
|
+
export let dialogHolder: HTMLDivElement = document.createElement('div');
|
|
3
|
+
|
|
4
|
+
/** 初始化弹窗容器 */
|
|
5
|
+
export function initDialogHolder() {
|
|
6
|
+
dialogHolder.id = 'hmDialogHolder';
|
|
7
|
+
dialogHolder.style.zIndex = '999999';
|
|
8
|
+
document.body.append(dialogHolder);
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** 菜单容器 */
|
|
2
|
+
export let menuHolder: HTMLDivElement = document.createElement('div');
|
|
3
|
+
|
|
4
|
+
/** 初始化菜单容器 */
|
|
5
|
+
export function initMenuHolder() {
|
|
6
|
+
menuHolder.id = 'hmMenuHolder';
|
|
7
|
+
let img = document.querySelector('#functionHolderImg');
|
|
8
|
+
console.debug(img)
|
|
9
|
+
console.debug(menuHolder);
|
|
10
|
+
if (img !== null) {
|
|
11
|
+
//@ts-ignore
|
|
12
|
+
img.parentElement.insertAdjacentElement('afterend', menuHolder);
|
|
13
|
+
}
|
|
14
|
+
// // 将menuHolder插入到img元素的父元素之后
|
|
15
|
+
// if (img && img.parentElement) {
|
|
16
|
+
// img.parentElement.insertAdjacentElement('afterend', menuHolder);
|
|
17
|
+
// } else {
|
|
18
|
+
// document.body.append(menuHolder);
|
|
19
|
+
// }
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** 移动面板容器 */
|
|
2
|
+
export let movePanelHolder: HTMLDivElement = document.createElement('div');
|
|
3
|
+
|
|
4
|
+
/** 初始化移动面板容器 */
|
|
5
|
+
export function initMovePanelHolder() {
|
|
6
|
+
movePanelHolder.id = 'hmMovePanelHolder';
|
|
7
|
+
movePanelHolder.style.zIndex = '999999';
|
|
8
|
+
document.body.append(movePanelHolder);
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** 渲染的容器元素 */
|
|
2
|
+
export let notificationHolder: HTMLDivElement = document.createElement('div');;
|
|
3
|
+
|
|
4
|
+
/** 初始化通知容器 */
|
|
5
|
+
export function initNotificationHolder() {
|
|
6
|
+
notificationHolder.id = 'hmNotificationHolder';
|
|
7
|
+
notificationHolder.style.zIndex = '999999';
|
|
8
|
+
document.body.append(notificationHolder);
|
|
9
|
+
}
|
package/src/main.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as core from './core';
|
|
2
|
+
import * as components from './components';
|
|
3
|
+
import * as apps from './apps';
|
|
4
|
+
import *as holders from './holders';
|
|
5
|
+
import *as easy_tools from './easy-tools';
|
|
6
|
+
import pkg from '../package.json' with { type: 'json' };
|
|
7
|
+
import { logger } from './core/log-tools';
|
|
8
|
+
import { notice, confirm } from './easy-tools';
|
|
9
|
+
|
|
10
|
+
/** package配置信息 */
|
|
11
|
+
const information = {
|
|
12
|
+
/** 项目名称 */
|
|
13
|
+
name: pkg.name,
|
|
14
|
+
/** 项目版本 */
|
|
15
|
+
version: pkg.version,
|
|
16
|
+
/** 项目更新日志 */
|
|
17
|
+
changelog: pkg.changelog,
|
|
18
|
+
/** 项目描述 */
|
|
19
|
+
description: pkg.description,
|
|
20
|
+
/** 项目作者 */
|
|
21
|
+
author: pkg.author,
|
|
22
|
+
/** 项目许可证 */
|
|
23
|
+
license: pkg.license,
|
|
24
|
+
/** 项目仓库 */
|
|
25
|
+
repository: pkg.repository,
|
|
26
|
+
/** 项目构建时间 */
|
|
27
|
+
buildTime: new Date().toISOString(),
|
|
28
|
+
|
|
29
|
+
/** 项目是否注入完成 */
|
|
30
|
+
ingected: false
|
|
31
|
+
}
|
|
32
|
+
async function main() {
|
|
33
|
+
await apps.main_app.init();
|
|
34
|
+
information.ingected = true;
|
|
35
|
+
}
|
|
36
|
+
main()
|
|
37
|
+
export {
|
|
38
|
+
information,
|
|
39
|
+
core,
|
|
40
|
+
components,
|
|
41
|
+
apps,
|
|
42
|
+
holders,
|
|
43
|
+
easy_tools,
|
|
44
|
+
|
|
45
|
+
logger,
|
|
46
|
+
confirm,
|
|
47
|
+
notice
|
|
48
|
+
|
|
49
|
+
}
|