Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Zila-itc committed Nov 1, 2024
1 parent 5f1badb commit 95661ce
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 46 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"react": "^18.3.1",
"electron-store": "^8.1.0",
"electron-window-state": "^5.0.3",
"pinokiod": "^2.15.1"
"pinokiod": "^2.15.1",
"pinokiojs":"^0.0.9"
},
"devDependencies": {
"@liangskyli/umijs-plugin-electron": "^0.4.0",
Expand Down Expand Up @@ -75,4 +76,4 @@
"wait-on": "^8.0.1",
"webpack": "^5.95.0"
}
}
}
16 changes: 10 additions & 6 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ let PORT;
//let PORT = 42000
//let PORT = (platform === 'linux' ? 42000 : 80)


const filter = function (item) {
return item.browserName === "Chrome";
};
Expand Down Expand Up @@ -281,7 +282,7 @@ const attach = (event, webContents) => {
webPreferences: {
webSecurity: false,
nativeWindowOpen: true,
contextIsolation: false,
contextIsolation: true,
nodeIntegrationInSubFrames: true,
preload: path.join(__dirname, "preload.js"),
},
Expand Down Expand Up @@ -310,7 +311,7 @@ const attach = (event, webContents) => {
webPreferences: {
webSecurity: false,
nativeWindowOpen: true,
contextIsolation: false,
contextIsolation: true,
nodeIntegrationInSubFrames: true,
preload: path.join(__dirname, "preload.js"),
},
Expand Down Expand Up @@ -371,9 +372,10 @@ const createWindow = (port) => {
webPreferences: {
webSecurity: false,

Check warning

Code scanning / CodeQL

Disabling Electron webSecurity Medium

Disabling webSecurity is strongly discouraged.
nativeWindowOpen: true,
contextIsolation: false,
contextIsolation: true,
nodeIntegrationInSubFrames: true,
preload: path.join(__dirname, "preload.js"),
sandbox: false,
},
});
// enable_cors(mainWindow)
Expand All @@ -382,7 +384,8 @@ const createWindow = (port) => {
} else {
root_url = `http://localhost:${port}`;
}
mainWindow.loadURL(root_url);
mainWindow.loadURL('http://localhost:8000');
mainWindow.webContents.openDevTools({ mode: 'right' })
// mainWindow.maximize();
mainWindowState.manage(mainWindow);
};
Expand All @@ -405,9 +408,10 @@ const loadNewWindow = (url, port) => {
webPreferences: {
webSecurity: false,

Check warning

Code scanning / CodeQL

Disabling Electron webSecurity Medium

Disabling webSecurity is strongly discouraged.
nativeWindowOpen: true,
contextIsolation: false,
contextIsolation: true,
nodeIntegrationInSubFrames: true,
preload: path.join(__dirname, "preload.js"),
sandbox: false,
},
});
// enable_cors(win)
Expand Down Expand Up @@ -481,7 +485,7 @@ if (!gotTheLock) {
webPreferences: {
webSecurity: false,

Check warning

Code scanning / CodeQL

Disabling Electron webSecurity Medium

Disabling webSecurity is strongly discouraged.
nativeWindowOpen: true,
contextIsolation: false,
contextIsolation: true,
nodeIntegrationInSubFrames: true,
preload: path.join(__dirname, "preload.js"),
},
Expand Down
61 changes: 25 additions & 36 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,12 @@
import { ProCard } from '@ant-design/pro-components';
import { useLocalStorageState } from 'ahooks';
import { Button, notification } from 'antd';
import Pinokio from 'pinokiojs';

const translate = (key: string) => {
return key;
};

const { i18nSync, showItemInFolder } = window.$api || {};

const handleSync = (opts = {} as any) => {
const { scanPath, ...restOpt } = opts || {};

i18nSync(scanPath, {
...restOpt,
cb(value, error: any) {
if (error) {
notification.error({
message: translate('Error'),
description: error?.message || 'Unknown Error',
});
return;
}
notification.success({
message: translate('Success'),
description: value,
btn: (
<Button
type="primary"
onClick={() => {
showItemInFolder(value);
}}
>
{translate('Output Folder')}
</Button>
),
});
},
});
};
const { showItemInFolder } = window.$api || {};

const WeView = () => {
return (
Expand All @@ -56,13 +25,33 @@ const WeView = () => {
};

export default function HomePage() {
const pinokio = new Pinokio({
http: "http://localhost:80",
fs: "http://localhost:80/fs",
rpc: "ws://localhost:80",
})

const api = async () => {
const allPort = pinokio.rpc
console.log('f', allPort);

}

useEffect(() => {
api();
}, []);

return (
<ProCard
title={translate('Configs')}
extra={
<Button onClick={() => {
window.open("/", "_blank", "self")
}}>API</Button>
<Button
onClick={() => {
window.open('http://localhost');
}}
>
Server Settings
</Button>
}
bordered
headerBordered
Expand Down
4 changes: 2 additions & 2 deletions src/preload/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { contextBridge, shell, ipcRenderer } from 'electron';
import i18nSync from './i18n-sync';
// import i18nSync from './i18n-sync';

const apiKey = '$api';

Expand Down Expand Up @@ -85,7 +85,7 @@ window.electronAPI = {

const api = {
versions: process.versions,
i18nSync,
// i18nSync,
showItemInFolder: shell.showItemInFolder,
hello,
// Communicate between renderer and main process
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10484,6 +10484,13 @@ pinokiod@^2.15.1:
yaml "^2.3.4"
yargs-unparser-custom-flag "^2.0.0"

pinokiojs@^0.0.9:
version "0.0.9"
resolved "https://registry.yarnpkg.com/pinokiojs/-/pinokiojs-0.0.9.tgz#953d7b96d6e0b041b31db86e10f71c4171db2bfc"
integrity sha512-CaHHq5KXr2fYyDnV7W0v+8YHcY21el5GpyU9ON0c+ulzEnextg76Co2q/gx48y/mZxopTgLGadCO/aXaR7STWg==
dependencies:
unws "^0.2.3"

pirates@^4.0.1, pirates@^4.0.4:
version "4.0.6"
resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.6.tgz#3018ae32ecfcff6c29ba2267cbf21166ac1f36b9"
Expand Down Expand Up @@ -14033,6 +14040,11 @@ untildify@^4.0.0:
resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b"
integrity sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==

unws@^0.2.3:
version "0.2.4"
resolved "https://registry.yarnpkg.com/unws/-/unws-0.2.4.tgz#cb6f27a98a7fab4bf1c2f842648f9a2fc8be80f2"
integrity sha512-/N1ajiqrSp0A/26/LBg7r10fOcPtGXCqJRJ61sijUFoGZMr6ESWGYn7i0cwr7fR7eEECY5HsitqtjGHDZLAu2w==

update-browserslist-db@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz#80846fba1d79e82547fb661f8d141e0945755fe5"
Expand Down

0 comments on commit 95661ce

Please sign in to comment.