Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
feat: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
lecepin committed Dec 2, 2023
1 parent 3f56e8c commit 467d2de
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 37 deletions.
5 changes: 3 additions & 2 deletions electron/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ export default function initIPC() {
});

ipcMain.handle('invoke_下载视频', async (event, { url, decodeKey, savePath }) => {
console.log(url,decodeKey);
console.log(url, decodeKey);
return downloadFile(
url,decodeKey,
url,
decodeKey,
`${savePath}/${Date.now()}.mp4`,
throttle(value => win?.webContents?.send?.('e_进度变化', value), 1000),
).catch(err => {
Expand Down
21 changes: 8 additions & 13 deletions electron/proxyServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ if (process.platform === 'win32') {
process.env.OPENSSL_CONF = CONFIG.OPEN_SSL_CNF_PATH;
}


const injection_script =`
const injection_script = `
(function () {
if (window.wvds !== undefined) {
return
Expand Down Expand Up @@ -68,11 +67,7 @@ const injection_script =`
})()
`;


export async function startServer({
win,
setProxyErrorCallback = f => f,
}) {
export async function startServer({ win, setProxyErrorCallback = f => f }) {
const port = await getPort();

return new Promise(async (resolve, reject) => {
Expand All @@ -99,24 +94,24 @@ export async function startServer({
{
phase: 'request',
hostname: 'aaaa.com',
as: 'json'
as: 'json',
},
(req, res) => {
res.string = "ok";
res.string = 'ok';
res.statusCode = 200;
win?.webContents?.send?.('VIDEO_CAPTURE', req.json)
win?.webContents?.send?.('VIDEO_CAPTURE', req.json);
},
);

proxy.intercept(
{
phase: 'response',
hostname: 'res.wx.qq.com',
as: "string"
as: 'string',
},
async (req, res) => {
if (req.url.includes("polyfills.publish")) {
res.string = res.string + "\n" + injection_script;
if (req.url.includes('polyfills.publish')) {
res.string = res.string + '\n' + injection_script;
}
},
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechat-video-downloader",
"version": "1.0.1",
"version": "2.0.0",
"description": "",
"main": "./build-electron/index.js",
"homepage": "./",
Expand Down
16 changes: 3 additions & 13 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function App() {
dataIndex: 'action',
key: 'action',
width: '210px',
render: (_, { url, decodeKey, hdUrl, fixUrl, fullFileName, }) => (
render: (_, { url, decodeKey, hdUrl, fixUrl, fullFileName }) => (
<div>
{fullFileName ? (
<Button
Expand All @@ -80,23 +80,13 @@ function App() {
icon={<DownloadOutlined />}
type="primary"
onClick={() => {
send({ type: 'e_下载', url: (hdUrl || url), decodeKey: decodeKey });
send({ type: 'e_下载', url: hdUrl || url, decodeKey: decodeKey });
}}
size="small"
>
{hdUrl ? "高清" : ""}下载
解密下载
</Button>
)}
&nbsp; &nbsp;
<Button
icon={<PlaySquareOutlined />}
onClick={() => {
send({ type: 'e_预览', url: (fixUrl || url) });
}}
size="small"
>
预览
</Button>
</div>
),
},
Expand Down
25 changes: 17 additions & 8 deletions src/fsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default createMachine(
},
invoke_启动服务: (context, event) => send => {
const fnDealVideoCapture = (eName, { url, size, description, decode_key, ...other }) => {
send({ type: 'e_视频捕获', url, size, description, decodeKey: decode_key, ...other });
send({ type: 'e_视频捕获', url, size, description, decodeKey: decode_key, ...other });
};

ipcRenderer
Expand Down Expand Up @@ -218,19 +218,28 @@ export default createMachine(
},
},
actions: {
action_视频捕获: actions.assign(({ captureList }, { url, size, description, decodeKey, ...other }) => {
captureList.push({ size, url, prettySize: prettyBytes(+size), description, decodeKey, ...other });
action_视频捕获: actions.assign(
({ captureList }, { url, size, description, decodeKey, ...other }) => {
captureList.push({
size,
url,
prettySize: prettyBytes(+size),
description,
decodeKey,
...other,
});

return {
captureList: uniqBy(captureList, 'url'),
};
}),
return {
captureList: uniqBy(captureList, 'url'),
};
},
),
action_清空捕获记录: actions.assign(() => {
return {
captureList: [],
};
}),
action_设置当前地址: actions.assign((_, { url,decodeKey }) => {
action_设置当前地址: actions.assign((_, { url, decodeKey }) => {
return {
currentUrl: url,
decodeKey: decodeKey,
Expand Down

0 comments on commit 467d2de

Please sign in to comment.