agent-loft 0.2.102 → 0.2.104
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/package.json +1 -1
- package/web/css/albums.css +0 -6
- package/web/css/messages.css +148 -22
- package/web/lib/dom.js +2 -2
- package/web/lib/image-viewer.js +29 -16
- package/web/workbuddy.png +0 -0
package/package.json
CHANGED
package/web/css/albums.css
CHANGED
|
@@ -35,12 +35,6 @@
|
|
|
35
35
|
.album-empty, .album-pending { padding: 20px; color: var(--fg-soft); font-size: 13px; }
|
|
36
36
|
.album-error { color: var(--danger); font-size: 13px; }
|
|
37
37
|
.album-missing { padding: 20px; color: #b4b4b4; font-size: 12px; }
|
|
38
|
-
.photo-viewer .photo-detail { padding: 8px 16px; color: var(--fg-soft); font-size: 12px; text-align: center; overflow-wrap: anywhere; }
|
|
39
|
-
.photo-viewer .photo-detail:empty { display: none; }
|
|
40
|
-
.photo-count { flex-shrink: 0; color: var(--fg-soft); font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
41
|
-
.photo-navigation { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 6px 12px 0; }
|
|
42
|
-
.photo-navigation .btn { font-size: 12px; }
|
|
43
|
-
.photo-viewer .diagram-viewer-hint { font-size: 11px; }
|
|
44
38
|
@media (max-width: 600px) {
|
|
45
39
|
.album-head { padding: 14px; flex-wrap: wrap; gap: 6px; }
|
|
46
40
|
.album-head strong { font-size: 16px; }
|
package/web/css/messages.css
CHANGED
|
@@ -1549,33 +1549,159 @@ a.att-file:hover {
|
|
|
1549
1549
|
.diagram-viewer {
|
|
1550
1550
|
position: fixed;
|
|
1551
1551
|
inset: 0;
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
width: calc(100% - 32px);
|
|
1555
|
-
height: calc(100dvh - 32px);
|
|
1552
|
+
width: 100%;
|
|
1553
|
+
height: 100dvh;
|
|
1556
1554
|
max-width: none;
|
|
1557
1555
|
max-height: none;
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1556
|
+
margin: 0;
|
|
1557
|
+
padding: 0;
|
|
1558
|
+
border: 0;
|
|
1559
|
+
border-radius: 0;
|
|
1560
|
+
background: var(--bg-side);
|
|
1561
1561
|
color: var(--fg);
|
|
1562
1562
|
overflow: hidden;
|
|
1563
|
+
--viewer-surface: var(--bg);
|
|
1564
|
+
}
|
|
1565
|
+
.diagram-viewer[open] { display: block; animation: viewer-appear 150ms ease-out; }
|
|
1566
|
+
.diagram-viewer::backdrop { background: var(--bg-side); }
|
|
1567
|
+
.diagram-viewer-head {
|
|
1568
|
+
position: absolute;
|
|
1569
|
+
z-index: 2;
|
|
1570
|
+
inset: 0 0 auto;
|
|
1571
|
+
display: flex;
|
|
1572
|
+
align-items: center;
|
|
1573
|
+
gap: 24px;
|
|
1574
|
+
min-height: 76px;
|
|
1575
|
+
padding: max(16px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 16px max(28px, env(safe-area-inset-left));
|
|
1576
|
+
}
|
|
1577
|
+
.viewer-meta { flex: 1; min-width: 0; }
|
|
1578
|
+
.diagram-viewer .photo-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
|
|
1579
|
+
.diagram-viewer .photo-detail { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--fg-faint); }
|
|
1580
|
+
.diagram-viewer .photo-detail:empty { display: none; }
|
|
1581
|
+
.diagram-viewer .photo-count { flex-shrink: 0; color: var(--fg-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
1582
|
+
.viewer-actions { display: flex; align-items: center; gap: 8px; }
|
|
1583
|
+
.diagram-viewer .viewer-button {
|
|
1584
|
+
display: inline-grid;
|
|
1585
|
+
place-items: center;
|
|
1586
|
+
flex-shrink: 0;
|
|
1587
|
+
width: 36px;
|
|
1588
|
+
height: 36px;
|
|
1589
|
+
padding: 0;
|
|
1590
|
+
border: 0;
|
|
1591
|
+
border-radius: 50%;
|
|
1592
|
+
background: transparent;
|
|
1593
|
+
color: var(--fg-soft);
|
|
1594
|
+
font: inherit;
|
|
1595
|
+
line-height: 1;
|
|
1596
|
+
text-decoration: none;
|
|
1597
|
+
cursor: pointer;
|
|
1598
|
+
-webkit-tap-highlight-color: transparent;
|
|
1599
|
+
transition: background 120ms, color 120ms;
|
|
1600
|
+
}
|
|
1601
|
+
.diagram-viewer .viewer-button:hover { background: var(--bg-hover); color: var(--fg); }
|
|
1602
|
+
.diagram-viewer .viewer-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
|
|
1603
|
+
.diagram-viewer .viewer-button:disabled { opacity: 0.2; cursor: default; }
|
|
1604
|
+
.diagram-viewer .viewer-button svg { display: block; width: 18px; height: 18px; }
|
|
1605
|
+
.diagram-viewer .viewer-close { width: 40px; height: 40px; }
|
|
1606
|
+
.diagram-viewer .viewer-close svg { width: 20px; height: 20px; }
|
|
1607
|
+
.diagram-stage {
|
|
1608
|
+
position: absolute;
|
|
1609
|
+
inset: 80px 64px 104px;
|
|
1610
|
+
min-height: 0;
|
|
1611
|
+
overflow: hidden;
|
|
1612
|
+
touch-action: none;
|
|
1613
|
+
cursor: grab;
|
|
1614
|
+
user-select: none;
|
|
1563
1615
|
}
|
|
1564
|
-
.diagram-viewer[open] { display: flex; flex-direction: column; }
|
|
1565
|
-
.diagram-viewer::backdrop { background: rgb(0 0 0 / 75%); }
|
|
1566
|
-
.diagram-viewer-head, .diagram-viewer-controls { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
|
|
1567
|
-
.diagram-viewer-head { justify-content: space-between; }
|
|
1568
|
-
.diagram-viewer-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1569
|
-
.diagram-viewer-head .btn { flex-shrink: 0; }
|
|
1570
|
-
.diagram-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; }
|
|
1571
1616
|
.diagram-stage.dragging { cursor: grabbing; }
|
|
1572
|
-
.diagram-stage img, .md .diagram-stage img {
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1617
|
+
.diagram-stage img, .md .diagram-stage img {
|
|
1618
|
+
position: absolute;
|
|
1619
|
+
left: 0;
|
|
1620
|
+
top: 0;
|
|
1621
|
+
display: block;
|
|
1622
|
+
max-width: none;
|
|
1623
|
+
max-height: none;
|
|
1624
|
+
margin: 0;
|
|
1625
|
+
border-radius: 6px;
|
|
1626
|
+
transform-origin: 0 0;
|
|
1627
|
+
pointer-events: none;
|
|
1628
|
+
}
|
|
1629
|
+
.diagram-viewer-status {
|
|
1630
|
+
position: absolute;
|
|
1631
|
+
left: 50%;
|
|
1632
|
+
bottom: 16px;
|
|
1633
|
+
transform: translateX(-50%);
|
|
1634
|
+
max-width: calc(100% - 24px);
|
|
1635
|
+
padding: 8px 14px;
|
|
1636
|
+
border-radius: 12px;
|
|
1637
|
+
background: var(--viewer-surface);
|
|
1638
|
+
box-shadow: 0 2px 16px rgb(0 0 0 / 6%);
|
|
1639
|
+
color: var(--fg-soft);
|
|
1640
|
+
font-size: 12px;
|
|
1641
|
+
text-align: center;
|
|
1642
|
+
pointer-events: none;
|
|
1643
|
+
}
|
|
1644
|
+
.diagram-viewer-status:empty { display: none; }
|
|
1645
|
+
.diagram-viewer-controls {
|
|
1646
|
+
position: absolute;
|
|
1647
|
+
z-index: 2;
|
|
1648
|
+
left: 50%;
|
|
1649
|
+
bottom: max(24px, env(safe-area-inset-bottom));
|
|
1650
|
+
transform: translateX(-50%);
|
|
1651
|
+
display: flex;
|
|
1652
|
+
align-items: center;
|
|
1653
|
+
gap: 4px;
|
|
1654
|
+
padding: 6px;
|
|
1655
|
+
border: 1px solid var(--border);
|
|
1656
|
+
border-radius: 999px;
|
|
1657
|
+
background: var(--viewer-surface);
|
|
1658
|
+
box-shadow: 0 4px 24px rgb(0 0 0 / 7%), 0 1px 3px rgb(0 0 0 / 3%);
|
|
1659
|
+
}
|
|
1660
|
+
@supports (background: color-mix(in srgb, white 90%, transparent)) {
|
|
1661
|
+
.diagram-viewer { --viewer-surface: color-mix(in srgb, var(--bg) 92%, transparent); }
|
|
1662
|
+
.diagram-viewer-controls, .diagram-viewer .viewer-prev, .diagram-viewer .viewer-next { backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
|
|
1663
|
+
}
|
|
1664
|
+
.diagram-viewer .viewer-original { width: 64px; border-radius: 999px; }
|
|
1665
|
+
.diagram-scale { font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
1666
|
+
.viewer-divider { width: 1px; height: 18px; margin: 0 4px; background: var(--border); }
|
|
1667
|
+
.diagram-viewer .viewer-prev, .diagram-viewer .viewer-next {
|
|
1668
|
+
position: absolute;
|
|
1669
|
+
z-index: 2;
|
|
1670
|
+
top: 50%;
|
|
1671
|
+
transform: translateY(-50%);
|
|
1672
|
+
width: 40px;
|
|
1673
|
+
height: 40px;
|
|
1674
|
+
background: var(--viewer-surface);
|
|
1675
|
+
}
|
|
1676
|
+
.diagram-viewer .viewer-prev { left: max(16px, env(safe-area-inset-left)); }
|
|
1677
|
+
.diagram-viewer .viewer-next { right: max(16px, env(safe-area-inset-right)); }
|
|
1678
|
+
.viewer-next svg { transform: rotate(180deg); }
|
|
1679
|
+
.diagram-stage[data-loading="true"]::after {
|
|
1680
|
+
content: "";
|
|
1681
|
+
position: absolute;
|
|
1682
|
+
top: calc(50% - 10px);
|
|
1683
|
+
left: calc(50% - 10px);
|
|
1684
|
+
width: 20px;
|
|
1685
|
+
height: 20px;
|
|
1686
|
+
border: 2px solid var(--border);
|
|
1687
|
+
border-top-color: var(--fg-faint);
|
|
1688
|
+
border-radius: 50%;
|
|
1689
|
+
animation: viewer-spin 700ms linear infinite;
|
|
1690
|
+
}
|
|
1691
|
+
@keyframes viewer-spin { to { transform: rotate(360deg); } }
|
|
1692
|
+
@keyframes viewer-appear { from { opacity: 0; } to { opacity: 1; } }
|
|
1578
1693
|
@media (max-width: 600px) {
|
|
1579
|
-
.diagram-viewer {
|
|
1580
|
-
.
|
|
1694
|
+
.diagram-viewer-head { gap: 12px; min-height: 68px; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left)); }
|
|
1695
|
+
.viewer-actions { gap: 0; }
|
|
1696
|
+
.diagram-viewer .photo-name { font-size: 12px; }
|
|
1697
|
+
.diagram-viewer .viewer-button { width: 44px; height: 44px; }
|
|
1698
|
+
.diagram-viewer .viewer-original { width: 64px; }
|
|
1699
|
+
.diagram-stage { inset: 80px 12px 104px; }
|
|
1700
|
+
.diagram-viewer-controls { bottom: max(20px, env(safe-area-inset-bottom)); padding: 4px; gap: 0; }
|
|
1701
|
+
.diagram-viewer .viewer-prev { left: 8px; }
|
|
1702
|
+
.diagram-viewer .viewer-next { right: 8px; }
|
|
1703
|
+
}
|
|
1704
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1705
|
+
.diagram-viewer[open], .diagram-stage[data-loading="true"]::after { animation: none; }
|
|
1706
|
+
.diagram-viewer .viewer-button { transition: none; }
|
|
1581
1707
|
}
|
package/web/lib/dom.js
CHANGED
|
@@ -87,8 +87,8 @@ export const ICON = {
|
|
|
87
87
|
ICON.claude = '<svg viewBox="0 0 640 640"><path fill="#D97757" fill-rule="evenodd" d="M173 2C168 3 167 4 158 17C146 32 146 32 151 52C155 66 155 66 164 81C188 118 252 233 250 235C248 238 246 237 241 233C238 230 221 218 203 204C185 191 156 169 138 156C94 122 96 123 92 122C90 122 84 121 77 120L66 120 58 129L49 139 51 152C52 159 53 165 53 165C53 168 65 179 74 186C80 190 92 199 101 205C110 211 129 225 144 235C185 262 247 304 252 307C254 310 255 311 254 312C253 315 246 315 212 311C196 309 170 307 153 306C114 304 35 298 24 297L14 296 8 301C2 305 1 305 1 310C0 314 0 314 7 323L14 333 21 334C31 337 103 341 170 342C230 344 251 345 252 347C253 347 253 349 253 351C252 355 251 355 190 390C136 420 124 427 102 442C68 465 69 464 68 477L67 486 74 493C79 498 81 499 83 498C84 498 91 497 98 496L110 495 194 440C240 410 279 386 280 385C281 385 281 386 281 387C281 389 277 394 269 404C262 411 248 429 238 442C227 456 204 486 186 509C143 564 143 563 143 574L142 583 152 588L161 593 167 590C172 588 174 586 196 563C220 536 230 524 295 435C308 416 315 408 316 408C318 408 318 408 316 417C315 421 312 436 310 450C306 475 295 533 284 584L279 608 283 618C287 628 287 628 296 634L304 640 313 636C321 633 323 632 327 628L331 623 340 526C348 445 349 429 351 428C353 427 353 426 369 454C395 498 454 586 459 588C461 588 465 589 469 590C476 591 476 591 484 588C492 586 492 585 494 581L496 576 495 562L493 547 456 492C436 461 419 435 419 434C419 433 420 432 421 432C423 432 460 463 486 486C501 499 553 538 557 539C563 541 564 540 569 534L573 528 571 520C570 514 569 512 566 509C556 500 502 450 478 429C447 401 420 374 420 372C420 370 424 371 443 375C453 378 493 388 533 397L606 414 622 406L638 398 639 392L640 385 634 377C628 369 626 367 617 361L606 354 574 351C553 350 528 349 502 348C464 347 425 344 423 342C422 341 419 342 472 329C496 323 531 316 549 312C568 308 594 302 606 299L629 294 633 283C638 273 638 272 637 267L636 262 625 257L613 251 591 255C548 262 523 267 486 275C439 285 443 284 441 283C440 281 441 278 450 263C463 241 486 209 540 142C547 133 547 132 551 118C553 110 555 103 555 102C555 101 551 94 545 86L536 72 521 72L507 72 499 79C480 94 436 145 396 199C381 219 375 226 371 226C370 226 369 225 369 225C369 223 376 184 386 133C390 114 395 83 398 66L403 35 396 26C390 18 389 17 383 13C379 12 375 10 375 10C374 10 369 13 364 16L354 23 349 35C343 49 344 45 339 105C337 125 335 152 333 167C331 181 329 202 329 212C326 245 326 244 324 244C322 244 321 241 317 229C313 216 311 211 286 162C261 113 248 87 226 35C212 4 212 4 181 1C179 0 175 1 173 2"/></svg>';
|
|
88
88
|
/** OpenAI 的标志,也是内置专家 Codex 的头像。跟着文字颜色(深色模式下是白的) */
|
|
89
89
|
ICON.codex = '<svg viewBox="0 0 640 640"><path fill="currentColor" fill-rule="evenodd" d="M253 1C193 8 141 51 122 109C120 115 118 121 117 123C117 127 117 127 108 130C31 154 -16 240 6 321C12 346 26 370 45 391L53 399 52 407C43 448 51 491 75 527C83 539 104 560 116 569C156 596 205 604 250 591L257 589 264 595C284 613 307 624 335 631C351 635 382 635 399 631C461 618 506 575 523 511C523 508 524 508 534 504C587 485 625 442 637 384C640 369 640 341 637 325C631 293 616 266 594 244L587 236 588 228C606 142 552 60 466 41C442 36 412 37 390 44L384 46 375 38C340 9 297 -4 253 1M259 39C258 39 253 39 249 40C206 46 169 78 156 119C150 137 150 139 150 224L150 302 153 305C156 308 206 338 207 338C208 338 208 296 208 245C208 181 208 150 209 148C211 140 215 138 280 100C314 80 343 64 343 63C345 61 322 48 308 44C293 39 272 37 259 39M405 78C385 82 385 82 309 126C271 148 249 161 248 163C246 166 245 168 245 198C245 220 245 230 246 230C247 230 283 209 326 184C412 134 410 135 416 135C422 135 421 135 489 174C524 195 552 211 553 211C554 209 554 196 553 186C547 133 512 92 462 79C448 76 418 75 405 78M103 173C62 194 36 238 38 284C40 316 53 346 75 368C86 379 88 380 145 413C171 428 199 444 206 448C217 454 221 456 224 456C227 456 281 427 281 425C281 425 245 403 201 378C157 353 120 331 119 329C112 323 113 327 112 244L112 169 103 173M385 194C370 202 358 209 358 209C358 210 394 231 438 256C482 281 519 303 521 305C522 306 525 309 526 311C528 316 528 316 528 390C528 444 528 465 529 465C531 465 547 456 554 451C612 407 618 321 566 267C554 256 553 255 497 222C416 176 420 178 416 178C413 178 406 181 385 194M282 252L246 273 246 317L246 362 282 382C303 394 320 403 320 403C321 403 388 365 393 362L395 361 395 317L394 273 358 252C337 240 320 231 320 231C320 231 303 240 282 252M432 389C432 453 432 484 431 486C429 494 425 497 360 535C325 554 297 571 297 571C295 572 307 580 317 585C336 593 353 597 374 596C432 593 475 558 489 502C491 490 492 336 489 331C488 328 483 325 460 312C445 303 433 296 432 296C432 296 432 338 432 389M376 414C367 419 331 440 297 460C230 498 228 500 222 499C217 498 220 500 150 459C117 440 89 424 88 424C87 424 86 440 87 450C91 492 115 527 153 545C183 561 223 563 254 551C264 547 388 476 391 472L394 469 394 436C394 419 394 404 394 404C394 404 386 408 376 414"/></svg>';
|
|
90
|
-
|
|
91
|
-
ICON.workbuddy =
|
|
90
|
+
/** WorkBuddy 的头像(青绿渐变猫脸),沿用 SVG 容器适配各处的图标尺寸 */
|
|
91
|
+
ICON.workbuddy = `<svg viewBox="0 0 320 320"><image href="${new URL("../workbuddy.png", import.meta.url).href}" width="320" height="320"/></svg>`;
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* 星星加载动画(回复末尾、打开会话时用)。开屏那个带台面的完整 logo 动画直接写在 index.html 里。
|
package/web/lib/image-viewer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h } from "./dom.js";
|
|
1
|
+
import { fill, h, icon } from "./dom.js";
|
|
2
2
|
|
|
3
3
|
/** 图片与图表共用预览:SVG 保持图片隔离,普通图片沿用同一套缩放与拖动。 */
|
|
4
4
|
export function openImageViewer(owner, src, title, trigger, { kind = "图表", download, gallery, start = 0, onIndexChange } = {}) {
|
|
@@ -7,11 +7,11 @@ export function openImageViewer(owner, src, title, trigger, { kind = "图表", d
|
|
|
7
7
|
const image = h("img", { alt: title, draggable: "false" });
|
|
8
8
|
const status = h("div", { class: "diagram-viewer-status photo-status", role: "status" });
|
|
9
9
|
const stage = h("div", { class: `diagram-stage${gallery ? " photo-stage" : ""}`, "aria-label": "拖动查看,滚轮或双指缩放" }, image, status);
|
|
10
|
-
const heading = h("strong", { class: "photo-name" }, title);
|
|
10
|
+
const heading = h("strong", { class: "photo-name", title }, title);
|
|
11
11
|
const detail = h("div", { class: "photo-detail" });
|
|
12
12
|
const count = h("span", { class: "photo-count", "aria-live": "polite" });
|
|
13
|
-
const previous = h("button", { class: "
|
|
14
|
-
const next = h("button", { class: "
|
|
13
|
+
const previous = h("button", { class: "viewer-button viewer-prev", "aria-label": "上一张照片", title: "上一张照片", onclick: () => show(index - 1) }, icon("back"));
|
|
14
|
+
const next = h("button", { class: "viewer-button viewer-next", "aria-label": "下一张照片", title: "下一张照片", onclick: () => show(index + 1) }, icon("back"));
|
|
15
15
|
let index = start, fallback = "", notice = "", swipe;
|
|
16
16
|
function show(n) {
|
|
17
17
|
n = Math.max(0, Math.min(n, gallery.length - 1));
|
|
@@ -20,9 +20,11 @@ export function openImageViewer(owner, src, title, trigger, { kind = "图表", d
|
|
|
20
20
|
const item = gallery[index];
|
|
21
21
|
width = height = 0;
|
|
22
22
|
image.style.visibility = "hidden";
|
|
23
|
+
stage.dataset.loading = "true";
|
|
23
24
|
notice = status.textContent = "";
|
|
24
25
|
fallback = item.fallback;
|
|
25
26
|
image.alt = heading.textContent = item.title;
|
|
27
|
+
heading.title = item.title;
|
|
26
28
|
detail.textContent = item.detail;
|
|
27
29
|
count.textContent = `${index + 1} / ${gallery.length}`;
|
|
28
30
|
previous.disabled = index === 0;
|
|
@@ -37,7 +39,8 @@ export function openImageViewer(owner, src, title, trigger, { kind = "图表", d
|
|
|
37
39
|
image.style.transform = `translate(${x}px, ${y}px) scale(${scale})`;
|
|
38
40
|
percent.textContent = `${Math.round(scale * 100)}%`;
|
|
39
41
|
};
|
|
40
|
-
|
|
42
|
+
// 图表是矢量图,打开时充分利用画布;照片保留原始分辨率上限。
|
|
43
|
+
const fitScale = () => Math.min(kind === "图表" ? 16 : 1, stage.clientWidth / width, stage.clientHeight / height);
|
|
41
44
|
const center = (s) => {
|
|
42
45
|
if (!width) return;
|
|
43
46
|
scale = s;
|
|
@@ -55,7 +58,7 @@ export function openImageViewer(owner, src, title, trigger, { kind = "图表", d
|
|
|
55
58
|
scale = next;
|
|
56
59
|
paint();
|
|
57
60
|
};
|
|
58
|
-
const control = (label,
|
|
61
|
+
const control = (label, content, onclick, className = "") => h("button", { class: `viewer-button ${className}`, "aria-label": label, title: label, onclick }, content);
|
|
59
62
|
const close = () => {
|
|
60
63
|
if (closed) return;
|
|
61
64
|
closed = true;
|
|
@@ -65,18 +68,26 @@ export function openImageViewer(owner, src, title, trigger, { kind = "图表", d
|
|
|
65
68
|
if (owner._closePreview === close) delete owner._closePreview;
|
|
66
69
|
if (trigger?.isConnected) trigger.focus({ preventScroll: true });
|
|
67
70
|
};
|
|
68
|
-
dialog
|
|
69
|
-
h("div", { class: "diagram-viewer-head" },
|
|
71
|
+
fill(dialog,
|
|
72
|
+
h("div", { class: "diagram-viewer-head" },
|
|
73
|
+
h("div", { class: "viewer-meta" }, heading, gallery ? detail : null),
|
|
74
|
+
gallery ? count : null,
|
|
75
|
+
h("div", { class: "viewer-actions" },
|
|
76
|
+
download ? h("a", { class: "viewer-button", href: download, download: title, "aria-label": "下载", title: "下载" },
|
|
77
|
+
h("span", { html: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3v12m-5-5 5 5 5-5M4 16v4h16v-4"/></svg>' })) : null,
|
|
78
|
+
control(`关闭${kind}预览`, icon("x"), close, "viewer-close"))),
|
|
70
79
|
stage,
|
|
71
|
-
gallery ?
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
control(
|
|
75
|
-
control(`放大${kind}`, "
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
h("div", { class: "diagram-viewer-hint" }, gallery ? "左右滑动切换 · 双指 / 滚轮缩放 · 放大后拖动 · Esc 关闭" : "滚轮 / 双指缩放 · 拖动查看 · Esc 关闭"),
|
|
80
|
+
gallery ? [previous, next] : null,
|
|
81
|
+
h("div", { class: "diagram-viewer-controls", role: "toolbar", "aria-label": "缩放控制" },
|
|
82
|
+
control(`缩小${kind}`, icon("minus"), () => zoom(scale / 1.25)),
|
|
83
|
+
control("原始大小", percent, () => center(1), "viewer-original"),
|
|
84
|
+
control(`放大${kind}`, icon("plus"), () => zoom(scale * 1.25)),
|
|
85
|
+
h("span", { class: "viewer-divider", "aria-hidden": "true" }),
|
|
86
|
+
control("适应窗口", icon("expand"), fit)),
|
|
79
87
|
);
|
|
88
|
+
stage.addEventListener("dblclick", () => {
|
|
89
|
+
if (width) Math.abs(scale - fitScale()) < 0.001 ? center(1) : fit();
|
|
90
|
+
});
|
|
80
91
|
stage.addEventListener("wheel", (e) => {
|
|
81
92
|
e.preventDefault();
|
|
82
93
|
const rect = stage.getBoundingClientRect();
|
|
@@ -138,6 +149,7 @@ export function openImageViewer(owner, src, title, trigger, { kind = "图表", d
|
|
|
138
149
|
else fit();
|
|
139
150
|
});
|
|
140
151
|
image.addEventListener("load", () => {
|
|
152
|
+
delete stage.dataset.loading;
|
|
141
153
|
status.textContent = notice;
|
|
142
154
|
image.style.visibility = "";
|
|
143
155
|
width = image.naturalWidth;
|
|
@@ -147,6 +159,7 @@ export function openImageViewer(owner, src, title, trigger, { kind = "图表", d
|
|
|
147
159
|
fit();
|
|
148
160
|
});
|
|
149
161
|
image.addEventListener("error", () => {
|
|
162
|
+
delete stage.dataset.loading;
|
|
150
163
|
if (fallback && image.getAttribute("src") !== fallback) {
|
|
151
164
|
notice = status.textContent = "预览不可用,显示缩略图";
|
|
152
165
|
image.src = fallback;
|
|
Binary file
|