diff --git a/.gitignore b/.gitignore index 12bc2b3ee3e90884a6db97506c55488fbcb98dc4..a192474fe4e65fba1e5f54ad46e757d151296560 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /backend/venv /backend/.idea .idea +.DS_Store .history/ .vscode/ diff --git a/README.zh.md b/README.zh.md index e3e104827df74a6889d4175e6057b1a689b15954..d5708699f94d8d885abcf833b46eaba33f164f07 100644 --- a/README.zh.md +++ b/README.zh.md @@ -134,7 +134,7 @@ npm install yarn yarn install --registry=https://registry.npmmirror.com # 启动服务 -yarn build +yarn dev # 浏览器访问 http://localhost:8080 # .env.development 文件中可配置启动端口等参数 # 构建生产环境 @@ -146,27 +146,25 @@ yarn build ## 后端💈 ~~~bash -1. 进入项目目录 cd backend -2. 在项目根目录中,复制 ./conf/env.example.py 文件为一份新的到 ./conf 文件夹下,并重命名为 env.py -3. 在 env.py 中配置数据库信息 - mysql数据库版本建议:8.0 - mysql数据库字符集:utf8mb4 -4. 安装依赖环境 - pip3 install -r requirements.txt -5. 执行迁移命令: - python3 manage.py makemigrations - python3 manage.py migrate -6. 初始化数据 - python3 manage.py init -7. 初始化省市县数据: - python3 manage.py init_area -8. 启动项目 - python3 manage.py runserver 0.0.0.0:8000 -或使用 uvicorn : - uvicorn application.asgi:application --port 8000 --host 0.0.0.0 --workers 8 +cd backend # 进入项目目录 +python -m venv venv # 创建虚拟环境 +source venv/bin/activate # 进入虚拟环境 +pip3 install -r requirements.txt # 安装依赖 + +# 执行迁移命令: +python3 manage.py makemigrations +python3 manage.py migrate + +# 初始化数据 +python3 manage.py init +# 初始化省市县数据: +python3 manage.py init_area +# 启动项目 +python3 manage.py runserver 0.0.0.0:8000 + +# 或使用 uvicorn : +uvicorn application.asgi:application --port 8000 --host 0.0.0.0 --workers 8 ~~~ -## 开发建议 -前后端backend与web各自单独一个窗口打开进行开发 ### 访问项目 diff --git a/backend/requirements.txt b/backend/requirements.txt index f443f6f09bb90f9ccaf10d05b5dd21f5f953a915..5837ef728df2d4ae371b2992a915ba675fc93c52 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -22,7 +22,6 @@ channels-redis==4.2.0 user-agents==2.2.0 six==1.16.0 whitenoise==6.7.0 -psycopg2==2.9.9 uvicorn==0.30.3 gunicorn==23.0.0 gevent==24.2.1 diff --git a/web/package.json b/web/package.json index 2a57a86c02822559e4bc734052f2e61533f52495..3bcc8f02c31e18381532535a07cc667996b05144 100644 --- a/web/package.json +++ b/web/package.json @@ -69,21 +69,23 @@ "vue-qr": "^4.0.9", "vue-router": "^4.4.3", "vxe-table": "^4.6.18", - "xe-utils": "^3.5.30" + "xe-utils": "^3.5.30", + "yarn": "^1.22.22" }, "devDependencies": { "@types/node": "^18.19.42", "@types/nprogress": "^0.2.3", "@types/sortablejs": "^1.15.8", - "@typescript-eslint/eslint-plugin": "^5.46.0", - "@typescript-eslint/parser": "^5.46.0", + "@typescript-eslint/eslint-plugin": "^8.0.0", + "@typescript-eslint/parser": "^8.0.0", "@vitejs/plugin-vue": "^5.1.2", + "@vitejs/plugin-vue-jsx": "^4.0.1", "@vue/compiler-sfc": "^3.4.38", "eslint": "^9.9.0", "eslint-plugin-vue": "^9.27.0", "prettier": "^2.8.1", "sass": "^1.56.2", - "typescript": "^4.9.4", + "typescript": "^5.0.0", "vite": "^5.4.1", "vite-plugin-vue-setup-extend": "^0.4.0", "vue-eslint-parser": "^9.4.3" diff --git a/web/vite.config.ts b/web/vite.config.ts index d6ebf26796b506cf9b7c8ab0a6fc4f1543af9b20..99fbf932e8dc5853039ff427cac337b4c8ff290f 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -2,8 +2,9 @@ import vue from '@vitejs/plugin-vue'; import { resolve } from 'path'; import { defineConfig, loadEnv, ConfigEnv } from 'vite'; import vueSetupExtend from 'vite-plugin-vue-setup-extend'; -import vueJsx from '@vitejs/plugin-vue-jsx' -import { generateVersionFile } from "/@/utils/upgrade"; +import fs from 'fs'; +import * as process from 'process'; +// 不使用 @vitejs/plugin-vue-jsx 插件,避免 ESM/CJS 兼容性问题 const pathResolve = (dir: string) => { return resolve(__dirname, '.', dir); @@ -20,9 +21,15 @@ const alias: Record = { const viteConfig = defineConfig((mode: ConfigEnv) => { const env = loadEnv(mode.mode, process.cwd()); // 当Vite构建时,生成版本文件 - generateVersionFile() + if (mode.command === 'build') { + // 生成版本文件到public目录下version文件中 + const VERSION_FILE_NAME = 'version-build'; + const package_version = process.env.npm_package_version; + const version = `${package_version}.${new Date().getTime()}`; + fs.writeFileSync(`public/${VERSION_FILE_NAME}`, version); + } return { - plugins: [vue(), vueJsx(), vueSetupExtend()], + plugins: [vue(), vueSetupExtend()], root: process.cwd(), resolve: { alias }, base: mode.command === 'serve' ? './' : env.VITE_PUBLIC_PATH,