feat: 本次提交更新内容如下
新项目模板初始化
This commit is contained in:
23
nkebao/src/App.tsx
Normal file
23
nkebao/src/App.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import React from "react";
|
||||
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
||||
import { Button } from "antd";
|
||||
import { Button as MobileButton } from "antd-mobile";
|
||||
import Home from "./pages/Home";
|
||||
import About from "./pages/About";
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<Home />} />
|
||||
<Route path="/about" element={<About />} />
|
||||
</Routes>
|
||||
<div style={{ margin: 16 }}>
|
||||
<Button type="primary">Antd 按钮</Button>
|
||||
<MobileButton color="primary">Antd-Mobile 按钮</MobileButton>
|
||||
</div>
|
||||
</BrowserRouter>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
22
nkebao/src/api/module/auth.ts
Normal file
22
nkebao/src/api/module/auth.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { request } from '@/api/request';
|
||||
|
||||
export const list = (data?: any) =>
|
||||
request('/cw/companyUser/list', data, 'GET');
|
||||
|
||||
export const joinAudit = (data: any) =>
|
||||
request('/cw/companyUser/joinAudit', data, 'PUT');
|
||||
|
||||
export const listJoinAudit = (data?: any) =>
|
||||
request('/cw/companyUser/listJoinAudit', data, 'GET');
|
||||
|
||||
export const CwCompanyUserApplyAdd = (data: any) =>
|
||||
request('/cw/CwCompanyUserApply/add', data, 'PUT');
|
||||
|
||||
export const CwCompanyUserApplyAdminList = (data?: any) =>
|
||||
request('/cw/CwCompanyUserApply/adminList', data, 'GET');
|
||||
|
||||
export const CwCompanyUserApplyAudit = (data: any) =>
|
||||
request('/cw/CwCompanyUserApply/audit', data, 'POST');
|
||||
|
||||
export const CwCompanyUserApplyUserList = (data?: any) =>
|
||||
request('/cw/CwCompanyUserApply/userList', data, 'GET');
|
||||
64
nkebao/src/api/request.ts
Normal file
64
nkebao/src/api/request.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import axios, { AxiosInstance, AxiosRequestConfig, Method, AxiosResponse } from 'axios';
|
||||
|
||||
const DEBOUNCE_GAP = 1000;
|
||||
const debounceMap = new Map<string, number>();
|
||||
|
||||
const instance: AxiosInstance = axios.create({
|
||||
baseURL: (import.meta as any).env?.VITE_API_BASE_URL || '/api',
|
||||
timeout: 10000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
instance.interceptors.request.use(config => {
|
||||
const token = localStorage.getItem('token');
|
||||
if (token) {
|
||||
config.headers = config.headers || {};
|
||||
config.headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
return config;
|
||||
});
|
||||
|
||||
instance.interceptors.response.use(
|
||||
(res: AxiosResponse) => {
|
||||
if (res.data && (res.data.code === 200 || res.data.success)) {
|
||||
return res.data.data ?? res.data;
|
||||
}
|
||||
window?.alert?.(res.data?.msg || '接口错误');
|
||||
return Promise.reject(res.data?.msg || '接口错误');
|
||||
},
|
||||
err => {
|
||||
window?.alert?.(err.message || '网络异常');
|
||||
return Promise.reject(err);
|
||||
}
|
||||
);
|
||||
|
||||
export function request(
|
||||
url: string,
|
||||
data?: any,
|
||||
method: Method = 'GET',
|
||||
config?: AxiosRequestConfig
|
||||
): Promise<any> {
|
||||
const key = `${method}_${url}_${JSON.stringify(data)}`;
|
||||
const now = Date.now();
|
||||
const last = debounceMap.get(key) || 0;
|
||||
if (now - last < DEBOUNCE_GAP) {
|
||||
return Promise.reject('请求过于频繁,请稍后再试');
|
||||
}
|
||||
debounceMap.set(key, now);
|
||||
|
||||
const axiosConfig: AxiosRequestConfig = {
|
||||
url,
|
||||
method,
|
||||
...config,
|
||||
};
|
||||
if (method.toUpperCase() === 'GET') {
|
||||
axiosConfig.params = data;
|
||||
} else {
|
||||
axiosConfig.data = data;
|
||||
}
|
||||
return instance(axiosConfig);
|
||||
}
|
||||
|
||||
export default request;
|
||||
7
nkebao/src/main.tsx
Normal file
7
nkebao/src/main.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import React from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import App from "./App";
|
||||
import "./styles/global.scss";
|
||||
|
||||
const root = createRoot(document.getElementById("root")!);
|
||||
root.render(<App />);
|
||||
7
nkebao/src/pages/About.tsx
Normal file
7
nkebao/src/pages/About.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import React from "react";
|
||||
|
||||
const About: React.FC = () => {
|
||||
return <h1>关于 About</h1>;
|
||||
};
|
||||
|
||||
export default About;
|
||||
7
nkebao/src/pages/Home.tsx
Normal file
7
nkebao/src/pages/Home.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import React from "react";
|
||||
|
||||
const Home: React.FC = () => {
|
||||
return <h1>首页 Home</h1>;
|
||||
};
|
||||
|
||||
export default Home;
|
||||
1
nkebao/src/react-app-env.d.ts
vendored
Normal file
1
nkebao/src/react-app-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="react-scripts" />
|
||||
18
nkebao/src/styles/global.scss
Normal file
18
nkebao/src/styles/global.scss
Normal file
@@ -0,0 +1,18 @@
|
||||
html, body {
|
||||
height: 100%;
|
||||
overflow: hidden; // 禁止 body 滚动和回弹
|
||||
}
|
||||
|
||||
#root, .app-content {
|
||||
height: 100vh;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch; // iOS 惯性滚动
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
Reference in New Issue
Block a user