feat:发布backup
This commit is contained in:
parent
7fa8bb49d6
commit
784001ed4f
|
@ -1,4 +1,3 @@
|
||||||
# 前缀为NEXT_PUBLIC_才可以被浏览器使用
|
# 前缀为NEXT_PUBLIC_才可以被浏览器使用
|
||||||
NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:8090
|
NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:8092
|
||||||
NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:8091
|
NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:8091
|
||||||
NEXT_PUBLIC_PRIVATE_KEY=
|
|
|
@ -1 +1,2 @@
|
||||||
NEXT_PUBLIC_TODO_REQUEST_URL=http://taskmanagerserver.com:8090
|
NEXT_PUBLIC_TODO_REQUEST_URL=http://www.huaruyu.com/todo-server
|
||||||
|
NEXT_PUBLIC_SECURITY_REQUEST_URL=http://www.huaruyu.com/security-server
|
|
@ -5,4 +5,4 @@ COPY out /usr/share/nginx/html
|
||||||
EXPOSE 3001
|
EXPOSE 3001
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
# docker build -t task-manager-nginx .
|
# docker build -t task-manager-nginx .
|
||||||
# docker run -d -p 3001:3001 --restart unless-stopped -v ./out:/usr/share/nginx/html --name task-manager-nginx task-manager-nginx
|
# docker run -d -p 3001:3001 --network task-manager --restart unless-stopped -v ./out:/usr/share/nginx/html --name task-manager-nginx task-manager-nginx
|
||||||
|
|
|
@ -30,6 +30,48 @@ http {
|
||||||
try_files $uri $uri.html $uri/ =404;
|
try_files $uri $uri.html $uri/ =404;
|
||||||
# try_files $uri $uri/ =404;
|
# try_files $uri $uri/ =404;
|
||||||
}
|
}
|
||||||
|
location ^~ /todo-server {
|
||||||
|
rewrite ^/todo-server/(.*)$ /$1 break;
|
||||||
|
proxy_pass http://huayu-platform-todo:8092;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
client_body_buffer_size 16k;
|
||||||
|
client_max_body_size 100M;
|
||||||
|
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With';
|
||||||
|
|
||||||
|
# 如果请求方法为 OPTIONS,则直接返回 204 状态码
|
||||||
|
if ($request_method = 'OPTIONS') {
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With';
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
location ^~ /security-server {
|
||||||
|
rewrite ^/security-server/(.*)$ /$1 break;
|
||||||
|
proxy_pass http://huayu-platform-security:8091;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
client_body_buffer_size 16k;
|
||||||
|
client_max_body_size 100M;
|
||||||
|
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With';
|
||||||
|
|
||||||
|
# 如果请求方法为 OPTIONS,则直接返回 204 状态码
|
||||||
|
if ($request_method = 'OPTIONS') {
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With';
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
}
|
||||||
location /task/ {
|
location /task/ {
|
||||||
rewrite ^/task/(.*)$ /task/$1.html break;
|
rewrite ^/task/(.*)$ /task/$1.html break;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 25 KiB |
|
@ -20,6 +20,10 @@ export default function RootLayout({
|
||||||
<html>
|
<html>
|
||||||
<Script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"/>
|
<Script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"/>
|
||||||
<Script src="https://cdn.jsdelivr.net/npm/dayjs@1/locale/zh-cn.js"/>
|
<Script src="https://cdn.jsdelivr.net/npm/dayjs@1/locale/zh-cn.js"/>
|
||||||
|
<head>
|
||||||
|
<title>任务管理</title>
|
||||||
|
<link rel="icon" href="/favicon.ico"/>
|
||||||
|
</head>
|
||||||
<body style={{margin: 0}}>{children}</body>
|
<body style={{margin: 0}}>{children}</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|
|
@ -8,18 +8,18 @@ import {
|
||||||
WeiboOutlined,
|
WeiboOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
|
LoginForm,
|
||||||
LoginFormPage,
|
LoginFormPage,
|
||||||
ProConfigProvider,
|
ProConfigProvider,
|
||||||
ProFormCaptcha,
|
ProFormCaptcha,
|
||||||
ProFormCheckbox,
|
ProFormCheckbox,
|
||||||
ProFormText,
|
ProFormText,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import {Button, Divider, Space, Tabs, message, theme} from 'antd';
|
import { Divider, Space, Tabs, message, theme} from 'antd';
|
||||||
import type {CSSProperties} from 'react';
|
import type {CSSProperties} from 'react';
|
||||||
import {useState} from 'react';
|
import {useState} from 'react';
|
||||||
import {LoginObject} from "@/lib/login/definitions";
|
import {LoginObject} from "@/lib/login/definitions";
|
||||||
import {httpReq} from "@/utils/axiosReq";
|
import {httpReq} from "@/utils/axiosReq";
|
||||||
import Cookies from 'js-cookie';
|
|
||||||
import { useRouter } from 'next/navigation'
|
import { useRouter } from 'next/navigation'
|
||||||
type LoginType = 'phone' | 'account';
|
type LoginType = 'phone' | 'account';
|
||||||
|
|
||||||
|
@ -31,9 +31,10 @@ const iconStyles: CSSProperties = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const Page = () => {
|
const Page = () => {
|
||||||
const [loginType, setLoginType] = useState<LoginType>('phone');
|
const [loginType, setLoginType] = useState<LoginType>('account');
|
||||||
const {token} = theme.useToken();
|
const {token} = theme.useToken();
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const [messageApi, contextHolder] = message.useMessage();
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
@ -41,25 +42,26 @@ const Page = () => {
|
||||||
height: '100vh',
|
height: '100vh',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LoginFormPage
|
{contextHolder}
|
||||||
backgroundImageUrl="https://mdn.alipayobjects.com/huamei_gcee1x/afts/img/A*y0ZTS6WLwvgAAAAAAAAAAAAADml6AQ/fmt.webp"
|
<LoginForm
|
||||||
logo="https://github.githubassets.com/favicons/favicon.png"
|
// backgroundImageUrl="https://mdn.alipayobjects.com/huamei_gcee1x/afts/img/A*y0ZTS6WLwvgAAAAAAAAAAAAADml6AQ/fmt.webp"
|
||||||
backgroundVideoUrl="https://gw.alipayobjects.com/v/huamei_gcee1x/afts/video/jXRBRK_VAwoAAAAAAAAAAAAAK4eUAQBr"
|
// logo="https://github.githubassets.com/favicons/favicon.png"
|
||||||
title="Github"
|
// backgroundVideoUrl="https://gw.alipayobjects.com/v/huamei_gcee1x/afts/video/jXRBRK_VAwoAAAAAAAAAAAAAK4eUAQBr"
|
||||||
|
title="任务管理"
|
||||||
containerStyle={{
|
containerStyle={{
|
||||||
backgroundColor: 'rgba(0, 0, 0,0.65)',
|
backgroundColor: 'rgba(0, 0, 0,0.65)',
|
||||||
backdropFilter: 'blur(4px)',
|
backdropFilter: 'blur(4px)',
|
||||||
}}
|
}}
|
||||||
subTitle="全球最大的代码托管平台"
|
// subTitle="任务管理"
|
||||||
activityConfig={{
|
// activityConfig={{
|
||||||
style: {
|
// style: {
|
||||||
boxShadow: '0px 0px 8px rgba(0, 0, 0, 0.2)',
|
// boxShadow: '0px 0px 8px rgba(0, 0, 0, 0.2)',
|
||||||
color: token.colorTextHeading,
|
// color: token.colorTextHeading,
|
||||||
borderRadius: 8,
|
// borderRadius: 8,
|
||||||
backgroundColor: 'rgba(255,255,255,0.25)',
|
// backgroundColor: 'rgba(255,255,255,0.25)',
|
||||||
backdropFilter: 'blur(4px)',
|
// backdropFilter: 'blur(4px)',
|
||||||
},
|
// },
|
||||||
}}
|
// }}
|
||||||
onFinish={(formData:LoginObject)=>{
|
onFinish={(formData:LoginObject)=>{
|
||||||
console.log("登录信息:"+formData.username+";"+formData.password)
|
console.log("登录信息:"+formData.username+";"+formData.password)
|
||||||
httpReq.post(process.env.NEXT_PUBLIC_SECURITY_REQUEST_URL+"/stateless/login/username",{
|
httpReq.post(process.env.NEXT_PUBLIC_SECURITY_REQUEST_URL+"/stateless/login/username",{
|
||||||
|
@ -73,72 +75,77 @@ const Page = () => {
|
||||||
// 删除名为 'platform-security' 的Cookie
|
// 删除名为 'platform-security' 的Cookie
|
||||||
// Cookies.remove('platform-security');
|
// Cookies.remove('platform-security');
|
||||||
// 设置一个有效期为7天的Cookie
|
// 设置一个有效期为7天的Cookie
|
||||||
Cookies.set('platform-security', response.data.data, { expires: 7 });
|
// Cookies.set('platform-security', response.data.data, { expires: 7 });
|
||||||
// 登录成功,跳转到首页或者回调
|
// 登录成功,跳转到首页或者回调
|
||||||
router.push('/task/project')
|
router.push('/task/project')
|
||||||
|
}else{
|
||||||
|
messageApi.open({
|
||||||
|
type: 'error',
|
||||||
|
content: response.data.status.message,
|
||||||
|
})
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
actions={
|
// actions={
|
||||||
<div style={{
|
// <div style={{
|
||||||
display: 'flex',
|
// display: 'flex',
|
||||||
justifyContent: 'center',
|
// justifyContent: 'center',
|
||||||
alignItems: 'center',
|
// alignItems: 'center',
|
||||||
flexDirection: 'column',}}>
|
// flexDirection: 'column',}}>
|
||||||
<Divider plain>
|
// <Divider plain>
|
||||||
<span style={{
|
// <span style={{
|
||||||
color: token.colorTextPlaceholder,
|
// color: token.colorTextPlaceholder,
|
||||||
fontWeight: 'normal',
|
// fontWeight: 'normal',
|
||||||
fontSize: 14,}}>
|
// fontSize: 14,}}>
|
||||||
其他登录方式
|
// 其他登录方式
|
||||||
</span>
|
// </span>
|
||||||
</Divider>
|
// </Divider>
|
||||||
<Space align="center" size={24}>
|
// <Space align="center" size={24}>
|
||||||
<div
|
// <div
|
||||||
style={{
|
// style={{
|
||||||
display: 'flex',
|
// display: 'flex',
|
||||||
justifyContent: 'center',
|
// justifyContent: 'center',
|
||||||
alignItems: 'center',
|
// alignItems: 'center',
|
||||||
flexDirection: 'column',
|
// flexDirection: 'column',
|
||||||
height: 40,
|
// height: 40,
|
||||||
width: 40,
|
// width: 40,
|
||||||
border: '1px solid ' + token.colorPrimaryBorder,
|
// border: '1px solid ' + token.colorPrimaryBorder,
|
||||||
borderRadius: '50%',
|
// borderRadius: '50%',
|
||||||
}}
|
// }}
|
||||||
>
|
// >
|
||||||
<AlipayOutlined style={{...iconStyles, color: '#1677FF'}}/>
|
// <AlipayOutlined style={{...iconStyles, color: '#1677FF'}}/>
|
||||||
</div>
|
// </div>
|
||||||
<div
|
// <div
|
||||||
style={{
|
// style={{
|
||||||
display: 'flex',
|
// display: 'flex',
|
||||||
justifyContent: 'center',
|
// justifyContent: 'center',
|
||||||
alignItems: 'center',
|
// alignItems: 'center',
|
||||||
flexDirection: 'column',
|
// flexDirection: 'column',
|
||||||
height: 40,
|
// height: 40,
|
||||||
width: 40,
|
// width: 40,
|
||||||
border: '1px solid ' + token.colorPrimaryBorder,
|
// border: '1px solid ' + token.colorPrimaryBorder,
|
||||||
borderRadius: '50%',
|
// borderRadius: '50%',
|
||||||
}}
|
// }}
|
||||||
>
|
// >
|
||||||
<TaobaoOutlined style={{...iconStyles, color: '#FF6A10'}}/>
|
// <TaobaoOutlined style={{...iconStyles, color: '#FF6A10'}}/>
|
||||||
</div>
|
// </div>
|
||||||
<div
|
// <div
|
||||||
style={{
|
// style={{
|
||||||
display: 'flex',
|
// display: 'flex',
|
||||||
justifyContent: 'center',
|
// justifyContent: 'center',
|
||||||
alignItems: 'center',
|
// alignItems: 'center',
|
||||||
flexDirection: 'column',
|
// flexDirection: 'column',
|
||||||
height: 40,
|
// height: 40,
|
||||||
width: 40,
|
// width: 40,
|
||||||
border: '1px solid ' + token.colorPrimaryBorder,
|
// border: '1px solid ' + token.colorPrimaryBorder,
|
||||||
borderRadius: '50%',
|
// borderRadius: '50%',
|
||||||
}}
|
// }}
|
||||||
>
|
// >
|
||||||
<WeiboOutlined style={{...iconStyles, color: '#1890ff'}}/>
|
// <WeiboOutlined style={{...iconStyles, color: '#1890ff'}}/>
|
||||||
</div>
|
// </div>
|
||||||
</Space>
|
// </Space>
|
||||||
</div>
|
// </div>
|
||||||
}
|
// }
|
||||||
>
|
>
|
||||||
<Tabs
|
<Tabs
|
||||||
centered
|
centered
|
||||||
|
@ -272,12 +279,12 @@ const Page = () => {
|
||||||
忘记密码
|
忘记密码
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</LoginFormPage>
|
</LoginForm>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default () => {
|
export default function Login(){
|
||||||
return (
|
return (
|
||||||
<ProConfigProvider dark>
|
<ProConfigProvider dark>
|
||||||
<Page/>
|
<Page/>
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {useEffect} from "react";
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const {replace} = useRouter();
|
const {replace} = useRouter();
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
replace("/task/four")
|
replace("/login")
|
||||||
},[])
|
},[])
|
||||||
dayjs.locale('zh-cn')
|
dayjs.locale('zh-cn')
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -29,9 +29,9 @@ export type ResponseVO<T>={
|
||||||
|
|
||||||
export type DataType ={
|
export type DataType ={
|
||||||
key: React.ReactNode;
|
key: React.ReactNode;
|
||||||
id: number;
|
id: string;
|
||||||
pid:number;
|
pid:string;
|
||||||
pPid:number;
|
pPid:string;
|
||||||
code: string;
|
code: string;
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
|
|
@ -2,111 +2,67 @@ import {unstable_noStore as noStore} from 'next/cache';
|
||||||
import {AxiosResponse} from "axios";
|
import {AxiosResponse} from "axios";
|
||||||
import {httpReq} from "@/utils/axiosReq";
|
import {httpReq} from "@/utils/axiosReq";
|
||||||
import {DataType, DictType, ResponseVO, ResultPage} from "@/lib/definitions";
|
import {DataType, DictType, ResponseVO, ResultPage} from "@/lib/definitions";
|
||||||
export async function getTaskTreeResult(requestParam:string): Promise<ResponseVO<ResultPage<DataType>>> {
|
|
||||||
|
export async function getTaskTreeResult(requestParam: string): Promise<ResponseVO<ResultPage<DataType>>> {
|
||||||
noStore();
|
noStore();
|
||||||
try {
|
// 使用 Axios 发送 POST 请求获取数据
|
||||||
// 使用 Axios 发送 POST 请求获取数据
|
const response: AxiosResponse<ResponseVO<ResultPage<DataType>>> = await httpReq.get(
|
||||||
const response: AxiosResponse<ResponseVO<ResultPage<DataType>>> = await httpReq.get(
|
process.env.NEXT_PUBLIC_TODO_REQUEST_URL + '/search/task_message_tree?search=' + encodeURIComponent(requestParam));
|
||||||
process.env.NEXT_PUBLIC_TODO_REQUEST_URL+'/search/task_message_tree?search='+encodeURIComponent(requestParam));
|
// 从响应中提取数据并返回
|
||||||
// 从响应中提取数据并返回
|
console.log("response.data", response.data)
|
||||||
console.log("response.data",response.data)
|
return response.data;
|
||||||
return response.data;
|
|
||||||
} catch (error) {
|
|
||||||
// 处理错误
|
|
||||||
console.error('Error fetching data:', error);
|
|
||||||
// 返回一个默认值或者抛出错误
|
|
||||||
throw new Error('Failed to fetch data');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
export async function commonUpdate(requestParam:any): Promise<ResponseVO<string>> {
|
|
||||||
|
export async function commonUpdate(requestParam: any): Promise<ResponseVO<string>> {
|
||||||
noStore();
|
noStore();
|
||||||
try {
|
// 使用 Axios 发送 PUT 请求获取数据
|
||||||
// 使用 Axios 发送 PUT 请求获取数据
|
const response: AxiosResponse<ResponseVO<string>> = await httpReq.put(
|
||||||
const response: AxiosResponse<ResponseVO<string>> = await httpReq.put(
|
process.env.NEXT_PUBLIC_TODO_REQUEST_URL + '/search/task_message_tree', requestParam);
|
||||||
process.env.NEXT_PUBLIC_TODO_REQUEST_URL+'/search/task_message_tree',requestParam);
|
// 从响应中提取数据并返回
|
||||||
// 从响应中提取数据并返回
|
return response.data;
|
||||||
return response.data;
|
|
||||||
} catch (error) {
|
|
||||||
// 处理错误
|
|
||||||
console.error('Error fetching data:', error);
|
|
||||||
// 返回一个默认值或者抛出错误
|
|
||||||
throw new Error('Failed to fetch data');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function taskTreeResult(): Promise<ResponseVO<ResultPage<DataType>>> {
|
export async function taskTreeResult(): Promise<ResponseVO<ResultPage<DataType>>> {
|
||||||
noStore();
|
noStore();
|
||||||
try {
|
// 使用 httpReq 发送 POST 请求获取数据
|
||||||
// 使用 httpReq 发送 POST 请求获取数据
|
const response: AxiosResponse<ResponseVO<ResultPage<DataType>>> = await httpReq.post(process.env.NEXT_PUBLIC_TODO_REQUEST_URL + '/task/tree', {
|
||||||
const response: AxiosResponse<ResponseVO<ResultPage<DataType>>> = await httpReq.post(process.env.NEXT_PUBLIC_TODO_REQUEST_URL+'/task/tree', {
|
pageSize: 10,
|
||||||
pageSize: 10,
|
pageNumber: 1
|
||||||
pageNumber: 1
|
});
|
||||||
});
|
// 从响应中提取数据并返回
|
||||||
// 从响应中提取数据并返回
|
return response.data;
|
||||||
return response.data;
|
|
||||||
} catch (error) {
|
|
||||||
// 处理错误
|
|
||||||
console.error('Error fetching data:', error);
|
|
||||||
// 返回一个默认值或者抛出错误
|
|
||||||
throw new Error('Failed to fetch data');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export async function getTask(id:number): Promise<ResponseVO<DataType>> {
|
|
||||||
noStore();
|
|
||||||
try {
|
|
||||||
// 使用 Axios 发送 GET 请求获取数据
|
|
||||||
const response: AxiosResponse<ResponseVO<DataType>> = await httpReq.get(process.env.NEXT_PUBLIC_TODO_REQUEST_URL+'/task/'+id);
|
|
||||||
// 从响应中提取数据并返回
|
|
||||||
return response.data;
|
|
||||||
} catch (error) {
|
|
||||||
// 处理错误
|
|
||||||
console.error('Error fetching data:', error);
|
|
||||||
// 返回一个默认值或者抛出错误
|
|
||||||
throw new Error('Failed to fetch data');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function addTask(task:DataType): Promise<ResponseVO<string>> {
|
export async function getTask(id: string): Promise<ResponseVO<DataType>> {
|
||||||
noStore();
|
noStore();
|
||||||
try {
|
// 使用 Axios 发送 GET 请求获取数据
|
||||||
// 使用 Axios 发送 POST 请求添加数据
|
const response: AxiosResponse<ResponseVO<DataType>> = await httpReq.get(process.env.NEXT_PUBLIC_TODO_REQUEST_URL + '/task/' + id);
|
||||||
const response: AxiosResponse<ResponseVO<string>> = await httpReq.post(process.env.NEXT_PUBLIC_TODO_REQUEST_URL+'/task', task);
|
// 从响应中提取数据并返回
|
||||||
// 从响应中提取数据并返回
|
return response.data;
|
||||||
return response.data;
|
|
||||||
} catch (error) {
|
|
||||||
// 处理错误
|
|
||||||
console.error('Error fetching data:', error);
|
|
||||||
// 返回一个默认值或者抛出错误
|
|
||||||
throw new Error('Failed to fetch data');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
export async function updateTask(task:DataType): Promise<ResponseVO<string>> {
|
|
||||||
|
export async function addTask(task: DataType): Promise<ResponseVO<string>> {
|
||||||
noStore();
|
noStore();
|
||||||
try {
|
// 使用 Axios 发送 POST 请求添加数据
|
||||||
// 使用 Axios 发送 PUT 请求修改数据
|
const response: AxiosResponse<ResponseVO<string>> = await httpReq.post(process.env.NEXT_PUBLIC_TODO_REQUEST_URL + '/task', task);
|
||||||
const response: AxiosResponse<ResponseVO<string>> = await httpReq.put(process.env.NEXT_PUBLIC_TODO_REQUEST_URL+'/task', task);
|
// 从响应中提取数据并返回
|
||||||
// 从响应中提取数据并返回
|
return response.data;
|
||||||
return response.data;
|
|
||||||
} catch (error) {
|
|
||||||
// 处理错误
|
|
||||||
console.error('Error fetching data:', error);
|
|
||||||
// 返回一个默认值或者抛出错误
|
|
||||||
throw new Error('Failed to fetch data');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
export async function deleteTask(id:number): Promise<ResponseVO<string>> {
|
|
||||||
|
export async function updateTask(task: DataType): Promise<ResponseVO<string>> {
|
||||||
noStore();
|
noStore();
|
||||||
try {
|
// 使用 Axios 发送 PUT 请求修改数据
|
||||||
// 使用 Axios 发送 DELETE 删除数据
|
const response: AxiosResponse<ResponseVO<string>> = await httpReq.put(process.env.NEXT_PUBLIC_TODO_REQUEST_URL + '/task', task);
|
||||||
const response: AxiosResponse<ResponseVO<string>> = await httpReq.delete(process.env.NEXT_PUBLIC_TODO_REQUEST_URL+'/task/'+id);
|
// 从响应中提取数据并返回
|
||||||
// 从响应中提取数据并返回
|
return response.data;
|
||||||
return response.data;
|
}
|
||||||
} catch (error) {
|
|
||||||
// 处理错误
|
export async function deleteTask(id: string): Promise<ResponseVO<string>> {
|
||||||
console.error('Error fetching data:', error);
|
noStore();
|
||||||
// 返回一个默认值或者抛出错误
|
// 使用 Axios 发送 DELETE 删除数据
|
||||||
throw new Error('Failed to fetch data');
|
const response: AxiosResponse<ResponseVO<string>> = await httpReq.delete(process.env.NEXT_PUBLIC_TODO_REQUEST_URL + '/task/' + id);
|
||||||
}
|
// 从响应中提取数据并返回
|
||||||
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
//0,重要紧急红色,1,重要不紧急黄色,2,不重要紧急灰色,3不重要,不紧急绿色
|
//0,重要紧急红色,1,重要不紧急黄色,2,不重要紧急灰色,3不重要,不紧急绿色
|
||||||
|
@ -124,7 +80,7 @@ export const taskPriorityList: DictType[] = [
|
||||||
order: 1,
|
order: 1,
|
||||||
color: 'yellow'
|
color: 'yellow'
|
||||||
}, {
|
}, {
|
||||||
id:1,
|
id: 1,
|
||||||
code: '1',
|
code: '1',
|
||||||
name: '不重要紧急',
|
name: '不重要紧急',
|
||||||
order: 2,
|
order: 2,
|
||||||
|
@ -210,6 +166,7 @@ export const taskStateList: DictType[] = [
|
||||||
color: 'YELLOW'
|
color: 'YELLOW'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
export enum OPERATION_BUTTON_TYPE {
|
export enum OPERATION_BUTTON_TYPE {
|
||||||
DETAIL,
|
DETAIL,
|
||||||
ADD_CHILD,
|
ADD_CHILD,
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
import React, {Fragment} from "react";
|
import React, {Fragment} from "react";
|
||||||
import {Button, Dropdown, MenuProps, message, Modal, Popconfirm, Space} from "antd";
|
import {Button, Dropdown, MenuProps, message, Modal, Popconfirm, Space} from "antd";
|
||||||
import {DownOutlined, QuestionCircleOutlined} from "@ant-design/icons";
|
import {DownOutlined, QuestionCircleOutlined} from "@ant-design/icons";
|
||||||
import {DetailForm} from "@/ui/task/four/DetailForm";
|
|
||||||
import {commonUpdate, deleteTask, OPERATION_BUTTON_TYPE} from "@/lib/task/project/data";
|
import {commonUpdate, deleteTask, OPERATION_BUTTON_TYPE} from "@/lib/task/project/data";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import {DetailModelForm} from "@/ui/task/project/DetailModelForm";
|
import {DetailModelForm} from "@/ui/task/project/DetailModelForm";
|
||||||
|
|
||||||
export interface OperationButtonProps {
|
export interface OperationButtonProps {
|
||||||
itemId: number,
|
itemId: string,
|
||||||
pid: number,
|
pid: string,
|
||||||
pPid: number,
|
pPid: string,
|
||||||
operationId?: string,
|
operationId?: string,
|
||||||
refreshDate?: () => void,
|
refreshDate?: () => void,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OperationModelProps {
|
interface OperationModelProps {
|
||||||
operationId: number,
|
operationId: number,
|
||||||
pPid: number,
|
pPid: string,
|
||||||
pid: number,
|
pid: string,
|
||||||
openModal: boolean
|
openModal: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,10 @@ import dayjs, {Dayjs} from "dayjs";
|
||||||
|
|
||||||
export type DetailModelFormProps={
|
export type DetailModelFormProps={
|
||||||
// 当前内容id
|
// 当前内容id
|
||||||
itemId?: number,
|
itemId?: string,
|
||||||
pid?:number,
|
pid?:string,
|
||||||
// 祖宗任务id
|
// 祖宗任务id
|
||||||
pPid?:number,
|
pPid?:string,
|
||||||
// 操作id
|
// 操作id
|
||||||
operationId: number,
|
operationId: number,
|
||||||
// 标题描述
|
// 标题描述
|
||||||
|
@ -37,12 +37,12 @@ export type DetailModelFormProps={
|
||||||
// 重新加载数据
|
// 重新加载数据
|
||||||
reloadData?: () => void
|
reloadData?: () => void
|
||||||
}
|
}
|
||||||
export type PidSelectTree= { label: string; value: number;pid:number; children?: PidSelectTree[] }
|
export type PidSelectTree= { label: string; value: string;pid:string; children?: PidSelectTree[] }
|
||||||
|
|
||||||
export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
console.log("DetailModelForm:props:",props)
|
console.log("DetailModelForm:props:",props)
|
||||||
const [form] = Form.useForm<DataType>();
|
const [form] = Form.useForm<DataType>();
|
||||||
const [pid, setPid] = useState<number>(props.pid?props.pid:0);
|
const [pid, setPid] = useState<string>(props.pid?props.pid:'0');
|
||||||
const [editFormDisable, setEditFormDisable] = useState(props.operationId === OPERATION_BUTTON_TYPE.DETAIL)
|
const [editFormDisable, setEditFormDisable] = useState(props.operationId === OPERATION_BUTTON_TYPE.DETAIL)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.itemId!=undefined&&(
|
if (props.itemId!=undefined&&(
|
||||||
|
@ -58,6 +58,7 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
task.data.expectedTimeRange = [task.data.expectedStartTime ? dayjs(task.data.expectedStartTime) : undefined,
|
task.data.expectedTimeRange = [task.data.expectedStartTime ? dayjs(task.data.expectedStartTime) : undefined,
|
||||||
task.data.expectedEndTime ? dayjs(task.data.expectedEndTime) : undefined];
|
task.data.expectedEndTime ? dayjs(task.data.expectedEndTime) : undefined];
|
||||||
form.setFieldsValue(task.data)
|
form.setFieldsValue(task.data)
|
||||||
|
console.log("form.setFieldsValue(task.data)"+JSON.stringify(task.data))
|
||||||
} else {
|
} else {
|
||||||
message.error(task.status.message);
|
message.error(task.status.message);
|
||||||
props.reloadData?.()
|
props.reloadData?.()
|
||||||
|
@ -99,7 +100,7 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
props.reloadData?.();
|
props.reloadData?.();
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
submitter={props.itemId!==undefined&&props.itemId!==-1?{
|
submitter={props.itemId!==undefined&&props.itemId!=='-1'?{
|
||||||
render: (prop, defaultDoms) => {
|
render: (prop, defaultDoms) => {
|
||||||
return [
|
return [
|
||||||
editFormDisable?<Button
|
editFormDisable?<Button
|
||||||
|
@ -141,7 +142,7 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
onFinish={async (values) => {
|
onFinish={async (values) => {
|
||||||
console.log('Received values of form: ', values);
|
console.log('Received values of form: ', values);
|
||||||
if (values.pid===undefined){
|
if (values.pid===undefined){
|
||||||
values.pid=0
|
values.pid='0'
|
||||||
}
|
}
|
||||||
if (values.expectedTimeRange?.[0]!=undefined) {
|
if (values.expectedTimeRange?.[0]!=undefined) {
|
||||||
values.expectedStartTime=dayjs(values.expectedTimeRange[0]).toDate()
|
values.expectedStartTime=dayjs(values.expectedTimeRange[0]).toDate()
|
||||||
|
@ -155,7 +156,6 @@ export const DetailModelForm: React.FC<DetailModelFormProps> = (props) => {
|
||||||
if (values.actualTimeRange?.[1]!=undefined) {
|
if (values.actualTimeRange?.[1]!=undefined) {
|
||||||
values.actualEndTime=dayjs(values.actualTimeRange[1]).toDate()
|
values.actualEndTime=dayjs(values.actualTimeRange[1]).toDate()
|
||||||
}
|
}
|
||||||
values.pid=pid;
|
|
||||||
var result:boolean=false;
|
var result:boolean=false;
|
||||||
|
|
||||||
let state = taskStateList.find(taskState => taskState.name === values.state?.toString());
|
let state = taskStateList.find(taskState => taskState.name === values.state?.toString());
|
||||||
|
|
|
@ -25,7 +25,7 @@ const TreeTablePro: React.FC = () => {
|
||||||
const [switchChecked, setSwitchChecked] = React.useState(true);
|
const [switchChecked, setSwitchChecked] = React.useState(true);
|
||||||
const [filterChecked, setFilterChecked] = React.useState(true);
|
const [filterChecked, setFilterChecked] = React.useState(true);
|
||||||
const [current,setCurrent] = React.useState(1);
|
const [current,setCurrent] = React.useState(1);
|
||||||
const [pageSize,setPageSize] = React.useState(5);
|
const [pageSize,setPageSize] = React.useState(10);
|
||||||
const { RangePicker } = DatePicker;
|
const { RangePicker } = DatePicker;
|
||||||
const columns: ProColumns<DataType>[] = [
|
const columns: ProColumns<DataType>[] = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,46 +1,83 @@
|
||||||
import axios, {Canceler, CancelToken, CancelTokenSource} from "axios";
|
import axios, {Canceler, CancelToken, CancelTokenSource} from "axios";
|
||||||
|
import {message} from "antd";
|
||||||
|
|
||||||
|
|
||||||
export const httpReq = axios.create({
|
export const httpReq = axios.create({
|
||||||
// cancelToken: new CancelToken(function (cancel:Canceler) {
|
// cancelToken: new CancelToken(function (cancel:Canceler) {
|
||||||
// },),
|
// },),
|
||||||
// validateStatus: function (status) {
|
validateStatus: function (status) {
|
||||||
// return status >= 200 && status < 300; // default
|
return status >= 200 && status < 300; // default
|
||||||
// },
|
},
|
||||||
|
timeout: 2000,
|
||||||
|
timeoutErrorMessage: "网络连接超时",
|
||||||
withCredentials: false,
|
withCredentials: false,
|
||||||
})
|
})
|
||||||
// 从cookie获取token
|
|
||||||
|
|
||||||
// 创建一个取消令牌
|
// 创建一个取消令牌
|
||||||
const cancelTokenSource: CancelTokenSource = axios.CancelToken.source();
|
const cancelTokenSource: CancelTokenSource = axios.CancelToken.source();
|
||||||
|
// 默认json格式
|
||||||
httpReq.defaults.headers.common['Accept'] = 'application/json';
|
httpReq.defaults.headers.common['Accept'] = 'application/json';
|
||||||
|
// 请求前处理
|
||||||
httpReq.interceptors.request.use((config) => {
|
httpReq.interceptors.request.use((config) => {
|
||||||
const token = localStorage.getItem('platform-security'); // 从本地存储中获取 token
|
// 从本地存储中获取 token
|
||||||
|
const token = localStorage.getItem('platform-security');
|
||||||
if (token) {
|
if (token) {
|
||||||
// config.headers.Authorization = `Bearer ${token}`;
|
config.headers.Authorization = `Bearer ${token}`;
|
||||||
config.headers.Authorization = `${token}`;
|
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
|
console.info("interceptors错误提示.request" + error)
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
})
|
})
|
||||||
|
// 响应前处理
|
||||||
httpReq.interceptors.response.use(
|
httpReq.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
// http请求最外层
|
// http请求最外层
|
||||||
if (response.status >= 500) {
|
if (response.status >= 500) {
|
||||||
console.log("系统异常")
|
message.error('系统异常');
|
||||||
} else if (response.status >= 400 && response.status <= 500) {
|
} else if (response.status >= 400 && response.status <= 500) {
|
||||||
console.log("无权限")
|
message.warning('无权限');
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
if (error.response && error.response.status === 401) {
|
if (axios.isCancel(error)) {
|
||||||
localStorage.removeItem('authToken');
|
message.error('连接取消');
|
||||||
window.location.href = '/login';
|
} else if (axios.isAxiosError(error)) {
|
||||||
|
console.error('Axios Error:', error.message);
|
||||||
|
if (error.response) {
|
||||||
|
if (error.response.status >= 500) {
|
||||||
|
message.error('系统异常');
|
||||||
|
} else if (error.response.status >= 400 && error.response.status <= 500) {
|
||||||
|
message.warning('无权限');
|
||||||
|
window.location.href = '/login';
|
||||||
|
}
|
||||||
|
// switch (error.response.status) {
|
||||||
|
// case 401:
|
||||||
|
// localStorage.removeItem('authToken');
|
||||||
|
// window.location.href = '/login';
|
||||||
|
// break;
|
||||||
|
// case 403:
|
||||||
|
// console.error('Forbidden:', error.response.data);
|
||||||
|
// break;
|
||||||
|
// case 404:
|
||||||
|
// console.error('Not Found:', error.response.data);
|
||||||
|
// break;
|
||||||
|
// case 500:
|
||||||
|
// console.error('Internal Server Error:', error.response.data);
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// console.error('Unknown Error:', error.response.data);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
message.error('No Response:' + error.message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error('Unknown Error:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.info("interceptors.response错误提示" + error)
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
);
|
);
|
Loading…
Reference in New Issue