From 430d6e4af28abd97ebb2445fcadfc90b1c0caa18 Mon Sep 17 00:00:00 2001 From: lencx Date: Tue, 13 Dec 2022 11:58:47 +0800 Subject: [PATCH] chore: add fe --- .gitattributes | 4 +- .github/workflows/release.yml | 2 +- .gitignore | 29 +++++++++- index.html | 13 +++++ package.json | 15 ++++- src-tauri/src/assets/core.js | 1 + src-tauri/src/assets/origin.js | 2 + src-tauri/src/assets/ua.js | 2 + src-tauri/tauri.conf.json | 15 +++-- src/App.css | 7 +++ src/App.tsx | 11 ++++ src/main.tsx | 11 ++++ src/style.css | 102 +++++++++++++++++++++++++++++++++ src/vite-env.d.ts | 1 + tsconfig.json | 21 +++++++ tsconfig.node.json | 9 +++ vite.config.ts | 27 +++++++++ 17 files changed, 262 insertions(+), 10 deletions(-) create mode 100644 index.html create mode 100644 src/App.css create mode 100644 src/App.tsx create mode 100644 src/main.tsx create mode 100644 src/style.css create mode 100644 src/vite-env.d.ts create mode 100644 tsconfig.json create mode 100644 tsconfig.node.json create mode 100644 vite.config.ts diff --git a/.gitattributes b/.gitattributes index a293ab2..857b7e2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,3 @@ -*.js linguist-vendored \ No newline at end of file +*.js linguist-vendored +*.tsx linguist-vendored +*.css linguist-vendored \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b6bf105..32d67d5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -75,7 +75,7 @@ jobs: ${{ runner.os }}-yarn- - name: Install app dependencies and build it - run: yarn + run: yarn && yarn build:fe - uses: tauri-apps/tauri-action@v0.3 env: diff --git a/.gitignore b/.gitignore index 20036f9..707eccc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,32 @@ -.DS_Store -*.lock - package-lock.json node_modules/ yarn.lock +*.lock +# rust target/ Cargo.lock + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/index.html b/index.html new file mode 100644 index 0000000..f28c8f0 --- /dev/null +++ b/index.html @@ -0,0 +1,13 @@ + + + + + + ChatGPT + + + +
+ + + diff --git a/package.json b/package.json index 79f4083..21ac65f 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,8 @@ "name": "chatgpt", "version": "0.0.0", "scripts": { + "dev:fe": "vite", + "build:fe": "tsc && vite build", "dev": "yarn tauri dev", "build": "yarn tauri build", "updater": "tr updater", @@ -27,8 +29,19 @@ "type": "git", "url": "https://github.com/lencx/ChatGPT" }, + "dependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0", + "@tauri-apps/api": "^1.2.0" + }, "devDependencies": { - "@tauri-apps/cli": "^1.2.1", + "@types/node": "^18.7.10", + "@types/react": "^18.0.15", + "@types/react-dom": "^18.0.6", + "@vitejs/plugin-react": "^3.0.0", + "typescript": "^4.6.4", + "vite": "^4.0.0", + "@tauri-apps/cli": "^1.2.2", "@tauri-release/cli": "^0.2.3" } } diff --git a/src-tauri/src/assets/core.js b/src-tauri/src/assets/core.js index 854b1aa..143c1a8 100644 --- a/src-tauri/src/assets/core.js +++ b/src-tauri/src/assets/core.js @@ -1,4 +1,5 @@ // *** Core Script - IPC *** + const uid = () => window.crypto.getRandomValues(new Uint32Array(1))[0]; function transformCallback(callback = () => {}, once = false) { const identifier = uid(); diff --git a/src-tauri/src/assets/origin.js b/src-tauri/src/assets/origin.js index 2933ffc..b2264f7 100644 --- a/src-tauri/src/assets/origin.js +++ b/src-tauri/src/assets/origin.js @@ -1,3 +1,5 @@ +// *** Core Script - Origin *** + function init() { document.body.innerHTML = `