Merge pull request #407 from lencx/dev

This commit is contained in:
lencx
2023-02-17 00:28:34 +08:00
committed by GitHub
22 changed files with 9660 additions and 144 deletions

View File

@@ -6,97 +6,192 @@ on:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs: jobs:
create-release: build-chatgpt:
runs-on: ubuntu-20.04 runs-on: ${{ matrix.os }}
outputs:
RELEASE_UPLOAD_ID: ${{ steps.create_release.outputs.id }}
steps:
- uses: actions/checkout@v2
- name: Query version number
id: get_version
shell: bash
run: |
echo "using version tag ${GITHUB_REF:10}"
echo "version=${GITHUB_REF:10}" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: '${{ env.version }}'
release_name: 'ChatGPT ${{ env.version }}'
body: 'See the assets to download this version and install.'
build-tauri:
needs: create-release
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
platform: [macos-latest, ubuntu-20.04, windows-latest] include:
- build: linux
os: ubuntu-latest
arch: x86_64
target: x86_64-unknown-linux-gnu
- build: macos
os: macos-latest
arch: x86_64
target: x86_64-apple-darwin
- buid: macos
os: macos-latest
arch: aarch64
target: aarch64-apple-darwin
- build: windows
os: windows-latest
arch: x86_64
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.platform }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: setup node
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false
- name: Install Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 18
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: install Rust stable - name: 'Setup Rust'
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
- name: install dependencies (ubuntu only) with:
if: matrix.platform == 'ubuntu-20.04' targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install dependencies (ubuntu only)
if: matrix.os == 'ubuntu-latest'
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
- name: Install app dependencies and build it - name: Build FE
run: yarn && yarn build:fe run: pnpm build:fe
# - name: Rewrite tauri.conf.json - name: Install rust target
# run: yarn fix:conf run: rustup target add ${{ matrix.target }}
- name: fix tray icon - name: fix tray icon
if: matrix.platform != 'macos-latest' if: matrix.os != 'macos-latest'
run: | run: |
yarn fix:tray pnpm fix:tray
- uses: tauri-apps/tauri-action@v0.3 - run: pnpm build --target ${{ matrix.target }}
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 📝: https://tauri.app/v1/guides/distribution/updater#signing-updates
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
- uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-latest'
with: with:
releaseId: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }} name: artifacts-${{ matrix.arch }}
path: |
./target/${{ matrix.target }}/release/bundle/appimage/**.AppImage.*
./target/${{ matrix.target }}/release/bundle/deb/**.deb
- uses: actions/upload-artifact@v3
if: matrix.os == 'macos-latest'
with:
name: artifacts-${{ matrix.arch }}
path: |
./target/${{ matrix.target }}/release/bundle/dmg/**.dmg
./target/${{ matrix.target }}/release/bundle/macos/**.app.*
- uses: actions/upload-artifact@v3
if: matrix.os == 'windows-latest'
with:
name: artifacts-${{ matrix.arch }}
path: |
./target/${{ matrix.target }}/release/bundle/msi/**
release-chatgpt:
needs: build-chatgpt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Query version number
run: echo "version=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Download x86_64 artifacts
uses: actions/download-artifact@v3
with:
name: artifacts-x86_64
path: artifacts/x86_64
- name: Download aarch64 artifacts
uses: actions/download-artifact@v3
with:
name: artifacts-aarch64
path: artifacts/aarch64
- name: Rename artifacts
run: |
mv "artifacts/aarch64/dmg/ChatGPT_${{ env.version }}_aarch64.dmg" "artifacts/ChatGPT_${{ env.version }}_macos_aarch64.dmg"
mv "artifacts/aarch64/macos/ChatGPT.app.tar.gz" "artifacts/ChatGPT_${{ env.version }}_macos_aarch64.app.tar.gz"
mv "artifacts/aarch64/macos/ChatGPT.app.tar.gz.sig" "artifacts/ChatGPT_${{ env.version }}_macos_aarch64.app.tar.gz.sig"
mv "artifacts/x86_64/dmg/ChatGPT_${{ env.version }}_x64.dmg" "artifacts/ChatGPT_${{ env.version }}_macos_x86_64.dmg"
mv "artifacts/x86_64/macos/ChatGPT.app.tar.gz" "artifacts/ChatGPT_${{ env.version }}_macos_x86_64.app.tar.gz"
mv "artifacts/x86_64/macos/ChatGPT.app.tar.gz.sig" "artifacts/ChatGPT_${{ env.version }}_macos_x86_64.app.tar.gz.sig"
mv "artifacts/x86_64/deb/chat-gpt_${{ env.version }}_amd64.deb" "artifacts/x86_64/deb/ChatGPT_${{ env.version }}_linux_x86_64.deb"
mv "artifacts/x86_64/appimage/chat-gpt_${{ env.version }}_amd64.AppImage.tar.gz" "artifacts/ChatGPT_${{ env.version }}_linux_x86_64.AppImage.tar.gz"
mv "artifacts/x86_64/appimage/chat-gpt_${{ env.version }}_amd64.AppImage.tar.gz.sig" "artifacts/ChatGPT_${{ env.version }}_linux_x86_64.AppImage.tar.gz.sig"
mv "artifacts/x86_64/ChatGPT_${{ env.version }}_x64_en-US.msi" "artifacts/ChatGPT_${{ env.version }}_windows_x86_64.msi"
mv "artifacts/x86_64/ChatGPT_${{ env.version }}_x64_en-US.msi.zip" "artifacts/ChatGPT_${{ env.version }}_windows_x86_64.msi.zip"
mv "artifacts/x86_64/ChatGPT_${{ env.version }}_x64_en-US.msi.zip.sig" "artifacts/ChatGPT_${{ env.version }}_windows_x86_64.msi.zip.sig"
- name: Create Release
uses: softprops/action-gh-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.version }}
name: ChatGPT v${{ env.version }}
body: See the assets to download this version and install.
prerelease: false
generate_release_notes: false
files: ./artifacts/**/*
updater: updater:
runs-on: ubuntu-20.04 runs-on: ubuntu-latest
needs: [create-release, build-tauri] needs: release-chatgpt
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- run: yarn
- run: yarn updater --token=${{ secrets.GITHUB_TOKEN }} - uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Updater JSON
run: pnpm updater --token=${{ secrets.GITHUB_TOKEN }}
- name: Deploy install.json - name: Deploy install.json
uses: peaceiris/actions-gh-pages@v3 uses: peaceiris/actions-gh-pages@v3
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
# 📝: Edit the deployment directory
publish_dir: ./updater publish_dir: ./updater
force_orphan: true # force_orphan: true
# publish-winget: - name: Query version number
# # Action can only be run on windows run: echo "version=${GITHUB_REF:11}" >> $GITHUB_ENV
# runs-on: windows-latest
# needs: [create-release, build-tauri] publish-winget:
# steps: # Action can only be run on windows
# - uses: vedantmgoyal2009/winget-releaser@v1 runs-on: windows-latest
# with: needs: [build-chatgpt, release-chatgpt]
# identifier: lencx.ChatGPT steps:
# token: ${{ secrets.WINGET_TOKEN }} - uses: vedantmgoyal2009/winget-releaser@v1
# version: ${{ env.version }} with:
identifier: lencx.ChatGPT
token: ${{ secrets.WINGET_TOKEN }}
version: ${{ github.event.release.tag_name }}

6
.gitignore vendored
View File

@@ -1,11 +1,11 @@
package-lock.json package-lock.json
node_modules/ node_modules/
yarn.lock
*.lock .yarn/*
.pnp.*
# rust # rust
target/ target/
Cargo.lock
# Logs # Logs
logs logs

4589
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -20,11 +20,11 @@
- [📝 更新日志](./UPDATE_LOG.md) - [📝 更新日志](./UPDATE_LOG.md)
- [🕒 历史版本...](https://github.com/lencx/ChatGPT/releases) - [🕒 历史版本...](https://github.com/lencx/ChatGPT/releases)
<!-- download start --> <!-- tr-download-start -->
### Windows ### Windows
- [ChatGPT_0.10.3_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT_0.10.3_x64_en-US.msi): - [ChatGPT_0.11.0_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.11.0/ChatGPT_0.11.0_x64_en-US.msi):
- 使用 [winget](https://winstall.app/apps/lencx.ChatGPT): - 使用 [winget](https://winstall.app/apps/lencx.ChatGPT):
```bash ```bash
@@ -35,12 +35,12 @@
winget install --id=lencx.ChatGPT -e --version 0.10.0 winget install --id=lencx.ChatGPT -e --version 0.10.0
``` ```
**注意:如果安装路径和应用名称相同,会导致冲突 ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.10.3))** **注意:如果安装路径和应用名称相同,会导致冲突 ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.11.0))**
### Mac ### Mac
- [ChatGPT_0.10.3_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT_0.10.3_x64.dmg) - [ChatGPT_0.11.0_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.11.0/ChatGPT_0.11.0_x64.dmg)
- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT.app.tar.gz) - [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.11.0/ChatGPT.app.tar.gz)
- Homebrew \ - Homebrew \
_[Homebrew 快捷安装](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_ _[Homebrew 快捷安装](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_
```sh ```sh
@@ -56,14 +56,14 @@
### Linux ### Linux
- [chat-gpt_0.10.3_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/chat-gpt_0.10.3_amd64.deb) - [chat-gpt_0.11.0_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.11.0/chat-gpt_0.11.0_amd64.deb)
- [chat-gpt_0.10.3_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/chat-gpt_0.10.3_amd64.AppImage): **工作可靠,`.deb` 运行失败时可以尝试它** - [chat-gpt_0.11.0_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.11.0/chat-gpt_0.11.0_amd64.AppImage): **工作可靠,`.deb` 运行失败时可以尝试它**
- 使用 [AUR](https://aur.archlinux.org/packages/chatgpt-desktop-bin): - 使用 [AUR](https://aur.archlinux.org/packages/chatgpt-desktop-bin):
```bash ```bash
yay -S chatgpt-desktop-bin yay -S chatgpt-desktop-bin
``` ```
<!-- download end --> <!-- tr-download-end -->
## 📢 公告 ## 📢 公告

View File

@@ -23,11 +23,11 @@
- [📝 Update Log](./UPDATE_LOG.md) - [📝 Update Log](./UPDATE_LOG.md)
- [🕒 History versions...](https://github.com/lencx/ChatGPT/releases) - [🕒 History versions...](https://github.com/lencx/ChatGPT/releases)
<!-- download start --> <!-- tr-download-start -->
### Windows ### Windows
- [ChatGPT_0.10.3_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT_0.10.3_x64_en-US.msi): Direct download installer - [ChatGPT_0.11.0_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.11.0/ChatGPT_0.11.0_x64_en-US.msi): Direct download installer
- Use [winget](https://winstall.app/apps/lencx.ChatGPT): - Use [winget](https://winstall.app/apps/lencx.ChatGPT):
```bash ```bash
@@ -37,19 +37,20 @@
# install the specified version # install the specified version
winget install --id=lencx.ChatGPT -e --version 0.10.0 winget install --id=lencx.ChatGPT -e --version 0.10.0
``` ```
- Use [Chocolatey](https://community.chocolatey.org/packages/chatgpt/0.8.1#versionhistory):
- Use [Chocolatey](https://community.chocolatey.org/packages/chatgpt/0.11.0#versionhistory):
```bash ```bash
# install the package # install the package
choco install chatgpt -y choco install chatgpt -y
``` ```
**Note: If the installation path and application name are the same, it will lead to conflict ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.10.3))** **Note: If the installation path and application name are the same, it will lead to conflict ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-0.11.0))**
### Mac ### Mac
- [ChatGPT_0.10.3_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT_0.10.3_x64.dmg): Direct download installer - [ChatGPT_0.11.0_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.11.0/ChatGPT_0.11.0_x64.dmg): Direct download installer
- [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/ChatGPT.app.tar.gz): Download the `.app` installer - [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.11.0/ChatGPT.app.tar.gz): Download the `.app` installer
- Homebrew \ - Homebrew \
Or you can install with _[Homebrew](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_ Or you can install with _[Homebrew](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_
```sh ```sh
@@ -65,13 +66,13 @@
### Linux ### Linux
- [chat-gpt_0.10.3_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/chat-gpt_0.10.3_amd64.deb): Download `.deb` installer, advantage small size, disadvantage poor compatibility - [chat-gpt_0.11.0_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.11.0/chat-gpt_0.11.0_amd64.deb): Download `.deb` installer, advantage small size, disadvantage poor compatibility
- [chat-gpt_0.10.3_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.10.3/chat-gpt_0.10.3_amd64.AppImage): Works reliably, you can try it if `.deb` fails to run - [chat-gpt_0.11.0_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.11.0/chat-gpt_0.11.0_amd64.AppImage): Works reliably, you can try it if `.deb` fails to run
- Available on [AUR](https://aur.archlinux.org/packages/chatgpt-desktop-bin) with the package name `chatgpt-desktop-bin`, and you can use your favourite AUR package manager to install it. - Available on [AUR](https://aur.archlinux.org/packages/chatgpt-desktop-bin) with the package name `chatgpt-desktop-bin`, and you can use your favourite AUR package manager to install it.
- Also, [Aur](https://aur.archlinux.org/packages/chatgpt-desktop-git) available with the package name `chatgpt-desktop-git`. - Also, [Aur](https://aur.archlinux.org/packages/chatgpt-desktop-git) available with the package name `chatgpt-desktop-git`.
<!-- chatgpt-desktop-git always builds the latest commits of main branch --> <!-- chatgpt-desktop-git always builds the latest commits of main branch -->
<!-- download end --> <!-- tr-download-end -->
## 📢 Announcement ## 📢 Announcement

View File

@@ -1,5 +1,18 @@
# UPDATE LOG # UPDATE LOG
## v0.11.0
Fix:
- User-defined close button behavior (exit or minimize) (`Control Center -> Settings -> Main Window -> Close Exit`). (https://github.com/lencx/ChatGPT/issues/359)
- Markdown content layout (https://github.com/lencx/ChatGPT/issues/378)
Feat:
- Set the main window and tray window size (https://github.com/lencx/ChatGPT/issues/405)
- Save window positions and sizes and restore them when the app is reopened (`Control Center -> Settings -> General -> Save Window State`)
- macOS support for aarch64 installer (https://github.com/lencx/ChatGPT/issues/380)
## v0.10.3 ## v0.10.3
> Note: As of now the ChatGPT desktop app has added a lot of exciting features and it continues to improve, as the app grows it has gone far beyond what ChatGPT was intended for. I want to make it the ultimate goal that any website can be easily wrapped to the desktop through user customization. So it needed an international user guide to guide users to use it more professionally. And https://app.nofwl.com is the manual for the app, which will be built into the app (`Menu -> Window -> ChatGPT User's Guide`) so you can access it anytime. It's just starting at the moment, so stay tuned. > Note: As of now the ChatGPT desktop app has added a lot of exciting features and it continues to improve, as the app grows it has gone far beyond what ChatGPT was intended for. I want to make it the ultimate goal that any website can be easily wrapped to the desktop through user customization. So it needed an international user guide to guide users to use it more professionally. And https://app.nofwl.com is the manual for the app, which will be built into the app (`Menu -> Window -> ChatGPT User's Guide`) so you can access it anytime. It's just starting at the moment, so stay tuned.

View File

@@ -1,8 +1,8 @@
cask "chatgpt" do cask "chatgpt" do
version "0.10.3" version "0.10.3"
sha256 "f44838a80844999191a303684fd7ae1811dd2fae6709aebe8bff23c70f9b8a10" sha256 "f44838a80844999191a303684fd7ae1811dd2fae6709aebe8bff23c70f9b8a10"
url "https://github.com/lencx/ChatGPT/releases/download/v#{version}/ChatGPT_#{version}_x64.dmg" url "https://github.com/lencx/ChatGPT/releases/download/v#{version}/ChatGPT_#{version}_macos_x86_64.dmg"
name "ChatGPT" name "ChatGPT"
desc "Desktop wrapper for OpenAI ChatGPT" desc "Desktop wrapper for OpenAI ChatGPT"
homepage "https://github.com/lencx/ChatGPT#readme" homepage "https://github.com/lencx/ChatGPT#readme"

View File

@@ -4,14 +4,14 @@
"scripts": { "scripts": {
"dev:fe": "vite", "dev:fe": "vite",
"build:fe": "tsc && vite build", "build:fe": "tsc && vite build",
"dev": "yarn tauri dev", "dev": "tauri dev",
"build": "yarn tauri build", "build": "tauri build",
"updater": "tr updater", "updater": "tr updater",
"release": "tr release --git", "release": "tr release --git",
"fix:conf": "tr override --json.tauri_updater_active=false", "fix:conf": "tr override --json.tauri_updater_active=false",
"fix:tray": "tr override --json.tauri_systemTray_iconPath=\"icons/tray-icon-light.png\" --json.tauri_systemTray_iconAsTemplate=false", "fix:tray": "tr override --json.tauri_systemTray_iconPath=\"icons/tray-icon-light.png\" --json.tauri_systemTray_iconAsTemplate=false",
"fix:tray:mac": "tr override --json.tauri_systemTray_iconPath=\"icons/tray-icon.png\" --json.tauri_systemTray_iconAsTemplate=true", "fix:tray:mac": "tr override --json.tauri_systemTray_iconPath=\"icons/tray-icon.png\" --json.tauri_systemTray_iconAsTemplate=true",
"download": "node ./scripts/download.js", "download": "tr download --mdfile=README.md,README-ZH_CN.md --f1=38 --f2=35",
"fmt:rs": "cargo fmt", "fmt:rs": "cargo fmt",
"tr": "tr", "tr": "tr",
"tauri": "tauri", "tauri": "tauri",
@@ -45,6 +45,7 @@
"dayjs": "^1.11.7", "dayjs": "^1.11.7",
"github-markdown-css": "^5.1.0", "github-markdown-css": "^5.1.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"monaco-editor": "^0.34.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-markdown": "^8.0.4", "react-markdown": "^8.0.4",
@@ -58,7 +59,7 @@
}, },
"devDependencies": { "devDependencies": {
"@tauri-apps/cli": "^1.2.2", "@tauri-apps/cli": "^1.2.2",
"@tauri-release/cli": "^0.2.3", "@tauri-release/cli": "^0.2.5",
"@types/lodash": "^4.14.191", "@types/lodash": "^4.14.191",
"@types/node": "^18.7.10", "@types/node": "^18.7.10",
"@types/react": "^18.0.15", "@types/react": "^18.0.15",

4764
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

33
scripts/download.js vendored
View File

@@ -1,33 +0,0 @@
const fs = require('fs');
const argv = process.argv.slice(2);
async function rewrite(filename) {
const content = fs.readFileSync(filename, 'utf8').split('\n');
const startRe = /<!-- download start -->/;
const endRe = /<!-- download end -->/;
let flag = false;
for (let i = 0; i < content.length; i++) {
if (startRe.test(content[i])) {
flag = true;
}
if (flag) {
if (!/winget install --id=lencx.ChatGPT -e --version/.test(content[i])) {
content[i] = content[i].replace(/(\d+).(\d+).(\d+)/g, argv[0]);
}
}
if (endRe.test(content[i])) {
break;
}
}
fs.writeFileSync(filename, content.join('\n'), 'utf8');
}
async function init() {
rewrite('README.md');
rewrite('README-ZH_CN.md');
}
init().catch(console.error);

View File

@@ -30,6 +30,7 @@ tauri = { version = "1.2.4", features = ["api-all", "devtools", "global-shortcut
tauri-plugin-positioner = { version = "1.0.4", features = ["system-tray"] } tauri-plugin-positioner = { version = "1.0.4", features = ["system-tray"] }
tauri-plugin-log = { git = "https://github.com/lencx/tauri-plugins-workspace", branch = "dev", features = ["colored"] } tauri-plugin-log = { git = "https://github.com/lencx/tauri-plugins-workspace", branch = "dev", features = ["colored"] }
tauri-plugin-autostart = { git = "https://github.com/lencx/tauri-plugins-workspace", branch = "dev" } tauri-plugin-autostart = { git = "https://github.com/lencx/tauri-plugins-workspace", branch = "dev" }
tauri-plugin-window-state = { git = "https://github.com/lencx/tauri-plugins-workspace", branch = "dev" }
# sqlx = { version = "0.6.2", features = ["runtime-tokio-rustls", "sqlite"] } # sqlx = { version = "0.6.2", features = ["runtime-tokio-rustls", "sqlite"] }

View File

@@ -62,7 +62,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
.title("ChatGPT") .title("ChatGPT")
.resizable(true) .resizable(true)
.fullscreen(false) .fullscreen(false)
.inner_size(800.0, 600.0) .inner_size(app_conf2.main_width, app_conf2.main_height)
.theme(Some(theme)) .theme(Some(theme))
.always_on_top(app_conf2.stay_on_top) .always_on_top(app_conf2.stay_on_top)
.initialization_script(&utils::user_script()) .initialization_script(&utils::user_script())

View File

@@ -18,7 +18,7 @@ pub fn tray_window(handle: &tauri::AppHandle) {
.title("ChatGPT") .title("ChatGPT")
.resizable(false) .resizable(false)
.fullscreen(false) .fullscreen(false)
.inner_size(360.0, 540.0) .inner_size(app_conf.tray_width, app_conf.tray_height)
.decorations(false) .decorations(false)
.always_on_top(true) .always_on_top(true)
.theme(Some(theme)) .theme(Some(theme))
@@ -150,8 +150,7 @@ pub mod cmd {
.build() .build()
.unwrap(); .unwrap();
}); });
} } else if let Some(v) = win {
if let Some(v) = win {
if !v.is_visible().unwrap() { if !v.is_visible().unwrap() {
v.show().unwrap(); v.show().unwrap();
} }

View File

@@ -35,17 +35,28 @@ pub_struct!(AppConf {
theme: String, theme: String,
// auto update policy: prompt / silent / disable // auto update policy: prompt / silent / disable
auto_update: String, auto_update: String,
tray: bool,
popup_search: bool,
stay_on_top: bool, stay_on_top: bool,
main_dashboard: bool, save_window_state: bool,
tray_dashboard: bool,
main_origin: String,
tray_origin: String,
default_origin: String,
ua_window: String,
ua_tray: String,
global_shortcut: Option<String>, global_shortcut: Option<String>,
default_origin: String,
// Main Window
isinit: bool,
popup_search: bool,
main_close: bool,
main_dashboard: bool,
main_origin: String,
ua_window: String,
main_width: f64,
main_height: f64,
// Tray Window
tray_width: f64,
tray_height: f64,
tray: bool,
tray_dashboard: bool,
tray_origin: String,
ua_tray: String,
}); });
impl AppConf { impl AppConf {
@@ -54,13 +65,20 @@ impl AppConf {
Self { Self {
titlebar: !cfg!(target_os = "macos"), titlebar: !cfg!(target_os = "macos"),
hide_dock_icon: false, hide_dock_icon: false,
save_window_state: false,
theme: "light".into(), theme: "light".into(),
auto_update: "prompt".into(), auto_update: "prompt".into(),
tray: true, tray: true,
popup_search: false, popup_search: false,
isinit: true,
main_close: false,
stay_on_top: false, stay_on_top: false,
main_dashboard: false, main_dashboard: false,
tray_dashboard: false, tray_dashboard: false,
main_width: 800.0,
main_height: 600.0,
tray_width: 360.0,
tray_height: 540.0,
main_origin: CHATGPT_URL.into(), main_origin: CHATGPT_URL.into(),
tray_origin: CHATGPT_URL.into(), tray_origin: CHATGPT_URL.into(),
default_origin: CHATGPT_URL.into(), default_origin: CHATGPT_URL.into(),

View File

@@ -87,16 +87,41 @@ async fn main() {
builder = builder.system_tray(menu::tray_menu()); builder = builder.system_tray(menu::tray_menu());
} }
if app_conf.save_window_state {
builder = builder.plugin(tauri_plugin_window_state::Builder::default().build());
}
builder builder
.on_menu_event(menu::menu_handler) .on_menu_event(menu::menu_handler)
.on_system_tray_event(menu::tray_handler) .on_system_tray_event(menu::tray_handler)
.on_window_event(|event| { .on_window_event(move |event| {
if let tauri::WindowEvent::CloseRequested { api, .. } = event.event() { if let tauri::WindowEvent::CloseRequested { api, .. } = event.event() {
let win = event.window(); let win = event.window().clone();
let app_conf = AppConf::read();
if win.label() == "core" { if win.label() == "core" {
event.window().minimize().unwrap(); if app_conf.isinit {
tauri::api::dialog::ask(
Some(event.window()),
"",
"Do you want to exit the application when you click the [x] button?",
move |is_ok| {
app_conf
.amend(serde_json::json!({ "isinit" : false, "main_close": is_ok }))
.write();
if is_ok {
std::process::exit(0);
} else {
win.minimize().unwrap();
}
},
);
} else if app_conf.main_close {
std::process::exit(0);
} else {
win.minimize().unwrap();
}
} else { } else {
win.close().unwrap(); event.window().close().unwrap();
} }
api.prevent_close(); api.prevent_close();
} }

View File

@@ -137,7 +137,7 @@ function addActionsButtons(actionsArea, TryAgainButton) {
} }
async function exportMarkdown() { async function exportMarkdown() {
const content = Array.from(document.querySelectorAll("main >div>div>div>div")).map(i => { const content = Array.from(document.querySelectorAll('main .items-center>div')).map(i => {
let j = i.cloneNode(true); let j = i.cloneNode(true);
if (/dark\:bg-gray-800/.test(i.getAttribute('class'))) { if (/dark\:bg-gray-800/.test(i.getAttribute('class'))) {
j.innerHTML = `<blockquote>${i.innerHTML}</blockquote>`; j.innerHTML = `<blockquote>${i.innerHTML}</blockquote>`;

View File

@@ -7,7 +7,7 @@
}, },
"package": { "package": {
"productName": "ChatGPT", "productName": "ChatGPT",
"version": "0.10.3" "version": "0.11.0"
}, },
"tauri": { "tauri": {
"allowlist": { "allowlist": {

View File

@@ -8,8 +8,8 @@ type rowSelectionOptions = {
key: 'id' | string; key: 'id' | string;
rowType: 'id' | 'row' | 'all'; rowType: 'id' | 'row' | 'all';
}; };
export function useTableRowSelection(options: Partial<rowSelectionOptions> = {}) { export function useTableRowSelection(options?: Partial<rowSelectionOptions>) {
const { key = 'id', rowType = 'id' } = options; const { key = 'id', rowType = 'id' } = options || {};
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]); const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
const [selectedRowIDs, setSelectedRowIDs] = useState<string[]>([]); const [selectedRowIDs, setSelectedRowIDs] = useState<string[]>([]);
const [selectedRows, setSelectedRows] = useState<Record<string | symbol, any>[]>([]); const [selectedRows, setSelectedRows] = useState<Record<string | symbol, any>[]>([]);

View File

@@ -18,6 +18,9 @@ export default function General() {
<Form.Item label="Stay On Top" name="stay_on_top" valuePropName="checked"> <Form.Item label="Stay On Top" name="stay_on_top" valuePropName="checked">
<Switch /> <Switch />
</Form.Item> </Form.Item>
<Form.Item label="Save Window State" name="save_window_state" valuePropName="checked">
<Switch />
</Form.Item>
{platformInfo === 'darwin' && ( {platformInfo === 'darwin' && (
<Form.Item label="Titlebar" name="titlebar" valuePropName="checked"> <Form.Item label="Titlebar" name="titlebar" valuePropName="checked">
<Switch /> <Switch />

View File

@@ -1,4 +1,4 @@
import { Form, Switch, Input, Tooltip } from 'antd'; import { Form, Switch, Input, InputNumber, Tooltip } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons'; import { QuestionCircleOutlined } from '@ant-design/icons';
import SwitchOrigin from '@/components/SwitchOrigin'; import SwitchOrigin from '@/components/SwitchOrigin';
@@ -30,12 +30,32 @@ const PopupSearchLabel = () => {
); );
}; };
const MainCloseLabel = () => {
return (
<span>
Close Exit{' '}
<Tooltip title="Click the close button whether to exit directly, the default minimized.">
<QuestionCircleOutlined style={{ color: '#1677ff' }} />
</Tooltip>
</span>
);
};
export default function MainWindow() { export default function MainWindow() {
return ( return (
<> <>
<Form.Item label={<PopupSearchLabel />} name="popup_search" valuePropName="checked"> <Form.Item label={<PopupSearchLabel />} name="popup_search" valuePropName="checked">
<Switch /> <Switch />
</Form.Item> </Form.Item>
<Form.Item label={<MainCloseLabel />} name="main_close" valuePropName="checked">
<Switch />
</Form.Item>
<Form.Item label="Default Width" name="main_width">
<InputNumber />
</Form.Item>
<Form.Item label="Default Height" name="main_height">
<InputNumber />
</Form.Item>
<SwitchOrigin name="main" /> <SwitchOrigin name="main" />
<Form.Item label="User Agent (Main)" name="ua_window"> <Form.Item label="User Agent (Main)" name="ua_window">
<Input.TextArea <Input.TextArea

View File

@@ -1,4 +1,4 @@
import { Form, Switch, Input, Tooltip } from 'antd'; import { Form, Switch, Input, InputNumber, Tooltip } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons'; import { QuestionCircleOutlined } from '@ant-design/icons';
import { DISABLE_AUTO_COMPLETE } from '@/utils'; import { DISABLE_AUTO_COMPLETE } from '@/utils';
@@ -23,6 +23,12 @@ export default function TrayWindow() {
<Form.Item label="Enable SystemTray" name="tray" valuePropName="checked"> <Form.Item label="Enable SystemTray" name="tray" valuePropName="checked">
<Switch /> <Switch />
</Form.Item> </Form.Item>
<Form.Item label="Default Width" name="tray_width">
<InputNumber />
</Form.Item>
<Form.Item label="Default Height" name="tray_height">
<InputNumber />
</Form.Item>
<SwitchOrigin name="tray" /> <SwitchOrigin name="tray" />
<Form.Item label={<UALabel />} name="ua_tray"> <Form.Item label={<UALabel />} name="ua_tray">
<Input.TextArea <Input.TextArea

View File

@@ -24,5 +24,19 @@ export default defineConfig({
minify: !process.env.TAURI_DEBUG ? 'esbuild' : false, minify: !process.env.TAURI_DEBUG ? 'esbuild' : false,
// produce sourcemaps for debug builds // produce sourcemaps for debug builds
sourcemap: !!process.env.TAURI_DEBUG, sourcemap: !!process.env.TAURI_DEBUG,
rollupOptions: {
output: {
manualChunks: {
ant: ['antd'],
antico: ['@ant-design/icons'],
editor: ['@monaco-editor/react'],
utils: ['lodash', 'uuid', 'dayjs', 'clsx'],
rrr: ['react', 'react-dom', 'react-router-dom'],
rm: ['react-markdown'],
rsh: ['react-syntax-highlighter'],
md: ['github-markdown-css', 'rehype-raw', 'remark-comment-config', 'remark-gfm'],
},
},
},
}, },
}); });