workspace-hook-trust-demo.html 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501
  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.0" />
  6. <title>Workspace Hook Trust Demo</title>
  7. <style>
  8. :root {
  9. color-scheme: dark;
  10. --app: #151515;
  11. --sidebar: #292a2a;
  12. --panel: #202020;
  13. --panel-raised: #2a2a2a;
  14. --row: #222222;
  15. --border: rgba(255, 255, 255, 0.09);
  16. --border-strong: rgba(255, 255, 255, 0.15);
  17. --text: #ececec;
  18. --muted: #9a9a9d;
  19. --subtle: #6e6e72;
  20. --orange: #f08032;
  21. --orange-bg: #2b1c13;
  22. --green: #72ba8d;
  23. --blue: #68a9d8;
  24. --focus: #63a6d6;
  25. font-family:
  26. Inter,
  27. ui-sans-serif,
  28. -apple-system,
  29. BlinkMacSystemFont,
  30. "Segoe UI",
  31. "PingFang SC",
  32. "Microsoft YaHei",
  33. sans-serif;
  34. }
  35. * {
  36. box-sizing: border-box;
  37. }
  38. html,
  39. body {
  40. margin: 0;
  41. min-height: 100%;
  42. background: #101010;
  43. color: var(--text);
  44. }
  45. body {
  46. min-height: 100vh;
  47. }
  48. .archive-notice {
  49. margin: 16px;
  50. padding: 12px 16px;
  51. border: 1px solid var(--orange);
  52. border-radius: 10px;
  53. background: var(--orange-bg);
  54. color: var(--text);
  55. }
  56. button,
  57. input {
  58. font: inherit;
  59. }
  60. button {
  61. color: inherit;
  62. }
  63. button:focus-visible,
  64. input:focus-visible {
  65. outline: 2px solid var(--focus);
  66. outline-offset: 2px;
  67. }
  68. .icon {
  69. width: 18px;
  70. height: 18px;
  71. flex: 0 0 auto;
  72. fill: none;
  73. stroke: currentColor;
  74. stroke-width: 1.8;
  75. stroke-linecap: round;
  76. stroke-linejoin: round;
  77. }
  78. .app {
  79. min-height: 100vh;
  80. display: grid;
  81. grid-template-columns: 310px minmax(0, 1fr);
  82. overflow: hidden;
  83. background: var(--app);
  84. border: 1px solid rgba(255, 255, 255, 0.22);
  85. border-radius: 18px;
  86. }
  87. .sidebar {
  88. min-height: 100vh;
  89. display: flex;
  90. flex-direction: column;
  91. padding: 22px 12px 18px;
  92. background: var(--sidebar);
  93. border-right: 1px solid var(--border);
  94. }
  95. .window-controls {
  96. display: flex;
  97. gap: 12px;
  98. padding: 2px 13px 28px;
  99. }
  100. .window-controls span {
  101. width: 20px;
  102. height: 20px;
  103. border-radius: 50%;
  104. }
  105. .window-controls span:nth-child(1) {
  106. background: #ff5f57;
  107. }
  108. .window-controls span:nth-child(2) {
  109. background: #febc2e;
  110. }
  111. .window-controls span:nth-child(3) {
  112. background: #28c840;
  113. }
  114. .back-link {
  115. display: flex;
  116. align-items: center;
  117. gap: 10px;
  118. min-height: 40px;
  119. margin: 0 4px 12px;
  120. padding: 0 10px;
  121. color: #9d9da0;
  122. font-size: 16px;
  123. font-weight: 650;
  124. }
  125. .sidebar-search {
  126. position: relative;
  127. margin-bottom: 18px;
  128. }
  129. .sidebar-search .icon {
  130. position: absolute;
  131. left: 13px;
  132. top: 50%;
  133. color: #858589;
  134. transform: translateY(-50%);
  135. }
  136. .sidebar-search input {
  137. width: 100%;
  138. height: 38px;
  139. border: 1px solid var(--border-strong);
  140. border-radius: 10px;
  141. background: rgba(255, 255, 255, 0.025);
  142. padding: 0 12px 0 40px;
  143. color: var(--text);
  144. }
  145. .sidebar-search input::placeholder {
  146. color: #747478;
  147. }
  148. .nav-section {
  149. margin-bottom: 13px;
  150. }
  151. .nav-heading {
  152. margin: 0 13px 6px;
  153. color: #707074;
  154. font-size: 13px;
  155. font-weight: 700;
  156. }
  157. .nav-item {
  158. width: 100%;
  159. min-height: 40px;
  160. display: flex;
  161. align-items: center;
  162. gap: 12px;
  163. border: 0;
  164. border-radius: 9px;
  165. background: transparent;
  166. padding: 0 12px;
  167. color: #c9c9cb;
  168. text-align: left;
  169. }
  170. .nav-item.active {
  171. background: rgba(255, 255, 255, 0.1);
  172. color: #f3f3f3;
  173. }
  174. .nav-item .icon {
  175. color: #b9b9bc;
  176. }
  177. .main {
  178. min-width: 0;
  179. min-height: 100vh;
  180. background: var(--app);
  181. padding: 64px 62px;
  182. }
  183. .main-inner {
  184. width: min(1120px, 100%);
  185. }
  186. .page-title {
  187. margin: 0;
  188. font-size: 38px;
  189. line-height: 1.2;
  190. letter-spacing: -0.02em;
  191. }
  192. .page-heading-row,
  193. .description-row,
  194. .tab-row,
  195. .review-summary {
  196. display: flex;
  197. align-items: center;
  198. }
  199. .page-heading-row {
  200. justify-content: space-between;
  201. }
  202. .icon-buttons {
  203. display: flex;
  204. gap: 8px;
  205. }
  206. .icon-button {
  207. width: 36px;
  208. height: 36px;
  209. display: grid;
  210. place-items: center;
  211. border: 0;
  212. border-radius: 8px;
  213. background: transparent;
  214. color: #99999c;
  215. cursor: pointer;
  216. }
  217. .icon-button:hover {
  218. background: rgba(255, 255, 255, 0.06);
  219. color: #dedede;
  220. }
  221. .description-row {
  222. justify-content: space-between;
  223. margin: 48px 0 26px;
  224. color: var(--muted);
  225. font-size: 17px;
  226. font-weight: 600;
  227. }
  228. .page-search {
  229. position: relative;
  230. margin-bottom: 24px;
  231. }
  232. .page-search .icon {
  233. position: absolute;
  234. top: 50%;
  235. left: 16px;
  236. color: #7f7f82;
  237. transform: translateY(-50%);
  238. }
  239. .page-search input {
  240. width: 100%;
  241. height: 52px;
  242. border: 1px solid var(--border-strong);
  243. border-radius: 14px;
  244. background: #292929;
  245. padding: 0 18px 0 48px;
  246. color: var(--text);
  247. font-size: 16px;
  248. }
  249. .page-search input::placeholder {
  250. color: #737377;
  251. }
  252. .tab-row {
  253. gap: 14px;
  254. margin-bottom: 24px;
  255. }
  256. .tabs {
  257. display: inline-flex;
  258. gap: 3px;
  259. padding: 3px;
  260. border-radius: 12px;
  261. background: #202020;
  262. }
  263. .tab {
  264. height: 38px;
  265. display: inline-flex;
  266. align-items: center;
  267. gap: 8px;
  268. border: 0;
  269. border-radius: 9px;
  270. background: transparent;
  271. padding: 0 14px;
  272. color: #97979a;
  273. cursor: pointer;
  274. }
  275. .tab.active {
  276. background: #151515;
  277. color: #e6e6e6;
  278. box-shadow: inset 0 0 0 1px var(--border);
  279. }
  280. .scope-note {
  281. display: flex;
  282. align-items: center;
  283. gap: 7px;
  284. color: #86868a;
  285. font-size: 14px;
  286. }
  287. .scope-note .icon {
  288. width: 16px;
  289. height: 16px;
  290. }
  291. .review-summary {
  292. width: 100%;
  293. min-height: 86px;
  294. justify-content: space-between;
  295. border: 1px solid var(--border);
  296. border-radius: 14px;
  297. background: #1d1d1d;
  298. padding: 0 20px;
  299. cursor: pointer;
  300. }
  301. .review-summary:hover {
  302. background: #202020;
  303. border-color: var(--border-strong);
  304. }
  305. .review-summary-main {
  306. display: flex;
  307. align-items: center;
  308. gap: 14px;
  309. }
  310. .review-summary-copy strong {
  311. display: block;
  312. margin-bottom: 4px;
  313. font-size: 16px;
  314. }
  315. .review-summary-copy span {
  316. color: var(--muted);
  317. font-size: 14px;
  318. }
  319. .review-summary-side {
  320. display: flex;
  321. align-items: center;
  322. gap: 14px;
  323. color: #c4c4c6;
  324. font-weight: 650;
  325. }
  326. .status-icon {
  327. width: 20px;
  328. height: 20px;
  329. color: var(--orange);
  330. }
  331. .review-summary[data-state="trusted"] .status-icon {
  332. color: var(--green);
  333. }
  334. .empty-state {
  335. min-height: 86px;
  336. display: none;
  337. align-items: center;
  338. border: 1px dashed var(--border-strong);
  339. border-radius: 14px;
  340. padding: 0 20px;
  341. color: var(--muted);
  342. }
  343. .backdrop {
  344. position: fixed;
  345. inset: 0;
  346. z-index: 20;
  347. display: none;
  348. align-items: center;
  349. justify-content: center;
  350. padding: 38px;
  351. background: rgba(0, 0, 0, 0.42);
  352. }
  353. .backdrop.open {
  354. display: flex;
  355. }
  356. .review-dialog {
  357. width: min(940px, calc(100vw - 76px));
  358. max-height: min(820px, calc(100vh - 76px));
  359. display: flex;
  360. flex-direction: column;
  361. overflow: hidden;
  362. border: 1px solid var(--border);
  363. border-radius: 25px;
  364. background: var(--panel-raised);
  365. box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  366. }
  367. .dialog-header {
  368. display: flex;
  369. align-items: flex-start;
  370. justify-content: space-between;
  371. padding: 28px 30px 20px;
  372. }
  373. .dialog-title-row {
  374. display: flex;
  375. align-items: center;
  376. gap: 12px;
  377. }
  378. .dialog-title-row .icon {
  379. width: 22px;
  380. height: 22px;
  381. color: #bdbdc0;
  382. }
  383. .dialog-title {
  384. margin: 0;
  385. font-size: 25px;
  386. line-height: 1.2;
  387. }
  388. .dialog-subtitle {
  389. margin: 7px 0 0 34px;
  390. color: var(--muted);
  391. font-size: 15px;
  392. }
  393. .warning {
  394. min-height: 54px;
  395. display: flex;
  396. align-items: center;
  397. gap: 11px;
  398. margin: 12px 30px 18px;
  399. border: 1px solid rgba(240, 128, 50, 0.2);
  400. border-radius: 14px;
  401. background: var(--orange-bg);
  402. padding: 0 18px;
  403. color: #ebebeb;
  404. font-size: 15px;
  405. font-weight: 620;
  406. }
  407. .warning .icon {
  408. color: var(--orange);
  409. }
  410. .hook-list {
  411. min-height: 0;
  412. overflow: auto;
  413. margin: 0 30px;
  414. border: 1px solid var(--border);
  415. border-radius: 17px;
  416. background: var(--row);
  417. }
  418. .event-group + .event-group {
  419. border-top: 1px solid var(--border);
  420. }
  421. .event-header {
  422. min-height: 72px;
  423. display: flex;
  424. align-items: center;
  425. justify-content: space-between;
  426. padding: 0 20px;
  427. }
  428. .event-name {
  429. display: flex;
  430. align-items: center;
  431. gap: 13px;
  432. }
  433. .event-name .hook-icon {
  434. width: 20px;
  435. height: 20px;
  436. color: #dedede;
  437. }
  438. .event-copy strong,
  439. .event-copy span {
  440. display: block;
  441. }
  442. .event-copy strong {
  443. margin-bottom: 3px;
  444. font-size: 16px;
  445. }
  446. .event-copy span {
  447. color: var(--muted);
  448. font-size: 14px;
  449. }
  450. .event-status {
  451. color: var(--orange);
  452. }
  453. .event-group.trusted .event-status {
  454. color: var(--green);
  455. }
  456. .event-group.once .event-status {
  457. color: #b7b7ba;
  458. }
  459. .hook-item {
  460. margin: 0 14px 14px;
  461. border-top: 1px solid var(--border);
  462. }
  463. .hook-line {
  464. min-height: 58px;
  465. display: grid;
  466. grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  467. align-items: center;
  468. gap: 10px;
  469. padding: 0 8px 0 20px;
  470. border-radius: 13px;
  471. }
  472. .hook-item.expanded .hook-line {
  473. margin-top: -1px;
  474. box-shadow: inset 0 0 0 2px var(--focus);
  475. }
  476. .hook-name-button {
  477. min-width: 0;
  478. display: flex;
  479. align-items: center;
  480. gap: 10px;
  481. border: 0;
  482. background: transparent;
  483. padding: 0;
  484. color: var(--text);
  485. text-align: left;
  486. cursor: pointer;
  487. }
  488. .hook-name {
  489. overflow: hidden;
  490. text-overflow: ellipsis;
  491. white-space: nowrap;
  492. font-size: 16px;
  493. }
  494. .row-icon-button {
  495. width: 30px;
  496. height: 30px;
  497. display: grid;
  498. place-items: center;
  499. border: 0;
  500. border-radius: 7px;
  501. background: transparent;
  502. color: #8a8a8e;
  503. cursor: pointer;
  504. }
  505. .trust-button {
  506. height: 36px;
  507. display: inline-flex;
  508. align-items: center;
  509. gap: 7px;
  510. border: 1px solid var(--border-strong);
  511. border-radius: 18px;
  512. background: rgba(255, 255, 255, 0.025);
  513. padding: 0 13px;
  514. color: #e5e5e5;
  515. font-weight: 650;
  516. cursor: pointer;
  517. }
  518. .trust-button.trusted {
  519. color: #cfd8d2;
  520. }
  521. .trust-button.once {
  522. color: #c9c9cc;
  523. }
  524. .trust-button .icon {
  525. width: 16px;
  526. height: 16px;
  527. }
  528. .switch {
  529. position: relative;
  530. width: 46px;
  531. height: 27px;
  532. display: inline-block;
  533. margin: 0 2px;
  534. }
  535. .switch input {
  536. position: absolute;
  537. opacity: 0;
  538. pointer-events: none;
  539. }
  540. .switch-track {
  541. position: absolute;
  542. inset: 0;
  543. border-radius: 999px;
  544. background: #3c3c3e;
  545. cursor: pointer;
  546. }
  547. .switch-track::after {
  548. content: "";
  549. position: absolute;
  550. top: 4px;
  551. left: 4px;
  552. width: 19px;
  553. height: 19px;
  554. border-radius: 50%;
  555. background: #a7a7aa;
  556. transition: transform 140ms ease;
  557. }
  558. .switch input:checked + .switch-track {
  559. background: #505052;
  560. }
  561. .switch input:checked + .switch-track::after {
  562. background: #d0d0d2;
  563. transform: translateX(19px);
  564. }
  565. .hook-details {
  566. display: none;
  567. margin: 10px 8px 0 50px;
  568. border: 1px solid var(--border);
  569. border-radius: 11px;
  570. background: #232323;
  571. padding: 16px 18px;
  572. }
  573. .hook-item.expanded .hook-details {
  574. display: block;
  575. }
  576. .detail-grid {
  577. display: grid;
  578. grid-template-columns: 90px minmax(0, 1fr);
  579. row-gap: 12px;
  580. color: #e3e3e3;
  581. font-size: 14px;
  582. }
  583. .detail-label {
  584. color: var(--muted);
  585. font-weight: 650;
  586. }
  587. .detail-value {
  588. min-width: 0;
  589. overflow-wrap: anywhere;
  590. }
  591. .detail-value code {
  592. font-family: "SFMono-Regular", Consolas, monospace;
  593. }
  594. .detail-foot {
  595. display: flex;
  596. align-items: center;
  597. justify-content: space-between;
  598. gap: 12px;
  599. margin-top: 15px;
  600. padding-top: 13px;
  601. border-top: 1px solid var(--border);
  602. color: var(--muted);
  603. font-size: 13px;
  604. }
  605. .text-button {
  606. border: 0;
  607. background: transparent;
  608. padding: 4px;
  609. color: #b8b8bb;
  610. cursor: pointer;
  611. }
  612. .text-button:hover {
  613. color: #f0f0f0;
  614. }
  615. .dialog-footer {
  616. display: flex;
  617. align-items: center;
  618. justify-content: space-between;
  619. gap: 16px;
  620. padding: 18px 30px 24px;
  621. }
  622. .waiting-note {
  623. display: flex;
  624. align-items: center;
  625. gap: 8px;
  626. color: var(--muted);
  627. font-size: 13px;
  628. }
  629. .waiting-dot {
  630. width: 8px;
  631. height: 8px;
  632. border-radius: 50%;
  633. background: var(--orange);
  634. }
  635. .footer-actions {
  636. display: flex;
  637. align-items: center;
  638. gap: 9px;
  639. }
  640. .button {
  641. min-height: 38px;
  642. border: 1px solid var(--border-strong);
  643. border-radius: 10px;
  644. background: #303030;
  645. padding: 0 15px;
  646. color: #e8e8e8;
  647. font-weight: 650;
  648. cursor: pointer;
  649. }
  650. .button:hover {
  651. background: #373737;
  652. }
  653. .button.primary {
  654. background: #e8e8e8;
  655. color: #181818;
  656. }
  657. .button.primary:hover {
  658. background: #ffffff;
  659. }
  660. .button:disabled {
  661. opacity: 0.45;
  662. cursor: default;
  663. }
  664. .toast {
  665. position: fixed;
  666. z-index: 40;
  667. left: 50%;
  668. bottom: 26px;
  669. min-width: 260px;
  670. max-width: calc(100vw - 40px);
  671. border: 1px solid var(--border-strong);
  672. border-radius: 10px;
  673. background: #292929;
  674. padding: 11px 16px;
  675. color: #e8e8e8;
  676. text-align: center;
  677. opacity: 0;
  678. pointer-events: none;
  679. transform: translate(-50%, 8px);
  680. transition:
  681. opacity 140ms ease,
  682. transform 140ms ease;
  683. }
  684. .toast.show {
  685. opacity: 1;
  686. transform: translate(-50%, 0);
  687. }
  688. @media (max-width: 900px) {
  689. .app {
  690. grid-template-columns: 240px minmax(0, 1fr);
  691. }
  692. .main {
  693. padding: 44px 30px;
  694. }
  695. .backdrop {
  696. padding: 20px;
  697. }
  698. .review-dialog {
  699. width: calc(100vw - 40px);
  700. max-height: calc(100vh - 40px);
  701. }
  702. .dialog-footer {
  703. align-items: flex-start;
  704. flex-direction: column;
  705. }
  706. .footer-actions {
  707. width: 100%;
  708. justify-content: flex-end;
  709. }
  710. }
  711. @media (max-width: 680px) {
  712. .app {
  713. display: block;
  714. border-radius: 0;
  715. }
  716. .sidebar {
  717. display: none;
  718. }
  719. .main {
  720. padding: 30px 20px;
  721. }
  722. .description-row {
  723. margin-top: 30px;
  724. }
  725. .scope-note {
  726. display: none;
  727. }
  728. .backdrop {
  729. align-items: stretch;
  730. padding: 0;
  731. }
  732. .review-dialog {
  733. width: 100%;
  734. max-height: none;
  735. border-radius: 0;
  736. }
  737. .hook-line {
  738. grid-template-columns: minmax(0, 1fr) auto auto auto;
  739. }
  740. .row-icon-button.external-link {
  741. display: none;
  742. }
  743. .hook-details {
  744. margin-left: 12px;
  745. }
  746. .footer-actions {
  747. align-items: stretch;
  748. flex-direction: column;
  749. }
  750. .button {
  751. width: 100%;
  752. }
  753. }
  754. </style>
  755. </head>
  756. <body>
  757. <div class="archive-notice">
  758. 历史交互原型:其中批量信任、本次授权、状态徽章和撤销交互已不再生效。现行设计见
  759. workspace-hook-trust-persistent-only.md:未信任行只在配置开关左侧显示“信任”,成功后按钮消失。
  760. </div>
  761. <svg width="0" height="0" style="position: absolute" aria-hidden="true">
  762. <symbol id="i-arrow-left" viewBox="0 0 24 24">
  763. <path d="m15 18-6-6 6-6" />
  764. </symbol>
  765. <symbol id="i-search" viewBox="0 0 24 24">
  766. <circle cx="11" cy="11" r="7" />
  767. <path d="m20 20-4-4" />
  768. </symbol>
  769. <symbol id="i-settings" viewBox="0 0 24 24">
  770. <circle cx="12" cy="12" r="3" />
  771. <path
  772. d="M19.4 15a1.7 1.7 0 0 0 .34 1.88l.06.06-2.83 2.83-.06-.06a1.7 1.7 0 0 0-1.88-.34 1.7 1.7 0 0 0-1.03 1.56V21h-4v-.08A1.7 1.7 0 0 0 8.97 19.4a1.7 1.7 0 0 0-1.88.34l-.06.06-2.83-2.83.06-.06A1.7 1.7 0 0 0 4.6 15a1.7 1.7 0 0 0-1.56-1.03H3v-4h.08A1.7 1.7 0 0 0 4.6 8.97a1.7 1.7 0 0 0-.34-1.88l-.06-.06L7.03 4.2l.06.06A1.7 1.7 0 0 0 8.97 4.6 1.7 1.7 0 0 0 10 3.04V3h4v.08a1.7 1.7 0 0 0 1.03 1.52 1.7 1.7 0 0 0 1.88-.34l.06-.06 2.83 2.83-.06.06a1.7 1.7 0 0 0-.34 1.88A1.7 1.7 0 0 0 20.96 10H21v4h-.08A1.7 1.7 0 0 0 19.4 15Z"
  773. />
  774. </symbol>
  775. <symbol id="i-sun" viewBox="0 0 24 24">
  776. <circle cx="12" cy="12" r="4" />
  777. <path
  778. d="M12 2v2M12 20v2M4.93 4.93l1.42 1.42M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.42-1.42M17.66 6.34l1.41-1.41"
  779. />
  780. </symbol>
  781. <symbol id="i-box" viewBox="0 0 24 24">
  782. <rect x="3" y="4" width="18" height="16" rx="3" />
  783. <path d="M3 9h18M8 14h.01" />
  784. </symbol>
  785. <symbol id="i-globe" viewBox="0 0 24 24">
  786. <circle cx="12" cy="12" r="9" />
  787. <path
  788. d="M3 12h18M12 3c2.5 2.7 3.5 5.7 3.5 9S14.5 18.3 12 21c-2.5-2.7-3.5-5.7-3.5-9S9.5 5.7 12 3Z"
  789. />
  790. </symbol>
  791. <symbol id="i-plug" viewBox="0 0 24 24">
  792. <path d="M8 12V5M16 12V5M6 8h12v4a6 6 0 0 1-12 0V8ZM12 18v3" />
  793. </symbol>
  794. <symbol id="i-command" viewBox="0 0 24 24">
  795. <path d="m4 17 5-5-5-5M11 19h9" />
  796. </symbol>
  797. <symbol id="i-hook" viewBox="0 0 24 24">
  798. <path d="M12 3v11a5 5 0 0 1-10 0v-1M12 8h4a4 4 0 1 1 0 8h-1" />
  799. <circle cx="12" cy="3" r="1" />
  800. </symbol>
  801. <symbol id="i-chart" viewBox="0 0 24 24">
  802. <path d="M4 20V10M10 20V4M16 20v-7M22 20H2" />
  803. </symbol>
  804. <symbol id="i-user" viewBox="0 0 24 24">
  805. <circle cx="12" cy="8" r="4" />
  806. <path d="M4 21a8 8 0 0 1 16 0" />
  807. </symbol>
  808. <symbol id="i-folder" viewBox="0 0 24 24">
  809. <path d="M3 6a2 2 0 0 1 2-2h5l2 2h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6Z" />
  810. </symbol>
  811. <symbol id="i-info" viewBox="0 0 24 24">
  812. <circle cx="12" cy="12" r="9" />
  813. <path d="M12 11v5M12 8h.01" />
  814. </symbol>
  815. <symbol id="i-plus" viewBox="0 0 24 24">
  816. <path d="M12 5v14M5 12h14" />
  817. </symbol>
  818. <symbol id="i-refresh" viewBox="0 0 24 24">
  819. <path
  820. d="M20 7v5h-5M4 17v-5h5M6.1 8a7 7 0 0 1 11.4-2.4L20 8M4 16l2.5 2.4A7 7 0 0 0 17.9 16"
  821. />
  822. </symbol>
  823. <symbol id="i-close" viewBox="0 0 24 24">
  824. <path d="m6 6 12 12M18 6 6 18" />
  825. </symbol>
  826. <symbol id="i-warning" viewBox="0 0 24 24">
  827. <circle cx="12" cy="12" r="9" />
  828. <path d="M12 7v6M12 17h.01" />
  829. </symbol>
  830. <symbol id="i-check" viewBox="0 0 24 24">
  831. <circle cx="12" cy="12" r="9" />
  832. <path d="m8 12 2.5 2.5L16 9" />
  833. </symbol>
  834. <symbol id="i-shield" viewBox="0 0 24 24">
  835. <path d="M12 3 20 6v6c0 4.8-3.3 7.8-8 9-4.7-1.2-8-4.2-8-9V6l8-3Z" />
  836. <path d="m9 12 2 2 4-4" />
  837. </symbol>
  838. <symbol id="i-chevron-right" viewBox="0 0 24 24">
  839. <path d="m9 18 6-6-6-6" />
  840. </symbol>
  841. <symbol id="i-chevron-down" viewBox="0 0 24 24">
  842. <path d="m6 9 6 6 6-6" />
  843. </symbol>
  844. <symbol id="i-external" viewBox="0 0 24 24">
  845. <path d="M14 4h6v6M20 4l-9 9" />
  846. <path d="M18 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h5" />
  847. </symbol>
  848. </svg>
  849. <div class="app">
  850. <aside class="sidebar" aria-label="设置导航">
  851. <div class="window-controls" aria-hidden="true">
  852. <span></span><span></span><span></span>
  853. </div>
  854. <div class="back-link">
  855. <svg class="icon"><use href="#i-arrow-left"></use></svg>
  856. 返回工作区
  857. </div>
  858. <div class="sidebar-search">
  859. <svg class="icon"><use href="#i-search"></use></svg>
  860. <input type="text" placeholder="搜索设置..." aria-label="搜索设置" />
  861. </div>
  862. <nav>
  863. <section class="nav-section">
  864. <div class="nav-heading">基础设置</div>
  865. <button class="nav-item">
  866. <svg class="icon"><use href="#i-settings"></use></svg>常规
  867. </button>
  868. <button class="nav-item">
  869. <svg class="icon"><use href="#i-sun"></use></svg>外观
  870. </button>
  871. <button class="nav-item">
  872. <svg class="icon"><use href="#i-box"></use></svg>模型设置
  873. </button>
  874. <button class="nav-item">
  875. <svg class="icon"><use href="#i-globe"></use></svg>浏览器
  876. </button>
  877. </section>
  878. <section class="nav-section">
  879. <div class="nav-heading">Agent 能力</div>
  880. <button class="nav-item">
  881. <svg class="icon"><use href="#i-plug"></use></svg>插件
  882. </button>
  883. <button class="nav-item">
  884. <svg class="icon"><use href="#i-box"></use></svg>技能
  885. </button>
  886. <button class="nav-item">
  887. <svg class="icon"><use href="#i-command"></use></svg>命令
  888. </button>
  889. <button class="nav-item active">
  890. <svg class="icon"><use href="#i-hook"></use></svg>钩子
  891. </button>
  892. </section>
  893. <section class="nav-section">
  894. <div class="nav-heading">数据与统计</div>
  895. <button class="nav-item">
  896. <svg class="icon"><use href="#i-shield"></use></svg>索引库
  897. </button>
  898. <button class="nav-item">
  899. <svg class="icon"><use href="#i-chart"></use></svg>使用统计
  900. </button>
  901. </section>
  902. </nav>
  903. </aside>
  904. <main class="main">
  905. <div class="main-inner">
  906. <div class="page-heading-row">
  907. <h1 class="page-title">钩子</h1>
  908. <div class="icon-buttons">
  909. <button class="icon-button" aria-label="添加钩子">
  910. <svg class="icon"><use href="#i-plus"></use></svg>
  911. </button>
  912. <button class="icon-button" id="resetButton" aria-label="重置演示">
  913. <svg class="icon"><use href="#i-refresh"></use></svg>
  914. </button>
  915. </div>
  916. </div>
  917. <div class="description-row">
  918. <span>管理任务生命周期钩子,在特定事件发生时自动执行命令。</span>
  919. </div>
  920. <div class="page-search">
  921. <svg class="icon"><use href="#i-search"></use></svg>
  922. <input id="hookSearch" type="search" placeholder="搜索钩子..." aria-label="搜索钩子" />
  923. </div>
  924. <div class="tab-row">
  925. <div class="tabs" role="tablist" aria-label="Hook 配置范围">
  926. <button class="tab" id="userTab" role="tab" aria-selected="false">
  927. <svg class="icon"><use href="#i-user"></use></svg>用户
  928. </button>
  929. <button class="tab active" id="workspaceTab" role="tab" aria-selected="true">
  930. <svg class="icon"><use href="#i-folder"></use></svg>工作区
  931. </button>
  932. </div>
  933. <div class="scope-note">
  934. <svg class="icon"><use href="#i-info"></use></svg>
  935. Hook 配置变更将在新任务中生效。
  936. </div>
  937. </div>
  938. <button class="review-summary" id="reviewSummary" data-state="pending">
  939. <div class="review-summary-main">
  940. <svg class="icon status-icon" id="summaryIcon"><use href="#i-warning"></use></svg>
  941. <div class="review-summary-copy">
  942. <strong id="summaryTitle">3 项待审核</strong>
  943. <span id="summaryDescription">工作区 Hook 在获得信任前不会执行</span>
  944. </div>
  945. </div>
  946. <div class="review-summary-side">
  947. <span id="summaryCount">查看</span>
  948. <svg class="icon"><use href="#i-chevron-right"></use></svg>
  949. </div>
  950. </button>
  951. <div class="empty-state" id="userEmpty">暂无用户级钩子配置</div>
  952. </div>
  953. </main>
  954. </div>
  955. <div
  956. class="backdrop open"
  957. id="backdrop"
  958. role="dialog"
  959. aria-modal="true"
  960. aria-labelledby="dialogTitle"
  961. >
  962. <section class="review-dialog">
  963. <header class="dialog-header">
  964. <div>
  965. <div class="dialog-title-row">
  966. <svg class="icon"><use href="#i-settings"></use></svg>
  967. <h2 class="dialog-title" id="dialogTitle">工作区配置</h2>
  968. </div>
  969. <p class="dialog-subtitle">/Users/dev/workspace/z-code</p>
  970. </div>
  971. <button class="icon-button" id="closeDialogButton" aria-label="关闭审核窗口">
  972. <svg class="icon"><use href="#i-close"></use></svg>
  973. </button>
  974. </header>
  975. <div class="warning" id="warningBanner">
  976. <svg class="icon"><use href="#i-warning"></use></svg>
  977. <span id="warningText"
  978. >Hook 可在沙盒外运行,因此请审查此工作区最近安装或修改的所有 Hook。</span
  979. >
  980. </div>
  981. <div class="hook-list" id="hookList"></div>
  982. <footer class="dialog-footer">
  983. <div>
  984. <div class="waiting-note" id="waitingNote">
  985. <span class="waiting-dot"></span>
  986. <span>当前任务正在等待 Hook 信任决定</span>
  987. </div>
  988. <button class="text-button" id="simulateChangeButton">模拟 Hook 配置发生变化</button>
  989. </div>
  990. <div class="footer-actions">
  991. <button class="button" id="continueBlockedButton">保持屏蔽并继续</button>
  992. <button class="button" id="allowOnceButton">仅允许当前任务</button>
  993. <button class="button primary" id="trustAllButton">信任全部</button>
  994. </div>
  995. </footer>
  996. </section>
  997. </div>
  998. <div class="toast" id="toast" role="status" aria-live="polite"></div>
  999. <script>
  1000. const ICON = (name) => `<svg class="icon"><use href="#i-${name}"></use></svg>`;
  1001. const initialHooks = () => [
  1002. {
  1003. id: "session-start",
  1004. event: "SessionStart",
  1005. eventDescription: "当新任务开始时",
  1006. name: "加载工作区上下文",
  1007. handler: "命令",
  1008. command: ".zcode/hooks/session-start.sh",
  1009. timeout: "30 秒",
  1010. source: ".zcode/config.json",
  1011. trusted: false,
  1012. once: false,
  1013. enabled: true,
  1014. expanded: true,
  1015. },
  1016. {
  1017. id: "pre-tool-use",
  1018. event: "PreToolUse",
  1019. eventDescription: "工具执行前",
  1020. name: "检查高风险命令",
  1021. handler: "命令",
  1022. command: ".zcode/hooks/pre-tool-use.sh",
  1023. timeout: "10 秒",
  1024. source: ".zcode/config.json",
  1025. trusted: false,
  1026. once: false,
  1027. enabled: true,
  1028. expanded: false,
  1029. },
  1030. {
  1031. id: "post-tool-use",
  1032. event: "PostToolUse",
  1033. eventDescription: "工具执行后",
  1034. name: "记录工具执行结果",
  1035. handler: "命令",
  1036. command: ".zcode/hooks/post-tool-use.sh",
  1037. timeout: "10 秒",
  1038. source: ".zcode/config.json",
  1039. trusted: false,
  1040. once: false,
  1041. enabled: true,
  1042. expanded: false,
  1043. },
  1044. ];
  1045. let hooks = initialHooks();
  1046. let scope = "workspace";
  1047. let taskWaiting = true;
  1048. let modalOpen = true;
  1049. let searchQuery = "";
  1050. let toastTimer;
  1051. const byId = (id) => document.getElementById(id);
  1052. function effectiveState(hook) {
  1053. if (!hook.enabled) return "disabled";
  1054. if (hook.trusted) return "trusted";
  1055. if (hook.once) return "once";
  1056. return "pending";
  1057. }
  1058. function pendingHooks() {
  1059. return hooks.filter((hook) => hook.enabled && !hook.trusted && !hook.once);
  1060. }
  1061. function showToast(message) {
  1062. const toast = byId("toast");
  1063. toast.textContent = message;
  1064. toast.classList.add("show");
  1065. clearTimeout(toastTimer);
  1066. toastTimer = setTimeout(() => toast.classList.remove("show"), 1900);
  1067. }
  1068. function renderMain() {
  1069. const pending = pendingHooks().length;
  1070. const enabled = hooks.filter((hook) => hook.enabled).length;
  1071. const allTrusted =
  1072. enabled > 0 && hooks.filter((hook) => hook.enabled && hook.trusted).length === enabled;
  1073. const hasOnce = hooks.some((hook) => hook.once && !hook.trusted);
  1074. const summary = byId("reviewSummary");
  1075. if (allTrusted) {
  1076. summary.dataset.state = "trusted";
  1077. byId("summaryIcon").innerHTML = '<use href="#i-check"></use>';
  1078. byId("summaryTitle").textContent = `${enabled} 项已审核`;
  1079. byId("summaryDescription").textContent = "当前 Hook 声明已获得工作区信任";
  1080. byId("summaryCount").textContent = "管理";
  1081. } else if (hasOnce && pending === 0) {
  1082. summary.dataset.state = "pending";
  1083. byId("summaryIcon").innerHTML = '<use href="#i-warning"></use>';
  1084. byId("summaryTitle").textContent = "当前任务已临时允许";
  1085. byId("summaryDescription").textContent = "下一任务仍需重新审核这些 Hook";
  1086. byId("summaryCount").textContent = "查看";
  1087. } else {
  1088. summary.dataset.state = "pending";
  1089. byId("summaryIcon").innerHTML = '<use href="#i-warning"></use>';
  1090. byId("summaryTitle").textContent = `${pending} 项待审核`;
  1091. byId("summaryDescription").textContent = taskWaiting
  1092. ? "当前任务正在等待;未信任的 Hook 保持屏蔽"
  1093. : "工作区 Hook 在获得信任前不会执行";
  1094. byId("summaryCount").textContent = "查看";
  1095. }
  1096. }
  1097. function renderHooks() {
  1098. const normalized = searchQuery.trim().toLowerCase();
  1099. const visibleHooks = hooks.filter((hook) => {
  1100. if (!normalized) return true;
  1101. return [hook.event, hook.eventDescription, hook.name, hook.command]
  1102. .join(" ")
  1103. .toLowerCase()
  1104. .includes(normalized);
  1105. });
  1106. byId("hookList").innerHTML = visibleHooks.length
  1107. ? visibleHooks
  1108. .map((hook) => {
  1109. const state = effectiveState(hook);
  1110. const trustLabel = hook.trusted ? "已信任" : hook.once ? "本次已允许" : "信任";
  1111. const statusIcon =
  1112. state === "trusted" ? "check" : state === "once" ? "check" : "warning";
  1113. return `
  1114. <section class="event-group ${state}" data-hook-id="${hook.id}">
  1115. <header class="event-header">
  1116. <div class="event-name">
  1117. ${ICON("hook")}
  1118. <div class="event-copy">
  1119. <strong>${hook.event}</strong>
  1120. <span>${hook.eventDescription}</span>
  1121. </div>
  1122. </div>
  1123. <svg class="icon event-status"><use href="#i-${statusIcon}"></use></svg>
  1124. </header>
  1125. <div class="hook-item ${hook.expanded ? "expanded" : ""}">
  1126. <div class="hook-line">
  1127. <button class="hook-name-button" data-action="expand" data-id="${hook.id}">
  1128. <span class="hook-name">${hook.name}</span>
  1129. </button>
  1130. <button class="row-icon-button external-link" aria-label="查看来源" data-action="source" data-id="${hook.id}">
  1131. ${ICON("external")}
  1132. </button>
  1133. <button class="row-icon-button" aria-label="展开详情" data-action="expand" data-id="${hook.id}">
  1134. ${ICON(hook.expanded ? "chevron-down" : "chevron-right")}
  1135. </button>
  1136. <button class="trust-button ${state}" data-action="trust" data-id="${hook.id}">
  1137. ${ICON("shield")}<span>${trustLabel}</span>
  1138. </button>
  1139. <label class="switch" aria-label="启用 ${hook.name}">
  1140. <input type="checkbox" data-action="toggle" data-id="${hook.id}" ${hook.enabled ? "checked" : ""} />
  1141. <span class="switch-track"></span>
  1142. </label>
  1143. </div>
  1144. <div class="hook-details">
  1145. <div class="detail-grid">
  1146. <span class="detail-label">处理程序</span><span class="detail-value">${hook.handler}</span>
  1147. <span class="detail-label">命令</span><span class="detail-value"><code>${hook.command}</code></span>
  1148. <span class="detail-label">超时</span><span class="detail-value">${hook.timeout}</span>
  1149. <span class="detail-label">来源</span><span class="detail-value"><code>${hook.source}</code></span>
  1150. </div>
  1151. <div class="detail-foot">
  1152. <span>信任与当前工作区及 Hook 声明绑定;命令变化后需要重新审核。</span>
  1153. ${
  1154. !hook.trusted && taskWaiting
  1155. ? `<button class="text-button" data-action="allow-once" data-id="${hook.id}">${hook.once ? "撤销本次允许" : "仅允许此 Hook 用于当前任务"}</button>`
  1156. : ""
  1157. }
  1158. </div>
  1159. </div>
  1160. </div>
  1161. </section>`;
  1162. })
  1163. .join("")
  1164. : '<div class="empty-state" style="display:flex;border:0">没有匹配的 Hook</div>';
  1165. const pending = pendingHooks().length;
  1166. const allReviewed = hooks
  1167. .filter((hook) => hook.enabled)
  1168. .every((hook) => hook.trusted || hook.once);
  1169. byId("warningText").textContent = allReviewed
  1170. ? "当前启用的 Hook 已完成本次审核。配置内容变化后将重新要求信任。"
  1171. : "Hook 可在沙盒外运行,因此请审查此工作区最近安装或修改的所有 Hook。";
  1172. byId("waitingNote").style.visibility = taskWaiting ? "visible" : "hidden";
  1173. byId("allowOnceButton").disabled = !taskWaiting || pending === 0;
  1174. byId("trustAllButton").disabled =
  1175. hooks.filter((hook) => hook.enabled && !hook.trusted).length === 0;
  1176. }
  1177. function renderScope() {
  1178. const isWorkspace = scope === "workspace";
  1179. byId("workspaceTab").classList.toggle("active", isWorkspace);
  1180. byId("workspaceTab").setAttribute("aria-selected", String(isWorkspace));
  1181. byId("userTab").classList.toggle("active", !isWorkspace);
  1182. byId("userTab").setAttribute("aria-selected", String(!isWorkspace));
  1183. byId("reviewSummary").style.display = isWorkspace ? "flex" : "none";
  1184. byId("userEmpty").style.display = isWorkspace ? "none" : "flex";
  1185. byId("backdrop").classList.toggle("open", modalOpen && isWorkspace);
  1186. }
  1187. function render() {
  1188. renderMain();
  1189. renderHooks();
  1190. renderScope();
  1191. }
  1192. function closeDialog() {
  1193. modalOpen = false;
  1194. renderScope();
  1195. }
  1196. function openDialog() {
  1197. if (scope !== "workspace") return;
  1198. modalOpen = true;
  1199. renderScope();
  1200. }
  1201. function trustHook(id) {
  1202. const hook = hooks.find((item) => item.id === id);
  1203. if (!hook) return;
  1204. hook.trusted = !hook.trusted;
  1205. hook.once = false;
  1206. if (hook.trusted && taskWaiting && pendingHooks().length === 0) {
  1207. taskWaiting = false;
  1208. showToast("审核完成,当前任务继续执行");
  1209. } else {
  1210. showToast(hook.trusted ? `已信任「${hook.name}」` : `已撤销「${hook.name}」的信任`);
  1211. }
  1212. render();
  1213. }
  1214. function allowHookOnce(id) {
  1215. const hook = hooks.find((item) => item.id === id);
  1216. if (!hook || !taskWaiting || hook.trusted) return;
  1217. hook.once = !hook.once;
  1218. if (hook.once && pendingHooks().length === 0) {
  1219. taskWaiting = false;
  1220. showToast("本次审核完成,当前任务继续执行");
  1221. } else {
  1222. showToast(
  1223. hook.once ? `当前任务已允许「${hook.name}」` : `已撤销「${hook.name}」的本次允许`,
  1224. );
  1225. }
  1226. render();
  1227. }
  1228. function toggleHook(id, enabled) {
  1229. const hook = hooks.find((item) => item.id === id);
  1230. if (!hook) return;
  1231. hook.enabled = enabled;
  1232. if (!enabled) hook.once = false;
  1233. showToast(enabled ? `已启用「${hook.name}」` : `已停用「${hook.name}」`);
  1234. render();
  1235. }
  1236. byId("hookList").addEventListener("click", (event) => {
  1237. const control = event.target.closest("[data-action]");
  1238. if (!control) return;
  1239. const id = control.dataset.id;
  1240. const hook = hooks.find((item) => item.id === id);
  1241. if (!hook) return;
  1242. if (control.dataset.action === "expand") {
  1243. hook.expanded = !hook.expanded;
  1244. renderHooks();
  1245. } else if (control.dataset.action === "trust") {
  1246. trustHook(id);
  1247. } else if (control.dataset.action === "allow-once") {
  1248. allowHookOnce(id);
  1249. } else if (control.dataset.action === "source") {
  1250. showToast(`来源:${hook.source}`);
  1251. }
  1252. });
  1253. byId("hookList").addEventListener("change", (event) => {
  1254. const control = event.target.closest('[data-action="toggle"]');
  1255. if (control) toggleHook(control.dataset.id, control.checked);
  1256. });
  1257. byId("reviewSummary").addEventListener("click", openDialog);
  1258. byId("closeDialogButton").addEventListener("click", closeDialog);
  1259. byId("backdrop").addEventListener("click", (event) => {
  1260. if (event.target === byId("backdrop")) closeDialog();
  1261. });
  1262. byId("userTab").addEventListener("click", () => {
  1263. scope = "user";
  1264. modalOpen = false;
  1265. renderScope();
  1266. });
  1267. byId("workspaceTab").addEventListener("click", () => {
  1268. scope = "workspace";
  1269. renderScope();
  1270. });
  1271. byId("hookSearch").addEventListener("input", (event) => {
  1272. searchQuery = event.target.value;
  1273. if (scope === "workspace" && searchQuery.trim()) modalOpen = true;
  1274. render();
  1275. });
  1276. byId("continueBlockedButton").addEventListener("click", () => {
  1277. taskWaiting = false;
  1278. hooks.forEach((hook) => (hook.once = false));
  1279. modalOpen = false;
  1280. showToast("任务已继续;未信任的 Hook 保持屏蔽");
  1281. render();
  1282. });
  1283. byId("allowOnceButton").addEventListener("click", () => {
  1284. hooks.forEach((hook) => {
  1285. if (hook.enabled && !hook.trusted) hook.once = true;
  1286. });
  1287. taskWaiting = false;
  1288. modalOpen = false;
  1289. showToast("仅为当前任务允许这些 Hook");
  1290. render();
  1291. });
  1292. byId("trustAllButton").addEventListener("click", () => {
  1293. hooks.forEach((hook) => {
  1294. if (hook.enabled) hook.trusted = true;
  1295. hook.once = false;
  1296. });
  1297. taskWaiting = false;
  1298. modalOpen = false;
  1299. showToast("已信任当前工作区的 Hook 声明");
  1300. render();
  1301. });
  1302. byId("simulateChangeButton").addEventListener("click", () => {
  1303. const changed = hooks[0];
  1304. changed.command = changed.command.includes("--strict")
  1305. ? ".zcode/hooks/session-start.sh"
  1306. : ".zcode/hooks/session-start.sh --strict";
  1307. changed.trusted = false;
  1308. changed.once = false;
  1309. changed.enabled = true;
  1310. changed.expanded = true;
  1311. taskWaiting = true;
  1312. showToast("SessionStart 命令已变化,需要重新审核");
  1313. render();
  1314. });
  1315. byId("resetButton").addEventListener("click", () => {
  1316. hooks = initialHooks();
  1317. scope = "workspace";
  1318. taskWaiting = true;
  1319. modalOpen = true;
  1320. searchQuery = "";
  1321. byId("hookSearch").value = "";
  1322. showToast("演示已重置");
  1323. render();
  1324. });
  1325. render();
  1326. </script>
  1327. </body>
  1328. </html>