Skip to content

Commit c44fbf0

Browse files
committed
feat: client version
1 parent 2f4cd01 commit c44fbf0

File tree

6 files changed

+2343
-22
lines changed

6 files changed

+2343
-22
lines changed

electron/main.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { app, BrowserWindow } from 'electron/main';
2+
import path from 'node:path';
3+
import { readFileSync } from "node:fs";
4+
import { fileURLToPath } from "url";
5+
6+
const isDev = process.env.NODE_ENV === 'development';
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
10+
function createWindow() {
11+
const win = new BrowserWindow({
12+
width: 800,
13+
height: 600,
14+
title: "florr.io - AyuScript"
15+
});
16+
17+
win.loadURL('https://florr.io/').then(() => {
18+
win.webContents.executeJavaScript(`
19+
window.electron = true
20+
`);
21+
if (isDev) {
22+
win.webContents.executeJavaScript(`
23+
import('http://localhost:5173/__vite-plugin-monkey.install.user.js')
24+
`);
25+
win.webContents.openDevTools();
26+
} else {
27+
const jsPath = path.join(__dirname, '../dist/ayuscript.user.js');
28+
const code = readFileSync(jsPath, 'utf-8');
29+
win.webContents.executeJavaScript(code);
30+
}
31+
});
32+
win.on('page-title-updated', (event) => {
33+
event.preventDefault();
34+
});
35+
win.on('close', (event) => {
36+
event.preventDefault()
37+
win.destroy();
38+
});
39+
}
40+
41+
app.whenReady().then(() => {
42+
createWindow();
43+
44+
app.on('activate', () => {
45+
if (BrowserWindow.getAllWindows().length === 0) {
46+
createWindow();
47+
}
48+
});
49+
});
50+
51+
app.on('window-all-closed', () => {
52+
app.quit();
53+
});

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
"private": true,
44
"version": "1.0.0",
55
"type": "module",
6+
"main": "electron/main.js",
67
"scripts": {
78
"proto:generate": "protoc --ts_proto_out=./src ./proto/*.proto --ts_proto_opt=esModuleInterop=true",
89
"proto:watch": "chokidar \"**/*.proto\" -c \"npm run proto:generate\"",
10+
"electron:start": "cross-env NODE_ENV=development electron .",
11+
"electron:build": "npm run build && electron-builder",
912
"dev": "vite",
1013
"build": "vite build",
1114
"preview": "vue-tsc -b && vite preview"
@@ -23,6 +26,9 @@
2326
"@vitejs/plugin-vue": "^5.2.4",
2427
"@vue/tsconfig": "^0.7.0",
2528
"chokidar-cli": "^3.0.0",
29+
"cross-env": "^10.0.0",
30+
"electron": "^37.4.0",
31+
"electron-builder": "^26.0.12",
2632
"js-confuser": "^2.0.0",
2733
"typescript": "^5.8.3",
2834
"vite": "^6.3.5",

src/App.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ onMounted(() => {
6262
webSocketService.connect();
6363
});
6464
});
65-
notice(t("notice.loaded"));
65+
if (window.electron) {
66+
notice(t("notice.loaded.client"));
67+
} else {
68+
notice(t("notice.loaded.browser"));
69+
}
6670
</script>
6771
<template>
6872
<Api/>

src/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ declare global {
1111
export interface Window {
1212
ayuScriptApi: AyuScriptAPI;
1313

14+
electron: true | undefined;
15+
1416
florrio: Florrio;
1517
Module: ModuleType;
1618
cp6: Cp6;

src/locales/en.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"notice": {
3-
"loaded": "AyuScript loaded.",
3+
"loaded": {
4+
"browser": "AyuScript (addon version) loaded",
5+
"client": "AyuScript (client version) loaded"
6+
},
47
"newVersion": "New version {version} published!",
58
"copy": "Copied to clipboard."
69
},

0 commit comments

Comments
 (0)