diff --git a/electron-builder.yml b/electron-builder.yml index a3235c8..0ccc997 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -1,5 +1,5 @@ -appId: com.electron.app -productName: my-app +appId: com.zephyr.app +productName: zephyr directories: buildResources: build files: @@ -12,7 +12,7 @@ files: asarUnpack: - resources/** win: - executableName: my-app + executableName: zephyr nsis: artifactName: ${name}-${version}-setup.${ext} shortcutName: ${productName} diff --git a/electron.vite.config.ts b/electron.vite.config.ts index cacdc3c..569abc9 100644 --- a/electron.vite.config.ts +++ b/electron.vite.config.ts @@ -25,6 +25,7 @@ export default defineConfig({ plugins: [externalizeDepsPlugin()], }, renderer: { + root: resolve(__dirname, "./src/renderer"), resolve: { alias: { config: resolve("config"), @@ -43,7 +44,7 @@ export default defineConfig({ rollupOptions: { input: { main: resolve(__dirname, "./src/renderer/index.html"), - about: resolve(__dirname, "src/renderer/about.html"), + about: resolve(__dirname, "./src/renderer/about.html"), }, }, }, diff --git a/src/main/modules/updater/index.ts b/src/main/modules/updater/index.ts index 0bb3835..7846a4e 100644 --- a/src/main/modules/updater/index.ts +++ b/src/main/modules/updater/index.ts @@ -1,8 +1,8 @@ import pkg from "electron-updater" import { app, dialog } from "electron" -import { injectable, inject } from "inversify" +import { injectable } from "inversify" import BaseClass from "main/base/base" -import { Setting } from "../setting" +// import { Setting } from "../setting" import _debug from "debug" import EventEmitter from "events" @@ -13,7 +13,9 @@ const { autoUpdater } = pkg export class Updater extends BaseClass { public events = new EventEmitter() - constructor(@inject(Setting) private _Setting: Setting) { + constructor( + // @inject(Setting) private _Setting: Setting + ) { super() // 配置自动更新 diff --git a/src/main/modules/zephyr/index.ts b/src/main/modules/zephyr/index.ts index 7f8c7c6..8f787d8 100644 --- a/src/main/modules/zephyr/index.ts +++ b/src/main/modules/zephyr/index.ts @@ -1,6 +1,5 @@ import { session, net } from "electron" -import { inject, injectable } from "inversify" -import IOC from "main/_ioc" +import { injectable } from "inversify" import BaseClass from "main/base/base" import _debug from "debug" @@ -8,10 +7,12 @@ const debug = _debug("app:zephyr") @injectable() class Zephyr extends BaseClass { - constructor(@inject(IOC) private _IOC: IOC) { + constructor( + // @inject(IOC) private _IOC: IOC + ) { super() this.interceptHandlerZephyr = this.interceptHandlerZephyr.bind(this) - debug("aaaaaaaaaaaaaaaaaaaaaa") + debug("zephyr init") } destroy() { diff --git a/src/main/utils/index.ts b/src/main/utils/index.ts index 0433eed..d0c3367 100644 --- a/src/main/utils/index.ts +++ b/src/main/utils/index.ts @@ -2,12 +2,12 @@ import { is } from "@electron-toolkit/utils" import { join } from "node:path" import { webContents } from "electron" -export function getFileUrl(app: string, route: string = "") { +export function getFileUrl(app: string) { let winURL = "" if (is.dev && process.env["ELECTRON_RENDERER_URL"]) { - winURL = process.env["ELECTRON_RENDERER_URL"] + `/${app}#/${route}` + winURL = process.env["ELECTRON_RENDERER_URL"] + `/${app}#/` } else { - winURL = join(__dirname, `../renderer/${app}#/${route}`) + winURL = join(__dirname, `../renderer/${app}#/`) } return winURL } diff --git a/src/renderer/src/assets/libs/scrollbot.ts b/src/renderer/src/assets/libs/scrollbot.ts index 6f3e62b..765657d 100644 --- a/src/renderer/src/assets/libs/scrollbot.ts +++ b/src/renderer/src/assets/libs/scrollbot.ts @@ -8,14 +8,14 @@ class Scrollbot { private scrollSpeed: number = 200 private parContent!: string private newPar!: HTMLDivElement - private sbContainer!: HTMLDivElement + // private sbContainer!: HTMLDivElement private scrollBarHolder!: HTMLDivElement private scrollBar!: HTMLDivElement private inP!: HTMLDivElement private sbHeight: number = 0 private mdown: boolean = false private customHeight: boolean = false - private scrollElement!: HTMLElement + // private scrollElement!: HTMLElement private onScrollF?: () => void private sB: ScrollStyle = {} private sBH: ScrollStyle = {} @@ -55,7 +55,7 @@ class Scrollbot { private setupElements(): void { this.newPar = document.createElement("div") - this.sbContainer = document.createElement("div") + // this.sbContainer = document.createElement("div") this.scrollBarHolder = document.createElement("div") this.scrollBar = document.createElement("div") this.inP = document.createElement("div") @@ -84,7 +84,7 @@ class Scrollbot { }px;width:100%;box-sizing:content-box;` this.sbHeight = (this.inP.clientHeight * 100) / this.inP.scrollHeight - this.scrollElement = this.inP + // this.scrollElement = this.inP this.updateScrollbarStyles() } diff --git a/src/renderer/src/components/AdjustLine.vue b/src/renderer/src/components/AdjustLine.vue index ec6cb21..ee93019 100644 --- a/src/renderer/src/components/AdjustLine.vue +++ b/src/renderer/src/components/AdjustLine.vue @@ -63,34 +63,34 @@ const currentSize = ref(props.defaultSize || 0) // 使用computed优化方向判断 const isHorizontal = computed(() => props.direction === "left" || props.direction === "right") -// 使用computed获取光标样式 -const cursorStyle = computed(() => (isHorizontal.value ? "ew-resize" : "ns-resize")) - -// 保存状态到localStorage的优化 -const storageKey = computed(() => `adjust-line-${props.mid}`) - -function saveSize(size: number) { - if (props.mid) { - try { - localStorage.setItem(storageKey.value, String(size)) - } catch (error) { - console.warn("Failed to save size to localStorage:", error) - } - } -} - -function loadSavedSize(): number | null { - if (props.mid) { - try { - const saved = localStorage.getItem(storageKey.value) - return saved ? Number(saved) : null - } catch (error) { - console.warn("Failed to load size from localStorage:", error) - return null - } - } - return null -} +// // 使用computed获取光标样式 +// const cursorStyle = computed(() => (isHorizontal.value ? "ew-resize" : "ns-resize")) + +// // 保存状态到localStorage的优化 +// const storageKey = computed(() => `adjust-line-${props.mid}`) + +// function saveSize(size: number) { +// if (props.mid) { +// try { +// localStorage.setItem(storageKey.value, String(size)) +// } catch (error) { +// console.warn("Failed to save size to localStorage:", error) +// } +// } +// } + +// function loadSavedSize(): number | null { +// if (props.mid) { +// try { +// const saved = localStorage.getItem(storageKey.value) +// return saved ? Number(saved) : null +// } catch (error) { +// console.warn("Failed to load size from localStorage:", error) +// return null +// } +// } +// return null +// } // 使用防抖优化resize事件 const emitResize = useDebounceFn((size: number) => { @@ -318,45 +318,45 @@ function handle(target: HTMLElement) { } } -function handleDrag(e: MouseEvent, target: HTMLElement) { - const startPos = isHorizontal.value ? e.clientX : e.clientY - const startSize = isHorizontal.value ? target.clientWidth : target.clientHeight - - const handleMouseMove = (e: MouseEvent) => { - const currentPos = isHorizontal.value ? e.clientX : e.clientY - const diff = props.direction === "right" || props.direction === "bottom" ? startPos - currentPos : currentPos - startPos - - let newSize = startSize - diff - - // 限制大小范围 - newSize = Math.max(props.minSize, Math.min(props.maxSize, newSize)) - - // 应用新尺寸 - if (isHorizontal.value) { - target.style.width = `${newSize}px` - } else { - target.style.height = `${newSize}px` - } - - currentSize.value = newSize - emit("resize", newSize) - } - - const handleMouseUp = () => { - document.removeEventListener("mousemove", handleMouseMove) - document.removeEventListener("mouseup", handleMouseUp) - document.body.style.userSelect = "" - isDragging.value = false - saveSize(currentSize.value) - emit("resizeEnd", currentSize.value) - } - - document.addEventListener("mousemove", handleMouseMove) - document.addEventListener("mouseup", handleMouseUp) - document.body.style.userSelect = "none" - isDragging.value = true - emit("resizeStart") -} +// function handleDrag(e: MouseEvent, target: HTMLElement) { +// const startPos = isHorizontal.value ? e.clientX : e.clientY +// const startSize = isHorizontal.value ? target.clientWidth : target.clientHeight + +// const handleMouseMove = (e: MouseEvent) => { +// const currentPos = isHorizontal.value ? e.clientX : e.clientY +// const diff = props.direction === "right" || props.direction === "bottom" ? startPos - currentPos : currentPos - startPos + +// let newSize = startSize - diff + +// // 限制大小范围 +// newSize = Math.max(props.minSize, Math.min(props.maxSize, newSize)) + +// // 应用新尺寸 +// if (isHorizontal.value) { +// target.style.width = `${newSize}px` +// } else { +// target.style.height = `${newSize}px` +// } + +// currentSize.value = newSize +// emit("resize", newSize) +// } + +// const handleMouseUp = () => { +// document.removeEventListener("mousemove", handleMouseMove) +// document.removeEventListener("mouseup", handleMouseUp) +// document.body.style.userSelect = "" +// isDragging.value = false +// saveSize(currentSize.value) +// emit("resizeEnd", currentSize.value) +// } + +// document.addEventListener("mousemove", handleMouseMove) +// document.addEventListener("mouseup", handleMouseUp) +// document.body.style.userSelect = "none" +// isDragging.value = true +// emit("resizeStart") +// } const debug = { log: (...args: any[]) => { @@ -377,6 +377,7 @@ function handleError(error: Error, context: string) { // 错误边界处理 onErrorCaptured((err, instance, info) => { handleError(err as Error, info) + console.log(instance); return false }) diff --git a/src/renderer/src/components/NavBar.vue b/src/renderer/src/components/NavBar.vue index bef06d3..312730f 100644 --- a/src/renderer/src/components/NavBar.vue +++ b/src/renderer/src/components/NavBar.vue @@ -30,6 +30,7 @@ import icon from "@res/icon.png" import config from "config" import { PopupMenu } from "@/bridge/PopupMenu" +const router = useRouter() const isFullScreen = ref(false) onBeforeMount(async () => { isFullScreen.value = await api.call("BasicCommand.isFullscreen") @@ -37,6 +38,12 @@ onBeforeMount(async () => { const onClickMenu = () => { const menu = new PopupMenu([ { + label: "返回", + async click() { + router.back() + }, + }, + { label: isFullScreen.value ? "取消全屏" : "全屏", async click() { isFullScreen.value = await api.call("BasicCommand.fullscreen") diff --git a/src/renderer/src/pages/_ui/App.vue b/src/renderer/src/pages/_ui/App.vue index 06cec19..f886cae 100644 --- a/src/renderer/src/pages/_ui/App.vue +++ b/src/renderer/src/pages/_ui/App.vue @@ -1,3 +1,10 @@ + +