feat: move to vite for faster builld

This commit is contained in:
ckt1031 2023-07-15 21:41:23 +08:00
parent caabdd1e21
commit 4e94c85a9a
63 changed files with 411 additions and 16907 deletions

View File

@ -24,7 +24,7 @@ jobs:
run: | run: |
cd web cd web
npm install npm install
REACT_APP_VERSION=$(git describe --tags) npm run build VITE_REACT_APP_VERSION=$(git describe --tags) npm run build
cd .. cd ..
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@v3

View File

@ -24,7 +24,7 @@ jobs:
run: | run: |
cd web cd web
npm install npm install
REACT_APP_VERSION=$(git describe --tags) npm run build VITE_REACT_APP_VERSION=$(git describe --tags) npm run build
cd .. cd ..
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@v3

View File

@ -27,7 +27,7 @@ jobs:
run: | run: |
cd web cd web
npm install npm install
REACT_APP_VERSION=$(git describe --tags) npm run build VITE_REACT_APP_VERSION=$(git describe --tags) npm run build
cd .. cd ..
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@v3

View File

@ -5,7 +5,7 @@ COPY ./web/package*.json ./
RUN npm ci RUN npm ci
COPY ./web . COPY ./web .
COPY ./VERSION . COPY ./VERSION .
RUN REACT_APP_VERSION=$(cat VERSION) npm run build RUN VITE_REACT_APP_VERSION=$(cat VERSION) npm run build
# Go build stage # Go build stage
FROM golang AS builder2 FROM golang AS builder2

View File

@ -57,12 +57,6 @@ _✨ All in one 的 OpenAI 接口,整合各种 API 访问方式,开箱即用
> **Warning**:从 `v0.3` 版本升级到 `v0.4` 版本需要手动迁移数据库,请手动执行[数据库迁移脚本](./bin/migration_v0.3-v0.4.sql)。 > **Warning**:从 `v0.3` 版本升级到 `v0.4` 版本需要手动迁移数据库,请手动执行[数据库迁移脚本](./bin/migration_v0.3-v0.4.sql)。
## 👍Forks 特殊功能⚡
1. 增强的**频道测试**以提高稳定性。
2. 支持 **Dall-E 2 模型图像生成** API。
3. 修复**登录页面**中缺少的 **Turnstile 验证码**
## 功能 ## 功能
1. 支持多种 API 访问渠道: 1. 支持多种 API 访问渠道:
+ [x] OpenAI 官方通道(支持配置镜像) + [x] OpenAI 官方通道(支持配置镜像)

View File

@ -10,7 +10,7 @@ WORKDIR /build
COPY ./web/package*.json ./ COPY ./web/package*.json ./
RUN npm ci RUN npm ci
COPY --from=translator /app . COPY --from=translator /app .
RUN cd web && REACT_APP_VERSION=$(cat VERSION) npm run build RUN cd web && VITE_REACT_APP_VERSION=$(cat VERSION) npm run build
# Go build stage # Go build stage
FROM golang:1.20.5 AS goBuilder FROM golang:1.20.5 AS goBuilder

View File

@ -10,8 +10,8 @@ npm start
npm run build npm run build
``` ```
If you want to change the default server, please set `REACT_APP_SERVER` environment variables before build, If you want to change the default server, please set `VITE_REACT_APP_SERVER` environment variables before build,
for example: `REACT_APP_SERVER=http://your.domain.com`. for example: `VITE_REACT_APP_SERVER=http://your.domain.com`.
Before you start editing, make sure your `Actions on Save` options have `Optimize imports` & `Run Prettier` enabled. Before you start editing, make sure your `Actions on Save` options have `Optimize imports` & `Run Prettier` enabled.

View File

@ -14,5 +14,6 @@
<body> <body>
<noscript>You need to enable JavaScript to run this app.</noscript> <noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div> <div id="root"></div>
<script type="module" src="./src/index.jsx"></script>
</body> </body>
</html> </html>

17269
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -16,10 +16,8 @@
"semantic-ui-react": "^2.1.4" "semantic-ui-react": "^2.1.4"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "vite preview",
"build": "react-scripts build", "build": "vite build"
"test": "react-scripts test",
"eject": "react-scripts eject"
}, },
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [
@ -40,9 +38,10 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@vitejs/plugin-react": "^4.0.3",
"prettier": "3.0.0", "prettier": "3.0.0",
"react-scripts": "^5.0.1" "terser": "^5.19.0",
"vite": "^4.4.4"
}, },
"prettier": { "prettier": {
"singleQuote": true, "singleQuote": true,

View File

@ -38,7 +38,7 @@ const Footer = () => {
) : ( ) : (
<div className='custom-footer'> <div className='custom-footer'>
<a href='https://github.com/songquanpeng/one-api' target='_blank'> <a href='https://github.com/songquanpeng/one-api' target='_blank'>
{systemName} {process.env.REACT_APP_VERSION}{' '} {systemName} {import.meta.env.VITE_REACT_APP_VERSION}{' '}
</a> </a>
{' '} {' '}
<a href='https://github.com/songquanpeng' target='_blank'> <a href='https://github.com/songquanpeng' target='_blank'>

View File

@ -99,7 +99,7 @@ const OtherSetting = () => {
'https://api.github.com/repos/songquanpeng/one-api/releases/latest', 'https://api.github.com/repos/songquanpeng/one-api/releases/latest',
); );
const { tag_name, body } = res.data; const { tag_name, body } = res.data;
if (tag_name === process.env.REACT_APP_VERSION) { if (tag_name === import.meta.env.VITE_REACT_APP_VERSION) {
showSuccess(`已是最新版本:${tag_name}`); showSuccess(`已是最新版本:${tag_name}`);
} else { } else {
setUpdateData({ setUpdateData({

View File

@ -2,7 +2,7 @@ import { showError } from './utils';
import axios from 'axios'; import axios from 'axios';
export const API = axios.create({ export const API = axios.create({
baseURL: process.env.REACT_APP_SERVER ? process.env.REACT_APP_SERVER : '', baseURL: import.meta.env.VITE_REACT_APP_SERVER ? import.meta.env.VITE_REACT_APP_SERVER : '',
}); });
API.interceptors.response.use( API.interceptors.response.use(

11
web/vite.config.js Normal file
View File

@ -0,0 +1,11 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
build: {
outDir: 'build',
minify: 'terser',
},
})