-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b56215f
commit cc5129c
Showing
16 changed files
with
252 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# @pear-rec/desktop | ||
|
||
## 1.3.0 | ||
|
||
feat: 增加钉图功能 | ||
|
||
## 1.2.11 | ||
|
||
feat: 打包发布到 git | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { app, BrowserWindow, shell } from 'electron'; | ||
import { join } from 'node:path'; | ||
import { ICON, preload, url, DIST, WEB_URL } from '../main/contract'; | ||
|
||
const pinImageHtml = join(DIST, './pinImage.html'); | ||
let pinImageWin: BrowserWindow | null = null; | ||
|
||
function createPinImageWin(search?: any): BrowserWindow { | ||
pinImageWin = new BrowserWindow({ | ||
title: 'pear-rec 图片', | ||
icon: ICON, | ||
height: 450, | ||
width: 600, | ||
frame: false, // 无边框窗口 | ||
resizable: true, // 窗口大小是否可调整 | ||
transparent: true, // 使窗口透明 | ||
fullscreenable: false, // 窗口是否可以进入全屏状态 | ||
alwaysOnTop: true, // 窗口是否永远在别的窗口的上面 | ||
autoHideMenuBar: true, // 自动隐藏菜单栏 | ||
webPreferences: { | ||
preload, | ||
}, | ||
}); | ||
|
||
const imgUrl = search?.imgUrl || ''; | ||
// pinImageWin.webContents.openDevTools(); | ||
if (url) { | ||
pinImageWin.loadURL(WEB_URL + `pinImage.html?imgUrl=${imgUrl}`); | ||
} else { | ||
pinImageWin.loadFile(pinImageHtml, { | ||
search: `?imgUrl=${imgUrl}`, | ||
}); | ||
} | ||
|
||
return pinImageWin; | ||
} | ||
|
||
// 打开关闭录屏窗口 | ||
function closePinImageWin() { | ||
pinImageWin?.isDestroyed() || pinImageWin?.close(); | ||
pinImageWin = null; | ||
} | ||
|
||
function openPinImageWin(search?: any) { | ||
if (!pinImageWin || pinImageWin?.isDestroyed()) { | ||
pinImageWin = createPinImageWin(search); | ||
} | ||
pinImageWin?.show(); | ||
} | ||
|
||
function showPinImageWin() { | ||
pinImageWin?.show(); | ||
} | ||
|
||
function hidePinImageWin() { | ||
pinImageWin?.hide(); | ||
} | ||
|
||
function minimizePinImageWin() { | ||
pinImageWin?.minimize(); | ||
} | ||
|
||
function maximizePinImageWin() { | ||
pinImageWin?.maximize(); | ||
} | ||
|
||
export { | ||
createPinImageWin, | ||
closePinImageWin, | ||
openPinImageWin, | ||
showPinImageWin, | ||
hidePinImageWin, | ||
minimizePinImageWin, | ||
maximizePinImageWin, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# @pear-rec/web | ||
|
||
## 1.3.0 | ||
|
||
feat: 增加钉图功能 | ||
|
||
## 1.2.14 | ||
|
||
fix: 录音选择格式 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="icon" type="image/x-icon" href="/imgs/logo/favicon.ico" /> | ||
<title>pear-rec | 图片</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="./pinImage/index.tsx"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.pinImage { | ||
width: 100%; | ||
height: 100vh; | ||
overflow: hidden; | ||
background-size: cover; | ||
background-repeat: no-repeat; | ||
background-position: center; | ||
-webkit-app-region: drag; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import type { MenuProps } from 'antd'; | ||
import ininitApp from '../../pages/main'; | ||
import { Dropdown, theme } from 'antd'; | ||
import { MinusOutlined, BorderOutlined, CloseOutlined } from '@ant-design/icons'; | ||
import { useApi } from '../../api'; | ||
import { useUserApi } from '../../api/user'; | ||
import styles from './index.module.scss'; | ||
const defaultImg = './imgs/th.webp'; | ||
|
||
const items: MenuProps['items'] = [ | ||
{ | ||
label: '关闭', | ||
key: '1', | ||
icon: <CloseOutlined />, | ||
}, | ||
{ | ||
label: '最小化', | ||
key: '2', | ||
icon: <MinusOutlined />, | ||
}, | ||
{ | ||
label: '最大化', | ||
key: '3', | ||
icon: <BorderOutlined />, | ||
}, | ||
]; | ||
|
||
const PinImage: React.FC = () => { | ||
const { t } = useTranslation(); | ||
const userApi = useUserApi(); | ||
const userRef = useRef({} as any); | ||
const [imgUrl, setImgUrl] = useState<any>(''); | ||
|
||
useEffect(() => { | ||
init(); | ||
userRef.current.id || getCurrentUser(); | ||
}, []); | ||
|
||
async function getCurrentUser() { | ||
try { | ||
const res = (await userApi.getCurrentUser()) as any; | ||
if (res.code == 0) { | ||
userRef.current = res.data; | ||
} | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
} | ||
|
||
async function init() { | ||
const paramsString = location.search; | ||
const searchParams = new URLSearchParams(paramsString); | ||
let _imgUrl = searchParams.get('imgUrl') || defaultImg; | ||
fetch(_imgUrl) | ||
.then((response) => response.blob()) // 将获取到的图片转为 Blob | ||
.then((blob) => { | ||
setImgUrl(`url(${URL.createObjectURL(blob)})`); | ||
}); | ||
} | ||
|
||
const onClick: MenuProps['onClick'] = ({ key }) => { | ||
if (key == '1') { | ||
window.electronAPI.sendPiCloseWin(); | ||
} else if (key == '2') { | ||
window.electronAPI.sendPiMinimizeWin(); | ||
} else { | ||
window.electronAPI.sendPiMaximizeWin(); | ||
} | ||
}; | ||
|
||
return ( | ||
<Dropdown menu={{ items, onClick }} trigger={['contextMenu']}> | ||
<div | ||
className={styles.pinImage} | ||
style={{ | ||
backgroundImage: imgUrl, | ||
}} | ||
></div> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
ininitApp(PinImage); | ||
export default PinImage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters