From 4db5a3717eab38399b2e268d45d83a846b86ac07 Mon Sep 17 00:00:00 2001 From: yangzi <1131696774@qq.com> Date: Tue, 19 Dec 2023 15:12:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(git=20workflow):=20=F0=9F=9A=80=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9Egit=20workflow=E3=80=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 2 +- .env.test | 2 +- .github/workflow/build.yml | 31 +++++++++++++++++++++++++++++++ src/components/layouts/index.less | 9 ++++++--- src/components/layouts/index.tsx | 6 +++--- src/typings/plugins.d.ts | 1 + src/views/login/index.tsx | 30 ++++++++++++++++++++---------- tsconfig.node.json | 17 ++--------------- vite.config.ts | 2 +- 9 files changed, 66 insertions(+), 34 deletions(-) create mode 100644 .github/workflow/build.yml diff --git a/.env.production b/.env.production index ab58919..023c378 100644 --- a/.env.production +++ b/.env.production @@ -15,4 +15,4 @@ VITE_DROP_CONSOLE = true VITE_PWA = true # 线上环境接口地址 -VITE_API_URL = "https://mock.mengxuegu.com/mock/629d727e6163854a32e8307e" +VITE_API_URL = "https://mock.apifox.com/m1/3705594-0-default" diff --git a/.env.test b/.env.test index 17dbebd..f8bc280 100644 --- a/.env.test +++ b/.env.test @@ -22,4 +22,4 @@ VITE_DROP_CONSOLE = true VITE_PWA = false # 测试环境接口地址 -VITE_API_URL = "https://mock.mengxuegu.com/mock/629d727e6163854a32e8307e" +VITE_API_URL = "https://mock.apifox.com/m1/3705594-0-default" diff --git a/.github/workflow/build.yml b/.github/workflow/build.yml new file mode 100644 index 0000000..12c2c83 --- /dev/null +++ b/.github/workflow/build.yml @@ -0,0 +1,31 @@ +# 工作流名称 +name: Auto Build + +# 从工作流生成的工作流运行的名称,如果省略,则使用提交时的commit信息 +run-name: Deploy by @${{ github.actor }} + +# 触发条件 +on: + push: + branches: + - master + +# 工作流的步骤 +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + - name: install and build + run: | + npm install + npm run build + - name: deploy + uses: JamesIves/github-pages-deploy-action@4.1.5 + with: + branch: gh-pages + folder: dist + clean: true diff --git a/src/components/layouts/index.less b/src/components/layouts/index.less index e0c9f68..50f22d4 100644 --- a/src/components/layouts/index.less +++ b/src/components/layouts/index.less @@ -47,9 +47,12 @@ } } .content-stage { + padding: 12px; overflow: auto; - .child-stage { - margin: 12px; - } + // height: 100%; + // .child-stage { + // margin: 12px; + // min-height: 100%; + // } } } diff --git a/src/components/layouts/index.tsx b/src/components/layouts/index.tsx index 8d29381..6698497 100644 --- a/src/components/layouts/index.tsx +++ b/src/components/layouts/index.tsx @@ -19,9 +19,9 @@ const Layouts: React.FC = () => {
{/* 子路由展示区域 */} -
- -
+ {/*
*/} + + {/*
*/}
diff --git a/src/typings/plugins.d.ts b/src/typings/plugins.d.ts index fadfeb7..639e9bb 100644 --- a/src/typings/plugins.d.ts +++ b/src/typings/plugins.d.ts @@ -1 +1,2 @@ declare module "qs"; +declare module "nprogress"; diff --git a/src/views/login/index.tsx b/src/views/login/index.tsx index f2ea02c..a199634 100644 --- a/src/views/login/index.tsx +++ b/src/views/login/index.tsx @@ -1,4 +1,4 @@ -import { Form, Button, Input, theme, notification } from "antd"; +import { Form, Button, Input, theme, notification, message } from "antd"; import { UserOutlined, LockOutlined } from "@ant-design/icons"; import { ValidateStatus } from "antd/es/form/FormItem"; import { useNavigate } from "react-router-dom"; @@ -9,11 +9,15 @@ import { useState } from "react"; import { login } from "@/api/modules/login"; import { LoginSpace } from "@/api/type"; import { getTimeState } from "@/utils/common"; +import { useDispatch } from "@/store"; +import { ResultEnum } from "@/enums/httpEnum"; +import { setToken } from "@/store/module/global"; const { useToken } = theme; function Login() { const navigate = useNavigate(); + const dispatch = useDispatch(); const onFinish = async (values: LoginSpace.reqLogin) => { let { username, password } = values; // 输入框校验 @@ -22,15 +26,21 @@ function Login() { // 登录 if (username && password) { - await login({ username, password }); - notification.success({ - message: getTimeState(), - description: "登录成功", - placement: "topRight", - duration: 3 - }); - // 跳转首页 - navigate("/dashboard/index", { replace: true }); + const { data } = await login({ username, password }); + if (data.code === ResultEnum.SUCCESS) { + //储存token + dispatch(setToken(data.data.token)); + notification.success({ + message: getTimeState(), + description: "登录成功", + placement: "topRight", + duration: 3 + }); + // 跳转首页 + navigate("/dashboard/index", { replace: true }); + } else { + message.error(data.msg); + } } }; const { token } = useToken(); diff --git a/tsconfig.node.json b/tsconfig.node.json index 4d040c9..7af9848 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -4,23 +4,10 @@ "skipLibCheck": true, "module": "ESNext", "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true, - "jsx": "react-jsx", - // 解析非相对模块名的基准目录 - "baseUrl": "./", - // 模块名到基于 baseUrl的路径映射的列表。 - "paths": { - "@": [ - "src" - ], - "@/*": [ - "src/*" - ] - } + "allowSyntheticDefaultImports": true }, "include": [ "vite.config.ts", - "src/utils/*", - "src/typings/*" + "./src/utils/getEnv.ts" ] } \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 016012d..600bd58 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -11,7 +11,6 @@ import { createProxy, wrapperEnv } from "./src/utils/getEnv"; export default defineConfig((mode: ConfigEnv): UserConfig => { const env = loadEnv(mode.mode, process.cwd()); const ViteEnv = wrapperEnv(env); - console.log(createProxy(ViteEnv.VITE_PROXY)); return { // 服务配置 @@ -55,6 +54,7 @@ export default defineConfig((mode: ConfigEnv): UserConfig => { pure: ViteEnv.VITE_DROP_CONSOLE ? ["console.log", "debugger"] : [] }, // 打包配置 + base: "./", build: { assetsDir: resolve(__dirname, "./public"), outDir: "dist",