diff --git a/src/backend/dao.py b/src/backend/dao.py index 1834dc4..b1948e4 100644 --- a/src/backend/dao.py +++ b/src/backend/dao.py @@ -2,7 +2,6 @@ from sqlalchemy import func from sqlalchemy.orm import Session -from sqlalchemy import func from .models import Job diff --git a/src/backend/main.py b/src/backend/main.py index e1968ec..953e29c 100644 --- a/src/backend/main.py +++ b/src/backend/main.py @@ -1,4 +1,3 @@ -import logging from pathlib import Path import uvicorn @@ -11,7 +10,7 @@ staticdir = Path(__file__).parent.parent.parent.joinpath("web/dist") # 目前采用 src 目录结构,导致打包时静态文件路径和开发时不一致,暂时先这样处理。 -if ~staticdir.exists(): +if not staticdir.exists(): staticdir = Path(__file__).parent.parent.joinpath("web/dist") app = FastAPI() diff --git a/web/src/App.jsx b/web/src/App.jsx index f48f9e9..819e08c 100644 --- a/web/src/App.jsx +++ b/web/src/App.jsx @@ -1,5 +1,4 @@ -import React from "react"; -import { Layout, theme } from "antd"; +import { Layout } from "antd"; const { Content } = Layout; import FooterWarp from "./components/FooterWarp"; @@ -9,15 +8,15 @@ import JobList from "./components/JobList/index.jsx"; const ContentWarp = () => { return ( - + ); }; const App = () => { - const { - token: { colorBgContainer }, - } = theme.useToken(); + // const { + // token: { colorBgContainer }, + // } = theme.useToken(); return ( diff --git a/web/src/backend/job.js b/web/src/backend/job.js index 7bbd98e..e72086a 100644 --- a/web/src/backend/job.js +++ b/web/src/backend/job.js @@ -2,8 +2,13 @@ import axios from "axios"; const serverUrl = ""; -const getJobs = () => { - return axios.get(serverUrl + "/api/jobs").then((response) => { +const getJobs = (city) => { + let url = serverUrl + "/api/jobs"; + if (city !== undefined) { + url = url + "?city=" + city; + } + + return axios.get(url).then((response) => { return response.data; }); }; diff --git a/web/src/chart.jsx b/web/src/chart.jsx index b0b0ba7..f551f28 100644 --- a/web/src/chart.jsx +++ b/web/src/chart.jsx @@ -1,69 +1,62 @@ -import ReactECharts from 'echarts-for-react'; -import {Col, Row} from "antd"; -import React from "react"; +import ReactECharts from "echarts-for-react"; +import { Col, Row } from "antd"; const option = { - xAxis: { - type: 'category', - data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] + xAxis: { + type: "category", + data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], + }, + yAxis: { + type: "value", + }, + series: [ + { + data: [150, 230, 224, 218, 135, 147, 260], + type: "line", }, - yAxis: { - type: 'value' - }, - series: [ - { - data: [150, 230, 224, 218, 135, 147, 260], - type: 'line' - } - ] + ], }; function Chart() { - return ( - - ) + return ; } export default function Charts() { - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ) + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); } diff --git a/web/src/components/JobList/index.jsx b/web/src/components/JobList/index.jsx index fa6f5ce..c371084 100644 --- a/web/src/components/JobList/index.jsx +++ b/web/src/components/JobList/index.jsx @@ -1,6 +1,7 @@ import React from "react"; import * as api from "../../backend/job"; -import { Table } from "antd"; +import { Select, Table } from "antd"; +import { Flex, Radio } from "antd"; const columns = [ { @@ -25,11 +26,54 @@ const columns = [ }, ]; +const cityList = [ + "全国", + "北京", + "深圳", + "上海", + "广州", + "成都", + "杭州", + "武汉", + "苏州", + "南京", + "西安", + "长沙", + "东莞", + "重庆", + "佛山", + "无锡", + "合肥", + "宁波", + "郑州", + "珠海", + "常州", + "嘉兴", + "中山", + "大连", + "厦门", + "天津", + "惠州", + "福州", + "济南", + "青岛", + "昆明", + "南昌", + "长春", + "南通", + "贵阳", + "沈阳", + "南宁", + "温州", + "湖州", +]; + export default function JobList(prop) { const [dataSource, setDataSource] = React.useState([]); + const [city, setCity] = React.useState("全国"); React.useEffect(() => { - api.getJobs().then((data) => { + api.getJobs(city).then((data) => { let counter = 1; data.map((item) => { item.key = counter++; @@ -37,11 +81,61 @@ export default function JobList(prop) { }); setDataSource(data); }); - }, []); + }, [city]); + + const handleCityChange = (e) => { + console.log(e.target.value); + setCity(e.target.value); + }; + + const handleCitySelect = (e) => { + console.log(e); + setCity(e); + }; + + const citySpilt = 11; + const minCityList = cityList.slice(0, citySpilt); + const lastCityList = cityList.slice(citySpilt); return ( <> - + + + 工作地点 + + + {minCityList.map((item) => ( + + {item} + + ))} + + + {lastCityList.map((item) => ( + + {item} + + ))} + + + + + + > ); } diff --git a/web/src/components/Navbar/index.jsx b/web/src/components/Navbar/index.jsx index 3416ef7..a840e34 100644 --- a/web/src/components/Navbar/index.jsx +++ b/web/src/components/Navbar/index.jsx @@ -1,34 +1,29 @@ -import React from "react"; -import {Menu, Layout} from "antd"; +import { Menu, Layout } from "antd"; -const {Header} = Layout; +const { Header } = Layout; import SearchBar from "../SearchBar"; const items = [ - { - key: "home", - title: "首页", - label: ( - 首页 - ), - }, + { + key: "home", + title: "首页", + label: 首页, + }, ]; export default function Navbar() { - return ( - - 5piderMan - - - - - - ) -} \ No newline at end of file + return ( + + 5piderMan + + + + + + ); +} diff --git a/web/src/components/SearchBar/index.jsx b/web/src/components/SearchBar/index.jsx index aa56e93..4a7ef56 100644 --- a/web/src/components/SearchBar/index.jsx +++ b/web/src/components/SearchBar/index.jsx @@ -1,15 +1,9 @@ -import React from 'react'; -import {Input} from 'antd'; +import { Input } from "antd"; -const {Search} = Input; +const { Search } = Input; const onSearch = (value, _e, info) => console.log(info?.source, value); export default function SearchBar() { - return ( - - ); -} \ No newline at end of file + return ; +}