diff --git a/README.md b/README.md index c403366..d7925e5 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,37 @@ -This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). +# 任务管理小应用 +平时事情不多但是容易忘记,最近也在学习react,便开发了这个应用。 -## Getting Started +应用将任务分为两种类型来管理:任务树和[四象线](https://baike.baidu.com/item/%E5%9B%9B%E8%B1%A1%E9%99%90%E6%B3%95/4228184?fr=ge_ala)任务管理 +## 任务树 +1. 层级展示任务 +2. 可在操作中四象线展示子任务 +## 四象线 +1. 向上重要 +2. 向左紧急 -First, run the development server: - -```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev +## 项目启动 +### 后端服务启动 +1. 后端启动应用需求:docker,redis,mysql8。 +2. jar通过docker打入镜像中,无需java环境。 +3. 使用docker/Dockerfile-server文件构建镜像及运行容器 +4. 通过docker/hosts修改自己数据库ip和redis的ip +5. 数据库端口:3306,数据库名:task_manager,数据库用户名及密码:task_manager_user/TaskMU0001,redis:无密码认证。(此条内容目前代码写死,后期修改为可配置) +构建镜像 +```shell +docker build -t task-manager-server -f Dockerfile-server . +``` +运行 +```shell +docker run -d -p 8090:8090 --restart unless-stopped -v ./hosts:/etc/hosts --name task-manager-server task-manager-server +``` +### 前端项目启动 +1. 前端启动应用需求:docker +2. 需要在电脑hosts(linux地址/etc/hosts,windows地址C:\Windows\System32\drivers\etc\hosts)中配置后端运行环境地址,例如添加:127.0.0.1 taskmanagerserver.com + 构建镜像 +```shell +docker build -t task-manager-nginx . +``` +运行 +```shell +docker run -d -p 3001:3001 --restart unless-stopped --name task-manager-nginx task-manager-nginx ``` - -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. - -This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! - -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. diff --git a/docker/Dockerfile b/docker/Dockerfile index 4f31b72..2d60168 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,4 +5,4 @@ COPY out /usr/share/nginx/html EXPOSE 3001 CMD ["nginx", "-g", "daemon off;"] # docker build -t task-manager-nginx . -# docker run -d -p 3001:3001 --name task-manager-nginx task-manager-nginx +# docker run -d -p 3001:3001 --restart unless-stopped --name task-manager-nginx task-manager-nginx diff --git a/docker/Dockerfile-server b/docker/Dockerfile-server index bb4107b..c64961b 100644 --- a/docker/Dockerfile-server +++ b/docker/Dockerfile-server @@ -5,4 +5,4 @@ EXPOSE 8090 CMD ["java", "-jar", "task-manager-server.jar"] # 指定文件名 当前路径 # docker build -t task-manager-server -f Dockerfile-server . -# docker run -d -p 8090:8090 --name task-manager-server task-manager-server +# docker run -d -p 8090:8090 --restart unless-stopped -v ./hosts:/etc/hosts --name task-manager-server task-manager-server diff --git a/docker/hosts b/docker/hosts new file mode 100644 index 0000000..d16cb5a --- /dev/null +++ b/docker/hosts @@ -0,0 +1,3 @@ +127.0.0.1 localhost +10.0.2.15 task-manager-server-mysql +10.0.2.15 task-manager-server-redis diff --git a/docker/nginx.conf b/docker/nginx.conf index aeede44..0056077 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -21,15 +21,18 @@ http { server_name localhost; # 访问日志路径 access_log /var/log/nginx/access.log; + # 站点根目录 + root /usr/share/nginx/html; # 代理配置 location / { - # 站点根目录 - root /usr/share/nginx/html; # 默认页面 index index.html index.htm; - try_files $uri $uri/ /index.html; + try_files $uri $uri.html $uri/ =404; # try_files $uri $uri/ =404; } + location /task/ { + rewrite ^/task/(.*)$ /task/$1.html break; + } # 静态文件缓存配置 location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { expires 7d; diff --git a/docker/task-manager-server.jar b/docker/task-manager-server.jar index 4366f40..abed5d9 100644 Binary files a/docker/task-manager-server.jar and b/docker/task-manager-server.jar differ diff --git a/next.config.mjs b/next.config.mjs index debd939..cf75e3d 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,6 +1,14 @@ /** @type {import('next').NextConfig} */ const nextConfig = { output: 'export', + // Optional: Change links `/me` -> `/me/` and emit `/me.html` -> `/me/index.html` + // trailingSlash: true, + + // Optional: Prevent automatic `/me` -> `/me/`, instead preserve `href` + // skipTrailingSlashRedirect: true, + + // Optional: Change the output directory `out` -> `dist` + // distDir: 'dist', }; export default nextConfig; diff --git a/src/app/lib/definitions.ts b/src/app/lib/definitions.ts index 50fcf29..eb30a44 100644 --- a/src/app/lib/definitions.ts +++ b/src/app/lib/definitions.ts @@ -41,7 +41,7 @@ export type DataType ={ action?:React.ReactNode; expectedStartTime?:Date|string; expectedEndTime?:Date; - expectedTimeRange?:(string|Dayjs)[]; + expectedTimeRange?:(string|Dayjs|undefined)[]; actualStartTime?:Date; actualEndTime?:Date; actualTimeRange?:(string|Dayjs)[] diff --git a/src/app/lib/task/project/data.tsx b/src/app/lib/task/project/data.tsx index ac19189..28fbe65 100644 --- a/src/app/lib/task/project/data.tsx +++ b/src/app/lib/task/project/data.tsx @@ -8,7 +8,7 @@ export async function getTaskTreeResult(requestParam:string): Promise>> = await axios.get( - 'http://localhost:8090/search/task_message_tree?search='+encodeURIComponent(requestParam)); + 'http://taskmanagerserver.com:8090/search/task_message_tree?search='+encodeURIComponent(requestParam)); // 从响应中提取数据并返回 return response.data; } catch (error) { @@ -23,7 +23,7 @@ export async function commonUpdate(requestParam:any): Promise try { // 使用 Axios 发送 PUT 请求获取数据 const response: AxiosResponse> = await axios.put( - 'http://localhost:8090/search/task_message_tree',requestParam); + 'http://taskmanagerserver.com:8090/search/task_message_tree',requestParam); // 从响应中提取数据并返回 return response.data; } catch (error) { @@ -38,7 +38,7 @@ export async function taskTreeResult(): Promise> noStore(); try { // 使用 Axios 发送 POST 请求获取数据 - const response: AxiosResponse>> = await axios.post('http://localhost:8090/task/tree', { + const response: AxiosResponse>> = await axios.post('http://taskmanagerserver.com:8090/task/tree', { pageSize: 10, pageNumber: 1 }); @@ -55,7 +55,7 @@ export async function getTask(id:number): Promise> { noStore(); try { // 使用 Axios 发送 GET 请求获取数据 - const response: AxiosResponse> = await axios.get('http://localhost:8090/task/'+id); + const response: AxiosResponse> = await axios.get('http://taskmanagerserver.com:8090/task/'+id); // 从响应中提取数据并返回 return response.data; } catch (error) { @@ -70,7 +70,7 @@ export async function addTask(task:DataType): Promise> { noStore(); try { // 使用 Axios 发送 POST 请求添加数据 - const response: AxiosResponse> = await axios.post('http://localhost:8090/task', task); + const response: AxiosResponse> = await axios.post('http://taskmanagerserver.com:8090/task', task); // 从响应中提取数据并返回 return response.data; } catch (error) { @@ -84,7 +84,7 @@ export async function updateTask(task:DataType): Promise> { noStore(); try { // 使用 Axios 发送 PUT 请求修改数据 - const response: AxiosResponse> = await axios.put('http://localhost:8090/task', task); + const response: AxiosResponse> = await axios.put('http://taskmanagerserver.com:8090/task', task); // 从响应中提取数据并返回 return response.data; } catch (error) { @@ -98,7 +98,7 @@ export async function deleteTask(id:number): Promise> { noStore(); try { // 使用 Axios 发送 DELETE 删除数据 - const response: AxiosResponse> = await axios.delete('http://localhost:8090/task/'+id); + const response: AxiosResponse> = await axios.delete('http://taskmanagerserver.com:8090/task/'+id); // 从响应中提取数据并返回 return response.data; } catch (error) { @@ -113,7 +113,7 @@ export async function editState(id:number,state:number): Promise> = await axios.patch('http://localhost:8090/task/'+id); + const response: AxiosResponse> = await axios.patch('http://taskmanagerserver.com:8090/task/'+id); // 从响应中提取数据并返回 return response.data; } catch (error) { @@ -128,7 +128,7 @@ export async function editPriority(id:number,priority:number): Promise> = await axios.patch('http://localhost:8090/task/'+id); + const response: AxiosResponse> = await axios.patch('http://taskmanagerserver.com:8090/task/'+id); // 从响应中提取数据并返回 return response.data; } catch (error) { diff --git a/src/app/task/layout.tsx b/src/app/task/layout.tsx index 1a78766..6261315 100644 --- a/src/app/task/layout.tsx +++ b/src/app/task/layout.tsx @@ -1,5 +1,5 @@ 'use client' -import React from "react"; +import React, {Fragment} from "react"; import {TitleOperation} from "@/app/ui/task/TitleOperation"; import LocalContext from "@/app/ui/LocalContent"; import dayjs from "dayjs"; @@ -20,7 +20,7 @@ export default function Layout({children}: { children: React.ReactNode }) { console.log('taskState,expectedStartTime,refreshDataFlag', taskState, expectedStartTime, refreshDataFlag) return ( -
+ -
+ ); } diff --git a/src/app/ui/task/TitleOperation.tsx b/src/app/ui/task/TitleOperation.tsx index 834ede2..33788ef 100644 --- a/src/app/ui/task/TitleOperation.tsx +++ b/src/app/ui/task/TitleOperation.tsx @@ -30,7 +30,7 @@ export const TitleOperation: React.FC = ({ expectStartTimeParseResult[0]&&expectStartTimeParseResult[0].value ? dayjs(expectStartTimeParseResult[0].value.toString()) : undefined, expectStartTimeParseResult[1]&&expectStartTimeParseResult[1].value ? dayjs(expectStartTimeParseResult[1].value.toString()) : undefined ]; - return + return {usePathname().startsWith("/task/project") ? <> diff --git a/src/app/ui/task/four/DetailForm.tsx b/src/app/ui/task/four/DetailForm.tsx index 5b309e0..a444858 100644 --- a/src/app/ui/task/four/DetailForm.tsx +++ b/src/app/ui/task/four/DetailForm.tsx @@ -66,6 +66,9 @@ export const DetailForm: React.FC = (props) => { props.handleCancel() } }) + }else if(props.operationId === OPERATION_BUTTON_TYPE.ADD|| props.operationId === OPERATION_BUTTON_TYPE.ADD_CHILD){ + let data={'expectedTimeRange':[dayjs(), undefined]}; + form.setFieldsValue(data) } }, []) const normFile = (e: any) => { @@ -234,10 +237,9 @@ export const DetailForm: React.FC = (props) => { placeholder={['开始时间', '结束时间']} allowEmpty={[true, true]} needConfirm={false} - defaultValue={[dayjs(), undefined]} showTime={{ hideDisabledOptions: true, - defaultValue: [dayjs('00:00:00', 'HH:mm:ss'), dayjs('11:59:59', 'HH:mm:ss')], + defaultValue: [dayjs('00:00:00', 'HH:mm:ss'), dayjs('23:59:59', 'HH:mm:ss')], }} // format="YYYY-MM-DD HH:mm:ss" />