chore: add fe

This commit is contained in:
lencx 2022-12-13 11:58:47 +08:00
parent 918d53c9b9
commit 430d6e4af2
17 changed files with 262 additions and 10 deletions

4
.gitattributes vendored
View File

@ -1 +1,3 @@
*.js linguist-vendored
*.js linguist-vendored
*.tsx linguist-vendored
*.css linguist-vendored

View File

@ -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:

29
.gitignore vendored
View File

@ -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?

13
index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ChatGPT</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

View File

@ -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"
}
}

View File

@ -1,4 +1,5 @@
// *** Core Script - IPC ***
const uid = () => window.crypto.getRandomValues(new Uint32Array(1))[0];
function transformCallback(callback = () => {}, once = false) {
const identifier = uid();

View File

@ -1,3 +1,5 @@
// *** Core Script - Origin ***
function init() {
document.body.innerHTML = `<style>
body {

View File

@ -1,3 +1,5 @@
// *** Core Script - User Agent ***
function init() {
document.body.innerHTML = `<style>
body {

View File

@ -1,8 +1,8 @@
{
"build": {
"beforeDevCommand": "",
"beforeBuildCommand": "",
"devPath": "../dist",
"beforeDevCommand": "npm run dev:fe",
"beforeBuildCommand": "npm run build:fe",
"devPath": "http://localhost:1420/",
"distDir": "../dist"
},
"package": {
@ -63,6 +63,13 @@
"https://lencx.github.io/ChatGPT/install.json"
],
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEIxMjY4OUI5MTVFNjBEMDUKUldRRkRlWVZ1WWttc1NGWEE0RFNSb0RqdnhsekRJZTkwK2hVLzhBZTZnaHExSEZ1ZEdzWkpXTHkK"
}
},
"windows": [
{
"label": "main",
"url": "index.html",
"visible": false
}
]
}
}

7
src/App.css vendored Normal file
View File

@ -0,0 +1,7 @@
.logo.vite:hover {
filter: drop-shadow(0 0 2em #747bff);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafb);
}

11
src/App.tsx vendored Normal file
View File

@ -0,0 +1,11 @@
import "./App.css";
function App() {
return (
<div className="container">
ChatGPT
</div>
);
}
export default App;

11
src/main.tsx vendored Normal file
View File

@ -0,0 +1,11 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./style.css";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
);

102
src/style.css vendored Normal file
View File

@ -0,0 +1,102 @@
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;
color: #0f0f0f;
background-color: #f6f6f6;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
.container {
margin: 0;
padding-top: 10vh;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: 0.75s;
}
.logo.tauri:hover {
filter: drop-shadow(0 0 2em #24c8db);
}
.row {
display: flex;
justify-content: center;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
h1 {
text-align: center;
}
input,
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
color: #0f0f0f;
background-color: #ffffff;
transition: border-color 0.25s;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}
button {
cursor: pointer;
}
button:hover {
border-color: #396cd8;
}
input,
button {
outline: none;
}
#greet-input {
margin-right: 5px;
}
@media (prefers-color-scheme: dark) {
:root {
color: #f6f6f6;
background-color: #2f2f2f;
}
a:hover {
color: #24c8db;
}
input,
button {
color: #ffffff;
background-color: #0f0f0f98;
}
}

1
src/vite-env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

21
tsconfig.json Normal file
View File

@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}

9
tsconfig.node.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

27
vite.config.ts Normal file
View File

@ -0,0 +1,27 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// prevent vite from obscuring rust errors
clearScreen: false,
// tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
},
// to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ["VITE_", "TAURI_"],
build: {
// Tauri supports es2021
target: ["es2021", "chrome100", "safari13"],
// don't minify for debug builds
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
// produce sourcemaps for debug builds
sourcemap: !!process.env.TAURI_DEBUG,
},
});