Skip to content

Commit

Permalink
fix: 录屏 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
027xiguapi committed Dec 7, 2023
1 parent f153fe2 commit ed75aa6
Show file tree
Hide file tree
Showing 15 changed files with 187 additions and 265 deletions.
6 changes: 3 additions & 3 deletions README.de-DE.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ pnpm run build:desktop

## Download

| OS | Windows | Linux | Macos |
| --- | --- | --- | --- |
| link | [Download](https://github.com/027xiguapi/pear-rec/releases/download/1.0.0-alpha/pear-rec_1.0.0-alpha.exe) |||
| OS | Windows | Linux | Macos |
| ---- | ----------------------------------------------------------- | ----- | ----- |
| link | [Download](https://github.com/027xiguapi/pear-rec/releases) | | |

## Feedback

Expand Down
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,11 @@ Features that have been ticked are the latest in the development process but may
- [x] English
- [x] German

## Test

| OS | Windows | Linux | Macos |
| ---- | ------- | ----- | ----- |
| Test | 🟢 |||

## Download

| OS | Windows | Linux | Macos |
| --- | --- | --- | --- |
| link | [Download](https://github.com/027xiguapi/pear-rec/releases/download/1.0.0-alpha/pear-rec_1.0.0-alpha.exe) |||
| OS | Windows | Linux | Macos |
| ---- | ----------------------------------------------------------- | ----- | ----- |
| link | [Download](https://github.com/027xiguapi/pear-rec/releases) | | |

## Feedback

Expand Down
12 changes: 3 additions & 9 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,11 @@ pnpm run build:desktop
- [x] 英语
- [x] 德语

## 测试

| 系统 | Windows | Linux | Macos |
| ---- | ------- | ----- | ----- |
| 测试 | 🟢 |||

## Download

| 系统 | Windows | Linux | Macos |
| --- | --- | --- | --- |
| 链接 | [下载](https://github.com/027xiguapi/pear-rec/releases/download/1.0.0-alpha/pear-rec_1.0.0-alpha.exe) |||
| 系统 | Windows | Linux | Macos |
| ---- | ------------------------------------------------------- | ----- | ----- |
| 链接 | [下载](https://github.com/027xiguapi/pear-rec/releases) | | |

国内可以用 [GitHub Proxy](https://ghproxy.com/) 加速下载

Expand Down
4 changes: 4 additions & 0 deletions packages/desktop/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @pear-rec/desktop

## 1.3.3

fix: 录屏 bug

## 1.3.2

feat: 自动更新软件
Expand Down
6 changes: 5 additions & 1 deletion packages/desktop/electron-builder.json5
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
*/
{
appId: 'com.electron.pear-rec',
asar: false,
productName: 'pear-rec',
copyright: 'Copyright © 2023 ${author}',
asar: false,
// asar: true,
// extraResources: ['node_modules/sql.js', 'node_modules/typeorm'],
// asarUnpack: ['node_modules/sql.js', 'node_modules/typeorm'],
directories: {
output: 'release/${version}',
},
files: ['dist-electron', 'dist'],
mac: {
icon: 'build/mac/icon.icns',
artifactName: '${productName}-Mac-${version}-Installer.${ext}',
target: ['dmg', 'zip'],
},
linux: {
icon: 'build/icons/png/1024x1024.png',
target: ['AppImage'],
artifactName: '${productName}-Linux-${version}.${ext}',
},
Expand Down
164 changes: 80 additions & 84 deletions packages/desktop/electron/win/clipScreenWin.ts
Original file line number Diff line number Diff line change
@@ -1,129 +1,125 @@
import { app, BrowserWindow, dialog, shell, screen } from "electron";
import { join, dirname } from "node:path";
import { ICON, preload, url, WEB_URL, DIST } from "../main/contract";
import { app, BrowserWindow, dialog, shell, screen } from 'electron';
import { join, dirname } from 'node:path';
import { ICON, preload, url, WEB_URL, DIST } from '../main/contract';
import {
openRecorderScreenWin,
setBoundsRecorderScreenWin,
showRecorderScreenWin,
hideRecorderScreenWin,
} from "./recorderScreenWin";
openRecorderScreenWin,
setBoundsRecorderScreenWin,
showRecorderScreenWin,
hideRecorderScreenWin,
} from './recorderScreenWin';

const clipScreenHtml = join(DIST, "./clipScreen.html");
const clipScreenHtml = join(DIST, './clipScreen.html');
let clipScreenWin: BrowserWindow | null = null;

function createClipScreenWin(): BrowserWindow {
clipScreenWin = new BrowserWindow({
title: "pear-rec_clipScreenWin",
icon: ICON,
autoHideMenuBar: true, // 自动隐藏菜单栏
frame: false, // 无边框窗口
resizable: true, // 窗口大小是否可调整
transparent: true, // 使窗口透明
fullscreenable: false, // 窗口是否可以进入全屏状态
alwaysOnTop: true, // 窗口是否永远在别的窗口的上面
// skipTaskbar: true,
webPreferences: {
preload,
},
});

if (url) {
clipScreenWin.loadURL(WEB_URL + "clipScreen.html");
// clipScreenWin.webContents.openDevTools();
} else {
clipScreenWin.loadFile(clipScreenHtml);
}

clipScreenWin.on("resize", () => {
const clipScreenWinBounds = getBoundsClipScreenWin();
setBoundsRecorderScreenWin(clipScreenWinBounds);
});

clipScreenWin.on("move", () => {
const clipScreenWinBounds = getBoundsClipScreenWin();
setBoundsRecorderScreenWin(clipScreenWinBounds);
});

clipScreenWin.on("restore", () => {
showRecorderScreenWin();
});

clipScreenWin.on("minimize", () => {
hideRecorderScreenWin();
});

return clipScreenWin;
clipScreenWin = new BrowserWindow({
title: 'pear-rec_clipScreenWin',
icon: ICON,
autoHideMenuBar: true, // 自动隐藏菜单栏
frame: false, // 无边框窗口
resizable: true, // 窗口大小是否可调整
transparent: true, // 使窗口透明
fullscreenable: false, // 窗口是否可以进入全屏状态
alwaysOnTop: true, // 窗口是否永远在别的窗口的上面
// skipTaskbar: true,
webPreferences: {
preload,
},
});

if (url) {
clipScreenWin.loadURL(WEB_URL + 'clipScreen.html');
// clipScreenWin.webContents.openDevTools();
} else {
clipScreenWin.loadFile(clipScreenHtml);
}

clipScreenWin.on('resize', () => {
const clipScreenWinBounds = getBoundsClipScreenWin();
setBoundsRecorderScreenWin(clipScreenWinBounds);
});

clipScreenWin.on('move', () => {
const clipScreenWinBounds = getBoundsClipScreenWin();
setBoundsRecorderScreenWin(clipScreenWinBounds);
});

clipScreenWin.on('restore', () => {
showRecorderScreenWin();
});

clipScreenWin.on('minimize', () => {
hideRecorderScreenWin();
});

return clipScreenWin;
}

function closeClipScreenWin() {
clipScreenWin?.isDestroyed() || clipScreenWin?.close();
clipScreenWin = null;
clipScreenWin?.isDestroyed() || clipScreenWin?.close();
clipScreenWin = null;
}

function showClipScreenWin() {
clipScreenWin?.show();
clipScreenWin?.show();
}

function openClipScreenWin() {
if (!clipScreenWin || clipScreenWin?.isDestroyed()) {
clipScreenWin = createClipScreenWin();
}
if (!clipScreenWin || clipScreenWin?.isDestroyed()) {
clipScreenWin = createClipScreenWin();
}

clipScreenWin?.show();
openRecorderScreenWin();
clipScreenWin?.show();
openRecorderScreenWin();
}

function getBoundsClipScreenWin() {
return clipScreenWin?.getBounds();
return clipScreenWin?.getBounds();
}

function hideClipScreenWin() {
clipScreenWin?.hide();
clipScreenWin?.hide();
}

function setAlwaysOnTopClipScreenWin(isAlwaysOnTop: boolean) {
clipScreenWin?.setAlwaysOnTop(isAlwaysOnTop);
clipScreenWin?.setAlwaysOnTop(isAlwaysOnTop);
}

function setMovableClipScreenWin(movable: boolean) {
clipScreenWin?.setMovable(movable);
clipScreenWin?.setMovable(movable);
}

function setResizableClipScreenWin(resizable: boolean) {
clipScreenWin?.setResizable(resizable);
clipScreenWin?.setResizable(resizable);
}

function minimizeClipScreenWin() {
clipScreenWin?.minimize();
clipScreenWin?.minimize();
}

function setIgnoreMouseEventsClipScreenWin(
event: any,
ignore: boolean,
options?: any,
) {
clipScreenWin?.setIgnoreMouseEvents(ignore, options);
function setIgnoreMouseEventsClipScreenWin(event: any, ignore: boolean, options?: any) {
clipScreenWin?.setIgnoreMouseEvents(ignore, options);
}

function setIsPlayClipScreenWin(isPlay: boolean) {
clipScreenWin?.webContents.send("cs:set-isPlay", isPlay);
clipScreenWin?.webContents.send('cs:set-isPlay', isPlay);
}

function setBoundsClipScreenWin(bounds: any) {
clipScreenWin?.setBounds({ ...bounds });
clipScreenWin?.setBounds({ ...bounds });
}

export {
showClipScreenWin,
closeClipScreenWin,
openClipScreenWin,
hideClipScreenWin,
getBoundsClipScreenWin,
setAlwaysOnTopClipScreenWin,
setIgnoreMouseEventsClipScreenWin,
setMovableClipScreenWin,
setResizableClipScreenWin,
setIsPlayClipScreenWin,
minimizeClipScreenWin,
setBoundsClipScreenWin,
showClipScreenWin,
closeClipScreenWin,
openClipScreenWin,
hideClipScreenWin,
getBoundsClipScreenWin,
setAlwaysOnTopClipScreenWin,
setIgnoreMouseEventsClipScreenWin,
setMovableClipScreenWin,
setResizableClipScreenWin,
setIsPlayClipScreenWin,
minimizeClipScreenWin,
setBoundsClipScreenWin,
};
4 changes: 2 additions & 2 deletions packages/desktop/electron/win/recorderFullScreenWin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { app, BrowserWindow, dialog, shell, screen, Rectangle } from 'electron';
import { join, basename, dirname } from 'node:path';
import { preload, url, DIST, ICON, WEB_URL, DIST_ELECTRON } from '../main/contract';

const recorderFullScreenHtml = join(DIST, './recordeFullScreen.html');
const recorderFullScreenHtml = join(DIST, './recorderFullScreen.html');
let recorderFullScreenWin: BrowserWindow | null = null;

function createRecorderFullScreenWin(): BrowserWindow {
Expand All @@ -27,10 +27,10 @@ function createRecorderFullScreenWin(): BrowserWindow {
recorderFullScreenWin?.setResizable(false);
if (url) {
recorderFullScreenWin.loadURL(WEB_URL + `recorderFullScreen.html`);
// recorderFullScreenWin.webContents.openDevTools();
} else {
recorderFullScreenWin.loadFile(recorderFullScreenHtml);
}
// recorderFullScreenWin.webContents.openDevTools();

return recorderFullScreenWin;
}
Expand Down
Loading

0 comments on commit ed75aa6

Please sign in to comment.