gz-laya-pilot 0.1.0 → 0.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/NOTICE.md +20 -2
- package/README.md +54 -2
- package/dist/agent/bridge.d.ts +21 -0
- package/dist/agent/bridge.js +158 -0
- package/dist/agent/bridge.js.map +1 -0
- package/dist/agent/report.d.ts +54 -0
- package/dist/agent/report.js +100 -0
- package/dist/agent/report.js.map +1 -0
- package/dist/agent/run.d.ts +19 -0
- package/dist/agent/run.js +121 -0
- package/dist/agent/run.js.map +1 -0
- package/dist/agent/schema.d.ts +42 -0
- package/dist/agent/schema.js +9 -0
- package/dist/agent/schema.js.map +1 -0
- package/dist/agent/worker.d.ts +1 -0
- package/dist/agent/worker.js +102 -0
- package/dist/agent/worker.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +7 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +14 -6
- package/src/agent/bridge.ts +180 -0
- package/src/agent/report.ts +139 -0
- package/src/agent/run.ts +136 -0
- package/src/agent/schema.ts +38 -0
- package/src/agent/worker.ts +114 -0
- package/src/cli.ts +5 -0
- package/src/index.ts +3 -0
- package/vendor/.gitattributes +5 -0
- package/vendor/UPSTREAM.json +168 -0
- package/vendor/laya-pilot/LICENSE +21 -0
- package/vendor/laya-pilot/README.en.md +116 -0
- package/vendor/laya-pilot/README.md +116 -0
- package/vendor/laya-pilot/ROADMAP.md +21 -0
- package/vendor/laya-pilot/config.example.json +14 -0
- package/vendor/laya-pilot/docs/architecture.md +21 -0
- package/vendor/laya-pilot/docs/browser-use-evaluation.md +32 -0
- package/vendor/laya-pilot/docs/demo.png +0 -0
- package/vendor/laya-pilot/docs/local-runtime.md +88 -0
- package/vendor/laya-pilot/docs/pr1-selection.md +33 -0
- package/vendor/laya-pilot/docs/retry-policy.md +14 -0
- package/vendor/laya-pilot/examples/demo-cases.xlsx +0 -0
- package/vendor/laya-pilot/examples/demo-server.mjs +19 -0
- package/vendor/laya-pilot/examples/demo.html +733 -0
- package/vendor/laya-pilot/lib/auth-state.mjs +141 -0
- package/vendor/laya-pilot/lib/browser-provider.mjs +43 -0
- package/vendor/laya-pilot/lib/diagnostics.mjs +210 -0
- package/vendor/laya-pilot/lib/discovery.mjs +474 -0
- package/vendor/laya-pilot/lib/dom.mjs +539 -0
- package/vendor/laya-pilot/lib/engine.mjs +879 -0
- package/vendor/laya-pilot/lib/form.mjs +377 -0
- package/vendor/laya-pilot/lib/language.mjs +273 -0
- package/vendor/laya-pilot/lib/model.mjs +271 -0
- package/vendor/laya-pilot/lib/page-capabilities.mjs +356 -0
- package/vendor/laya-pilot/lib/page-exploration.mjs +372 -0
- package/vendor/laya-pilot/lib/page-session.mjs +69 -0
- package/vendor/laya-pilot/lib/pending-writes.mjs +50 -0
- package/vendor/laya-pilot/lib/planner.mjs +127 -0
- package/vendor/laya-pilot/lib/project-config.mjs +95 -0
- package/vendor/laya-pilot/lib/readiness.mjs +179 -0
- package/vendor/laya-pilot/lib/related-records.mjs +328 -0
- package/vendor/laya-pilot/lib/replay-model.mjs +44 -0
- package/vendor/laya-pilot/lib/run-state.mjs +133 -0
- package/vendor/laya-pilot/lib/test-data.mjs +128 -0
- package/vendor/laya-pilot/lib/workflow-policy.mjs +68 -0
- package/vendor/laya-pilot/lib/workflow.mjs +2321 -0
- package/vendor/laya-pilot/lib/workflow_excel.py +462 -0
- package/vendor/laya-pilot/requirements-local.txt +2 -0
- package/vendor/laya-pilot/requirements.txt +1 -0
- package/vendor/laya-pilot/runner.mjs +452 -0
- package/vendor/laya-pilot/tests/api.test.mjs +98 -0
- package/vendor/laya-pilot/tests/browser/runtime.test.mjs +847 -0
- package/vendor/laya-pilot/tests/config.test.mjs +109 -0
- package/vendor/laya-pilot/tests/diagnostics.test.mjs +91 -0
- package/vendor/laya-pilot/tests/discovery.test.mjs +76 -0
- package/vendor/laya-pilot/tests/fixtures/local-model/laya.py +28 -0
- package/vendor/laya-pilot/tests/fixtures/local-model/torch.py +5 -0
- package/vendor/laya-pilot/tests/guards.test.mjs +43 -0
- package/vendor/laya-pilot/tests/language.test.mjs +39 -0
- package/vendor/laya-pilot/tests/planner.test.mjs +129 -0
- package/vendor/laya-pilot/tests/readiness.test.mjs +118 -0
- package/vendor/laya-pilot/tests/real-model.smoke.mjs +74 -0
- package/vendor/laya-pilot/tests/replay-model.test.mjs +90 -0
- package/vendor/laya-pilot/tests/retries.test.mjs +270 -0
- package/vendor/laya-pilot/tests/run-state.test.mjs +162 -0
- package/vendor/laya-pilot/tests/selected-pr1.test.mjs +309 -0
- package/vendor/laya-pilot/tests/test-data.test.mjs +83 -0
- package/vendor/laya-pilot/tests/test_workflow_excel.py +162 -0
- package/vendor/laya-pilot/tests/worker_test.py +33 -0
- package/vendor/laya-pilot/tests/workflow.test.mjs +98 -0
- package/vendor/laya-pilot/worker.py +135 -0
- package/vendor/patches/0001-native-field-recipes.patch +3009 -0
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
6
|
+
<title>LayaPilot · Demo</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
font-family:
|
|
10
|
+
Inter,
|
|
11
|
+
-apple-system,
|
|
12
|
+
BlinkMacSystemFont,
|
|
13
|
+
'Segoe UI',
|
|
14
|
+
sans-serif;
|
|
15
|
+
color: #17253a;
|
|
16
|
+
background: #f3f6fb;
|
|
17
|
+
font-synthesis: none;
|
|
18
|
+
}
|
|
19
|
+
* {
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
}
|
|
22
|
+
body {
|
|
23
|
+
margin: 0;
|
|
24
|
+
min-height: 100vh;
|
|
25
|
+
}
|
|
26
|
+
button,
|
|
27
|
+
input,
|
|
28
|
+
select {
|
|
29
|
+
font: inherit;
|
|
30
|
+
}
|
|
31
|
+
button {
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
34
|
+
button:disabled {
|
|
35
|
+
cursor: not-allowed;
|
|
36
|
+
opacity: 0.45;
|
|
37
|
+
}
|
|
38
|
+
a {
|
|
39
|
+
color: inherit;
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
}
|
|
42
|
+
.shell {
|
|
43
|
+
min-height: 100vh;
|
|
44
|
+
display: grid;
|
|
45
|
+
grid-template-columns: 248px minmax(0, 1fr);
|
|
46
|
+
}
|
|
47
|
+
.sidebar {
|
|
48
|
+
background: #10263f;
|
|
49
|
+
color: #d7e6f6;
|
|
50
|
+
padding: 28px 16px;
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-direction: column;
|
|
53
|
+
gap: 42px;
|
|
54
|
+
box-shadow: 8px 0 28px #10263f0c;
|
|
55
|
+
}
|
|
56
|
+
.brand {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
gap: 12px;
|
|
60
|
+
padding: 0 14px;
|
|
61
|
+
color: white;
|
|
62
|
+
font-size: 17px;
|
|
63
|
+
font-weight: 750;
|
|
64
|
+
letter-spacing: -0.03em;
|
|
65
|
+
}
|
|
66
|
+
.brand-mark {
|
|
67
|
+
display: grid;
|
|
68
|
+
place-items: center;
|
|
69
|
+
width: 36px;
|
|
70
|
+
height: 36px;
|
|
71
|
+
border-radius: 12px;
|
|
72
|
+
background: linear-gradient(145deg, #53c6e6, #7067d8);
|
|
73
|
+
color: white;
|
|
74
|
+
font-size: 18px;
|
|
75
|
+
box-shadow: 0 8px 22px #5d86d444;
|
|
76
|
+
}
|
|
77
|
+
.nav-caption {
|
|
78
|
+
color: #7894b2;
|
|
79
|
+
text-transform: uppercase;
|
|
80
|
+
letter-spacing: 0.15em;
|
|
81
|
+
font-size: 10px;
|
|
82
|
+
font-weight: 800;
|
|
83
|
+
padding: 0 14px;
|
|
84
|
+
margin-bottom: 12px;
|
|
85
|
+
}
|
|
86
|
+
.nav-list {
|
|
87
|
+
display: grid;
|
|
88
|
+
gap: 6px;
|
|
89
|
+
}
|
|
90
|
+
.nav-list a {
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
gap: 11px;
|
|
94
|
+
padding: 12px 14px;
|
|
95
|
+
border-radius: 11px;
|
|
96
|
+
color: #c1d4e8;
|
|
97
|
+
font-size: 14px;
|
|
98
|
+
font-weight: 550;
|
|
99
|
+
transition:
|
|
100
|
+
background 0.18s,
|
|
101
|
+
color 0.18s;
|
|
102
|
+
}
|
|
103
|
+
.nav-list a:hover,
|
|
104
|
+
.nav-list a[aria-current='page'] {
|
|
105
|
+
background: #264868;
|
|
106
|
+
color: white;
|
|
107
|
+
}
|
|
108
|
+
.nav-list a[aria-current='page'] {
|
|
109
|
+
box-shadow: inset 3px 0 #6cd8e9;
|
|
110
|
+
}
|
|
111
|
+
.nav-list .icon {
|
|
112
|
+
width: 22px;
|
|
113
|
+
text-align: center;
|
|
114
|
+
color: #8ccde2;
|
|
115
|
+
font-size: 17px;
|
|
116
|
+
}
|
|
117
|
+
.sidebar-note {
|
|
118
|
+
margin-top: auto;
|
|
119
|
+
padding: 15px;
|
|
120
|
+
border-radius: 14px;
|
|
121
|
+
background: #193b5c;
|
|
122
|
+
border: 1px solid #315577;
|
|
123
|
+
}
|
|
124
|
+
.sidebar-note strong {
|
|
125
|
+
display: block;
|
|
126
|
+
color: white;
|
|
127
|
+
font-size: 12px;
|
|
128
|
+
}
|
|
129
|
+
.sidebar-note p {
|
|
130
|
+
margin: 6px 0 0;
|
|
131
|
+
color: #a9bfd5;
|
|
132
|
+
font-size: 12px;
|
|
133
|
+
line-height: 1.55;
|
|
134
|
+
}
|
|
135
|
+
.workspace {
|
|
136
|
+
min-width: 0;
|
|
137
|
+
}
|
|
138
|
+
.topbar {
|
|
139
|
+
height: 74px;
|
|
140
|
+
background: #fff;
|
|
141
|
+
border-bottom: 1px solid #e7edf5;
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
justify-content: space-between;
|
|
145
|
+
padding: 0 38px;
|
|
146
|
+
}
|
|
147
|
+
.topbar .trail {
|
|
148
|
+
color: #8291a4;
|
|
149
|
+
font-size: 13px;
|
|
150
|
+
}
|
|
151
|
+
.topbar .trail strong {
|
|
152
|
+
color: #30435b;
|
|
153
|
+
font-weight: 650;
|
|
154
|
+
}
|
|
155
|
+
.topbar .demo-pill {
|
|
156
|
+
border-radius: 100px;
|
|
157
|
+
padding: 7px 12px;
|
|
158
|
+
background: #e7f8f6;
|
|
159
|
+
color: #14796e;
|
|
160
|
+
font-size: 11px;
|
|
161
|
+
font-weight: 750;
|
|
162
|
+
letter-spacing: 0.08em;
|
|
163
|
+
}
|
|
164
|
+
.content {
|
|
165
|
+
max-width: 1320px;
|
|
166
|
+
padding: 34px 38px 70px;
|
|
167
|
+
margin: 0 auto;
|
|
168
|
+
}
|
|
169
|
+
.eyebrow {
|
|
170
|
+
color: #4877b4;
|
|
171
|
+
font-size: 11px;
|
|
172
|
+
font-weight: 800;
|
|
173
|
+
letter-spacing: 0.14em;
|
|
174
|
+
text-transform: uppercase;
|
|
175
|
+
margin: 0 0 8px;
|
|
176
|
+
}
|
|
177
|
+
.hero {
|
|
178
|
+
padding: 26px 29px;
|
|
179
|
+
background: linear-gradient(115deg, #1b4673 0%, #27628d 56%, #5e74b5 100%);
|
|
180
|
+
border-radius: 22px;
|
|
181
|
+
color: white;
|
|
182
|
+
box-shadow: 0 16px 36px #254c801e;
|
|
183
|
+
position: relative;
|
|
184
|
+
overflow: hidden;
|
|
185
|
+
margin-bottom: 24px;
|
|
186
|
+
}
|
|
187
|
+
.hero:after {
|
|
188
|
+
content: '';
|
|
189
|
+
position: absolute;
|
|
190
|
+
width: 330px;
|
|
191
|
+
height: 330px;
|
|
192
|
+
border-radius: 50%;
|
|
193
|
+
border: 1px solid #ffffff3b;
|
|
194
|
+
right: -60px;
|
|
195
|
+
top: -220px;
|
|
196
|
+
box-shadow:
|
|
197
|
+
0 0 0 56px #ffffff0c,
|
|
198
|
+
0 0 0 112px #ffffff09;
|
|
199
|
+
}
|
|
200
|
+
.hero h2 {
|
|
201
|
+
font-size: 25px;
|
|
202
|
+
letter-spacing: -0.03em;
|
|
203
|
+
margin: 0 0 6px;
|
|
204
|
+
}
|
|
205
|
+
.hero p {
|
|
206
|
+
margin: 0;
|
|
207
|
+
color: #d4e9fb;
|
|
208
|
+
font-size: 13px;
|
|
209
|
+
line-height: 1.6;
|
|
210
|
+
}
|
|
211
|
+
.hero .hero-kicker {
|
|
212
|
+
font-size: 11px;
|
|
213
|
+
color: #a5e5ef;
|
|
214
|
+
font-weight: 800;
|
|
215
|
+
letter-spacing: 0.13em;
|
|
216
|
+
margin-bottom: 8px;
|
|
217
|
+
}
|
|
218
|
+
.panel {
|
|
219
|
+
background: #fff;
|
|
220
|
+
border: 1px solid #e4ebf3;
|
|
221
|
+
border-radius: 18px;
|
|
222
|
+
box-shadow: 0 6px 24px #1a36520a;
|
|
223
|
+
padding: 28px;
|
|
224
|
+
}
|
|
225
|
+
.panel h1 {
|
|
226
|
+
font-size: 23px;
|
|
227
|
+
letter-spacing: -0.035em;
|
|
228
|
+
margin: 0 0 24px;
|
|
229
|
+
color: #182d46;
|
|
230
|
+
}
|
|
231
|
+
.panel h1:after {
|
|
232
|
+
content: '';
|
|
233
|
+
display: block;
|
|
234
|
+
margin-top: 12px;
|
|
235
|
+
width: 34px;
|
|
236
|
+
height: 3px;
|
|
237
|
+
border-radius: 4px;
|
|
238
|
+
background: #37a7c0;
|
|
239
|
+
}
|
|
240
|
+
.panel label {
|
|
241
|
+
display: inline-block;
|
|
242
|
+
font-size: 13px;
|
|
243
|
+
font-weight: 650;
|
|
244
|
+
color: #3b5068;
|
|
245
|
+
margin-right: 10px;
|
|
246
|
+
}
|
|
247
|
+
.panel input:not([type='checkbox']),
|
|
248
|
+
.panel select,
|
|
249
|
+
dialog input {
|
|
250
|
+
height: 40px;
|
|
251
|
+
min-width: 215px;
|
|
252
|
+
background: #fff;
|
|
253
|
+
border: 1px solid #cdd9e8;
|
|
254
|
+
border-radius: 9px;
|
|
255
|
+
padding: 0 12px;
|
|
256
|
+
color: #1c2d44;
|
|
257
|
+
outline: none;
|
|
258
|
+
transition:
|
|
259
|
+
border-color 0.16s,
|
|
260
|
+
box-shadow 0.16s;
|
|
261
|
+
}
|
|
262
|
+
.panel input:focus,
|
|
263
|
+
.panel select:focus,
|
|
264
|
+
dialog input:focus {
|
|
265
|
+
border-color: #3999c2;
|
|
266
|
+
box-shadow: 0 0 0 3px #3999c21a;
|
|
267
|
+
}
|
|
268
|
+
.panel input[type='checkbox'] {
|
|
269
|
+
accent-color: #2589b4;
|
|
270
|
+
width: 16px;
|
|
271
|
+
height: 16px;
|
|
272
|
+
margin-right: 8px;
|
|
273
|
+
vertical-align: middle;
|
|
274
|
+
}
|
|
275
|
+
.panel button,
|
|
276
|
+
dialog button {
|
|
277
|
+
border: 1px solid #cad8e7;
|
|
278
|
+
border-radius: 9px;
|
|
279
|
+
background: #fff;
|
|
280
|
+
color: #2d536f;
|
|
281
|
+
height: 40px;
|
|
282
|
+
padding: 0 16px;
|
|
283
|
+
margin-left: 8px;
|
|
284
|
+
font-weight: 650;
|
|
285
|
+
transition:
|
|
286
|
+
background 0.16s,
|
|
287
|
+
transform 0.16s,
|
|
288
|
+
box-shadow 0.16s;
|
|
289
|
+
}
|
|
290
|
+
.panel button:hover:not(:disabled),
|
|
291
|
+
dialog button:hover:not(:disabled) {
|
|
292
|
+
background: #eef7fb;
|
|
293
|
+
transform: translateY(-1px);
|
|
294
|
+
}
|
|
295
|
+
.panel button:nth-of-type(1),
|
|
296
|
+
dialog button:nth-of-type(1) {
|
|
297
|
+
background: #246d9c;
|
|
298
|
+
border-color: #246d9c;
|
|
299
|
+
color: white;
|
|
300
|
+
box-shadow: 0 5px 13px #246d9c26;
|
|
301
|
+
}
|
|
302
|
+
.panel button:nth-of-type(1):hover:not(:disabled),
|
|
303
|
+
dialog button:nth-of-type(1):hover:not(:disabled) {
|
|
304
|
+
background: #1c5d88;
|
|
305
|
+
}
|
|
306
|
+
.panel section {
|
|
307
|
+
overflow-x: auto;
|
|
308
|
+
margin-top: 22px;
|
|
309
|
+
}
|
|
310
|
+
.panel table {
|
|
311
|
+
border-collapse: separate;
|
|
312
|
+
border-spacing: 0;
|
|
313
|
+
width: 100%;
|
|
314
|
+
font-size: 13px;
|
|
315
|
+
}
|
|
316
|
+
.panel th {
|
|
317
|
+
background: #f5f8fc;
|
|
318
|
+
color: #708198;
|
|
319
|
+
text-transform: uppercase;
|
|
320
|
+
letter-spacing: 0.05em;
|
|
321
|
+
font-size: 11px;
|
|
322
|
+
font-weight: 750;
|
|
323
|
+
text-align: left;
|
|
324
|
+
padding: 13px 16px;
|
|
325
|
+
border-top: 1px solid #e8edf3;
|
|
326
|
+
border-bottom: 1px solid #e8edf3;
|
|
327
|
+
}
|
|
328
|
+
.panel th:first-child {
|
|
329
|
+
border-left: 1px solid #e8edf3;
|
|
330
|
+
border-top-left-radius: 10px;
|
|
331
|
+
}
|
|
332
|
+
.panel th:last-child {
|
|
333
|
+
border-right: 1px solid #e8edf3;
|
|
334
|
+
border-top-right-radius: 10px;
|
|
335
|
+
}
|
|
336
|
+
.panel td {
|
|
337
|
+
padding: 14px 16px;
|
|
338
|
+
border-bottom: 1px solid #edf1f5;
|
|
339
|
+
color: #2c415b;
|
|
340
|
+
}
|
|
341
|
+
.panel td:last-child {
|
|
342
|
+
white-space: nowrap;
|
|
343
|
+
}
|
|
344
|
+
.panel tbody tr:hover td {
|
|
345
|
+
background: #fbfdff;
|
|
346
|
+
}
|
|
347
|
+
.panel td button {
|
|
348
|
+
height: 31px;
|
|
349
|
+
padding: 0 10px;
|
|
350
|
+
margin: 0 5px 0 0;
|
|
351
|
+
font-size: 12px;
|
|
352
|
+
background: #f6fafc;
|
|
353
|
+
box-shadow: none;
|
|
354
|
+
}
|
|
355
|
+
.panel [role='status'] {
|
|
356
|
+
padding: 11px 14px;
|
|
357
|
+
background: #e9f7f1;
|
|
358
|
+
color: #217d58;
|
|
359
|
+
border-radius: 9px;
|
|
360
|
+
font-size: 13px;
|
|
361
|
+
}
|
|
362
|
+
.panel fieldset {
|
|
363
|
+
border: 1px solid #dde6ee;
|
|
364
|
+
border-radius: 10px;
|
|
365
|
+
margin: 12px 0;
|
|
366
|
+
padding: 15px;
|
|
367
|
+
}
|
|
368
|
+
dialog {
|
|
369
|
+
border: 1px solid #dfe8f1;
|
|
370
|
+
border-radius: 18px;
|
|
371
|
+
min-width: min(480px, calc(100vw - 28px));
|
|
372
|
+
max-width: calc(100vw - 28px);
|
|
373
|
+
padding: 28px;
|
|
374
|
+
color: #243750;
|
|
375
|
+
box-shadow: 0 24px 70px #10233d40;
|
|
376
|
+
}
|
|
377
|
+
dialog::backdrop {
|
|
378
|
+
background: #11243c77;
|
|
379
|
+
backdrop-filter: blur(3px);
|
|
380
|
+
}
|
|
381
|
+
dialog h2 {
|
|
382
|
+
margin: 0 0 18px;
|
|
383
|
+
font-size: 21px;
|
|
384
|
+
}
|
|
385
|
+
dialog label {
|
|
386
|
+
display: block;
|
|
387
|
+
font-size: 13px;
|
|
388
|
+
font-weight: 650;
|
|
389
|
+
margin: 10px 0 7px;
|
|
390
|
+
}
|
|
391
|
+
dialog input {
|
|
392
|
+
width: 100%;
|
|
393
|
+
margin-bottom: 22px;
|
|
394
|
+
}
|
|
395
|
+
dialog p {
|
|
396
|
+
line-height: 1.6;
|
|
397
|
+
}
|
|
398
|
+
dialog button {
|
|
399
|
+
margin-left: 0;
|
|
400
|
+
margin-right: 8px;
|
|
401
|
+
}
|
|
402
|
+
.footer {
|
|
403
|
+
color: #97a6b7;
|
|
404
|
+
text-align: right;
|
|
405
|
+
font-size: 11px;
|
|
406
|
+
margin-top: 20px;
|
|
407
|
+
}
|
|
408
|
+
@media (max-width: 850px) {
|
|
409
|
+
.shell {
|
|
410
|
+
grid-template-columns: 1fr;
|
|
411
|
+
}
|
|
412
|
+
.sidebar {
|
|
413
|
+
padding: 15px;
|
|
414
|
+
gap: 12px;
|
|
415
|
+
}
|
|
416
|
+
.brand {
|
|
417
|
+
font-size: 14px;
|
|
418
|
+
}
|
|
419
|
+
.nav-caption,
|
|
420
|
+
.sidebar-note {
|
|
421
|
+
display: none;
|
|
422
|
+
}
|
|
423
|
+
.nav-list {
|
|
424
|
+
display: flex;
|
|
425
|
+
overflow: auto;
|
|
426
|
+
}
|
|
427
|
+
.nav-list a {
|
|
428
|
+
white-space: nowrap;
|
|
429
|
+
padding: 9px;
|
|
430
|
+
}
|
|
431
|
+
.topbar {
|
|
432
|
+
height: 60px;
|
|
433
|
+
padding: 0 18px;
|
|
434
|
+
}
|
|
435
|
+
.content {
|
|
436
|
+
padding: 20px 15px 40px;
|
|
437
|
+
}
|
|
438
|
+
.panel {
|
|
439
|
+
padding: 20px;
|
|
440
|
+
}
|
|
441
|
+
.panel input:not([type='checkbox']) {
|
|
442
|
+
min-width: 0;
|
|
443
|
+
width: 100%;
|
|
444
|
+
margin: 8px 0;
|
|
445
|
+
}
|
|
446
|
+
.panel button {
|
|
447
|
+
margin: 6px 6px 0 0;
|
|
448
|
+
}
|
|
449
|
+
.hero {
|
|
450
|
+
padding: 22px;
|
|
451
|
+
}
|
|
452
|
+
.hero h2 {
|
|
453
|
+
font-size: 21px;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.ant-form-item-has-error input {
|
|
458
|
+
border-color: #dd5e67 !important;
|
|
459
|
+
box-shadow: 0 0 0 3px #dd5e6717 !important;
|
|
460
|
+
}
|
|
461
|
+
.ant-form-item-explain-error {
|
|
462
|
+
display: block;
|
|
463
|
+
color: #ca4752;
|
|
464
|
+
font-size: 12px;
|
|
465
|
+
margin: -14px 0 18px;
|
|
466
|
+
}
|
|
467
|
+
.ant-form-item-explain-error[hidden] {
|
|
468
|
+
display: none;
|
|
469
|
+
}
|
|
470
|
+
</style>
|
|
471
|
+
</head>
|
|
472
|
+
<body>
|
|
473
|
+
<div class="shell">
|
|
474
|
+
<aside class="sidebar">
|
|
475
|
+
<div class="brand"><span class="brand-mark">✦</span><span>LayaPilot</span></div>
|
|
476
|
+
<div>
|
|
477
|
+
<p class="nav-caption">Test workspace</p>
|
|
478
|
+
<nav class="nav-list">
|
|
479
|
+
<a href="/customers"><span class="icon">◉</span>客户管理</a
|
|
480
|
+
><a href="/orders"><span class="icon">▤</span>订单管理</a
|
|
481
|
+
><a href="/settings"><span class="icon">◇</span>通知设置</a
|
|
482
|
+
><a href="/inventory"><span class="icon">▣</span>Inventory</a>
|
|
483
|
+
</nav>
|
|
484
|
+
</div>
|
|
485
|
+
<div class="sidebar-note">
|
|
486
|
+
<strong>Interactive demo</strong>
|
|
487
|
+
<p>用于验证动态 DOM、表单操作和测试用例生成。数据仅保存在当前浏览器。</p>
|
|
488
|
+
</div>
|
|
489
|
+
</aside>
|
|
490
|
+
<div class="workspace">
|
|
491
|
+
<header class="topbar">
|
|
492
|
+
<div class="trail">Workspace / <strong>Demo cases</strong></div>
|
|
493
|
+
<span class="demo-pill">LOCAL DEMO</span>
|
|
494
|
+
</header>
|
|
495
|
+
<div class="content">
|
|
496
|
+
<section class="hero">
|
|
497
|
+
<div class="hero-kicker">BROWSER TESTING PLAYGROUND</div>
|
|
498
|
+
<h2>看得见的测试过程</h2>
|
|
499
|
+
<p>用真实页面交互验证定位、断言和回放,每次刷新都会重新生成控件标识。</p>
|
|
500
|
+
</section>
|
|
501
|
+
<p class="eyebrow">Demo module</p>
|
|
502
|
+
<main class="panel" id="root"></main>
|
|
503
|
+
<div class="footer">LayaPilot · local fixture</div>
|
|
504
|
+
</div>
|
|
505
|
+
</div>
|
|
506
|
+
</div>
|
|
507
|
+
<script>
|
|
508
|
+
const root = document.querySelector('#root'),
|
|
509
|
+
route = location.pathname,
|
|
510
|
+
id = () => Math.random().toString(36).slice(2),
|
|
511
|
+
saveError = __SAVE_ERROR__;
|
|
512
|
+
document.querySelectorAll('.nav-list a').forEach((a) => {
|
|
513
|
+
if (a.pathname === route || (route === '/' && a.pathname === '/customers'))
|
|
514
|
+
a.setAttribute('aria-current', 'page');
|
|
515
|
+
});
|
|
516
|
+
let customers = JSON.parse(
|
|
517
|
+
localStorage.getItem('laya-demo-customers') ||
|
|
518
|
+
'["Laya演示客户","常规客户乙","常规客户丙"]',
|
|
519
|
+
);
|
|
520
|
+
const persist = () =>
|
|
521
|
+
localStorage.setItem('laya-demo-customers', JSON.stringify(customers));
|
|
522
|
+
const table = (headers, rows) =>
|
|
523
|
+
'<table><thead><tr>' +
|
|
524
|
+
headers.map((x) => '<th>' + x + '</th>').join('') +
|
|
525
|
+
'</tr></thead><tbody>' +
|
|
526
|
+
rows
|
|
527
|
+
.map((row) => '<tr>' + row.map((x) => '<td>' + x + '</td>').join('') + '</tr>')
|
|
528
|
+
.join('') +
|
|
529
|
+
'</tbody></table>';
|
|
530
|
+
function customer() {
|
|
531
|
+
const key = id();
|
|
532
|
+
root.innerHTML =
|
|
533
|
+
'<h1>客户管理</h1><label for="' +
|
|
534
|
+
key +
|
|
535
|
+
'">客户名称</label><input id="' +
|
|
536
|
+
key +
|
|
537
|
+
'"><button>搜索</button><button>重置</button><button>新增客户</button><section></section>';
|
|
538
|
+
const render = () => {
|
|
539
|
+
const section = root.querySelector('section');
|
|
540
|
+
section.innerHTML = table(
|
|
541
|
+
['客户名称', '状态', '操作'],
|
|
542
|
+
customers
|
|
543
|
+
.filter((x) => x.includes(root.querySelector('input').value))
|
|
544
|
+
.map((x) => [x, '启用', '']),
|
|
545
|
+
);
|
|
546
|
+
for (const row of section.querySelectorAll('tbody tr')) {
|
|
547
|
+
const name = row.cells[0].innerText,
|
|
548
|
+
cell = row.cells[2];
|
|
549
|
+
for (const action of ['查看', '编辑', '删除']) {
|
|
550
|
+
const button = document.createElement('button');
|
|
551
|
+
button.textContent = action;
|
|
552
|
+
button.onclick = () => act(action, name);
|
|
553
|
+
cell.append(button);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
render();
|
|
558
|
+
function act(action, name) {
|
|
559
|
+
const d = document.createElement('dialog'),
|
|
560
|
+
k = id();
|
|
561
|
+
document.body.append(d);
|
|
562
|
+
d.showModal();
|
|
563
|
+
if (action === '查看') {
|
|
564
|
+
d.innerHTML = '<h2>客户详情</h2><p></p><button>关闭</button>';
|
|
565
|
+
d.querySelector('p').textContent = name;
|
|
566
|
+
d.querySelector('button').onclick = () => d.remove();
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
if (action === '编辑') {
|
|
570
|
+
d.innerHTML =
|
|
571
|
+
'<h2>编辑客户</h2><div class="ant-form-item"><label class="ant-form-item-required" for="' +
|
|
572
|
+
k +
|
|
573
|
+
'">客户名称</label><input aria-required="true" id="' +
|
|
574
|
+
k +
|
|
575
|
+
'" placeholder="请输入客户名称"><span role="alert" class="ant-form-item-explain-error" hidden>请输入唯一的客户名称</span></div><button>保存</button><button>取消</button>';
|
|
576
|
+
d.querySelector('input').value = name;
|
|
577
|
+
d.querySelector('input').oninput = () => {
|
|
578
|
+
d.querySelector('.ant-form-item').classList.remove(
|
|
579
|
+
'ant-form-item-has-error',
|
|
580
|
+
);
|
|
581
|
+
d.querySelector('[role=alert]').hidden = true;
|
|
582
|
+
};
|
|
583
|
+
d.querySelector('button').onclick = () => {
|
|
584
|
+
const value = d.querySelector('input').value.trim();
|
|
585
|
+
if (!value || (customers.includes(value) && value !== name)) {
|
|
586
|
+
d.querySelector('.ant-form-item').classList.add(
|
|
587
|
+
'ant-form-item-has-error',
|
|
588
|
+
);
|
|
589
|
+
d.querySelector('[role=alert]').hidden = false;
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
customers[customers.indexOf(name)] = value;
|
|
593
|
+
persist();
|
|
594
|
+
d.remove();
|
|
595
|
+
render();
|
|
596
|
+
};
|
|
597
|
+
d.querySelectorAll('button')[1].onclick = () => d.remove();
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
d.innerHTML =
|
|
601
|
+
'<h2>确认删除客户?</h2><p></p><button>确定</button><button>取消</button>';
|
|
602
|
+
d.querySelector('p').textContent = name;
|
|
603
|
+
d.querySelector('button').onclick = () => {
|
|
604
|
+
customers = customers.filter((x) => x !== name);
|
|
605
|
+
persist();
|
|
606
|
+
d.remove();
|
|
607
|
+
render();
|
|
608
|
+
};
|
|
609
|
+
d.querySelectorAll('button')[1].onclick = () => d.remove();
|
|
610
|
+
}
|
|
611
|
+
root.querySelectorAll('button')[0].onclick = () => {
|
|
612
|
+
setTimeout(render, 450);
|
|
613
|
+
};
|
|
614
|
+
root.querySelectorAll('button')[1].onclick = () => {
|
|
615
|
+
root.querySelector('input').value = '';
|
|
616
|
+
render();
|
|
617
|
+
};
|
|
618
|
+
root.querySelectorAll('button')[2].onclick = () => {
|
|
619
|
+
const d = document.createElement('dialog'),
|
|
620
|
+
k = id();
|
|
621
|
+
d.innerHTML =
|
|
622
|
+
'<h2>新增客户</h2><div class="ant-form-item"><label class="ant-form-item-required" for="' +
|
|
623
|
+
k +
|
|
624
|
+
'">客户名称</label><input aria-required="true" id="' +
|
|
625
|
+
k +
|
|
626
|
+
'" placeholder="请输入客户名称"><span role="alert" class="ant-form-item-explain-error" hidden>请输入唯一的客户名称</span></div><button>保存</button><button>取消</button>';
|
|
627
|
+
document.body.append(d);
|
|
628
|
+
d.showModal();
|
|
629
|
+
d.querySelector('input').oninput = () => {
|
|
630
|
+
d.querySelector('.ant-form-item').classList.remove(
|
|
631
|
+
'ant-form-item-has-error',
|
|
632
|
+
);
|
|
633
|
+
d.querySelector('[role=alert]').hidden = true;
|
|
634
|
+
};
|
|
635
|
+
d.querySelector('button').onclick = () => {
|
|
636
|
+
const value = d.querySelector('input').value.trim();
|
|
637
|
+
if (!value || customers.includes(value)) {
|
|
638
|
+
d.querySelector('.ant-form-item').classList.add(
|
|
639
|
+
'ant-form-item-has-error',
|
|
640
|
+
);
|
|
641
|
+
d.querySelector('[role=alert]').hidden = false;
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
if (saveError) fetch('/api/save-fail', { method: 'POST' });
|
|
645
|
+
customers.push(value);
|
|
646
|
+
persist();
|
|
647
|
+
d.remove();
|
|
648
|
+
render();
|
|
649
|
+
const p = document.createElement('p');
|
|
650
|
+
p.setAttribute('role', 'status');
|
|
651
|
+
p.textContent = '保存成功';
|
|
652
|
+
root.append(p);
|
|
653
|
+
};
|
|
654
|
+
d.querySelectorAll('button')[1].onclick = () => d.remove();
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
if (route === '/customers' || route === '/') customer();
|
|
658
|
+
if (route === '/orders') {
|
|
659
|
+
const k = id();
|
|
660
|
+
root.innerHTML =
|
|
661
|
+
'<h1>订单管理</h1><label for="' +
|
|
662
|
+
k +
|
|
663
|
+
'">订单状态</label><select id="' +
|
|
664
|
+
k +
|
|
665
|
+
'"><option>全部</option><option>待处理</option><option>已完成</option></select><button>查询</button><section></section>';
|
|
666
|
+
const all = [
|
|
667
|
+
['订单A', '待处理'],
|
|
668
|
+
['订单B', '已完成'],
|
|
669
|
+
];
|
|
670
|
+
const render = () =>
|
|
671
|
+
(root.querySelector('section').innerHTML = table(
|
|
672
|
+
['订单编号', '状态'],
|
|
673
|
+
all.filter(
|
|
674
|
+
(x) =>
|
|
675
|
+
root.querySelector('select').value === '全部' ||
|
|
676
|
+
x[1] === root.querySelector('select').value,
|
|
677
|
+
),
|
|
678
|
+
));
|
|
679
|
+
render();
|
|
680
|
+
root.querySelector('button').onclick = render;
|
|
681
|
+
}
|
|
682
|
+
if (route === '/settings') {
|
|
683
|
+
const k = id();
|
|
684
|
+
root.innerHTML =
|
|
685
|
+
'<h1>通知设置</h1><label><input type="checkbox" id="' +
|
|
686
|
+
k +
|
|
687
|
+
'">接收通知</label><button disabled>保存设置</button><p>设置尚未修改</p>';
|
|
688
|
+
root.querySelector('input').onchange = () => {
|
|
689
|
+
root.querySelector('button').disabled = !root.querySelector('input').checked;
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
if (route === '/inventory') {
|
|
693
|
+
const k = id();
|
|
694
|
+
root.innerHTML =
|
|
695
|
+
'<h1>Inventory</h1><label for="' +
|
|
696
|
+
k +
|
|
697
|
+
'">Product name</label><input id="' +
|
|
698
|
+
k +
|
|
699
|
+
'"><button>Search</button><button>Reset</button><section></section>';
|
|
700
|
+
const products = ['Demo pen', 'Demo book', 'Blue notebook'];
|
|
701
|
+
const render = () =>
|
|
702
|
+
(root.querySelector('section').innerHTML = table(
|
|
703
|
+
['Product', 'Stock'],
|
|
704
|
+
products
|
|
705
|
+
.filter((x) =>
|
|
706
|
+
x
|
|
707
|
+
.toLowerCase()
|
|
708
|
+
.includes(root.querySelector('input').value.toLowerCase()),
|
|
709
|
+
)
|
|
710
|
+
.map((x) => [x, 15]),
|
|
711
|
+
));
|
|
712
|
+
render();
|
|
713
|
+
root.querySelectorAll('button')[0].onclick = render;
|
|
714
|
+
root.querySelectorAll('button')[1].onclick = () => {
|
|
715
|
+
root.querySelector('input').value = '';
|
|
716
|
+
render();
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
if (route === '/ambiguous') {
|
|
720
|
+
root.innerHTML =
|
|
721
|
+
'<h1>同名按钮场景</h1><fieldset><legend>客户查询</legend><button>查询</button></fieldset><fieldset><legend>订单查询</legend><button>查询</button></fieldset>';
|
|
722
|
+
}
|
|
723
|
+
if (route === '/late') {
|
|
724
|
+
root.innerHTML = '<h1>异步渲染</h1><p>正在加载</p>';
|
|
725
|
+
setTimeout(() => {
|
|
726
|
+
root.innerHTML = '<h1>异步渲染</h1><button>显示结果</button>';
|
|
727
|
+
root.querySelector('button').onclick = () =>
|
|
728
|
+
(root.innerHTML = '<p>加载完成</p>');
|
|
729
|
+
}, 1000);
|
|
730
|
+
}
|
|
731
|
+
</script>
|
|
732
|
+
</body>
|
|
733
|
+
</html>
|