fix: use legacy react-scripts

This commit is contained in:
ckt1031 2023-07-20 19:55:22 +08:00
parent 66e02a4bcf
commit f126d783c9
62 changed files with 15861 additions and 557 deletions

View File

@ -24,7 +24,7 @@ jobs:
run: | run: |
cd web cd web
npm install npm install
VITE_REACT_APP_VERSION=$(git describe --tags) npm run build 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
VITE_REACT_APP_VERSION=$(git describe --tags) npm run build 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
VITE_REACT_APP_VERSION=$(git describe --tags) npm run build 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 VITE_REACT_APP_VERSION=$(cat VERSION) npm run build RUN REACT_APP_VERSION=$(cat VERSION) npm run build
# Go build stage # Go build stage
FROM golang AS builder2 FROM golang AS builder2

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 && VITE_REACT_APP_VERSION=$(cat VERSION) npm run build RUN cd web && 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 `VITE_REACT_APP_SERVER` environment variables before build, If you want to change the default server, please set `REACT_APP_SERVER` environment variables before build,
for example: `VITE_REACT_APP_SERVER=http://your.domain.com`. for example: `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.

16374
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,15 +9,18 @@
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-dropzone": "^14.2.3", "react-dropzone": "^14.2.3",
"react-router-dom": "^6.14.1", "react-router-dom": "^6.14.2",
"react-scripts": "5.0.1",
"react-toastify": "^9.1.3", "react-toastify": "^9.1.3",
"react-turnstile": "^1.1.1", "react-turnstile": "^1.1.1",
"semantic-ui-css": "^2.5.0", "semantic-ui-css": "^2.5.0",
"semantic-ui-react": "^2.1.4" "semantic-ui-react": "^2.1.4"
}, },
"scripts": { "scripts": {
"start": "vite preview", "start": "react-scripts start",
"build": "vite build" "build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}, },
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [
@ -38,9 +41,7 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@vitejs/plugin-react": "^4.0.3", "prettier": "^3.0.0"
"prettier": "3.0.0",
"vite": "^4.4.4"
}, },
"prettier": { "prettier": {
"singleQuote": true, "singleQuote": true,

View File

@ -14,6 +14,5 @@
<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>

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} {import.meta.env.VITE_REACT_APP_VERSION}{' '} {systemName} {process.env.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 === import.meta.env.VITE_REACT_APP_VERSION) { if (tag_name === process.env.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: import.meta.env.VITE_REACT_APP_SERVER ? import.meta.env.VITE_REACT_APP_SERVER : '', baseURL: process.env.REACT_APP_SERVER ? process.env.REACT_APP_SERVER : '',
}); });
API.interceptors.response.use( API.interceptors.response.use(

View File

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