Skip to content

Commit

Permalink
webview
Browse files Browse the repository at this point in the history
  • Loading branch information
caorushizi committed Jan 21, 2024
1 parent 90c6c76 commit f19cc6b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/main/src/helper/downloader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { DownloadParams } from "../../interfaces";
import { m3u8DownloaderWin32 } from "./m3u8-win32";
import { m3u8DownloaderDarwin } from "./m3u8-darwin";
import { biliDownloader } from "./bilibili";
import { isWin } from "../variables";

export const downloader = (params: DownloadParams): Promise<void> => {
if (params.type === "bilibili") {
return biliDownloader(params);
}

if (params.type === "m3u8") {
if (process.platform === "win32") {
if (isWin) {
return m3u8DownloaderWin32(params);
} else {
return m3u8DownloaderDarwin(params);
Expand Down
3 changes: 2 additions & 1 deletion packages/main/src/preload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { contextBridge, ipcRenderer, shell } from "electron";
import { contextBridge, ipcRenderer } from "electron/renderer";
import { shell } from "electron/common";
import { AppStore, BrowserStore, EnvPath } from "./main";
import { type Favorite } from "./entity/Favorite";
import {
Expand Down
5 changes: 4 additions & 1 deletion packages/main/src/services/WebviewService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TYPES } from "../types";
import isDev from "electron-is-dev";
import {
PERSIST_WEBVIEW,
isWin,
mobileUA,
pcUA,
pluginPath,
Expand Down Expand Up @@ -253,8 +254,10 @@ export default class WebviewService {
}

setBounds(bounds: Electron.Rectangle): void {
if (process.platform === "darwin") {
if (isWin) {
bounds.y = bounds.y + 30;
} else {
bounds.y = bounds.y - 0;
}
this.view.setBounds(bounds);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/main/src/windows/MainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import LoggerService from "../services/LoggerService";
import DownloadService from "../services/DownloadService";
import StoreService from "../services/StoreService";
import VideoRepository from "../repository/VideoRepository";
import { isWin } from "../helper";

@injectable()
export default class MainWindow extends Window {
Expand Down Expand Up @@ -80,7 +81,7 @@ export default class MainWindow extends Window {

secondInstance = () => {
if (!this.window) return;
if (process.platform === "win32") {
if (isWin) {
if (this.window) {
if (this.window.isMinimized()) {
this.window.restore();
Expand Down
5 changes: 0 additions & 5 deletions packages/renderer/src/components/WebView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ const WebView: FC<WebViewProps> = ({ className }) => {
if (webviewRef.current != null) {
// 监控 webview 元素的大小
resizeObserver.current = new ResizeObserver((entries) => {
if (!webviewRef.current) {
return;
}

const rect = computeRect(webviewRef.current?.getBoundingClientRect());

const entry = entries[0];
const viewRect = computeRect(entry.contentRect);
viewRect.x += rect.x;
Expand Down

0 comments on commit f19cc6b

Please sign in to comment.