@mytools-all/mytools-ocr 0.1.0 → 0.2.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/README.md +32 -21
- package/THIRD_PARTY.md +3 -25
- package/app.mjs +95 -201
- package/history.mjs +13 -0
- package/index.html +5 -104
- package/package.json +42 -41
- package/plugin.json +38 -27
- package/program.mjs +72 -0
- package/tool.css +296 -295
- package/umi.mjs +34 -0
- package/common.mjs +0 -69
- package/md5.LICENSE +0 -20
- package/md5.mjs +0 -10
- package/utils.mjs +0 -201
package/tool.css
CHANGED
|
@@ -1,295 +1,296 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
font:
|
|
3
|
-
13px/1.6 "Segoe UI",
|
|
4
|
-
"Microsoft YaHei",
|
|
5
|
-
sans-serif;
|
|
6
|
-
color-scheme: light;
|
|
7
|
-
--bg: #fff;
|
|
8
|
-
--surface: #f6f7f9;
|
|
9
|
-
--fg: #333b48;
|
|
10
|
-
--muted: #89919e;
|
|
11
|
-
--border: #e8ebf0;
|
|
12
|
-
--accent: #377cf6;
|
|
13
|
-
--soft: #edf3ff;
|
|
14
|
-
--danger: #db4552;
|
|
15
|
-
}
|
|
16
|
-
* {
|
|
17
|
-
box-sizing: border-box;
|
|
18
|
-
}
|
|
19
|
-
body {
|
|
20
|
-
margin: 0;
|
|
21
|
-
color: var(--fg);
|
|
22
|
-
background: var(--bg);
|
|
23
|
-
height: 100vh;
|
|
24
|
-
overflow: hidden;
|
|
25
|
-
}
|
|
26
|
-
button,
|
|
27
|
-
input,
|
|
28
|
-
textarea,
|
|
29
|
-
select {
|
|
30
|
-
font: inherit;
|
|
31
|
-
color: inherit;
|
|
32
|
-
}
|
|
33
|
-
button {
|
|
34
|
-
border: 1px solid var(--border);
|
|
35
|
-
border-radius: 5px;
|
|
36
|
-
background: var(--bg);
|
|
37
|
-
padding: 5px 12px;
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
white-space: nowrap;
|
|
40
|
-
}
|
|
41
|
-
button:hover {
|
|
42
|
-
border-color: var(--accent);
|
|
43
|
-
color: var(--accent);
|
|
44
|
-
}
|
|
45
|
-
button:disabled {
|
|
46
|
-
opacity: 0.45;
|
|
47
|
-
cursor: default;
|
|
48
|
-
}
|
|
49
|
-
.primary {
|
|
50
|
-
background: var(--accent);
|
|
51
|
-
border-color: var(--accent);
|
|
52
|
-
color: white;
|
|
53
|
-
}
|
|
54
|
-
.primary:hover {
|
|
55
|
-
color: white;
|
|
56
|
-
filter: brightness(1.06);
|
|
57
|
-
}
|
|
58
|
-
input,
|
|
59
|
-
textarea,
|
|
60
|
-
select {
|
|
61
|
-
border: 1px solid var(--border);
|
|
62
|
-
border-radius: 4px;
|
|
63
|
-
padding: 7px 9px;
|
|
64
|
-
background: var(--bg);
|
|
65
|
-
min-width: 0;
|
|
66
|
-
}
|
|
67
|
-
textarea {
|
|
68
|
-
resize: none;
|
|
69
|
-
line-height: 1.7;
|
|
70
|
-
tab-size: 2;
|
|
71
|
-
font-family: Consolas, "Microsoft YaHei", monospace;
|
|
72
|
-
}
|
|
73
|
-
input:focus,
|
|
74
|
-
textarea:focus,
|
|
75
|
-
select:focus {
|
|
76
|
-
outline: 1px solid var(--accent);
|
|
77
|
-
}
|
|
78
|
-
button:focus-visible {
|
|
79
|
-
outline: 2px solid var(--accent);
|
|
80
|
-
outline-offset: 2px;
|
|
81
|
-
}
|
|
82
|
-
main {
|
|
83
|
-
display: flex;
|
|
84
|
-
flex-direction: column;
|
|
85
|
-
height: 100%;
|
|
86
|
-
min-height: 0;
|
|
87
|
-
}
|
|
88
|
-
.toolbar {
|
|
89
|
-
display: flex;
|
|
90
|
-
align-items: center;
|
|
91
|
-
gap: 8px;
|
|
92
|
-
padding: 10px 14px;
|
|
93
|
-
border-bottom: 1px solid var(--border);
|
|
94
|
-
flex-wrap: wrap;
|
|
95
|
-
}
|
|
96
|
-
.toolbar strong {
|
|
97
|
-
font-size: 14px;
|
|
98
|
-
margin-right: 10px;
|
|
99
|
-
}
|
|
100
|
-
.spacer {
|
|
101
|
-
flex: 1;
|
|
102
|
-
}
|
|
103
|
-
.content {
|
|
104
|
-
flex: 1;
|
|
105
|
-
min-height: 0;
|
|
106
|
-
overflow: auto;
|
|
107
|
-
padding: 16px;
|
|
108
|
-
}
|
|
109
|
-
.split {
|
|
110
|
-
display: grid;
|
|
111
|
-
grid-template-columns: 1fr 1fr;
|
|
112
|
-
flex: 1;
|
|
113
|
-
min-height: 0;
|
|
114
|
-
}
|
|
115
|
-
.split > * {
|
|
116
|
-
min-width: 0;
|
|
117
|
-
overflow: auto;
|
|
118
|
-
}
|
|
119
|
-
.split > :first-child {
|
|
120
|
-
border-right: 1px solid var(--border);
|
|
121
|
-
}
|
|
122
|
-
.editor {
|
|
123
|
-
width: 100%;
|
|
124
|
-
height: 100%;
|
|
125
|
-
border: 0;
|
|
126
|
-
border-radius: 0;
|
|
127
|
-
padding: 16px;
|
|
128
|
-
outline: none !important;
|
|
129
|
-
background: var(--bg);
|
|
130
|
-
}
|
|
131
|
-
.muted,
|
|
132
|
-
small {
|
|
133
|
-
color: var(--muted);
|
|
134
|
-
}
|
|
135
|
-
.status {
|
|
136
|
-
font-size: 12px;
|
|
137
|
-
min-height: 26px;
|
|
138
|
-
border-top: 1px solid var(--border);
|
|
139
|
-
padding: 3px 14px;
|
|
140
|
-
color: var(--muted);
|
|
141
|
-
}
|
|
142
|
-
.status[data-error="true"] {
|
|
143
|
-
color: var(--danger);
|
|
144
|
-
}
|
|
145
|
-
.tabs {
|
|
146
|
-
display: flex;
|
|
147
|
-
gap: 5px;
|
|
148
|
-
align-items: center;
|
|
149
|
-
}
|
|
150
|
-
.tabs button {
|
|
151
|
-
border: 0;
|
|
152
|
-
background: transparent;
|
|
153
|
-
}
|
|
154
|
-
.tabs .active {
|
|
155
|
-
color: var(--accent);
|
|
156
|
-
background: var(--soft);
|
|
157
|
-
}
|
|
158
|
-
.empty {
|
|
159
|
-
padding: 48px 16px;
|
|
160
|
-
text-align: center;
|
|
161
|
-
color: var(--muted);
|
|
162
|
-
}
|
|
163
|
-
table {
|
|
164
|
-
border-collapse: collapse;
|
|
165
|
-
width: 100%;
|
|
166
|
-
text-align: left;
|
|
167
|
-
}
|
|
168
|
-
th {
|
|
169
|
-
font-size: 12px;
|
|
170
|
-
color: var(--muted);
|
|
171
|
-
font-weight: 400;
|
|
172
|
-
background: var(--surface);
|
|
173
|
-
position: sticky;
|
|
174
|
-
top: 0;
|
|
175
|
-
}
|
|
176
|
-
th,
|
|
177
|
-
td {
|
|
178
|
-
padding: 9px 12px;
|
|
179
|
-
border-bottom: 1px solid var(--border);
|
|
180
|
-
}
|
|
181
|
-
tr.selected {
|
|
182
|
-
background: var(--soft);
|
|
183
|
-
}
|
|
184
|
-
pre {
|
|
185
|
-
white-space: pre-wrap;
|
|
186
|
-
overflow-wrap: anywhere;
|
|
187
|
-
margin: 0;
|
|
188
|
-
}
|
|
189
|
-
label {
|
|
190
|
-
display: flex;
|
|
191
|
-
gap: 8px;
|
|
192
|
-
align-items: center;
|
|
193
|
-
}
|
|
194
|
-
.stack {
|
|
195
|
-
display: flex;
|
|
196
|
-
flex-direction: column;
|
|
197
|
-
gap: 12px;
|
|
198
|
-
}
|
|
199
|
-
.row {
|
|
200
|
-
display: flex;
|
|
201
|
-
gap: 8px;
|
|
202
|
-
align-items: center;
|
|
203
|
-
}
|
|
204
|
-
.panel {
|
|
205
|
-
border: 1px solid var(--border);
|
|
206
|
-
border-radius: 6px;
|
|
207
|
-
padding: 14px;
|
|
208
|
-
}
|
|
209
|
-
.badge {
|
|
210
|
-
font-size: 11px;
|
|
211
|
-
padding: 1px 7px;
|
|
212
|
-
border-radius: 4px;
|
|
213
|
-
background: var(--surface);
|
|
214
|
-
color: var(--muted);
|
|
215
|
-
}
|
|
216
|
-
.danger {
|
|
217
|
-
color: var(--danger);
|
|
218
|
-
}
|
|
219
|
-
.hidden {
|
|
220
|
-
display: none !important;
|
|
221
|
-
}
|
|
222
|
-
#theme {
|
|
223
|
-
padding: 3px 8px;
|
|
224
|
-
}
|
|
225
|
-
.sidebar {
|
|
226
|
-
width: 155px;
|
|
227
|
-
background: var(--surface);
|
|
228
|
-
padding: 14px 10px;
|
|
229
|
-
border-right: 1px solid var(--border);
|
|
230
|
-
overflow: auto;
|
|
231
|
-
}
|
|
232
|
-
.sidebar button {
|
|
233
|
-
display: block;
|
|
234
|
-
width: 100%;
|
|
235
|
-
text-align: left;
|
|
236
|
-
border: 0;
|
|
237
|
-
background: transparent;
|
|
238
|
-
margin-bottom: 4px;
|
|
239
|
-
}
|
|
240
|
-
.sidebar .active {
|
|
241
|
-
background: var(--soft);
|
|
242
|
-
color: var(--accent);
|
|
243
|
-
}
|
|
244
|
-
.workspace {
|
|
245
|
-
display: flex;
|
|
246
|
-
flex: 1;
|
|
247
|
-
min-height: 0;
|
|
248
|
-
}
|
|
249
|
-
.workspace > .content {
|
|
250
|
-
flex: 1;
|
|
251
|
-
}
|
|
252
|
-
details {
|
|
253
|
-
border-bottom: 1px solid var(--border);
|
|
254
|
-
padding: 7px 0;
|
|
255
|
-
}
|
|
256
|
-
summary {
|
|
257
|
-
cursor: pointer;
|
|
258
|
-
}
|
|
259
|
-
::-webkit-scrollbar {
|
|
260
|
-
width: 6px;
|
|
261
|
-
height: 6px;
|
|
262
|
-
}
|
|
263
|
-
::-webkit-scrollbar-thumb {
|
|
264
|
-
background: #b9c0cb60;
|
|
265
|
-
border-radius: 8px;
|
|
266
|
-
}
|
|
267
|
-
html[data-theme="dark"] {
|
|
268
|
-
color-scheme: dark;
|
|
269
|
-
--bg: #1b1e24;
|
|
270
|
-
--surface: #222731;
|
|
271
|
-
--fg: #dce1eb;
|
|
272
|
-
--muted: #8894a8;
|
|
273
|
-
--border: #333a47;
|
|
274
|
-
--accent: #6ca7ff;
|
|
275
|
-
--soft: #27364c;
|
|
276
|
-
--danger: #ff8490;
|
|
277
|
-
}
|
|
278
|
-
@media (max-width: 560px) {
|
|
279
|
-
.sidebar {
|
|
280
|
-
width: 115px;
|
|
281
|
-
}
|
|
282
|
-
.toolbar {
|
|
283
|
-
padding: 8px;
|
|
284
|
-
gap: 5px;
|
|
285
|
-
}
|
|
286
|
-
button {
|
|
287
|
-
padding: 5px 8px;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
@media (prefers-reduced-motion: reduce) {
|
|
291
|
-
* {
|
|
292
|
-
scroll-behavior: auto !important;
|
|
293
|
-
animation: none !important;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
1
|
+
:root {
|
|
2
|
+
font:
|
|
3
|
+
13px/1.6 "Segoe UI",
|
|
4
|
+
"Microsoft YaHei",
|
|
5
|
+
sans-serif;
|
|
6
|
+
color-scheme: light;
|
|
7
|
+
--bg: #fff;
|
|
8
|
+
--surface: #f6f7f9;
|
|
9
|
+
--fg: #333b48;
|
|
10
|
+
--muted: #89919e;
|
|
11
|
+
--border: #e8ebf0;
|
|
12
|
+
--accent: #377cf6;
|
|
13
|
+
--soft: #edf3ff;
|
|
14
|
+
--danger: #db4552;
|
|
15
|
+
}
|
|
16
|
+
* {
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
}
|
|
19
|
+
body {
|
|
20
|
+
margin: 0;
|
|
21
|
+
color: var(--fg);
|
|
22
|
+
background: var(--bg);
|
|
23
|
+
height: 100vh;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
}
|
|
26
|
+
button,
|
|
27
|
+
input,
|
|
28
|
+
textarea,
|
|
29
|
+
select {
|
|
30
|
+
font: inherit;
|
|
31
|
+
color: inherit;
|
|
32
|
+
}
|
|
33
|
+
button {
|
|
34
|
+
border: 1px solid var(--border);
|
|
35
|
+
border-radius: 5px;
|
|
36
|
+
background: var(--bg);
|
|
37
|
+
padding: 5px 12px;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
white-space: nowrap;
|
|
40
|
+
}
|
|
41
|
+
button:hover {
|
|
42
|
+
border-color: var(--accent);
|
|
43
|
+
color: var(--accent);
|
|
44
|
+
}
|
|
45
|
+
button:disabled {
|
|
46
|
+
opacity: 0.45;
|
|
47
|
+
cursor: default;
|
|
48
|
+
}
|
|
49
|
+
.primary {
|
|
50
|
+
background: var(--accent);
|
|
51
|
+
border-color: var(--accent);
|
|
52
|
+
color: white;
|
|
53
|
+
}
|
|
54
|
+
.primary:hover {
|
|
55
|
+
color: white;
|
|
56
|
+
filter: brightness(1.06);
|
|
57
|
+
}
|
|
58
|
+
input,
|
|
59
|
+
textarea,
|
|
60
|
+
select {
|
|
61
|
+
border: 1px solid var(--border);
|
|
62
|
+
border-radius: 4px;
|
|
63
|
+
padding: 7px 9px;
|
|
64
|
+
background: var(--bg);
|
|
65
|
+
min-width: 0;
|
|
66
|
+
}
|
|
67
|
+
textarea {
|
|
68
|
+
resize: none;
|
|
69
|
+
line-height: 1.7;
|
|
70
|
+
tab-size: 2;
|
|
71
|
+
font-family: Consolas, "Microsoft YaHei", monospace;
|
|
72
|
+
}
|
|
73
|
+
input:focus,
|
|
74
|
+
textarea:focus,
|
|
75
|
+
select:focus {
|
|
76
|
+
outline: 1px solid var(--accent);
|
|
77
|
+
}
|
|
78
|
+
button:focus-visible {
|
|
79
|
+
outline: 2px solid var(--accent);
|
|
80
|
+
outline-offset: 2px;
|
|
81
|
+
}
|
|
82
|
+
main {
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
height: 100%;
|
|
86
|
+
min-height: 0;
|
|
87
|
+
}
|
|
88
|
+
.toolbar {
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
gap: 8px;
|
|
92
|
+
padding: 10px 14px;
|
|
93
|
+
border-bottom: 1px solid var(--border);
|
|
94
|
+
flex-wrap: wrap;
|
|
95
|
+
}
|
|
96
|
+
.toolbar strong {
|
|
97
|
+
font-size: 14px;
|
|
98
|
+
margin-right: 10px;
|
|
99
|
+
}
|
|
100
|
+
.spacer {
|
|
101
|
+
flex: 1;
|
|
102
|
+
}
|
|
103
|
+
.content {
|
|
104
|
+
flex: 1;
|
|
105
|
+
min-height: 0;
|
|
106
|
+
overflow: auto;
|
|
107
|
+
padding: 16px;
|
|
108
|
+
}
|
|
109
|
+
.split {
|
|
110
|
+
display: grid;
|
|
111
|
+
grid-template-columns: 1fr 1fr;
|
|
112
|
+
flex: 1;
|
|
113
|
+
min-height: 0;
|
|
114
|
+
}
|
|
115
|
+
.split > * {
|
|
116
|
+
min-width: 0;
|
|
117
|
+
overflow: auto;
|
|
118
|
+
}
|
|
119
|
+
.split > :first-child {
|
|
120
|
+
border-right: 1px solid var(--border);
|
|
121
|
+
}
|
|
122
|
+
.editor {
|
|
123
|
+
width: 100%;
|
|
124
|
+
height: 100%;
|
|
125
|
+
border: 0;
|
|
126
|
+
border-radius: 0;
|
|
127
|
+
padding: 16px;
|
|
128
|
+
outline: none !important;
|
|
129
|
+
background: var(--bg);
|
|
130
|
+
}
|
|
131
|
+
.muted,
|
|
132
|
+
small {
|
|
133
|
+
color: var(--muted);
|
|
134
|
+
}
|
|
135
|
+
.status {
|
|
136
|
+
font-size: 12px;
|
|
137
|
+
min-height: 26px;
|
|
138
|
+
border-top: 1px solid var(--border);
|
|
139
|
+
padding: 3px 14px;
|
|
140
|
+
color: var(--muted);
|
|
141
|
+
}
|
|
142
|
+
.status[data-error="true"] {
|
|
143
|
+
color: var(--danger);
|
|
144
|
+
}
|
|
145
|
+
.tabs {
|
|
146
|
+
display: flex;
|
|
147
|
+
gap: 5px;
|
|
148
|
+
align-items: center;
|
|
149
|
+
}
|
|
150
|
+
.tabs button {
|
|
151
|
+
border: 0;
|
|
152
|
+
background: transparent;
|
|
153
|
+
}
|
|
154
|
+
.tabs .active {
|
|
155
|
+
color: var(--accent);
|
|
156
|
+
background: var(--soft);
|
|
157
|
+
}
|
|
158
|
+
.empty {
|
|
159
|
+
padding: 48px 16px;
|
|
160
|
+
text-align: center;
|
|
161
|
+
color: var(--muted);
|
|
162
|
+
}
|
|
163
|
+
table {
|
|
164
|
+
border-collapse: collapse;
|
|
165
|
+
width: 100%;
|
|
166
|
+
text-align: left;
|
|
167
|
+
}
|
|
168
|
+
th {
|
|
169
|
+
font-size: 12px;
|
|
170
|
+
color: var(--muted);
|
|
171
|
+
font-weight: 400;
|
|
172
|
+
background: var(--surface);
|
|
173
|
+
position: sticky;
|
|
174
|
+
top: 0;
|
|
175
|
+
}
|
|
176
|
+
th,
|
|
177
|
+
td {
|
|
178
|
+
padding: 9px 12px;
|
|
179
|
+
border-bottom: 1px solid var(--border);
|
|
180
|
+
}
|
|
181
|
+
tr.selected {
|
|
182
|
+
background: var(--soft);
|
|
183
|
+
}
|
|
184
|
+
pre {
|
|
185
|
+
white-space: pre-wrap;
|
|
186
|
+
overflow-wrap: anywhere;
|
|
187
|
+
margin: 0;
|
|
188
|
+
}
|
|
189
|
+
label {
|
|
190
|
+
display: flex;
|
|
191
|
+
gap: 8px;
|
|
192
|
+
align-items: center;
|
|
193
|
+
}
|
|
194
|
+
.stack {
|
|
195
|
+
display: flex;
|
|
196
|
+
flex-direction: column;
|
|
197
|
+
gap: 12px;
|
|
198
|
+
}
|
|
199
|
+
.row {
|
|
200
|
+
display: flex;
|
|
201
|
+
gap: 8px;
|
|
202
|
+
align-items: center;
|
|
203
|
+
}
|
|
204
|
+
.panel {
|
|
205
|
+
border: 1px solid var(--border);
|
|
206
|
+
border-radius: 6px;
|
|
207
|
+
padding: 14px;
|
|
208
|
+
}
|
|
209
|
+
.badge {
|
|
210
|
+
font-size: 11px;
|
|
211
|
+
padding: 1px 7px;
|
|
212
|
+
border-radius: 4px;
|
|
213
|
+
background: var(--surface);
|
|
214
|
+
color: var(--muted);
|
|
215
|
+
}
|
|
216
|
+
.danger {
|
|
217
|
+
color: var(--danger);
|
|
218
|
+
}
|
|
219
|
+
.hidden {
|
|
220
|
+
display: none !important;
|
|
221
|
+
}
|
|
222
|
+
#theme {
|
|
223
|
+
padding: 3px 8px;
|
|
224
|
+
}
|
|
225
|
+
.sidebar {
|
|
226
|
+
width: 155px;
|
|
227
|
+
background: var(--surface);
|
|
228
|
+
padding: 14px 10px;
|
|
229
|
+
border-right: 1px solid var(--border);
|
|
230
|
+
overflow: auto;
|
|
231
|
+
}
|
|
232
|
+
.sidebar button {
|
|
233
|
+
display: block;
|
|
234
|
+
width: 100%;
|
|
235
|
+
text-align: left;
|
|
236
|
+
border: 0;
|
|
237
|
+
background: transparent;
|
|
238
|
+
margin-bottom: 4px;
|
|
239
|
+
}
|
|
240
|
+
.sidebar .active {
|
|
241
|
+
background: var(--soft);
|
|
242
|
+
color: var(--accent);
|
|
243
|
+
}
|
|
244
|
+
.workspace {
|
|
245
|
+
display: flex;
|
|
246
|
+
flex: 1;
|
|
247
|
+
min-height: 0;
|
|
248
|
+
}
|
|
249
|
+
.workspace > .content {
|
|
250
|
+
flex: 1;
|
|
251
|
+
}
|
|
252
|
+
details {
|
|
253
|
+
border-bottom: 1px solid var(--border);
|
|
254
|
+
padding: 7px 0;
|
|
255
|
+
}
|
|
256
|
+
summary {
|
|
257
|
+
cursor: pointer;
|
|
258
|
+
}
|
|
259
|
+
::-webkit-scrollbar {
|
|
260
|
+
width: 6px;
|
|
261
|
+
height: 6px;
|
|
262
|
+
}
|
|
263
|
+
::-webkit-scrollbar-thumb {
|
|
264
|
+
background: #b9c0cb60;
|
|
265
|
+
border-radius: 8px;
|
|
266
|
+
}
|
|
267
|
+
html[data-theme="dark"] {
|
|
268
|
+
color-scheme: dark;
|
|
269
|
+
--bg: #1b1e24;
|
|
270
|
+
--surface: #222731;
|
|
271
|
+
--fg: #dce1eb;
|
|
272
|
+
--muted: #8894a8;
|
|
273
|
+
--border: #333a47;
|
|
274
|
+
--accent: #6ca7ff;
|
|
275
|
+
--soft: #27364c;
|
|
276
|
+
--danger: #ff8490;
|
|
277
|
+
}
|
|
278
|
+
@media (max-width: 560px) {
|
|
279
|
+
.sidebar {
|
|
280
|
+
width: 115px;
|
|
281
|
+
}
|
|
282
|
+
.toolbar {
|
|
283
|
+
padding: 8px;
|
|
284
|
+
gap: 5px;
|
|
285
|
+
}
|
|
286
|
+
button {
|
|
287
|
+
padding: 5px 8px;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
@media (prefers-reduced-motion: reduce) {
|
|
291
|
+
* {
|
|
292
|
+
scroll-behavior: auto !important;
|
|
293
|
+
animation: none !important;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
.program-path-row{display:flex;align-items:center;gap:12px;min-width:0}.program-path-row label{flex:none}.program-path-row input{flex:1;min-width:0}.program-actions{display:flex;align-items:center;gap:8px;overflow-x:auto;flex:none}.program-actions button{white-space:nowrap;flex:none}#program-status{margin-left:auto;white-space:nowrap;font-size:12px;color:var(--muted)}#program-status[data-state=connected]{color:var(--accent)}#program-status[data-state=error]{color:var(--danger)}#program-dialog{width:min(620px,90vw);color:var(--fg);background:var(--bg);border:1px solid var(--border);border-radius:12px;padding:20px}#program-dialog::backdrop{background:#0007}#program-options{width:100%;margin-bottom:16px}
|
package/umi.mjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const DEFAULT_ENDPOINT = 'http://127.0.0.1:1224';
|
|
2
|
+
export function endpoint(value = DEFAULT_ENDPOINT) {
|
|
3
|
+
let url;
|
|
4
|
+
try { url = new URL(value); } catch { throw Error('请输入本机服务地址,例如 http://127.0.0.1:1224'); }
|
|
5
|
+
if (url.protocol !== 'http:' || !['127.0.0.1','localhost','[::1]'].includes(url.hostname) || url.username || url.password || url.search || url.hash || url.pathname !== '/') throw Error('仅允许本机 HTTP 地址,不支持外部服务器或额外路径');
|
|
6
|
+
return url.origin;
|
|
7
|
+
}
|
|
8
|
+
export function imageBase64(value) {
|
|
9
|
+
const match = /^data:image\/(?:png|jpeg|bmp);base64,([A-Za-z0-9+/]+={0,2})$/i.exec(value);
|
|
10
|
+
if (!match || match[1].length % 4 || match[1].length > 4*1024*1024) throw Error('请选择不超过 3 MB 的 JPG / PNG / BMP 图片');
|
|
11
|
+
return match[1];
|
|
12
|
+
}
|
|
13
|
+
export function responseJson(response) {
|
|
14
|
+
if (response?.status !== 200) throw Error('Umi-OCR 返回 HTTP '+(response?.status ?? '未知'));
|
|
15
|
+
try { return JSON.parse(response.body); } catch { throw Error('Umi-OCR 返回的内容不是有效 JSON,请核对本机服务地址'); }
|
|
16
|
+
}
|
|
17
|
+
export function resultText(result) {
|
|
18
|
+
if (result?.code === 101) return '';
|
|
19
|
+
if (result?.code !== 100) throw Error('Umi-OCR 识别失败:'+(typeof result?.data === 'string' ? result.data : '返回码 '+result?.code));
|
|
20
|
+
if (typeof result.data === 'string') return result.data;
|
|
21
|
+
if (Array.isArray(result.data) && result.data.every(item => typeof item?.text === 'string')) return result.data.map(item=>item.text).join('\n');
|
|
22
|
+
throw Error('Umi-OCR 识别结果格式无效');
|
|
23
|
+
}
|
|
24
|
+
export function friendlyError(error) {
|
|
25
|
+
const text=error?.message || String(error);
|
|
26
|
+
if (/connect|connection|timed? ?out|timeout|10061|拒绝连接|连接失败/i.test(text)) return '无法连接或识别超时:请确认 Umi-OCR 正在运行,并在全局设置开启 HTTP 服务(默认 127.0.0.1:1224);首次识别需加载模型,稍后可重试。';
|
|
27
|
+
return text;
|
|
28
|
+
}
|
|
29
|
+
export const UMI_DOWNLOAD_URL = 'https://github.com/hiroi-sora/Umi-OCR/releases';
|
|
30
|
+
export function isConnectionFailure(error) {
|
|
31
|
+
const text=error?.message||String(error);
|
|
32
|
+
if(/permission|denied|授权|权限|timeout|timed? ?out|超时/i.test(text))return false;
|
|
33
|
+
return /ECONNREFUSED|10061|refused|failed to connect|connect.*fail|connection.*fail|network error|拒绝连接|连接失败|无法连接/i.test(text);
|
|
34
|
+
}
|
package/common.mjs
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
export const $ = (selector) => document.querySelector(selector);
|
|
2
|
-
export const $$ = (selector) => [...document.querySelectorAll(selector)];
|
|
3
|
-
export function status(text, error = false) {
|
|
4
|
-
const el = $("#status");
|
|
5
|
-
if (el) {
|
|
6
|
-
el.textContent = text;
|
|
7
|
-
el.dataset.error = String(error);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export function action(fn) {
|
|
11
|
-
return async (...args) => {
|
|
12
|
-
try {
|
|
13
|
-
return await fn(...args);
|
|
14
|
-
} catch (e) {
|
|
15
|
-
status(e.message || String(e), true);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export async function call(id, args = {}) {
|
|
20
|
-
if (!window.mytools) throw Error("请从 MyTools 打开此工具");
|
|
21
|
-
return window.mytools.call(id, args);
|
|
22
|
-
}
|
|
23
|
-
export const copy = async (text) => {
|
|
24
|
-
await call("clipboard.write", { text: String(text) });
|
|
25
|
-
status("已复制到剪贴板");
|
|
26
|
-
};
|
|
27
|
-
export function ready(fn) {
|
|
28
|
-
if (window.mytools) window.mytools.onPluginReady(action(fn));
|
|
29
|
-
else status("预览模式:系统能力需从 MyTools 使用");
|
|
30
|
-
}
|
|
31
|
-
export const escapeHtml = (text) =>
|
|
32
|
-
String(text).replace(
|
|
33
|
-
/[&<>"']/g,
|
|
34
|
-
(c) =>
|
|
35
|
-
({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[
|
|
36
|
-
c
|
|
37
|
-
],
|
|
38
|
-
);
|
|
39
|
-
export function download(name, text, type = "text/plain") {
|
|
40
|
-
const url = URL.createObjectURL(new Blob([text], { type }));
|
|
41
|
-
const a = document.createElement("a");
|
|
42
|
-
a.href = url;
|
|
43
|
-
a.download = name;
|
|
44
|
-
a.click();
|
|
45
|
-
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
46
|
-
}
|
|
47
|
-
export function debounce(fn, ms = 200) {
|
|
48
|
-
let timer;
|
|
49
|
-
return (...args) => {
|
|
50
|
-
clearTimeout(timer);
|
|
51
|
-
timer = setTimeout(() => fn(...args), ms);
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
export const formatBytes = (n) =>
|
|
55
|
-
n < 1024
|
|
56
|
-
? n + " B"
|
|
57
|
-
: n < 1048576
|
|
58
|
-
? (n / 1024).toFixed(1) + " KB"
|
|
59
|
-
: (n / 1048576).toFixed(1) + " MB";
|
|
60
|
-
const savedTheme = localStorage.getItem("tool-theme");
|
|
61
|
-
document.documentElement.dataset.theme =
|
|
62
|
-
savedTheme ||
|
|
63
|
-
(matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
|
64
|
-
$("#theme")?.addEventListener("click", () => {
|
|
65
|
-
const theme =
|
|
66
|
-
document.documentElement.dataset.theme === "dark" ? "light" : "dark";
|
|
67
|
-
document.documentElement.dataset.theme = theme;
|
|
68
|
-
localStorage.setItem("tool-theme", theme);
|
|
69
|
-
});
|