浏览代码

chore: generate

opencode-agent[bot] 4 月之前
父节点
当前提交
6f7d63e9ce
共有 2 个文件被更改,包括 143 次插入140 次删除
  1. 133 133
      packages/app/src/components/titlebar.tsx
  2. 10 7
      packages/desktop-electron/src/renderer/webview-zoom.ts

+ 133 - 133
packages/app/src/components/titlebar.tsx

@@ -185,151 +185,151 @@ export function Titlebar() {
         class="grid h-full min-h-full w-full grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center"
         style={{ zoom: counterZoom() }}
       >
-      <div
-        classList={{
-          "flex items-center min-w-0": true,
-          "pl-2": !mac(),
-        }}
-      >
-        <Show when={mac()}>
-          <div class="h-full shrink-0" style={{ width: `${72 / zoom()}px` }} />
-          <div class="xl:hidden w-10 shrink-0 flex items-center justify-center">
-            <IconButton
-              icon="menu"
-              variant="ghost"
-              class="titlebar-icon rounded-md"
-              onClick={layout.mobileSidebar.toggle}
-              aria-label={language.t("sidebar.menu.toggle")}
-              aria-expanded={layout.mobileSidebar.opened()}
-            />
-          </div>
-        </Show>
-        <Show when={!mac()}>
-          <div class="xl:hidden w-[48px] shrink-0 flex items-center justify-center">
-            <IconButton
-              icon="menu"
-              variant="ghost"
-              class="titlebar-icon rounded-md"
-              onClick={layout.mobileSidebar.toggle}
-              aria-label={language.t("sidebar.menu.toggle")}
-              aria-expanded={layout.mobileSidebar.opened()}
-            />
-          </div>
-        </Show>
-        <div class="flex items-center gap-1 shrink-0">
-          <TooltipKeybind
-            class={web() ? "hidden xl:flex shrink-0 ml-14" : "hidden xl:flex shrink-0 ml-2"}
-            placement="bottom"
-            title={language.t("command.sidebar.toggle")}
-            keybind={command.keybind("sidebar.toggle")}
-          >
-            <Button
-              variant="ghost"
-              class="group/sidebar-toggle titlebar-icon w-8 h-6 p-0 box-border"
-              onClick={layout.sidebar.toggle}
-              aria-label={language.t("command.sidebar.toggle")}
-              aria-expanded={layout.sidebar.opened()}
+        <div
+          classList={{
+            "flex items-center min-w-0": true,
+            "pl-2": !mac(),
+          }}
+        >
+          <Show when={mac()}>
+            <div class="h-full shrink-0" style={{ width: `${72 / zoom()}px` }} />
+            <div class="xl:hidden w-10 shrink-0 flex items-center justify-center">
+              <IconButton
+                icon="menu"
+                variant="ghost"
+                class="titlebar-icon rounded-md"
+                onClick={layout.mobileSidebar.toggle}
+                aria-label={language.t("sidebar.menu.toggle")}
+                aria-expanded={layout.mobileSidebar.opened()}
+              />
+            </div>
+          </Show>
+          <Show when={!mac()}>
+            <div class="xl:hidden w-[48px] shrink-0 flex items-center justify-center">
+              <IconButton
+                icon="menu"
+                variant="ghost"
+                class="titlebar-icon rounded-md"
+                onClick={layout.mobileSidebar.toggle}
+                aria-label={language.t("sidebar.menu.toggle")}
+                aria-expanded={layout.mobileSidebar.opened()}
+              />
+            </div>
+          </Show>
+          <div class="flex items-center gap-1 shrink-0">
+            <TooltipKeybind
+              class={web() ? "hidden xl:flex shrink-0 ml-14" : "hidden xl:flex shrink-0 ml-2"}
+              placement="bottom"
+              title={language.t("command.sidebar.toggle")}
+              keybind={command.keybind("sidebar.toggle")}
             >
-              <Icon size="small" name={layout.sidebar.opened() ? "sidebar-active" : "sidebar"} />
-            </Button>
-          </TooltipKeybind>
-          <div class="hidden xl:flex items-center shrink-0">
-            <Show when={params.dir}>
-              <div
-                class="flex items-center shrink-0 w-8 mr-1"
-                aria-hidden={layout.sidebar.opened() ? "true" : undefined}
+              <Button
+                variant="ghost"
+                class="group/sidebar-toggle titlebar-icon w-8 h-6 p-0 box-border"
+                onClick={layout.sidebar.toggle}
+                aria-label={language.t("command.sidebar.toggle")}
+                aria-expanded={layout.sidebar.opened()}
               >
+                <Icon size="small" name={layout.sidebar.opened() ? "sidebar-active" : "sidebar"} />
+              </Button>
+            </TooltipKeybind>
+            <div class="hidden xl:flex items-center shrink-0">
+              <Show when={params.dir}>
                 <div
-                  class="transition-opacity"
-                  classList={{
-                    "opacity-100 duration-120 ease-out": !layout.sidebar.opened(),
-                    "opacity-0 duration-120 ease-in delay-0 pointer-events-none": layout.sidebar.opened(),
-                  }}
+                  class="flex items-center shrink-0 w-8 mr-1"
+                  aria-hidden={layout.sidebar.opened() ? "true" : undefined}
                 >
-                  <TooltipKeybind
-                    placement="bottom"
-                    title={language.t("command.session.new")}
-                    keybind={command.keybind("session.new")}
-                    openDelay={2000}
+                  <div
+                    class="transition-opacity"
+                    classList={{
+                      "opacity-100 duration-120 ease-out": !layout.sidebar.opened(),
+                      "opacity-0 duration-120 ease-in delay-0 pointer-events-none": layout.sidebar.opened(),
+                    }}
                   >
-                    <Button
-                      variant="ghost"
-                      icon={creating() ? "new-session-active" : "new-session"}
-                      class="titlebar-icon w-8 h-6 p-0 box-border"
-                      disabled={layout.sidebar.opened()}
-                      tabIndex={layout.sidebar.opened() ? -1 : undefined}
-                      onClick={() => {
-                        if (!params.dir) return
-                        navigate(`/${params.dir}/session`)
-                      }}
-                      aria-label={language.t("command.session.new")}
-                      aria-current={creating() ? "page" : undefined}
-                    />
-                  </TooltipKeybind>
-                </div>
-              </div>
-            </Show>
-            <div
-              class="flex items-center shrink-0"
-              classList={{
-                "-translate-x-[36px]": layout.sidebar.opened() && !!params.dir,
-                "duration-180 ease-out": !layout.sidebar.opened(),
-                "duration-180 ease-in": layout.sidebar.opened(),
-              }}
-            >
-              <Show when={hasProjects() && nav()}>
-                <div class="flex items-center gap-0 transition-transform">
-                  <Tooltip placement="bottom" value={language.t("common.goBack")} openDelay={2000}>
-                    <Button
-                      variant="ghost"
-                      icon="chevron-left"
-                      class="titlebar-icon w-6 h-6 p-0 box-border"
-                      disabled={!canBack()}
-                      onClick={back}
-                      aria-label={language.t("common.goBack")}
-                    />
-                  </Tooltip>
-                  <Tooltip placement="bottom" value={language.t("common.goForward")} openDelay={2000}>
-                    <Button
-                      variant="ghost"
-                      icon="chevron-right"
-                      class="titlebar-icon w-6 h-6 p-0 box-border"
-                      disabled={!canForward()}
-                      onClick={forward}
-                      aria-label={language.t("common.goForward")}
-                    />
-                  </Tooltip>
+                    <TooltipKeybind
+                      placement="bottom"
+                      title={language.t("command.session.new")}
+                      keybind={command.keybind("session.new")}
+                      openDelay={2000}
+                    >
+                      <Button
+                        variant="ghost"
+                        icon={creating() ? "new-session-active" : "new-session"}
+                        class="titlebar-icon w-8 h-6 p-0 box-border"
+                        disabled={layout.sidebar.opened()}
+                        tabIndex={layout.sidebar.opened() ? -1 : undefined}
+                        onClick={() => {
+                          if (!params.dir) return
+                          navigate(`/${params.dir}/session`)
+                        }}
+                        aria-label={language.t("command.session.new")}
+                        aria-current={creating() ? "page" : undefined}
+                      />
+                    </TooltipKeybind>
+                  </div>
                 </div>
               </Show>
-              <div id="opencode-titlebar-left" class="flex items-center gap-3 min-w-0 px-2" />
-              {["beta", "dev"].includes(import.meta.env.VITE_OPENCODE_CHANNEL) && (
-                <div class="bg-icon-interactive-base text-[#FFF] font-medium px-2 rounded-sm uppercase font-mono">
-                  {import.meta.env.VITE_OPENCODE_CHANNEL.toUpperCase()}
-                </div>
-              )}
+              <div
+                class="flex items-center shrink-0"
+                classList={{
+                  "-translate-x-[36px]": layout.sidebar.opened() && !!params.dir,
+                  "duration-180 ease-out": !layout.sidebar.opened(),
+                  "duration-180 ease-in": layout.sidebar.opened(),
+                }}
+              >
+                <Show when={hasProjects() && nav()}>
+                  <div class="flex items-center gap-0 transition-transform">
+                    <Tooltip placement="bottom" value={language.t("common.goBack")} openDelay={2000}>
+                      <Button
+                        variant="ghost"
+                        icon="chevron-left"
+                        class="titlebar-icon w-6 h-6 p-0 box-border"
+                        disabled={!canBack()}
+                        onClick={back}
+                        aria-label={language.t("common.goBack")}
+                      />
+                    </Tooltip>
+                    <Tooltip placement="bottom" value={language.t("common.goForward")} openDelay={2000}>
+                      <Button
+                        variant="ghost"
+                        icon="chevron-right"
+                        class="titlebar-icon w-6 h-6 p-0 box-border"
+                        disabled={!canForward()}
+                        onClick={forward}
+                        aria-label={language.t("common.goForward")}
+                      />
+                    </Tooltip>
+                  </div>
+                </Show>
+                <div id="opencode-titlebar-left" class="flex items-center gap-3 min-w-0 px-2" />
+                {["beta", "dev"].includes(import.meta.env.VITE_OPENCODE_CHANNEL) && (
+                  <div class="bg-icon-interactive-base text-[#FFF] font-medium px-2 rounded-sm uppercase font-mono">
+                    {import.meta.env.VITE_OPENCODE_CHANNEL.toUpperCase()}
+                  </div>
+                )}
+              </div>
             </div>
           </div>
         </div>
-      </div>
 
-      <div class="min-w-0 flex items-center justify-center pointer-events-none">
-        <div id="opencode-titlebar-center" class="pointer-events-auto min-w-0 flex justify-center w-fit max-w-full" />
-      </div>
+        <div class="min-w-0 flex items-center justify-center pointer-events-none">
+          <div id="opencode-titlebar-center" class="pointer-events-auto min-w-0 flex justify-center w-fit max-w-full" />
+        </div>
 
-      <div
-        classList={{
-          "flex items-center min-w-0 justify-end": true,
-          "pr-2": !windows(),
-        }}
-        data-tauri-drag-region
-        onMouseDown={drag}
-      >
-        <div id="opencode-titlebar-right" class="flex items-center gap-1 shrink-0 justify-end" />
-        <Show when={windows()}>
-          {!tauriApi() && <div class="shrink-0" style={{ width: windowsControlsWidth() }} />}
-          <div data-tauri-decorum-tb class="flex flex-row" />
-        </Show>
-      </div>
+        <div
+          classList={{
+            "flex items-center min-w-0 justify-end": true,
+            "pr-2": !windows(),
+          }}
+          data-tauri-drag-region
+          onMouseDown={drag}
+        >
+          <div id="opencode-titlebar-right" class="flex items-center gap-1 shrink-0 justify-end" />
+          <Show when={windows()}>
+            {!tauriApi() && <div class="shrink-0" style={{ width: windowsControlsWidth() }} />}
+            <div data-tauri-decorum-tb class="flex flex-row" />
+          </Show>
+        </div>
       </div>
     </header>
   )

+ 10 - 7
packages/desktop-electron/src/renderer/webview-zoom.ts

@@ -21,13 +21,16 @@ const clamp = (value: number) => Math.min(Math.max(value, MIN_ZOOM_LEVEL), MAX_Z
 
 const applyZoom = (next: number) => {
   requestedZoom = next
-  void window.api.setZoomFactor(next).then(() => {
-    if (requestedZoom !== next) return
-    setWebviewZoom(next)
-  }).catch(() => {
-    if (requestedZoom !== next) return
-    requestedZoom = webviewZoom()
-  })
+  void window.api
+    .setZoomFactor(next)
+    .then(() => {
+      if (requestedZoom !== next) return
+      setWebviewZoom(next)
+    })
+    .catch(() => {
+      if (requestedZoom !== next) return
+      requestedZoom = webviewZoom()
+    })
 }
 
 window.addEventListener("keydown", (event) => {