ascript 1.3.27__py3-none-win_amd64.whl
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.
- ascript/__init__.py +8 -0
- ascript/hooks/__init__.py +0 -0
- ascript/hooks/hook-ascript.py +2 -0
- ascript/windows/__init__.py +29 -0
- ascript/windows/daos/__init__.py +0 -0
- ascript/windows/daos/screen.py +143 -0
- ascript/windows/hardware/__init__.py +5 -0
- ascript/windows/hardware/keyboard.py +279 -0
- ascript/windows/hardware/logitech_driver.py +179 -0
- ascript/windows/hardware/mouse.py +308 -0
- ascript/windows/license/__init__.py +16 -0
- ascript/windows/license/achttp.cp310-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp311-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp312-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp313-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp314-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp38-win_amd64.pyd +0 -0
- ascript/windows/license/achttp.cp39-win_amd64.pyd +0 -0
- ascript/windows/media/__init__.py +0 -0
- ascript/windows/resources/__init__.py +0 -0
- ascript/windows/resources/libs/logitech/x64/LogitechGkeyEnginesWrapper.dll +0 -0
- ascript/windows/resources/libs/logitech/x86/LogitechGkeyEnginesWrapper.dll +0 -0
- ascript/windows/resources/templates/__init__.py +0 -0
- ascript/windows/resources/templates/__init__py.win.template +51 -0
- ascript/windows/resources/templates/build.as.win.template +14 -0
- ascript/windows/resources/templates/build.py +71 -0
- ascript/windows/resources/templates/logo_windows.ico +0 -0
- ascript/windows/resources/templates/windows/main.py +50 -0
- ascript/windows/resources/templates/windows/pyproject.toml +44 -0
- ascript/windows/resources/templates/windows/res/img/logo.ico +0 -0
- ascript/windows/screen/__init__.py +13 -0
- ascript/windows/screen/as_cv.py +382 -0
- ascript/windows/screen/canny.py +128 -0
- ascript/windows/screen/code_scanner.py +72 -0
- ascript/windows/screen/color_algorithms.py +277 -0
- ascript/windows/screen/find_colors.py +251 -0
- ascript/windows/screen/find_images.py +217 -0
- ascript/windows/screen/ocr/__init__.py +4 -0
- ascript/windows/screen/ocr/ocr.py +223 -0
- ascript/windows/screen/ocr/rapidocr_hook.py +301 -0
- ascript/windows/screen/ocrx.py +169 -0
- ascript/windows/screen/screen_core.py +139 -0
- ascript/windows/store/__init__.py +21 -0
- ascript/windows/system/__init__.py +8 -0
- ascript/windows/system/device.py +355 -0
- ascript/windows/system/easy_print.py +115 -0
- ascript/windows/system/env.py +492 -0
- ascript/windows/system/exception/__init__.py +1 -0
- ascript/windows/system/key_value.py +145 -0
- ascript/windows/system/pip.py +175 -0
- ascript/windows/system/r.py +165 -0
- ascript/windows/system/runtime.py +62 -0
- ascript/windows/tools/__init__.py +27 -0
- ascript/windows/tools/__main__.py +21 -0
- ascript/windows/tools/action.json +33 -0
- ascript/windows/tools/action.py +168 -0
- ascript/windows/tools/colors_tool.py +391 -0
- ascript/windows/tools/config.py +26 -0
- ascript/windows/tools/dumptool.py +18 -0
- ascript/windows/tools/eel_api.py +495 -0
- ascript/windows/tools/gpplug/__init__.py +0 -0
- ascript/windows/tools/gpplug/plug.py +70 -0
- ascript/windows/tools/mouse_catch.py +168 -0
- ascript/windows/tools/plug_manager.py +38 -0
- ascript/windows/tools/tool_api.py +906 -0
- ascript/windows/tools/tool_window.py +56 -0
- ascript/windows/tools/uia_worker.py +365 -0
- ascript/windows/tools/web/app_store_window.html +481 -0
- ascript/windows/tools/web/colors.html +532 -0
- ascript/windows/tools/web/css/screen.css +1342 -0
- ascript/windows/tools/web/css/viewtree.css +357 -0
- ascript/windows/tools/web/flot_control.html +195 -0
- ascript/windows/tools/web/img/ico/favicon.png +0 -0
- ascript/windows/tools/web/img/ico/paintpalette.png +0 -0
- ascript/windows/tools/web/img/svg/find_colors.svg +1 -0
- ascript/windows/tools/web/img/svg/find_images.svg +1 -0
- ascript/windows/tools/web/img/svg/illustration-6.svg +89 -0
- ascript/windows/tools/web/img/svg/img_default.svg +1 -0
- ascript/windows/tools/web/img/svg/ocr.svg +1 -0
- ascript/windows/tools/web/js/screen/colors.js +466 -0
- ascript/windows/tools/web/js/screen/gp_plug.js +108 -0
- ascript/windows/tools/web/js/screen/image_mouse.js +464 -0
- ascript/windows/tools/web/js/screen/img_view.js +558 -0
- ascript/windows/tools/web/js/screen/plug.js +246 -0
- ascript/windows/tools/web/js/screen/screen.js +690 -0
- ascript/windows/tools/web/js/screen/screen_api.js +778 -0
- ascript/windows/tools/web/js/screen/screen_maker.js +10 -0
- ascript/windows/tools/web/js/utils/map.js +73 -0
- ascript/windows/tools/web/js/utils/upload.js +157 -0
- ascript/windows/tools/web/js/viewtree/niv_js.js +27 -0
- ascript/windows/tools/web/js/viewtree/vtree.js +1510 -0
- ascript/windows/tools/web/libs/bootstrap/css/bootstrap.min.css +6 -0
- ascript/windows/tools/web/libs/bootstrap/js/bootstrap.bundle.min.js +7 -0
- ascript/windows/tools/web/libs/bootstrap-icons/0-circle.svg +4 -0
- ascript/windows/tools/web/libs/bootstrap-icons/0-square.svg +4 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.css +2078 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.json +2052 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.min.css +5 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.scss +2090 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/fonts/bootstrap-icons.woff +0 -0
- ascript/windows/tools/web/libs/bootstrap-icons/font/fonts/bootstrap-icons.woff2 +0 -0
- ascript/windows/tools/web/libs/feather-icons/dist/feather.min.js +13 -0
- ascript/windows/tools/web/libs/feather-icons/dist/icons.json +1 -0
- ascript/windows/tools/web/libs/jquery/core.js +399 -0
- ascript/windows/tools/web/libs/jquery/jquery.js +10598 -0
- ascript/windows/tools/web/libs/jquery/jquery.min.js +4 -0
- ascript/windows/tools/web/libs/jquery/jquery.min.js.zip +0 -0
- ascript/windows/tools/web/libs/jquery/jquery.slim.js +8495 -0
- ascript/windows/tools/web/libs/jquery/jquery.slim.min.js +2 -0
- ascript/windows/tools/web/libs/jquery-menu/jquery.contextMenu.js +2134 -0
- ascript/windows/tools/web/libs/jquery-menu/jquery.contextMenu.min.css +16 -0
- ascript/windows/tools/web/libs/jquery-zTree/css/zTreeStyle.css +97 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/1_close.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/1_open.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/2.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/3.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/4.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/5.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/6.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/7.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/8.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/diy/9.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/line_conn.gif +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/loading.gif +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/tree-node-btn.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/zTreeStandard.gif +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/img/zTreeStandard.png +0 -0
- ascript/windows/tools/web/libs/jquery-zTree/js/jquery.ztree.all.min.js +3 -0
- ascript/windows/tools/web/libs/treeview/css/jquery.treeview.css +79 -0
- ascript/windows/tools/web/libs/treeview/img/file.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/ico_loading.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/icon4.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/icon5.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/icon6.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/py.png +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-black-line.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-black.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-default-line.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-default.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-famfamfam-line.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-famfamfam.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-gray-line.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-gray.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-red-line.gif +0 -0
- ascript/windows/tools/web/libs/treeview/img/treeview-red.gif +0 -0
- ascript/windows/tools/web/libs/treeview/js/jquery.treeview.edit.js +37 -0
- ascript/windows/tools/web/libs/treeview/js/jquery.treeview.js +250 -0
- ascript/windows/tools/web/license_window.html +255 -0
- ascript/windows/tools/web/plugs/a.html +653 -0
- ascript/windows/tools/web/plugs/demo.html +52 -0
- ascript/windows/tools/web/plugs/find_colors.html +629 -0
- ascript/windows/tools/web/plugs/find_images.html +699 -0
- ascript/windows/tools/web/plugs/rapidocr.html +954 -0
- ascript/windows/tools/web/vtree.html +496 -0
- ascript/windows/tools/webview/assets/index-HymBPl-I.css +1 -0
- ascript/windows/tools/webview/assets/index-PqA_m8tL.js +17 -0
- ascript/windows/tools/webview/index.html +13 -0
- ascript/windows/ui/__init__.py +6 -0
- ascript/windows/ui/app_store_window.py +272 -0
- ascript/windows/ui/draw_window.py +231 -0
- ascript/windows/ui/flot_test.py +297 -0
- ascript/windows/ui/flot_window.py +488 -0
- ascript/windows/ui/license_window.py +111 -0
- ascript/windows/ui/web_window.py +466 -0
- ascript/windows/utils/__init__.py +0 -0
- ascript/windows/utils/node_utils.py +20 -0
- ascript/windows/utils/screen_utils.py +280 -0
- ascript/windows/window/Selector.py +1015 -0
- ascript/windows/window/Window.py +747 -0
- ascript/windows/window/__init__.py +5 -0
- ascript/windows/window/launcher.py +213 -0
- ascript/windows/window/uia_runtime.py +26 -0
- ascript-1.3.27.dist-info/METADATA +41 -0
- ascript-1.3.27.dist-info/RECORD +177 -0
- ascript-1.3.27.dist-info/WHEEL +5 -0
- ascript-1.3.27.dist-info/entry_points.txt +2 -0
- ascript-1.3.27.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
|
|
2
|
+
// var image = document.getElementById('img_preview');
|
|
3
|
+
var img_deleft_dom;
|
|
4
|
+
var conimg = $("#container_img");
|
|
5
|
+
var image_data_object;
|
|
6
|
+
const uploadDir = "~/data/screenshot/"
|
|
7
|
+
|
|
8
|
+
var mouse_move_xyc = {};
|
|
9
|
+
var is_mouse_downed = false;
|
|
10
|
+
var is_show_box = false;
|
|
11
|
+
var part_box = $("#part_box");
|
|
12
|
+
|
|
13
|
+
var source_path = null;
|
|
14
|
+
|
|
15
|
+
var gp_path = null
|
|
16
|
+
|
|
17
|
+
var gpobj = undefined;
|
|
18
|
+
|
|
19
|
+
var image_list_res = undefined;
|
|
20
|
+
|
|
21
|
+
var image_list_max_show = 5
|
|
22
|
+
|
|
23
|
+
var is_imgcon_mouse_down = false
|
|
24
|
+
var is_iframecon_mouse_down = false
|
|
25
|
+
|
|
26
|
+
// var device_id = getQueryString('device_id')
|
|
27
|
+
|
|
28
|
+
$(document).ready(function () {
|
|
29
|
+
// initImgLogic()
|
|
30
|
+
getImgList(true)
|
|
31
|
+
initImageListLogic()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
//
|
|
35
|
+
// $('[data-toggle="tooltip"]').tooltip()
|
|
36
|
+
// init_Image_Mouse()
|
|
37
|
+
// init_key_logic()
|
|
38
|
+
// init_as_moduls()
|
|
39
|
+
// getGpLineList()
|
|
40
|
+
dragChangeContainer()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// refreshWindows();
|
|
44
|
+
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// function gpiframeout(){
|
|
48
|
+
// var iframe = document.querySelector('iframe');
|
|
49
|
+
// iframe.onload = function() {
|
|
50
|
+
// if (iframe.contentWindow && iframe.contentWindow.document) {
|
|
51
|
+
// // 注意:这仅在同源时有效
|
|
52
|
+
// iframe.contentWindow.document.addEventListener('keydown', function(event) {
|
|
53
|
+
// console.log('Keydown event inside iframe (if same-origin):', event.key);
|
|
54
|
+
// });
|
|
55
|
+
// }
|
|
56
|
+
// };
|
|
57
|
+
// }
|
|
58
|
+
|
|
59
|
+
function dragChangeContainer() {
|
|
60
|
+
var src_posi_Y = 0, src_posi_X = 0, dest_posi_Y = 0, dest_posi_X = 0, move_Y = 0, destHeight = 0, destWidth = 0, moveed = false, right = 0, bottom = 0, consleHeight, height = 0;
|
|
61
|
+
|
|
62
|
+
$(".touch_slide")
|
|
63
|
+
.mousedown(function (e) {
|
|
64
|
+
is_imgcon_mouse_down = true;
|
|
65
|
+
src_posi_Y = e.pageY;
|
|
66
|
+
src_posi_X = e.pageX;
|
|
67
|
+
// alert(right);
|
|
68
|
+
right = $(".screen-img-container").width()
|
|
69
|
+
// e.stopPropagation()
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
$(".gp_touch_bar")
|
|
73
|
+
.mousedown(function (e) {
|
|
74
|
+
is_iframecon_mouse_down = true;
|
|
75
|
+
src_posi_Y = e.pageY;
|
|
76
|
+
src_posi_X = e.pageX;
|
|
77
|
+
// alert(right);
|
|
78
|
+
height = $(".coder-iframe").height()
|
|
79
|
+
// e.stopPropagation()
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
$(document).bind("click mouseup", function (e) {
|
|
83
|
+
if (is_imgcon_mouse_down) {
|
|
84
|
+
is_imgcon_mouse_down = false;
|
|
85
|
+
moveed = false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (is_iframecon_mouse_down) {
|
|
89
|
+
is_iframecon_mouse_down = false;
|
|
90
|
+
moveed = false;
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
.mousemove(function (e) {
|
|
94
|
+
|
|
95
|
+
if (is_imgcon_mouse_down) {
|
|
96
|
+
|
|
97
|
+
dest_posi_Y = e.pageY;
|
|
98
|
+
dest_posi_X = e.pageX;
|
|
99
|
+
move_X = dest_posi_X - src_posi_X;
|
|
100
|
+
move_Y = dest_posi_Y - src_posi_Y;
|
|
101
|
+
|
|
102
|
+
// alert(right + move_X)
|
|
103
|
+
if (right + move_X > 20) {
|
|
104
|
+
// console.log(right + move_X + "px")
|
|
105
|
+
$(".screen-img-container").width(right + move_X + "px");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
moveed = true;
|
|
109
|
+
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (is_iframecon_mouse_down) {
|
|
114
|
+
|
|
115
|
+
dest_posi_Y = e.pageY;
|
|
116
|
+
dest_posi_X = e.pageX;
|
|
117
|
+
move_X = dest_posi_X - src_posi_X;
|
|
118
|
+
move_Y = dest_posi_Y - src_posi_Y;
|
|
119
|
+
|
|
120
|
+
// alert(right + move_X)
|
|
121
|
+
if (height + move_Y > 20) {
|
|
122
|
+
// console.log(right + move_X + "px")
|
|
123
|
+
$(".coder-iframe").height(height + move_Y + "px");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
moveed = true;
|
|
127
|
+
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
async function getImgList() {
|
|
141
|
+
// 1. UI 状态准备
|
|
142
|
+
$(".screen-img-list").empty();
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
// 2. 调用刚才写的 Eel 方法
|
|
146
|
+
// 注意:Python 端方法名为 colors_tool_screenshot_files
|
|
147
|
+
let res = await eel.colors_tool_screenshot_files()();
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
if (res.status === "success") {
|
|
152
|
+
// 兼容你原来的变量逻辑
|
|
153
|
+
image_list_res = res;
|
|
154
|
+
|
|
155
|
+
// 设置路径
|
|
156
|
+
$("#cache_imgs_path").text(res.path)
|
|
157
|
+
|
|
158
|
+
// 调用你原来的渲染函数
|
|
159
|
+
fill_imagelist_items(res);
|
|
160
|
+
|
|
161
|
+
// 更新显示数量
|
|
162
|
+
$(".imglist_size").text(res.data.length);
|
|
163
|
+
} else {
|
|
164
|
+
console.error("获取文件列表失败:", res.message);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
} catch (err) {
|
|
168
|
+
console.error("Eel 调用异常:", err);
|
|
169
|
+
alert("通讯异常: " + err);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function mk_image_show_no() {
|
|
174
|
+
var curren_no = image_list_max_show;
|
|
175
|
+
var max_no = image_list_res.data.length;
|
|
176
|
+
$("#screen-imglist-bar-no").text(`${curren_no}/${max_no}`)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
// 假设你有一个拖动条的监听事件
|
|
181
|
+
// function onSidebarResize(newWidthPx) {
|
|
182
|
+
// // 将新的宽度同步给 CSS 变量,画廊面板会自动跟随移动并伸缩
|
|
183
|
+
// document.documentElement.style.setProperty('--left-width', newWidthPx + 'px');
|
|
184
|
+
// }
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
// 初始化观察器:当图片进入视口时才真正请求加载数据
|
|
188
|
+
/**
|
|
189
|
+
* 懒加载观察器
|
|
190
|
+
* 当图片条目滚动到可见区域时,才调用 load_item_image 加载真实内容
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* 1. 懒加载观察器重构
|
|
194
|
+
*/
|
|
195
|
+
const imageObserver = new IntersectionObserver((entries, observer) => {
|
|
196
|
+
entries.forEach(entry => {
|
|
197
|
+
if (entry.isIntersecting) {
|
|
198
|
+
const $item = $(entry.target);
|
|
199
|
+
// 改为从 data-filepath 获取完整路径
|
|
200
|
+
const filepath = $item.attr('data-filepath');
|
|
201
|
+
const $img = $item.find('.img-content');
|
|
202
|
+
|
|
203
|
+
// 触发异步加载:建议在 load_item_image 内部实现压缩或按需加载
|
|
204
|
+
if (typeof load_item_image === "function") {
|
|
205
|
+
load_item_image($img, filepath);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// 加载后取消观察
|
|
209
|
+
observer.unobserve(entry.target);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}, {
|
|
213
|
+
root: document.querySelector('.screen-img-list'),
|
|
214
|
+
rootMargin: '200px' // 稍微增大边距,减少用户滚动时的白块感
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
let first_entger_load_histroy = true;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* 2. 填充图片列表重构
|
|
221
|
+
* @param {Object} res 格式要求: { data: ["C:/path/1.jpg", "C:/path/2.jpg"] }
|
|
222
|
+
*/
|
|
223
|
+
async function fill_imagelist_items(res) {
|
|
224
|
+
if (!res || !res.data) return;
|
|
225
|
+
|
|
226
|
+
const $listContainer = $(".screen-img-list");
|
|
227
|
+
$listContainer.empty();
|
|
228
|
+
|
|
229
|
+
// 确保容器拥有网格布局类
|
|
230
|
+
$listContainer.addClass("row row-cols-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-6 g-2 m-0");
|
|
231
|
+
|
|
232
|
+
res.data.forEach((filepath, index) => {
|
|
233
|
+
// 从完整路径中提取文件名用于显示
|
|
234
|
+
const displayFilename = filepath.split(/[\\\/]/).pop();
|
|
235
|
+
|
|
236
|
+
// 构建 HTML 结构,使用 data-filepath 存储完整路径
|
|
237
|
+
const $item = $(`
|
|
238
|
+
<div class="col screen-img-item-wrapper" data-filepath="${filepath}">
|
|
239
|
+
<div class="img-card shadow-sm border rounded">
|
|
240
|
+
<img class="img-content"
|
|
241
|
+
src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
|
|
242
|
+
alt="${displayFilename}">
|
|
243
|
+
<div class="img-name text-truncate" title="${displayFilename}">${displayFilename}</div>
|
|
244
|
+
<button class="btn-del btn btn-danger">
|
|
245
|
+
<i class="bi bi-trash3"></i>
|
|
246
|
+
</button>
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
`);
|
|
250
|
+
|
|
251
|
+
// 首次进入默认加载第一张预览
|
|
252
|
+
if (first_entger_load_histroy && index === 0) {
|
|
253
|
+
if (typeof showImg === "function") showImg(filepath);
|
|
254
|
+
first_entger_load_histroy = false;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// 3. 绑定点击预览事件
|
|
258
|
+
$item.on('click', function () {
|
|
259
|
+
$('.img-card').removeClass('border-primary shadow-lg');
|
|
260
|
+
$(this).find('.img-card').addClass('border-primary shadow-lg');
|
|
261
|
+
|
|
262
|
+
// 直接使用当前循环作用域内的 filepath
|
|
263
|
+
if (typeof showImg === "function") {
|
|
264
|
+
showImg(filepath);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// 4. 绑定单个删除事件 (直接使用 filepath,不再拼接)
|
|
269
|
+
$item.find('.btn-del').on('click', function (e) {
|
|
270
|
+
e.stopPropagation();
|
|
271
|
+
|
|
272
|
+
// 立即反馈 UI
|
|
273
|
+
$item.css({
|
|
274
|
+
'opacity': '0.3',
|
|
275
|
+
'pointer-events': 'none',
|
|
276
|
+
'transition': 'all 0.2s'
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
if (typeof eel !== 'undefined') {
|
|
280
|
+
// 直接传递 filepath 给后端
|
|
281
|
+
eel.file_delete(filepath)((success) => {
|
|
282
|
+
if (success) {
|
|
283
|
+
$item.css('transform', 'scale(0.8)');
|
|
284
|
+
$item.fadeOut(250, function () {
|
|
285
|
+
$(this).remove();
|
|
286
|
+
// 更新数量统计
|
|
287
|
+
$('.imglist_size').text($('.screen-img-item-wrapper').length);
|
|
288
|
+
});
|
|
289
|
+
} else {
|
|
290
|
+
// 失败恢复
|
|
291
|
+
$item.find('.img-card').addClass('border-danger');
|
|
292
|
+
setTimeout(() => {
|
|
293
|
+
$item.css({ 'opacity': '1', 'pointer-events': 'auto' });
|
|
294
|
+
$item.find('.img-card').removeClass('border-danger');
|
|
295
|
+
}, 500);
|
|
296
|
+
console.error("删除失败: " + filepath);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// 5. 添加并启动观察
|
|
303
|
+
$listContainer.append($item);
|
|
304
|
+
imageObserver.observe($item[0]);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
// 6. 更新计数器
|
|
308
|
+
$('.imglist_size').text(res.data.length);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// 全局加载队列控制,防止一瞬间发给 Python 几百个请求导致 Eel 消息堵塞
|
|
312
|
+
const loadQueue = {
|
|
313
|
+
activeCount: 0,
|
|
314
|
+
maxConcurrent: 5, // 同时最多只处理 5 个图片请求
|
|
315
|
+
queue: [],
|
|
316
|
+
|
|
317
|
+
add(task) {
|
|
318
|
+
this.queue.push(task);
|
|
319
|
+
this.run();
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
run() {
|
|
323
|
+
if (this.activeCount < this.maxConcurrent && this.queue.length > 0) {
|
|
324
|
+
const task = this.queue.shift();
|
|
325
|
+
this.activeCount++;
|
|
326
|
+
task().finally(() => {
|
|
327
|
+
this.activeCount--;
|
|
328
|
+
this.run();
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// 重构后的 load_item_image
|
|
335
|
+
function load_item_image($img, filepath) {
|
|
336
|
+
loadQueue.add(async () => {
|
|
337
|
+
return new Promise((resolve) => {
|
|
338
|
+
eel.ascript_get_image(filepath, 300)((res) => {
|
|
339
|
+
if (res.status === "success") {
|
|
340
|
+
$img.attr('src', res.data);
|
|
341
|
+
}
|
|
342
|
+
resolve();
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
function imagelist_mouseover(e) {
|
|
350
|
+
|
|
351
|
+
var srch = $(this).attr("srch")
|
|
352
|
+
if (srch.length > 0) {
|
|
353
|
+
$(this).attr("src", srch)
|
|
354
|
+
$(this).attr("srch", "");
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
$("#delect_img").show();
|
|
359
|
+
// alert("")
|
|
360
|
+
|
|
361
|
+
// alert($(e.target).attr('src'))
|
|
362
|
+
var dom = $(e.target);
|
|
363
|
+
img_deleft_dom = $(e.target);
|
|
364
|
+
var left = dom.width() + dom.position().left - dom.scrollLeft() - $("#delect_img").width() + 13;
|
|
365
|
+
// alert(left)
|
|
366
|
+
$("#delect_img").css("left", left + "px");
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
function getImageData() {
|
|
372
|
+
$(image).css("height", "auto");
|
|
373
|
+
$(image).css("width", "auto");
|
|
374
|
+
var cvs = document.getElementById('preview_img_canvas');
|
|
375
|
+
cvs.width = image.width;
|
|
376
|
+
cvs.height = image.height;
|
|
377
|
+
var ctx = cvs.getContext('2d');
|
|
378
|
+
var dimImage = document.getElementById('img_preview')
|
|
379
|
+
ctx.drawImage(dimImage, 0, 0);
|
|
380
|
+
return ctx.getImageData(0, 0, dimImage.width, dimImage.height);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
var image_list_filled = false
|
|
384
|
+
function initImageListLogic() {
|
|
385
|
+
// $(".screen-img-list-con").fadeIn(100);
|
|
386
|
+
// $(".history-btn").mouseover(function () {
|
|
387
|
+
// // alert('123')
|
|
388
|
+
// openGallery();
|
|
389
|
+
// })
|
|
390
|
+
|
|
391
|
+
// $("#imageGallery").mouseleave(function () {
|
|
392
|
+
// closeGallery();
|
|
393
|
+
// })
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function uploadFile(p) {
|
|
397
|
+
$("#fileupload").trigger('click');
|
|
398
|
+
$("#fileupload").change(function (e) {
|
|
399
|
+
// alert($('#fileupload')[0].files.length)
|
|
400
|
+
if ($('#fileupload')[0].files.length >= 1) {
|
|
401
|
+
var formData = new FormData();
|
|
402
|
+
var fName = $('#fileupload')[0].files[0].name;
|
|
403
|
+
// var fName = new Date().getTime()+".png"
|
|
404
|
+
formData.append("data", e.target.files[0]);
|
|
405
|
+
// formData.append("path", uploadDir+fName);
|
|
406
|
+
$.ajax({
|
|
407
|
+
url: baseUrl + '/api/file/upload?path=' + (uploadDir + fName),
|
|
408
|
+
type: 'POST',
|
|
409
|
+
cache: false,
|
|
410
|
+
data: formData,
|
|
411
|
+
processData: false,
|
|
412
|
+
contentType: false
|
|
413
|
+
}).done(function (res) {
|
|
414
|
+
// $("#upload_pic").text("导入图片");
|
|
415
|
+
// addPicCacheListItem(fName,false)
|
|
416
|
+
getImgList(false)
|
|
417
|
+
|
|
418
|
+
}).fail(function (res) {
|
|
419
|
+
// getFilesList();
|
|
420
|
+
// $("#upload_pic").text("导入图片");
|
|
421
|
+
alert("上传失败")
|
|
422
|
+
});
|
|
423
|
+
} else {
|
|
424
|
+
// $("#upload_pic").text("导入图片");
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
function init_key_logic() {
|
|
432
|
+
$(document).keypress(function (e) {
|
|
433
|
+
// alert("22")
|
|
434
|
+
var keynumber = e.keyCode - 48;
|
|
435
|
+
if (keynumber > 0 && keynumber < 10 ) {
|
|
436
|
+
|
|
437
|
+
gpframe = document.getElementById("gpiframe")
|
|
438
|
+
|
|
439
|
+
// alert(JSON.stringify(mouse_move_xyc))
|
|
440
|
+
// $("#header_color_current").val(`${mouse_move_xyc.x},${mouse_move_xyc.y},#${mouse_move_xyc.c}`)
|
|
441
|
+
|
|
442
|
+
copyToClipboard(`${mouse_move_xyc.x},${mouse_move_xyc.y},#${mouse_move_xyc.c}`, " 已将此取色数据已复制到剪贴板")
|
|
443
|
+
|
|
444
|
+
if (gpframe && gpframe.contentWindow.gp) {
|
|
445
|
+
gpframe.contentWindow.on_color_picked(keynumber, mouse_move_xyc)
|
|
446
|
+
|
|
447
|
+
}
|
|
448
|
+
// alert("1")
|
|
449
|
+
// on_color
|
|
450
|
+
|
|
451
|
+
// var cdom = $("#choose_colors_item_"+keynumber);
|
|
452
|
+
// cdom.find(".choose_colors_item_input").val(mouse_move_xyc.x+","+mouse_move_xyc.y+" #"+mouse_move_xyc.c)
|
|
453
|
+
// cdom.find(".choose_colors_item_bgcolor").css("background-color","#"+mouse_move_xyc.c)
|
|
454
|
+
// chooseColors[keynumber] = mouse_move_xyc;
|
|
455
|
+
// makeFindColorsStr();
|
|
456
|
+
|
|
457
|
+
// var bgitemdom = cdom.find(".choose_colors_item_bgcolor")
|
|
458
|
+
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// print(cdom.val())
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function init_as_moduls() {
|
|
467
|
+
gpapi.module.get_all(function (data) {
|
|
468
|
+
$(".as_modules").empty();
|
|
469
|
+
// if(data.data.length<1){
|
|
470
|
+
// $("#model_create").click();
|
|
471
|
+
// return;
|
|
472
|
+
// }
|
|
473
|
+
data.data.forEach(function (e, index) {
|
|
474
|
+
if (index == 0) {
|
|
475
|
+
gpapi.module.current = e
|
|
476
|
+
// alert(JSON.stringify(e))
|
|
477
|
+
}
|
|
478
|
+
var item = $(`<option value="${index}">${e.name}</option>`);
|
|
479
|
+
$(".as_modules").append(item);
|
|
480
|
+
|
|
481
|
+
});
|
|
482
|
+
gpapi.module.all = data.data;
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
$(".as_modules").change(function () {
|
|
486
|
+
// alert($(this).val())
|
|
487
|
+
gpapi.module.current = gpapi.module.all[Number($(this).val())];
|
|
488
|
+
|
|
489
|
+
// alert(gpapi.module.current.name)
|
|
490
|
+
})
|
|
491
|
+
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function delect_gptest_module(m_name) {
|
|
495
|
+
// alert(m_name)
|
|
496
|
+
$.ajax({
|
|
497
|
+
url: `${baseUrl}/api/gp/test/remove`,
|
|
498
|
+
type: 'post',
|
|
499
|
+
data: { name: m_name },
|
|
500
|
+
async: true,
|
|
501
|
+
success: function (res) {
|
|
502
|
+
if (res.code == 1) {
|
|
503
|
+
// alert("成功")
|
|
504
|
+
} else {
|
|
505
|
+
alert(res.msg)
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
error: function (err) {
|
|
509
|
+
alert(err)
|
|
510
|
+
}
|
|
511
|
+
})
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function delect_gpline_module(m_name) {
|
|
515
|
+
// alert(m_name)
|
|
516
|
+
$.ajax({
|
|
517
|
+
url: `${baseUrl}/api/gp/plug/remove`,
|
|
518
|
+
type: 'post',
|
|
519
|
+
data: { name: m_name },
|
|
520
|
+
async: true,
|
|
521
|
+
success: function (res) {
|
|
522
|
+
if (res.code == 1) {
|
|
523
|
+
// alert("成功")
|
|
524
|
+
} else {
|
|
525
|
+
alert(res.msg)
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
error: function (err) {
|
|
529
|
+
alert(err)
|
|
530
|
+
}
|
|
531
|
+
})
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function getGpLineList() {
|
|
535
|
+
var url = "http://py.airscript.cn/api/web/plug/list?limit=10000&gp=1";
|
|
536
|
+
$.ajax({
|
|
537
|
+
url: url,
|
|
538
|
+
type: 'get',
|
|
539
|
+
data: {},
|
|
540
|
+
async: true,
|
|
541
|
+
success: function (res) {
|
|
542
|
+
if (res.code == 1) {
|
|
543
|
+
// alert(res)
|
|
544
|
+
fill_GPLineList(res)
|
|
545
|
+
} else {
|
|
546
|
+
alert(res.msg)
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
error: function (err) {
|
|
550
|
+
alert(err)
|
|
551
|
+
}
|
|
552
|
+
})
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function fill_GPLineList(res) {
|
|
556
|
+
res.data.forEach((item, index) => {
|
|
557
|
+
// gp_line_list
|
|
558
|
+
var dom = $("#gp_line_list_item").clone()
|
|
559
|
+
dom.find(".gp_id").text(item.name + ":" + item.version)
|
|
560
|
+
dom.find(".gp_author").text(item.auth);
|
|
561
|
+
dom.find(".gp_hot").text(item.download);
|
|
562
|
+
dom.find(".gp_add").click(function () {
|
|
563
|
+
$(this).addClass("gploading")
|
|
564
|
+
$(this).text("加载中")
|
|
565
|
+
$(this).prop('disabled', true);
|
|
566
|
+
add_line_gp(item.name + ":" + item.version, function (is_success) {
|
|
567
|
+
$(".gploading").prop('disabled', false);
|
|
568
|
+
if (is_success) {
|
|
569
|
+
$(".gploading").text("已加载")
|
|
570
|
+
} else {
|
|
571
|
+
$(".gploading").text("重试")
|
|
572
|
+
}
|
|
573
|
+
$(".gploading").removeClass("gploading")
|
|
574
|
+
|
|
575
|
+
})
|
|
576
|
+
|
|
577
|
+
// $(this).prop('disabled', true);
|
|
578
|
+
|
|
579
|
+
})
|
|
580
|
+
|
|
581
|
+
dom.find(".gp_info").click(function () {
|
|
582
|
+
window.open(`http://dev.airscript.cn/plug?id=${item.id}`, "_blank")
|
|
583
|
+
})
|
|
584
|
+
|
|
585
|
+
var domcs = dom.find(".gp_line_childs");
|
|
586
|
+
|
|
587
|
+
item.gp.forEach((citem, index) => {
|
|
588
|
+
var domc = $("#gp_line_list_item_child").clone()
|
|
589
|
+
domc.find(".gp_line_id").text(citem.id)
|
|
590
|
+
domc.find(".gp_line_des").text(citem.des)
|
|
591
|
+
domc.appendTo(domcs)
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
dom.appendTo("#gp_line_list")
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function add_line_gp(gp_name, listener) {
|
|
600
|
+
$.ajax({
|
|
601
|
+
url: `${baseUrl}/api/gp/plug`,
|
|
602
|
+
type: 'post',
|
|
603
|
+
data: { name: gp_name },
|
|
604
|
+
async: true,
|
|
605
|
+
success: function (res) {
|
|
606
|
+
if (res.code == 1) {
|
|
607
|
+
get_gpplug_list()
|
|
608
|
+
if (listener) {
|
|
609
|
+
listener(true)
|
|
610
|
+
}
|
|
611
|
+
// alert("成功")
|
|
612
|
+
// get_gpplug_list()
|
|
613
|
+
// $("#gp_test_modal").modal("hide")
|
|
614
|
+
} else {
|
|
615
|
+
if (listener) {
|
|
616
|
+
listener(true)
|
|
617
|
+
}
|
|
618
|
+
alert(res.msg)
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
error: function (err) {
|
|
622
|
+
alert(err)
|
|
623
|
+
}
|
|
624
|
+
})
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
function openGallery() {
|
|
630
|
+
const $gallery = $('#imageGallery');
|
|
631
|
+
|
|
632
|
+
// 1. 判断当前是否已经是显示状态
|
|
633
|
+
// 如果不包含 d-none,说明已经是开启状态,则执行关闭逻辑
|
|
634
|
+
if (!$gallery.hasClass('d-none')) {
|
|
635
|
+
closeGallery();
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// 2. 如果是隐藏状态,执行开启逻辑
|
|
640
|
+
$gallery.removeClass('d-none').addClass('d-flex');
|
|
641
|
+
|
|
642
|
+
// 3. 性能优化:同步侧边栏宽度
|
|
643
|
+
const sidebarWidth = $('.screen-img-container').outerWidth();
|
|
644
|
+
document.documentElement.style.setProperty('--left-width', sidebarWidth + 'px');
|
|
645
|
+
|
|
646
|
+
// 4. 可选:刷新数据
|
|
647
|
+
// if (typeof refreshImageData === 'function') refreshImageData();
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* 关闭画廊 (保持独立,方便其他地方调用)
|
|
652
|
+
*/
|
|
653
|
+
function closeGallery() {
|
|
654
|
+
$('#imageGallery').removeClass('d-flex').addClass('d-none');
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* 关闭画廊
|
|
659
|
+
*/
|
|
660
|
+
function closeGallery() {
|
|
661
|
+
// 恢复 d-none 隐藏面板
|
|
662
|
+
$('#imageGallery').removeClass('d-flex').addClass('d-none');
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// 全局按键监听
|
|
666
|
+
$(document).on('mousedown', function (e) {
|
|
667
|
+
const $gallery = $('#imageGallery');
|
|
668
|
+
const $openBtn = $('.history-btn'); // 假设这是你打开画廊的那个图标按钮的类名
|
|
669
|
+
|
|
670
|
+
// 逻辑判断:
|
|
671
|
+
// 1. 面板当前必须是显示的
|
|
672
|
+
// 2. 点击的目标不是面板本身,也不是面板内部的元素
|
|
673
|
+
// 3. 点击的目标不是那个触发打开的按钮(防止刚打开就触发关闭)
|
|
674
|
+
if (!$gallery.hasClass('d-none')) {
|
|
675
|
+
if (!$gallery.is(e.target) &&
|
|
676
|
+
$gallery.has(e.target).length === 0 &&
|
|
677
|
+
!$openBtn.is(e.target) &&
|
|
678
|
+
$openBtn.has(e.target).length === 0) {
|
|
679
|
+
|
|
680
|
+
closeGallery();
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
// 刚才的 Esc 键监听保持不变
|
|
686
|
+
$(document).on('keydown', function (e) {
|
|
687
|
+
if ((e.key === "Escape" || e.keyCode === 27) && !$('#imageGallery').hasClass('d-none')) {
|
|
688
|
+
closeGallery();
|
|
689
|
+
}
|
|
690
|
+
});
|