Skip to content

Commit 430d6e4

Browse files
committed
chore: add fe
1 parent 918d53c commit 430d6e4

17 files changed

+262
-10
lines changed

.gitattributes

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
*.js linguist-vendored
1+
*.js linguist-vendored
2+
*.tsx linguist-vendored
3+
*.css linguist-vendored

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
${{ runner.os }}-yarn-
7676
7777
- name: Install app dependencies and build it
78-
run: yarn
78+
run: yarn && yarn build:fe
7979

8080
- uses: tauri-apps/[email protected]
8181
env:

.gitignore

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
1-
.DS_Store
2-
*.lock
3-
41
package-lock.json
52
node_modules/
63
yarn.lock
4+
*.lock
75

6+
# rust
87
target/
98
Cargo.lock
9+
10+
# Logs
11+
logs
12+
*.log
13+
npm-debug.log*
14+
yarn-debug.log*
15+
yarn-error.log*
16+
pnpm-debug.log*
17+
lerna-debug.log*
18+
19+
dist
20+
dist-ssr
21+
*.local
22+
23+
# Editor directories and files
24+
.vscode/*
25+
!.vscode/extensions.json
26+
.idea
27+
.DS_Store
28+
*.suo
29+
*.ntvs*
30+
*.njsproj
31+
*.sln
32+
*.sw?

index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>ChatGPT</title>
7+
</head>
8+
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

package.json

+14-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"name": "chatgpt",
33
"version": "0.0.0",
44
"scripts": {
5+
"dev:fe": "vite",
6+
"build:fe": "tsc && vite build",
57
"dev": "yarn tauri dev",
68
"build": "yarn tauri build",
79
"updater": "tr updater",
@@ -27,8 +29,19 @@
2729
"type": "git",
2830
"url": "https://github.com/lencx/ChatGPT"
2931
},
32+
"dependencies": {
33+
"react": "^18.2.0",
34+
"react-dom": "^18.2.0",
35+
"@tauri-apps/api": "^1.2.0"
36+
},
3037
"devDependencies": {
31-
"@tauri-apps/cli": "^1.2.1",
38+
"@types/node": "^18.7.10",
39+
"@types/react": "^18.0.15",
40+
"@types/react-dom": "^18.0.6",
41+
"@vitejs/plugin-react": "^3.0.0",
42+
"typescript": "^4.6.4",
43+
"vite": "^4.0.0",
44+
"@tauri-apps/cli": "^1.2.2",
3245
"@tauri-release/cli": "^0.2.3"
3346
}
3447
}

src-tauri/src/assets/core.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// *** Core Script - IPC ***
2+
23
const uid = () => window.crypto.getRandomValues(new Uint32Array(1))[0];
34
function transformCallback(callback = () => {}, once = false) {
45
const identifier = uid();

src-tauri/src/assets/origin.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// *** Core Script - Origin ***
2+
13
function init() {
24
document.body.innerHTML = `<style>
35
body {

src-tauri/src/assets/ua.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// *** Core Script - User Agent ***
2+
13
function init() {
24
document.body.innerHTML = `<style>
35
body {

src-tauri/tauri.conf.json

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"build": {
3-
"beforeDevCommand": "",
4-
"beforeBuildCommand": "",
5-
"devPath": "../dist",
3+
"beforeDevCommand": "npm run dev:fe",
4+
"beforeBuildCommand": "npm run build:fe",
5+
"devPath": "http://localhost:1420/",
66
"distDir": "../dist"
77
},
88
"package": {
@@ -63,6 +63,13 @@
6363
"https://lencx.github.io/ChatGPT/install.json"
6464
],
6565
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEIxMjY4OUI5MTVFNjBEMDUKUldRRkRlWVZ1WWttc1NGWEE0RFNSb0RqdnhsekRJZTkwK2hVLzhBZTZnaHExSEZ1ZEdzWkpXTHkK"
66-
}
66+
},
67+
"windows": [
68+
{
69+
"label": "main",
70+
"url": "index.html",
71+
"visible": false
72+
}
73+
]
6774
}
6875
}

src/App.css

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.logo.vite:hover {
2+
filter: drop-shadow(0 0 2em #747bff);
3+
}
4+
5+
.logo.react:hover {
6+
filter: drop-shadow(0 0 2em #61dafb);
7+
}

src/App.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import "./App.css";
2+
3+
function App() {
4+
return (
5+
<div className="container">
6+
ChatGPT
7+
</div>
8+
);
9+
}
10+
11+
export default App;

src/main.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react";
2+
import ReactDOM from "react-dom/client";
3+
4+
import App from "./App";
5+
import "./style.css";
6+
7+
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
8+
<React.StrictMode>
9+
<App />
10+
</React.StrictMode>
11+
);

src/style.css

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
:root {
2+
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
3+
font-size: 16px;
4+
line-height: 24px;
5+
font-weight: 400;
6+
7+
color: #0f0f0f;
8+
background-color: #f6f6f6;
9+
10+
font-synthesis: none;
11+
text-rendering: optimizeLegibility;
12+
-webkit-font-smoothing: antialiased;
13+
-moz-osx-font-smoothing: grayscale;
14+
-webkit-text-size-adjust: 100%;
15+
}
16+
17+
.container {
18+
margin: 0;
19+
padding-top: 10vh;
20+
display: flex;
21+
flex-direction: column;
22+
justify-content: center;
23+
text-align: center;
24+
}
25+
26+
.logo {
27+
height: 6em;
28+
padding: 1.5em;
29+
will-change: filter;
30+
transition: 0.75s;
31+
}
32+
33+
.logo.tauri:hover {
34+
filter: drop-shadow(0 0 2em #24c8db);
35+
}
36+
37+
.row {
38+
display: flex;
39+
justify-content: center;
40+
}
41+
42+
a {
43+
font-weight: 500;
44+
color: #646cff;
45+
text-decoration: inherit;
46+
}
47+
48+
a:hover {
49+
color: #535bf2;
50+
}
51+
52+
h1 {
53+
text-align: center;
54+
}
55+
56+
input,
57+
button {
58+
border-radius: 8px;
59+
border: 1px solid transparent;
60+
padding: 0.6em 1.2em;
61+
font-size: 1em;
62+
font-weight: 500;
63+
font-family: inherit;
64+
color: #0f0f0f;
65+
background-color: #ffffff;
66+
transition: border-color 0.25s;
67+
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
68+
}
69+
70+
button {
71+
cursor: pointer;
72+
}
73+
74+
button:hover {
75+
border-color: #396cd8;
76+
}
77+
78+
input,
79+
button {
80+
outline: none;
81+
}
82+
83+
#greet-input {
84+
margin-right: 5px;
85+
}
86+
87+
@media (prefers-color-scheme: dark) {
88+
:root {
89+
color: #f6f6f6;
90+
background-color: #2f2f2f;
91+
}
92+
93+
a:hover {
94+
color: #24c8db;
95+
}
96+
97+
input,
98+
button {
99+
color: #ffffff;
100+
background-color: #0f0f0f98;
101+
}
102+
}

src/vite-env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

tsconfig.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"useDefineForClassFields": true,
5+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
6+
"allowJs": false,
7+
"skipLibCheck": true,
8+
"esModuleInterop": false,
9+
"allowSyntheticDefaultImports": true,
10+
"strict": true,
11+
"forceConsistentCasingInFileNames": true,
12+
"module": "ESNext",
13+
"moduleResolution": "Node",
14+
"resolveJsonModule": true,
15+
"isolatedModules": true,
16+
"noEmit": true,
17+
"jsx": "react-jsx"
18+
},
19+
"include": ["src"],
20+
"references": [{ "path": "./tsconfig.node.json" }]
21+
}

tsconfig.node.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"module": "ESNext",
5+
"moduleResolution": "Node",
6+
"allowSyntheticDefaultImports": true
7+
},
8+
"include": ["vite.config.ts"]
9+
}

vite.config.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { defineConfig } from "vite";
2+
import react from "@vitejs/plugin-react";
3+
4+
// https://vitejs.dev/config/
5+
export default defineConfig({
6+
plugins: [react()],
7+
8+
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
9+
// prevent vite from obscuring rust errors
10+
clearScreen: false,
11+
// tauri expects a fixed port, fail if that port is not available
12+
server: {
13+
port: 1420,
14+
strictPort: true,
15+
},
16+
// to make use of `TAURI_DEBUG` and other env variables
17+
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
18+
envPrefix: ["VITE_", "TAURI_"],
19+
build: {
20+
// Tauri supports es2021
21+
target: ["es2021", "chrome100", "safari13"],
22+
// don't minify for debug builds
23+
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
24+
// produce sourcemaps for debug builds
25+
sourcemap: !!process.env.TAURI_DEBUG,
26+
},
27+
});

0 commit comments

Comments
 (0)