Skip to content

Commit

Permalink
feat(git workflow): 🚀 新增git workflow、优化配置文件
Browse files Browse the repository at this point in the history
  • Loading branch information
coder-czy committed Dec 19, 2023
1 parent 7fa8c15 commit 4db5a37
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -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"
31 changes: 31 additions & 0 deletions .github/workflow/build.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
branch: gh-pages
folder: dist
clean: true
9 changes: 6 additions & 3 deletions src/components/layouts/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@
}
}
.content-stage {
padding: 12px;
overflow: auto;
.child-stage {
margin: 12px;
}
// height: 100%;
// .child-stage {
// margin: 12px;
// min-height: 100%;
// }
}
}
6 changes: 3 additions & 3 deletions src/components/layouts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const Layouts: React.FC = () => {
<Header />
<Content className="content-stage">
{/* 子路由展示区域 */}
<div className="child-stage">
<Outlet />
</div>
{/* <div className="child-stage"> */}
<Outlet />
{/* </div> */}
</Content>
<Footer></Footer>
</Layout>
Expand Down
1 change: 1 addition & 0 deletions src/typings/plugins.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
declare module "qs";
declare module "nprogress";
30 changes: 20 additions & 10 deletions src/views/login/index.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
// 输入框校验
Expand All @@ -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();
Expand Down
17 changes: 2 additions & 15 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
// 服务配置
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 4db5a37

Please sign in to comment.