nv-log-bw 1.0.0

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/TEST/once.html ADDED
@@ -0,0 +1,762 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>NV Log Viewer 示例</title>
5
+ <script>var nvlogbw=(()=>{var w=(c,t)=>()=>(t||c((t={exports:{}}).exports,t),t.exports);var L=w((S,y)=>{var b=class extends HTMLElement{static get observedAttributes(){return["max-logs","theme","show-time","time-format","auto-scroll","show-stats","hide-button","auto-destroy","draggable"]}constructor(){super(),this._state={logs:[],showLogs:!0,filters:{info:!0,success:!0,warning:!0,error:!0,ignore:!0},isOpen:!1,isMinimized:!1,originalPosition:{x:0,y:0},originalSize:{width:"800px",height:"600px"},dragInfo:{isDragging:!1,startX:0,startY:0,initialLeft:0,initialTop:0},isDraggingEnabled:!0},this._eventListeners=new Map,this._createFileInput(),this.attachShadow({mode:"open"}),this._config=this._getConfig(),this._render(),this._setupEventListeners()}attributeChangedCallback(t,e,o){if(e!==o)switch(t){case"max-logs":this._config.maxLogs=Math.max(1,parseInt(o,10)||100),this._trimLogs(),this._updateLogsDisplay(),this._updateStats();break;case"theme":this._config.theme=o==="light"?"light":"dark",this._updateTheme();break;case"show-time":this._config.showTime=o!=="false",this._updateLogsDisplay();break;case"time-format":this._config.timeFormat=o||"HH:mm:ss",this._updateLogsDisplay();break;case"auto-scroll":this._config.autoScroll=o!=="false";break;case"show-stats":this._config.showStats=o!=="false",this._updateStatsVisibility();break;case"hide-button":this._config.hideButton=o!=="false",this._updateButtonsVisibility();break;case"auto-destroy":this._config.autoDestroy=o!=="false",this._updateCloseButton();break;case"draggable":this._config.draggable=o!=="false",this._updateDraggableState();break}}connectedCallback(){this._config=this._getConfig(),this._render(),this._setupEventListeners(),this._config.autoDestroy&&window.addEventListener("beforeunload",()=>this._cleanup())}disconnectedCallback(){this._cleanup()}_createFileInput(){this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.accept=".json,.txt,.log",this._fileInput.style.position="fixed",this._fileInput.style.top="-1000px",this._fileInput.style.left="-1000px",this._fileInput.style.opacity="0",this._fileInput.style.pointerEvents="none",this._fileInput.style.zIndex="-1000",this._fileInput.addEventListener("change",t=>this._handleFileImport(t)),document.body.appendChild(this._fileInput)}_getConfig(){return{maxLogs:Math.max(1,parseInt(this.getAttribute("max-logs")||100,10)),theme:this.getAttribute("theme")==="light"?"light":"dark",showTime:this.getAttribute("show-time")!=="false",timeFormat:this.getAttribute("time-format")||"HH:mm:ss",autoScroll:this.getAttribute("auto-scroll")!=="false",showStats:this.getAttribute("show-stats")!=="false",hideButton:this.getAttribute("hide-button")==="true",autoDestroy:this.getAttribute("auto-destroy")==="true",draggable:this.getAttribute("draggable")!=="false"}}_trimLogs(){this._state.logs.length>this._config.maxLogs&&(this._state.logs=this._state.logs.slice(-this._config.maxLogs))}_updateLogsDisplay(){let t=this.shadowRoot.querySelector("#logContent");if(!t)return;let e=this._state.logs.filter(o=>this._state.filters[o.type]);if(e.length===0){t.innerHTML='<div class="empty-state">\u{1F4DD} \u6CA1\u6709\u65E5\u5FD7\u8BB0\u5F55</div>';return}t.innerHTML="",e.forEach(o=>{let s=document.createElement("div");s.className=`log-entry ${o.type}`;let r="";if(this._config.showTime){let i=new Date(o.time);if(this._config.timeFormat==="relative")r=this._getRelativeTime(o.time);else if(this._config.timeFormat==="HH:mm:ss")r=i.toLocaleTimeString("zh-CN",{hour12:!1});else if(this._config.timeFormat==="HH:mm:ss.ms"){let n=i.toLocaleTimeString("zh-CN",{hour12:!1}),l=String(i.getMilliseconds()).padStart(3,"0");r=`${n}.${l}`}else r=i.toLocaleString("zh-CN")}s.innerHTML=`
6
+ ${this._config.showTime?`<span class="log-time">${r}</span>`:""}
7
+ <span class="log-message">${this._escapeHtml(String(o.message))}</span>
8
+ `,t.appendChild(s)}),this._config.autoScroll&&(t.scrollTop=t.scrollHeight)}_escapeHtml(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}_getRelativeTime(t){let o=Date.now()-t;return o<6e4?`${Math.floor(o/1e3)}\u79D2\u524D`:o<36e5?`${Math.floor(o/6e4)}\u5206\u949F\u524D`:o<864e5?`${Math.floor(o/36e5)}\u5C0F\u65F6\u524D`:`${Math.floor(o/864e5)}\u5929\u524D`}_updateDraggableState(){let t=this.shadowRoot.querySelector("#dragHandle"),e=this.shadowRoot.querySelector("#logHeader"),o=this.shadowRoot.querySelector("#minimizedTitle"),s=this.shadowRoot.querySelector("#popupContainer");t&&(this._config.draggable?(t.style.display="block",t.style.cursor="move",e&&(e.style.cursor="move"),o&&(o.style.cursor="move"),s&&(s.style.cursor="default")):(t.style.display="none",t.style.cursor="default",e&&(e.style.cursor="default"),o&&(o.style.cursor="default"),s&&(s.style.cursor="default")))}_render(){let t=document.createElement("style");t.textContent=this._getStyles(),this.shadowRoot.innerHTML="",this.shadowRoot.appendChild(t),this.shadowRoot.innerHTML+=`
9
+ <!-- \u6D6E\u52A8\u6309\u94AE -->
10
+ <div id="floatingContainer" class="floating-container" style="display: ${this._config.hideButton?"none":"block"}">
11
+ ${this._state.isOpen?"":`
12
+ <div class="floating-button" id="floatingButton" title="\u6253\u5F00\u65E5\u5FD7">
13
+ \u{1F4C4}
14
+ </div>
15
+ `}
16
+ </div>
17
+
18
+ <!-- \u5F39\u51FA\u7A97\u53E3 -->
19
+ <div class="popup-container" id="popupContainer" style="display: none;">
20
+ <!-- \u5B8C\u6574\u7684\u65E5\u5FD7\u5BB9\u5668 -->
21
+ <div class="log-container ${this._state.showLogs?"expanded":"collapsed"} ${this._config.theme}">
22
+ <div class="log-header" id="logHeader">
23
+ <div class="log-title">
24
+ ${this._config.draggable?'<span class="drag-handle" id="dragHandle" title="\u62D6\u52A8">\u2194</span>':""}
25
+ <span class="log-icon">\u{1F4C4}</span>
26
+ <h3>\u65E5\u5FD7\u67E5\u770B\u5668</h3>
27
+ <span class="log-count" id="logCount">0</span>
28
+ </div>
29
+ <div class="log-actions">
30
+ <button class="toggle-btn" title="${this._state.showLogs?"\u9690\u85CF\u65E5\u5FD7":"\u663E\u793A\u65E5\u5FD7"}">
31
+ ${this._state.showLogs?"\u{1F441}\uFE0F":"\u{1F441}\uFE0F\u200D\u{1F5E8}\uFE0F"}
32
+ </button>
33
+ <button class="clear-btn" title="\u6E05\u7A7A\u65E5\u5FD7">\u{1F5D1}\uFE0F</button>
34
+ <button class="export-btn" title="\u5BFC\u51FA\u65E5\u5FD7">\u{1F4E5}</button>
35
+ <button class="import-btn" title="\u5BFC\u5165\u65E5\u5FD7">\u{1F4E4}</button>
36
+ <button class="copy-btn" title="\u590D\u5236\u65E5\u5FD7">\u{1F4CB}</button>
37
+ <button class="popup-btn" id="minimizeBtn" title="\u6700\u5C0F\u5316">_</button>
38
+ <button class="popup-btn" id="closeBtn" title="${this._config.autoDestroy?"\u5173\u95ED\u5E76\u9500\u6BC1":"\u9690\u85CF"}">\u2715</button>
39
+ </div>
40
+ </div>
41
+
42
+ <div class="log-content" id="logContent">
43
+ <div class="empty-state">\u{1F4DD} \u6CA1\u6709\u65E5\u5FD7\u8BB0\u5F55</div>
44
+ </div>
45
+
46
+ <div class="log-footer">
47
+ <div class="log-filter">
48
+ <label class="filter-label">
49
+ <input type="checkbox" class="filter-checkbox" data-type="info" checked>
50
+ <span class="filter-badge info">\u4FE1\u606F</span>
51
+ </label>
52
+ <label class="filter-label">
53
+ <input type="checkbox" class="filter-checkbox" data-type="success" checked>
54
+ <span class="filter-badge success">\u6210\u529F</span>
55
+ </label>
56
+ <label class="filter-label">
57
+ <input type="checkbox" class="filter-checkbox" data-type="warning" checked>
58
+ <span class="filter-badge warning">\u8B66\u544A</span>
59
+ </label>
60
+ <label class="filter-label">
61
+ <input type="checkbox" class="filter-checkbox" data-type="error" checked>
62
+ <span class="filter-badge error">\u9519\u8BEF</span>
63
+ </label>
64
+ <label class="filter-label">
65
+ <input type="checkbox" class="filter-checkbox" data-type="ignore" checked>
66
+ <span class="filter-badge ignore">\u5FFD\u7565</span>
67
+ </label>
68
+ </div>
69
+ <div class="log-stats">
70
+ <div class="stat-row">
71
+ <span>\u603B\u8BA1: <span id="totalCount">0</span></span>
72
+ <span>\u4FE1\u606F: <span id="infoCount">0</span></span>
73
+ <span>\u6210\u529F: <span id="successCount">0</span></span>
74
+ <span>\u8B66\u544A: <span id="warningCount">0</span></span>
75
+ <span>\u9519\u8BEF: <span id="errorCount">0</span></span>
76
+ <span>\u5FFD\u7565: <span id="ignoreCount">0</span></span>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
81
+
82
+ <!-- \u6700\u5C0F\u5316\u65F6\u7684\u6807\u9898\u680F -->
83
+ <div class="minimized-title" id="minimizedTitle" style="display: none;">
84
+ <div class="minimized-title-left">
85
+ <span>\u{1F4C4} \u65E5\u5FD7\u67E5\u770B\u5668</span>
86
+ <span class="minimized-log-count" id="minimizedLogCount">0</span>
87
+ <div class="minimized-actions">
88
+ <button class="minimized-popup-btn" id="maximizeBtn" title="\u6700\u5927\u5316">\u25A1</button>
89
+ <button class="minimized-popup-btn" id="closeMinimizedBtn" title="${this._config.autoDestroy?"\u5173\u95ED\u5E76\u9500\u6BC1":"\u9690\u85CF"}">\u2715</button>
90
+ </div>
91
+ </div>
92
+ </div>
93
+
94
+ <div class="resize-handle" id="resizeHandle"></div>
95
+ </div>
96
+ `,this._updateTheme(),this._updateDraggableState()}_getStyles(){return`
97
+ :host {
98
+ display: block;
99
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
100
+ font-size: 12px;
101
+ width: 100%;
102
+ }
103
+
104
+ /* \u6D6E\u52A8\u6309\u94AE\u6837\u5F0F */
105
+ .floating-container {
106
+ position: fixed;
107
+ bottom: 20px;
108
+ right: 20px;
109
+ z-index: 9998;
110
+ }
111
+
112
+ .floating-button {
113
+ width: 50px;
114
+ height: 50px;
115
+ border-radius: 50%;
116
+ background: #1890ff;
117
+ color: white;
118
+ display: flex;
119
+ align-items: center;
120
+ justify-content: center;
121
+ font-size: 20px;
122
+ cursor: pointer;
123
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
124
+ transition: all 0.3s ease;
125
+ user-select: none;
126
+ }
127
+
128
+ .floating-button:hover {
129
+ background: #40a9ff;
130
+ transform: scale(1.1);
131
+ }
132
+
133
+ .floating-button:active {
134
+ transform: scale(0.95);
135
+ }
136
+
137
+ /* \u5F39\u51FA\u7A97\u53E3\u6837\u5F0F */
138
+ .popup-container {
139
+ position: fixed;
140
+ z-index: 9999;
141
+ width: 800px;
142
+ height: 600px;
143
+ display: none;
144
+ border-radius: 8px;
145
+ overflow: hidden;
146
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
147
+ resize: both;
148
+ min-width: 400px;
149
+ min-height: 300px;
150
+ }
151
+
152
+ .popup-container.open {
153
+ display: block;
154
+ }
155
+
156
+ .popup-container.minimized {
157
+ width: 320px !important;
158
+ height: 40px !important;
159
+ min-height: 40px !important;
160
+ min-width: 320px !important;
161
+ resize: none;
162
+ border-radius: 6px;
163
+ display: block;
164
+ }
165
+
166
+ .popup-container.minimized .log-container {
167
+ display: none !important;
168
+ }
169
+
170
+ .popup-container.minimized .resize-handle {
171
+ display: none;
172
+ }
173
+
174
+ /* \u6700\u5C0F\u5316\u65F6\u7684\u6807\u9898\u680F\u6837\u5F0F */
175
+ .minimized-title {
176
+ position: absolute;
177
+ top: 0;
178
+ left: 0;
179
+ right: 0;
180
+ bottom: 0;
181
+ display: none;
182
+ align-items: center;
183
+ padding: 0 12px;
184
+ background: var(--header-bg);
185
+ color: var(--text-color);
186
+ font-size: 12px;
187
+ font-weight: 600;
188
+ cursor: move;
189
+ border-radius: 6px;
190
+ overflow: hidden;
191
+ z-index: 1000;
192
+ }
193
+
194
+ .popup-container.minimized .minimized-title {
195
+ display: flex;
196
+ }
197
+
198
+ .minimized-title-left {
199
+ display: flex;
200
+ align-items: center;
201
+ gap: 8px;
202
+ flex: 1;
203
+ }
204
+
205
+ .minimized-log-count {
206
+ background: var(--button-bg);
207
+ color: var(--button-text);
208
+ padding: 2px 8px;
209
+ border-radius: 10px;
210
+ font-size: 11px;
211
+ font-weight: 500;
212
+ min-width: 20px;
213
+ text-align: center;
214
+ }
215
+
216
+ .minimized-actions {
217
+ display: flex;
218
+ align-items: center;
219
+ gap: 4px;
220
+ margin-left: auto;
221
+ }
222
+
223
+ .minimized-popup-btn {
224
+ background: var(--button-bg);
225
+ border: none;
226
+ border-radius: 4px;
227
+ color: var(--button-text);
228
+ cursor: pointer;
229
+ font-size: 12px;
230
+ width: 24px;
231
+ height: 24px;
232
+ display: flex;
233
+ align-items: center;
234
+ justify-content: center;
235
+ transition: all 0.2s;
236
+ opacity: 0.8;
237
+ font-family: monospace;
238
+ }
239
+
240
+ .minimized-popup-btn:hover {
241
+ background: var(--button-hover);
242
+ transform: translateY(-1px);
243
+ opacity: 1;
244
+ }
245
+
246
+ .resize-handle {
247
+ position: absolute;
248
+ width: 20px;
249
+ height: 20px;
250
+ right: 0;
251
+ bottom: 0;
252
+ cursor: se-resize;
253
+ z-index: 10000;
254
+ }
255
+
256
+ .popup-container.minimized .resize-handle {
257
+ display: none;
258
+ }
259
+
260
+ /* \u6697\u8272\u4E3B\u9898 */
261
+ .log-container.dark {
262
+ --bg-color: #1e1e1e;
263
+ --header-bg: #252526;
264
+ --border-color: #3e3e42;
265
+ --text-color: #d4d4d4;
266
+ --text-muted: #8c8c8c;
267
+ --log-entry-bg: #2d2d30;
268
+ --hover-bg: #323234;
269
+ --info-color: #3794ff;
270
+ --info-bg: rgba(55, 148, 255, 0.1);
271
+ --success-color: #4ec9b0;
272
+ --success-bg: rgba(78, 201, 176, 0.1);
273
+ --warning-color: #dcdcaa;
274
+ --warning-bg: rgba(220, 220, 170, 0.1);
275
+ --error-color: #f48771;
276
+ --error-bg: rgba(244, 135, 113, 0.1);
277
+ --ignore-color: #8a8a8a;
278
+ --ignore-bg: rgba(138, 138, 138, 0.1);
279
+ --button-bg: #3e3e42;
280
+ --button-hover: #4a4a4e;
281
+ --button-text: #d4d4d4;
282
+ --filter-badge-bg: #3e3e42;
283
+ }
284
+
285
+ /* \u4EAE\u8272\u4E3B\u9898 */
286
+ .log-container.light {
287
+ --bg-color: #ffffff;
288
+ --header-bg: #f5f5f5;
289
+ --border-color: #e0e0e0;
290
+ --text-color: #333333;
291
+ --text-muted: #666666;
292
+ --log-entry-bg: #f9f9f9;
293
+ --hover-bg: #f0f0f0;
294
+ --info-color: #1890ff;
295
+ --info-bg: rgba(24, 144, 255, 0.08);
296
+ --success-color: #52c41a;
297
+ --success-bg: rgba(82, 196, 26, 0.08);
298
+ --warning-color: #faad14;
299
+ --warning-bg: rgba(250, 173, 20, 0.08);
300
+ --error-color: #ff4d4f;
301
+ --error-bg: rgba(255, 77, 79, 0.08);
302
+ --ignore-color: #999999;
303
+ --ignore-bg: rgba(153, 153, 153, 0.08);
304
+ --button-bg: #e8e8e8;
305
+ --button-hover: #d9d9d9;
306
+ --button-text: #595959;
307
+ --filter-badge-bg: #e8e8e8;
308
+ }
309
+
310
+ .log-container {
311
+ border: 1px solid var(--border-color);
312
+ border-radius: 8px;
313
+ overflow: hidden;
314
+ transition: all 0.3s ease;
315
+ background: var(--bg-color);
316
+ color: var(--text-color);
317
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
318
+ width: 100%;
319
+ height: 100%;
320
+ display: flex;
321
+ flex-direction: column;
322
+ }
323
+
324
+ .log-container.collapsed {
325
+ height: auto;
326
+ min-height: 0;
327
+ flex: 0 0 auto;
328
+ }
329
+
330
+ .log-container.collapsed .log-header {
331
+ border-bottom: none;
332
+ }
333
+
334
+ .log-container.collapsed .log-content,
335
+ .log-container.collapsed .log-footer {
336
+ display: none;
337
+ }
338
+
339
+ .log-container.expanded {
340
+ flex: 1;
341
+ min-height: 0;
342
+ }
343
+
344
+ .log-container.expanded .log-content,
345
+ .log-container.expanded .log-footer {
346
+ display: block;
347
+ }
348
+
349
+ .log-header {
350
+ display: flex;
351
+ justify-content: space-between;
352
+ align-items: center;
353
+ padding: 10px 16px;
354
+ background: var(--header-bg);
355
+ border-bottom: 1px solid var(--border-color);
356
+ user-select: none;
357
+ transition: background-color 0.2s;
358
+ flex-shrink: 0;
359
+ }
360
+
361
+ .log-header:hover {
362
+ background: var(--hover-bg);
363
+ }
364
+
365
+ .log-title {
366
+ display: flex;
367
+ align-items: center;
368
+ gap: 10px;
369
+ }
370
+
371
+ .drag-handle {
372
+ cursor: move;
373
+ opacity: 0.6;
374
+ font-size: 16px;
375
+ padding: 4px;
376
+ border-radius: 4px;
377
+ transition: all 0.2s;
378
+ }
379
+
380
+ .drag-handle:hover {
381
+ opacity: 1;
382
+ background: var(--button-bg);
383
+ }
384
+
385
+ .log-icon {
386
+ font-size: 16px;
387
+ opacity: 0.8;
388
+ }
389
+
390
+ .log-title h3 {
391
+ margin: 0;
392
+ font-size: 14px;
393
+ font-weight: 600;
394
+ }
395
+
396
+ .log-count {
397
+ background: var(--button-bg);
398
+ color: var(--button-text);
399
+ padding: 2px 8px;
400
+ border-radius: 10px;
401
+ font-size: 11px;
402
+ font-weight: 500;
403
+ min-width: 20px;
404
+ text-align: center;
405
+ }
406
+
407
+ .log-actions {
408
+ display: flex;
409
+ gap: 6px;
410
+ }
411
+
412
+ /* \u6309\u94AE\u6837\u5F0F */
413
+ .popup-btn,
414
+ .toggle-btn,
415
+ .clear-btn,
416
+ .export-btn,
417
+ .import-btn,
418
+ .copy-btn {
419
+ background: var(--button-bg);
420
+ border: none;
421
+ border-radius: 4px;
422
+ color: var(--button-text);
423
+ cursor: pointer;
424
+ font-size: 13px;
425
+ width: 28px;
426
+ height: 28px;
427
+ display: flex;
428
+ align-items: center;
429
+ justify-content: center;
430
+ transition: all 0.2s;
431
+ opacity: 0.8;
432
+ }
433
+
434
+ .popup-btn:hover,
435
+ .toggle-btn:hover,
436
+ .clear-btn:hover,
437
+ .export-btn:hover,
438
+ .import-btn:hover,
439
+ .copy-btn:hover {
440
+ background: var(--button-hover);
441
+ transform: translateY(-1px);
442
+ opacity: 1;
443
+ }
444
+
445
+ /* \u65E5\u5FD7\u5185\u5BB9\u6837\u5F0F */
446
+ .log-content {
447
+ overflow-y: auto;
448
+ flex: 1;
449
+ padding: 8px;
450
+ font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, 'Courier New', monospace;
451
+ line-height: 1.5;
452
+ word-break: break-word;
453
+ white-space: pre-wrap;
454
+ scroll-behavior: smooth;
455
+ min-height: 0;
456
+ }
457
+
458
+ .log-entry {
459
+ margin-bottom: 4px;
460
+ padding: 8px 10px;
461
+ border-radius: 4px;
462
+ border-left: 3px solid transparent;
463
+ background: var(--log-entry-bg);
464
+ transition: all 0.2s ease;
465
+ animation: fadeIn 0.3s ease;
466
+ position: relative;
467
+ }
468
+
469
+ .log-entry:hover {
470
+ background: var(--hover-bg);
471
+ transform: translateX(2px);
472
+ }
473
+
474
+ .log-entry.info {
475
+ border-left-color: var(--info-color);
476
+ background: var(--info-bg);
477
+ }
478
+
479
+ .log-entry.info:hover {
480
+ background: var(--info-bg);
481
+ filter: brightness(1.1);
482
+ }
483
+
484
+ .log-entry.success {
485
+ border-left-color: var(--success-color);
486
+ background: var(--success-bg);
487
+ }
488
+
489
+ .log-entry.success:hover {
490
+ background: var(--success-bg);
491
+ filter: brightness(1.1);
492
+ }
493
+
494
+ .log-entry.warning {
495
+ border-left-color: var(--warning-color);
496
+ background: var(--warning-bg);
497
+ }
498
+
499
+ .log-entry.warning:hover {
500
+ background: var(--warning-bg);
501
+ filter: brightness(1.1);
502
+ }
503
+
504
+ .log-entry.error {
505
+ border-left-color: var(--error-color);
506
+ background: var(--error-bg);
507
+ }
508
+
509
+ .log-entry.error:hover {
510
+ background: var(--error-bg);
511
+ filter: brightness(1.1);
512
+ }
513
+
514
+ .log-entry.ignore {
515
+ border-left-color: var(--ignore-color);
516
+ background: var(--ignore-bg);
517
+ opacity: 0.7;
518
+ }
519
+
520
+ .log-entry.ignore:hover {
521
+ background: var(--ignore-bg);
522
+ filter: brightness(1.1);
523
+ opacity: 0.9;
524
+ }
525
+
526
+ .log-time {
527
+ color: var(--text-muted);
528
+ font-size: 10px;
529
+ margin-right: 10px;
530
+ user-select: none;
531
+ font-variant-numeric: tabular-nums;
532
+ }
533
+
534
+ .log-message {
535
+ font-size: 12px;
536
+ word-break: break-word;
537
+ }
538
+
539
+ .log-footer {
540
+ padding: 10px 16px;
541
+ border-top: 1px solid var(--border-color);
542
+ background: var(--header-bg);
543
+ font-size: 11px;
544
+ flex-shrink: 0;
545
+ }
546
+
547
+ .log-filter {
548
+ display: flex;
549
+ flex-wrap: wrap;
550
+ gap: 12px;
551
+ margin-bottom: 8px;
552
+ }
553
+
554
+ .filter-label {
555
+ display: flex;
556
+ align-items: center;
557
+ gap: 5px;
558
+ cursor: pointer;
559
+ color: var(--text-muted);
560
+ transition: opacity 0.2s;
561
+ }
562
+
563
+ .filter-label:hover {
564
+ opacity: 0.8;
565
+ }
566
+
567
+ .filter-checkbox {
568
+ margin: 0;
569
+ cursor: pointer;
570
+ }
571
+
572
+ .filter-badge {
573
+ padding: 2px 8px;
574
+ border-radius: 3px;
575
+ font-size: 10px;
576
+ font-weight: 500;
577
+ background: var(--filter-badge-bg);
578
+ }
579
+
580
+ .filter-badge.info {
581
+ background: var(--info-bg);
582
+ color: var(--info-color);
583
+ }
584
+
585
+ .filter-badge.success {
586
+ background: var(--success-bg);
587
+ color: var(--success-color);
588
+ }
589
+
590
+ .filter-badge.warning {
591
+ background: var(--warning-bg);
592
+ color: var(--warning-color);
593
+ }
594
+
595
+ .filter-badge.error {
596
+ background: var(--error-bg);
597
+ color: var(--error-color);
598
+ }
599
+
600
+ .filter-badge.ignore {
601
+ background: var(--ignore-bg);
602
+ color: var(--ignore-color);
603
+ }
604
+
605
+ .log-stats {
606
+ color: var(--text-muted);
607
+ }
608
+
609
+ .stat-row {
610
+ display: flex;
611
+ flex-wrap: wrap;
612
+ gap: 12px;
613
+ justify-content: space-between;
614
+ }
615
+
616
+ .stat-row span {
617
+ display: inline-flex;
618
+ align-items: center;
619
+ gap: 4px;
620
+ }
621
+
622
+ .stat-row #totalCount {
623
+ font-weight: 600;
624
+ color: var(--text-color);
625
+ }
626
+
627
+ .stat-row #infoCount {
628
+ color: var(--info-color);
629
+ font-weight: 600;
630
+ }
631
+
632
+ .stat-row #successCount {
633
+ color: var(--success-color);
634
+ font-weight: 600;
635
+ }
636
+
637
+ .stat-row #warningCount {
638
+ color: var(--warning-color);
639
+ font-weight: 600;
640
+ }
641
+
642
+ .stat-row #errorCount {
643
+ color: var(--error-color);
644
+ font-weight: 600;
645
+ }
646
+
647
+ .stat-row #ignoreCount {
648
+ color: var(--ignore-color);
649
+ font-weight: 600;
650
+ }
651
+
652
+ .empty-state {
653
+ text-align: center;
654
+ color: var(--text-muted);
655
+ padding: 40px 20px;
656
+ font-style: italic;
657
+ user-select: none;
658
+ }
659
+
660
+ .import-notice {
661
+ background: var(--info-bg);
662
+ border-left: 3px solid var(--info-color);
663
+ color: var(--text-color);
664
+ padding: 10px;
665
+ margin: 8px;
666
+ border-radius: 4px;
667
+ font-size: 11px;
668
+ animation: fadeIn 0.3s ease;
669
+ }
670
+
671
+ .import-notice.success {
672
+ background: var(--success-bg);
673
+ border-left-color: var(--success-color);
674
+ }
675
+
676
+ .import-notice.error {
677
+ background: var(--error-bg);
678
+ border-left-color: var(--error-color);
679
+ }
680
+
681
+ @keyframes fadeIn {
682
+ from {
683
+ opacity: 0;
684
+ transform: translateY(-5px);
685
+ }
686
+ to {
687
+ opacity: 1;
688
+ transform: translateY(0);
689
+ }
690
+ }
691
+
692
+ @keyframes pulse {
693
+ 0%, 100% {
694
+ opacity: 1;
695
+ }
696
+ 50% {
697
+ opacity: 0.5;
698
+ }
699
+ }
700
+
701
+ /* \u6EDA\u52A8\u6761\u6837\u5F0F */
702
+ .log-content::-webkit-scrollbar {
703
+ width: 6px;
704
+ }
705
+
706
+ .log-content::-webkit-scrollbar-track {
707
+ background: var(--bg-color);
708
+ }
709
+
710
+ .log-content::-webkit-scrollbar-thumb {
711
+ background: var(--border-color);
712
+ border-radius: 3px;
713
+ }
714
+
715
+ .log-content::-webkit-scrollbar-thumb:hover {
716
+ background: var(--text-muted);
717
+ }
718
+ `}_setupEventListeners(){this._eventListeners.forEach(({type:e,handler:o,target:s})=>{s&&s.removeEventListener&&s.removeEventListener(e,o)}),this._eventListeners.clear();let t=e=>{e.target.classList.contains("toggle-btn")?(e.stopPropagation(),e.preventDefault(),this.toggleVisibility()):e.target.classList.contains("clear-btn")?(e.stopPropagation(),e.preventDefault(),this.clearLogs()):e.target.classList.contains("export-btn")?(e.stopPropagation(),e.preventDefault(),this.exportLogs()):e.target.classList.contains("import-btn")?(e.stopPropagation(),e.preventDefault(),this._triggerImport()):e.target.classList.contains("copy-btn")?(e.stopPropagation(),e.preventDefault(),this.copyLogs()):e.target.classList.contains("filter-checkbox")?(e.stopPropagation(),e.preventDefault(),this._applyFilters()):e.target.id==="minimizeBtn"?(e.stopPropagation(),e.preventDefault(),this._minimize()):e.target.id==="closeBtn"?(e.stopPropagation(),e.preventDefault(),this.clos()):e.target.id==="closeMinimizedBtn"?(e.stopPropagation(),e.preventDefault(),this.clos()):e.target.id==="maximizeBtn"?(e.stopPropagation(),e.preventDefault(),this._restore()):e.target.id==="floatingButton"&&(e.stopPropagation(),e.preventDefault(),this.open())};this.shadowRoot.addEventListener("click",t),this._eventListeners.set("click",{type:"click",handler:t,target:this.shadowRoot}),this._setupFloatingButtonDrag(),this._setupDrag(),this._setupResize()}_setupFloatingButtonDrag(){let t=this.shadowRoot.querySelector("#floatingButton"),e=this.shadowRoot.querySelector("#floatingContainer");if(!t||!e)return;let o=!1,s,r,i,n;t.addEventListener("mousedown",l=>{l.preventDefault(),l.stopPropagation();let a=e.getBoundingClientRect();s=l.clientX,r=l.clientY,i=a.left,n=a.top,o=!0;let g=h=>{if(!o)return;let p=h.clientX-s,u=h.clientY-r,f=i+p,m=n+u,x=window.innerWidth-a.width,v=window.innerHeight-a.height;f=Math.max(0,Math.min(f,x)),m=Math.max(0,Math.min(m,v)),e.style.left=`${f}px`,e.style.top=`${m}px`,e.style.right="auto",e.style.bottom="auto"},d=()=>{o=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",d)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",d)})}_setupDrag(){if(!this._config.draggable)return;let t=this.shadowRoot.querySelector("#popupContainer"),e=this.shadowRoot.querySelector("#dragHandle"),o=this.shadowRoot.querySelector("#logHeader"),s=this.shadowRoot.querySelector("#minimizedTitle");if(!t)return;let r=i=>{i.preventDefault(),i.stopPropagation();let n=t.getBoundingClientRect();this._state.dragInfo.isDragging=!0,this._state.dragInfo.startX=i.clientX,this._state.dragInfo.startY=i.clientY,this._state.dragInfo.initialLeft=n.left,this._state.dragInfo.initialTop=n.top;let l=g=>{if(!this._state.dragInfo.isDragging)return;let d=g.clientX-this._state.dragInfo.startX,h=g.clientY-this._state.dragInfo.startY,p=this._state.dragInfo.initialLeft+d,u=this._state.dragInfo.initialTop+h,f=window.innerWidth-n.width,m=window.innerHeight-n.height;p=Math.max(0,Math.min(p,f)),u=Math.max(0,Math.min(u,m)),t.style.left=`${p}px`,t.style.top=`${u}px`,t.style.transform="none"},a=()=>{this._state.dragInfo.isDragging=!1,document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",a)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",a)};e&&e.addEventListener("mousedown",r),o&&o.addEventListener("mousedown",i=>{this._config.draggable&&i.target!==e&&!i.target.classList.contains("toggle-btn")&&!i.target.classList.contains("clear-btn")&&!i.target.classList.contains("export-btn")&&!i.target.classList.contains("import-btn")&&!i.target.classList.contains("copy-btn")&&!i.target.classList.contains("popup-btn")&&r(i)}),s&&s.addEventListener("mousedown",i=>{this._config.draggable&&(i.target.classList.contains("minimized-popup-btn")||r(i))})}_setupResize(){let t=this.shadowRoot.querySelector("#popupContainer"),e=this.shadowRoot.querySelector("#resizeHandle");if(!t||!e)return;let o=!1,s,r,i,n,l=d=>{if(t.classList.contains("minimized"))return;o=!0;let h=t.getBoundingClientRect();s=h.width,r=h.height,i=d.clientX,n=d.clientY,d.preventDefault()},a=d=>{if(!o)return;let h=s+(d.clientX-i),p=r+(d.clientY-n);t.style.width=`${Math.max(400,h)}px`,t.style.height=`${Math.max(300,p)}px`,d.preventDefault()},g=()=>{o=!1};e.addEventListener("mousedown",l),document.addEventListener("mousemove",a),document.addEventListener("mouseup",g)}_cleanup(){this._eventListeners.forEach(({type:t,handler:e,target:o})=>{o&&o.removeEventListener&&o.removeEventListener(t,e)}),this._eventListeners.clear(),this._fileInput&&this._fileInput.parentNode&&this._fileInput.parentNode.removeChild(this._fileInput),this._config.autoDestroy&&this.remove()}_updateTheme(){let t=this.shadowRoot.querySelector(".log-container");t&&(t.className=`log-container ${this._state.showLogs?"expanded":"collapsed"} ${this._config.theme}`)}_updateStatsVisibility(){let t=this.shadowRoot.querySelector(".log-footer");t&&(t.style.display=this._config.showStats?"block":"none")}_updateButtonsVisibility(){let t=this.shadowRoot.querySelector("#floatingContainer");t&&(this._config.hideButton?t.style.display="none":t.style.display=this._state.isOpen?"none":"block")}_updateCloseButton(){let t=this.shadowRoot.querySelector("#closeBtn"),e=this.shadowRoot.querySelector("#closeMinimizedBtn"),o=this._config.autoDestroy?"\u5173\u95ED\u5E76\u9500\u6BC1":"\u9690\u85CF";t&&(t.title=o),e&&(e.title=o)}_updateStats(){let t={total:this._state.logs.length,info:0,success:0,warning:0,error:0,ignore:0};this._state.logs.forEach(g=>{t[g.type]!==void 0&&t[g.type]++});let e=this.shadowRoot.querySelector("#logCount"),o=this.shadowRoot.querySelector("#minimizedLogCount"),s=this.shadowRoot.querySelector("#totalCount"),r=this.shadowRoot.querySelector("#infoCount"),i=this.shadowRoot.querySelector("#successCount"),n=this.shadowRoot.querySelector("#warningCount"),l=this.shadowRoot.querySelector("#errorCount"),a=this.shadowRoot.querySelector("#ignoreCount");e&&(e.textContent=t.total),o&&(o.textContent=t.total),s&&(s.textContent=t.total),r&&(r.textContent=t.info),i&&(i.textContent=t.success),n&&(n.textContent=t.warning),l&&(l.textContent=t.error),a&&(a.textContent=t.ignore)}_applyFilters(){this.shadowRoot.querySelectorAll(".filter-checkbox").forEach(e=>{let o=e.dataset.type;this._state.filters[o]=e.checked}),this._updateLogsDisplay()}_triggerImport(){this._fileInput.click()}async _handleFileImport(t){let e=t.target.files[0];if(e)try{this.addLog("\u5F00\u59CB\u5BFC\u5165\u65E5\u5FD7\u6587\u4EF6...","info");let o=await e.text(),s=[],r="unknown";try{let n=JSON.parse(o);Array.isArray(n)?(s=n,r="json"):typeof n=="object"&&n.logs&&Array.isArray(n.logs)&&(s=n.logs,r="json-with-metadata")}catch{let l=o.split(`
719
+ `).filter(a=>a.trim());s=this._parseTextLogs(l),r="text"}if(s.length===0)throw new Error("\u6587\u4EF6\u4E2D\u6CA1\u6709\u627E\u5230\u6709\u6548\u7684\u65E5\u5FD7\u6570\u636E");let i=s.map(n=>this._normalizeLogEntry(n)).filter(n=>n!==null);if(i.length===0)throw new Error("\u6587\u4EF6\u4E2D\u6CA1\u6709\u6709\u6548\u7684\u65E5\u5FD7\u6761\u76EE");this._state.logs.push(...i),this._trimLogs(),this._updateLogsDisplay(),this._updateStats(),this._showImportNotice(`\u6210\u529F\u5BFC\u5165 ${i.length} \u6761\u65E5\u5FD7 (${r}\u683C\u5F0F)`,"success"),this.addLog(`\u4ECE\u6587\u4EF6\u5BFC\u5165 ${i.length} \u6761\u65E5\u5FD7`,"success"),this.dispatchEvent(new CustomEvent("nv-log-import",{detail:{count:i.length,format:r,logs:i}}))}catch(o){console.error("\u5BFC\u5165\u65E5\u5FD7\u5931\u8D25:",o),this._showImportNotice(`\u5BFC\u5165\u5931\u8D25: ${o.message}`,"error"),this.addLog(`\u5BFC\u5165\u65E5\u5FD7\u5931\u8D25: ${o.message}`,"error")}}_parseTextLogs(t){let e=[],o=/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)?)\]/,s=/^\[(\d{2}:\d{2}:\d{2}(?:\.\d+)?)\]/,r=/\[(INFO|SUCCESS|WARNING|ERROR|IGNORE)\]/i;return t.forEach((i,n)=>{if(!i.trim())return;let l=Date.now(),a="info",g=i,d=i.match(o)||i.match(s);if(d){try{l=new Date(d[1]).getTime()||Date.now()-(t.length-n)*1e3}catch{l=Date.now()-(t.length-n)*1e3}g=i.substring(d[0].length).trim()}let h=g.match(r);if(h){let p=h[1].toLowerCase();["info","success","warning","error","ignore"].includes(p)&&(a=p),g=g.replace(r,"").trim()}e.push({time:l,type:a,message:g})}),e}_normalizeLogEntry(t){if(t==null)return null;if(typeof t=="string")return{time:Date.now(),type:"info",message:t};if(typeof t=="object"){let e={time:t.time||t.timestamp||Date.now(),type:(t.type||t.level||"info").toLowerCase(),message:String(t.message||t.msg||t.text||JSON.stringify(t))};return["info","success","warning","error","ignore"].includes(e.type)||(e.type="info"),(typeof e.time!="number"||isNaN(e.time))&&(e.time=Date.now()),e}return null}_showImportNotice(t,e="info"){let o=this.shadowRoot.querySelector("#logContent");if(!o)return;let s=document.createElement("div");s.className=`import-notice ${e}`,s.textContent=t,o.appendChild(s),setTimeout(()=>{s.parentNode===o&&o.removeChild(s)},3e3)}addLog(t,e="info",o=Date.now()){let s;if(typeof t=="object"&&t!==null){if(s=this._normalizeLogEntry(t),!s){console.warn("\u65E0\u6548\u7684\u65E5\u5FD7\u5BF9\u8C61:",t);return}}else["info","success","warning","error","ignore"].includes(e)||(e="info"),s={message:String(t),type:e,time:o};this._state.logs.push(s),this._trimLogs(),this._updateLogsDisplay(),this._updateStats(),this.dispatchEvent(new CustomEvent("nv-log-add",{detail:{log:s,total:this._state.logs.length,stats:this._getStats()}}))}clearLogs(){let t=this._state.logs.length;this._state.logs=[],this._updateLogsDisplay(),this._updateStats(),this.dispatchEvent(new CustomEvent("nv-log-clear",{detail:{clearedCount:t}}))}toggleVisibility(){this._state.showLogs=!this._state.showLogs;let t=this.shadowRoot.querySelector(".log-container");t&&(t.className=`log-container ${this._state.showLogs?"expanded":"collapsed"} ${this._config.theme}`);let e=this.shadowRoot.querySelector(".toggle-btn");e&&(e.title=this._state.showLogs?"\u9690\u85CF\u65E5\u5FD7":"\u663E\u793A\u65E5\u5FD7",e.textContent=this._state.showLogs?"\u{1F441}\uFE0F":"\u{1F441}\uFE0F\u200D\u{1F5E8}\uFE0F"),this.dispatchEvent(new CustomEvent("nv-log-toggle",{detail:{visible:this._state.showLogs}}))}exportLogs(t="json"){try{if(this._state.logs.length===0){this.addLog("\u6CA1\u6709\u65E5\u5FD7\u53EF\u5BFC\u51FA","warning");return}let e="",o="",s="";if(t==="json"){let a={exportTime:new Date().toISOString(),totalLogs:this._state.logs.length,logs:this._state.logs};e=JSON.stringify(a,null,2),o="application/json",s="json"}else e=this._state.logs.map(a=>`[${new Date(a.time).toLocaleString("zh-CN")}] [${a.type.toUpperCase()}] ${a.message}`).join(`
720
+ `),o="text/plain;charset=utf-8",s="txt";let r=new Blob([e],{type:o}),i=URL.createObjectURL(r),n=document.createElement("a"),l=new Date().toISOString().replace(/[:.]/g,"-");n.href=i,n.download=`logs_${l}.${s}`,n.click(),URL.revokeObjectURL(i),this.addLog(`\u65E5\u5FD7\u5DF2\u5BFC\u51FA (${this._state.logs.length} \u6761, ${t}\u683C\u5F0F)`,"success")}catch(e){this.addLog(`\u5BFC\u51FA\u65E5\u5FD7\u5931\u8D25: ${e.message}`,"error")}}async importLogs(t,e="auto"){try{let o=[],s="unknown";if(e==="auto"||e==="json")try{let i=JSON.parse(t);Array.isArray(i)?(o=i,s="json"):typeof i=="object"&&i.logs&&Array.isArray(i.logs)&&(o=i.logs,s="json-with-metadata")}catch{if(e==="json")throw new Error("JSON\u683C\u5F0F\u89E3\u6790\u5931\u8D25")}if(o.length===0){let i=t.split(`
721
+ `).filter(n=>n.trim());o=this._parseTextLogs(i),s="text"}if(o.length===0)throw new Error("\u6CA1\u6709\u627E\u5230\u6709\u6548\u7684\u65E5\u5FD7\u6570\u636E");let r=o.map(i=>this._normalizeLogEntry(i)).filter(i=>i!==null);if(r.length===0)throw new Error("\u6CA1\u6709\u6709\u6548\u7684\u65E5\u5FD7\u6761\u76EE");return this._state.logs.push(...r),this._trimLogs(),this._updateLogsDisplay(),this._updateStats(),this.addLog(`\u5BFC\u5165 ${r.length} \u6761\u65E5\u5FD7 (${s}\u683C\u5F0F)`,"success"),this.dispatchEvent(new CustomEvent("nv-log-import",{detail:{count:r.length,format:s,logs:r}})),{success:!0,count:r.length,format:s}}catch(o){throw console.error("\u5BFC\u5165\u65E5\u5FD7\u5931\u8D25:",o),this.addLog(`\u5BFC\u5165\u65E5\u5FD7\u5931\u8D25: ${o.message}`,"error"),o}}async copyLogs(){try{let t=this._state.logs.map(e=>`[${new Date(e.time).toLocaleString("zh-CN")}] [${e.type.toUpperCase()}] ${e.message}`).join(`
722
+ `);await navigator.clipboard.writeText(t),this.addLog("\u65E5\u5FD7\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F","success")}catch(t){this.addLog(`\u590D\u5236\u65E5\u5FD7\u5931\u8D25: ${t.message}`,"error")}}getLogs(){return[...this._state.logs]}getLogsByType(t){return Array.isArray(t)||(t=[t]),this._state.logs.filter(e=>t.includes(e.type))}_getStats(){let t={total:this._state.logs.length,info:0,success:0,warning:0,error:0,ignore:0};return this._state.logs.forEach(e=>{t[e.type]!==void 0&&t[e.type]++}),t}setMaxLogs(t){this._config.maxLogs=Math.max(1,parseInt(t,10)||100),this._trimLogs(),this._updateLogsDisplay(),this._updateStats()}setTheme(t){this._config.theme=t==="light"?"light":"dark",this._updateTheme()}setShowTime(t){this._config.showTime=!!t,this._updateLogsDisplay()}setTimeFormat(t){this._config.timeFormat=t,this._updateLogsDisplay()}setAutoScroll(t){this._config.autoScroll=!!t}setShowStats(t){this._config.showStats=!!t,this._updateStatsVisibility()}setHideButton(t){this._config.hideButton=!!t,this._updateButtonsVisibility()}setAutoDestroy(t){this._config.autoDestroy=!!t,this._updateCloseButton()}setDraggable(t){this._config.draggable=!!t,this._updateDraggableState()}open(){if(!this._state.isOpen){let t=this.shadowRoot.querySelector("#popupContainer");if(t){t.style.display="block",t.classList.add("open"),t.classList.remove("minimized");let e=this.shadowRoot.querySelector("#minimizedTitle");e&&(e.style.display="none");let o=800,s=600,r=Math.max(0,(window.innerWidth-o)/2),i=Math.max(0,(window.innerHeight-s)/2);if(t.style.width=`${o}px`,t.style.height=`${s}px`,t.style.left=`${r}px`,t.style.top=`${i}px`,t.style.transform="none",this._state.isMinimized=!1,this._state.showLogs=!0,this._updateLogsDisplay(),this._updateTheme(),this._updateDraggableState(),!this._config.hideButton){let n=this.shadowRoot.querySelector("#floatingContainer");n&&(n.style.display="none")}}this._state.isOpen=!0,this.addLog("\u{1F4C1} \u65E5\u5FD7\u67E5\u770B\u5668\u5DF2\u6253\u5F00","info")}}clos(){if(this._state.isOpen){let t=this.shadowRoot.querySelector("#popupContainer");if(t){this._state.originalPosition={x:parseInt(t.style.left)||0,y:parseInt(t.style.top)||0},t.classList.remove("open"),t.style.display="none";let e=this.shadowRoot.querySelector("#minimizedTitle");e&&(e.style.display="none")}if(this._state.isOpen=!1,!this._config.hideButton){let e=this.shadowRoot.querySelector("#floatingContainer");e&&(e.style.display="block")}this.addLog("\u{1F4C1} \u65E5\u5FD7\u67E5\u770B\u5668\u5DF2\u5173\u95ED","info"),this._config.autoDestroy&&setTimeout(()=>{this._cleanup()},100)}}_minimize(){let t=this.shadowRoot.querySelector("#popupContainer"),e=this.shadowRoot.querySelector("#minimizedTitle");t&&e&&(this._state.originalSize={width:t.style.width||"800px",height:t.style.height||"600px",minHeight:t.style.minHeight},t.classList.add("minimized"),t.style.width="320px",t.style.height="40px",t.style.minHeight="40px",t.style.minWidth="320px",e.style.display="flex",this._state.isMinimized=!0,this.addLog("\u{1F4F1} \u65E5\u5FD7\u67E5\u770B\u5668\u5DF2\u6700\u5C0F\u5316","info"))}_restore(){let t=this.shadowRoot.querySelector("#popupContainer"),e=this.shadowRoot.querySelector("#minimizedTitle");t&&e&&(t.classList.remove("minimized"),e.style.display="none",this._state.originalSize?(t.style.width=this._state.originalSize.width,t.style.height=this._state.originalSize.height,this._state.originalSize.minHeight?t.style.minHeight=this._state.originalSize.minHeight:t.style.minHeight="300px"):(t.style.width="800px",t.style.height="600px",t.style.minHeight="300px"),t.style.minWidth="400px",this._state.isMinimized=!1,this.addLog("\u{1F4F1} \u65E5\u5FD7\u67E5\u770B\u5668\u5DF2\u6062\u590D","info"))}};b.ELEMENT_NAME="nv-log-viewer";var _=async(c={})=>{let t=document.createElement("nv-log-viewer");return t.setAttribute("hide-button",c.hideButton!==!1?"true":"false"),t.setAttribute("auto-destroy",c.autoDestroy!==!1?"true":"false"),c.maxLogs&&t.setAttribute("max-logs",c.maxLogs),c.theme&&t.setAttribute("theme",c.theme),c.showTime!==void 0&&t.setAttribute("show-time",c.showTime),c.timeFormat&&t.setAttribute("time-format",c.timeFormat),c.showStats!==void 0&&t.setAttribute("show-stats",c.showStats),c.autoScroll!==void 0&&t.setAttribute("auto-scroll",c.autoScroll),document.body.appendChild(t),await new Promise(e=>setTimeout(e,100)),t.open(),t};customElements.get("nv-log-viewer")||customElements.define("nv-log-viewer",b);typeof y<"u"&&y.exports&&(y.exports={NvLogViewer:b,once:_})});return L();})();
723
+ </script>
724
+ </head>
725
+ <body>
726
+ <h1>NV Log Viewer 演示</h1>
727
+
728
+ <button onclick="testOnce()">打开一次性日志查看器</button>
729
+ <button onclick="testManual()">手动创建日志查看器</button>
730
+
731
+ <script>
732
+ async function testOnce() {
733
+ const logger = await nvlogbw.once({
734
+ maxLogs: 500,
735
+ theme: 'dark',
736
+ hideButton: true,
737
+ autoDestroy: true
738
+ });
739
+
740
+ logger.addLog('🎉 一次性日志查看器已打开', 'success');
741
+ logger.addLog('🚀 可以正常记录日志', 'info');
742
+ logger.addLog('⚠️ 关闭窗口将自动销毁', 'warning');
743
+ }
744
+
745
+ async function testManual() {
746
+ const logger = document.createElement('nv-log-viewer');
747
+ logger.setAttribute('max-logs', '1000');
748
+ logger.setAttribute('theme', 'light');
749
+ logger.setAttribute('auto-destroy', 'false');
750
+
751
+ document.body.appendChild(logger);
752
+ await new Promise(resolve => setTimeout(resolve, 100));
753
+
754
+ logger.open();
755
+ logger.addLog('🔧 手动创建的日志查看器', 'info');
756
+ logger.addLog('💾 关闭后可以重新打开', 'success');
757
+
758
+ window.logger = logger;
759
+ }
760
+ </script>
761
+ </body>
762
+ </html>