mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 15:33:59 +01:00
feat: desktop app (#169)
* electron * github actions * fix publish.yml * more concise * update linux target * gitignore add newline
This commit is contained in:
parent
77963d3aaa
commit
4903399d56
27
.github/workflows/publish.yml
vendored
Normal file
27
.github/workflows/publish.yml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
name: Build and publish desktop app
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: 'publish'
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Use Node.js 18
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Build
|
||||
run: yarn make
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -22,3 +22,5 @@ dist-ssr
|
|||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
release/
|
||||
|
|
46
electron/index.cjs
Normal file
46
electron/index.cjs
Normal file
|
@ -0,0 +1,46 @@
|
|||
const path = require('path');
|
||||
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const isDev = require('electron-is-dev');
|
||||
|
||||
if (require('electron-squirrel-startup')) app.quit();
|
||||
|
||||
function createWindow() {
|
||||
let iconPath = '';
|
||||
if (isDev) {
|
||||
iconPath = path.join(__dirname, '../public/favicon-516x516.png');
|
||||
} else {
|
||||
iconPath = path.join(__dirname, '../dist/favicon-516x516.png');
|
||||
}
|
||||
|
||||
const win = new BrowserWindow({
|
||||
show: false,
|
||||
icon: iconPath,
|
||||
});
|
||||
win.maximize();
|
||||
win.show();
|
||||
|
||||
win.loadURL(
|
||||
isDev
|
||||
? 'http://localhost:5173'
|
||||
: `file://${path.join(__dirname, '../dist/index.html')}`
|
||||
);
|
||||
|
||||
if (isDev) {
|
||||
win.webContents.openDevTools({ mode: 'detach' });
|
||||
}
|
||||
}
|
||||
|
||||
app.whenReady().then(createWindow);
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
39
package.json
39
package.json
|
@ -1,15 +1,44 @@
|
|||
{
|
||||
"name": "better-chatgpt",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"type": "module",
|
||||
"homepage": "./",
|
||||
"main": "electron/index.cjs",
|
||||
"author": "Jing Hua <betterchatgpt@mail.tjh.sg>",
|
||||
"description": "Play and chat smarter with BetterChatGPT - an amazing open-source web app with a better UI for exploring OpenAI's ChatGPT API!",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview"
|
||||
"preview": "vite preview",
|
||||
"electron": "concurrently -k \"BROWSER=none yarn dev\" \"wait-on tcp:5173 && electron .\"",
|
||||
"pack": "yarn build && electron-builder --dir",
|
||||
"make": "yarn build && electron-builder"
|
||||
},
|
||||
"build": {
|
||||
"appId": "better-chatgpt",
|
||||
"productName": "Better ChatGPT",
|
||||
"directories": {
|
||||
"output": "release"
|
||||
},
|
||||
"dmg": {
|
||||
"title": "${productName} ${version}",
|
||||
"icon": "dist/favicon-516x516.png"
|
||||
},
|
||||
"linux": {
|
||||
"target": "tar.gz",
|
||||
"category": "Chat",
|
||||
"icon": "dist/favicon-516x516.png"
|
||||
},
|
||||
"win": {
|
||||
"target": "NSIS",
|
||||
"icon": "dist/favicon-516x516.png"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@dqbd/tiktoken": "^1.0.2",
|
||||
"electron-is-dev": "^2.0.0",
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"html2canvas": "^1.4.1",
|
||||
"i18next": "^22.4.11",
|
||||
"i18next-browser-languagedetector": "^7.0.1",
|
||||
|
@ -36,11 +65,15 @@
|
|||
"@types/uuid": "^9.0.1",
|
||||
"@vitejs/plugin-react-swc": "^3.0.0",
|
||||
"autoprefixer": "^10.4.13",
|
||||
"concurrently": "^8.0.1",
|
||||
"electron": "^23.2.0",
|
||||
"electron-builder": "^23.6.0",
|
||||
"postcss": "^8.4.21",
|
||||
"tailwindcss": "^3.2.7",
|
||||
"typescript": "^4.9.3",
|
||||
"vite": "^4.1.0",
|
||||
"vite-plugin-top-level-await": "^1.3.0",
|
||||
"vite-plugin-wasm": "^3.2.2"
|
||||
"vite-plugin-wasm": "^3.2.2",
|
||||
"wait-on": "^7.0.1"
|
||||
}
|
||||
}
|
||||
|
|
BIN
public/favicon-516x516.png
Normal file
BIN
public/favicon-516x516.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
|
@ -28,6 +28,6 @@
|
|||
"@src/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src"],
|
||||
"include": ["src", "electron/index.cjs"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue