Skip to content

Commit

Permalink
fix: 开机自启动 bug、图片预览钉图 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
027xiguapi committed Mar 5, 2024
1 parent f93ff16 commit 068b76c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 13 deletions.
5 changes: 4 additions & 1 deletion packages/desktop/electron/main/ipcMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
shell,
webContents,
} from 'electron';
import * as canvasWin from '../win/canvasWin';
import * as clipScreenWin from '../win/clipScreenWin';
import * as editGifWin from '../win/editGifWin';
import * as editImageWin from '../win/editImageWin';
Expand All @@ -26,7 +27,6 @@ import * as spliceImageWin from '../win/spliceImageWin';
import * as viewAudioWin from '../win/viewAudioWin';
import * as viewImageWin from '../win/viewImageWin';
import * as viewVideoWin from '../win/viewVideoWin';
import * as canvasWin from '../win/canvasWin';
import logger from './logger';
import * as utils from './utils';

Expand Down Expand Up @@ -208,6 +208,9 @@ function initIpcMain() {
ipcMain.on('vi:open-file', (e, imgUrl) => {
shell.openExternal(imgUrl);
});
ipcMain.on('vi:alwaysOnTop-win', (e, isTop) => {
viewImageWin.setIsAlwaysOnTopViewImageWin(isTop);
});
ipcMain.handle('vi:set-always-on-top', () => {
const isAlwaysOnTop = viewImageWin.getIsAlwaysOnTopViewImageWin();
return viewImageWin.setIsAlwaysOnTopViewImageWin(!isAlwaysOnTop);
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/electron/preload/electronAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
sendViMinimizeWin: () => ipcRenderer.send('vi:minimize-win'),
sendViMaximizeWin: () => ipcRenderer.send('vi:maximize-win'),
sendViUnmaximizeWin: () => ipcRenderer.send('vi:unmaximize-win'),
sendViAlwaysOnTopWin: (isTop: boolean) => ipcRenderer.send('vi:alwaysOnTop-win', isTop),
sendViOpenFile: (imgUrl: string) => ipcRenderer.send('vi:open-file', imgUrl),
invokeViSetIsAlwaysOnTop: () => ipcRenderer.invoke('vi:set-always-on-top'),
invokeViGetImgs: (imgUrl: string) => ipcRenderer.invoke('vi:get-imgs', imgUrl),
Expand Down
4 changes: 4 additions & 0 deletions packages/web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @pear-rec/web

## 1.4.12

fix: 开机自启动 bug、图片预览钉图 bug

## 1.4.11

fix: 动图导出 bug、视频解析动图 bug
Expand Down
4 changes: 4 additions & 0 deletions packages/web/src/components/common/header/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
width: 100px;
height: 100%;
line-height: 32px;
white-space: nowrap;
text-align: left;
span {
display: inline-block;
Expand All @@ -28,6 +29,7 @@
}
.center {
flex: auto;
white-space: nowrap;
text-align: center;
-webkit-app-region: drag;
.icon {
Expand All @@ -37,6 +39,8 @@
}
.right {
width: 100px;
min-width: 100px;
white-space: nowrap;
.icon {
-webkit-app-region: no-drag;
}
Expand Down
11 changes: 9 additions & 2 deletions packages/web/src/components/common/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const logo = './imgs/icons/png/512x512.png';
const Header = (props) => {
const { t } = useTranslation();
const [isMaximize, setIsMaximize] = useState(false);
const [isTop, setIsTop] = useState(false);

async function handleMinimizeWin() {
props.onMinimizeWin();
Expand All @@ -42,6 +43,12 @@ const Header = (props) => {
setIsMaximize(!isMaximize);
}

function handleAlwaysOnTopWin() {
let _isTop = !isTop;
props.onAlwaysOnTopWin(_isTop);
setIsTop(_isTop);
}

return (
<div className={`${props.className} ${styles.header}`}>
<div className="left" title="pear-rec">
Expand Down Expand Up @@ -91,9 +98,9 @@ const Header = (props) => {
<Button
className="alwaysOnTopWin icon"
type="text"
icon={<PushpinOutlined />}
icon={<PushpinOutlined style={{ color: isTop ? '#08c' : '' }} />}
title={t('nav.alwaysOnTopWin')}
onClick={() => props.onAlwaysOnTopWin()}
onClick={() => handleAlwaysOnTopWin()}
/>
<Button
className="openFile icon"
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/components/setting/basicSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const BasicSetting = (props) => {

function handleSetOpenAtLogin(isOpen: boolean) {
db.settings.update(setting.id, { openAtLogin: isOpen });
window.electronAPI?.sendSeSetOpenAtLogin(isOpen);
}

async function getOpenAtLogin() {
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/components/setting/userSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const UserSetting = (props) => {
<img alt="logo" src={logo} />
</div>
<div className="info">
<p>版本:1.3.12</p>
<p>版本:1.3.13</p>
<p>{uuid}</p>
<p>{formatTime(createdTime)}</p>
<Button type="primary" className="resetBtn" danger onClick={handleResetClick}>
Expand Down
14 changes: 5 additions & 9 deletions packages/web/src/pages/viewImage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,13 @@ const ViewImage = () => {
}

function handleToggleMaximizeWin(isMaximize) {
isMaximize ? window.electronAPI.sendViUnmaximizeWin() : window.electronAPI.sendViMaximizeWin();
isMaximize
? window.electronAPI?.sendViUnmaximizeWin()
: window.electronAPI?.sendViMaximizeWin();
}

function handleAlwaysOnTopWin() {
const imgUrl = imgs[initialViewIndexRef.current]?.filePath;
if (window.isElectron) {
window.electronAPI.sendViCloseWin();
window.electronAPI.sendPiOpenWin({ imgUrl });
} else {
window.open(`/pinImage.html?imgUrl=${imgUrl}`);
}
function handleAlwaysOnTopWin(isTop: boolean) {
window.electronAPI?.sendViAlwaysOnTopWin(isTop);
}

function handleOpenFile() {
Expand Down

0 comments on commit 068b76c

Please sign in to comment.