Skip to content

Commit

Permalink
# add link
Browse files Browse the repository at this point in the history
  • Loading branch information
czy21 committed Mar 6, 2024
1 parent 77089e6 commit 409af1d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";

import {Layout, Menu} from 'antd';
import {Link} from "react-router-dom";
import menus, {MenuModel} from "@/menu";
import { Layout, Menu } from 'antd';
import { Link } from "react-router-dom";
import menus, { MenuModel } from "@/menu";


function recursiveMenu(menus: MenuModel[]) {
Expand All @@ -26,7 +26,7 @@ function recursiveMenu(menus: MenuModel[]) {
<Menu.Item key={i}>
{t.icon}
<span>{t.name}</span>
{t.path && <Link to={t.path}/>}
{t.path && <Link to={t.path} target={t.redirect ? "_blank" : ""} />}
</Menu.Item>
)
})
Expand All @@ -45,7 +45,7 @@ export default class Header extends React.Component<any, any> {
alignItems: 'center',
}}
>
<Menu>
<Menu mode="horizontal" theme="dark">
{recursiveMenu(menus)}
</Menu>
</Layout.Header>
Expand Down
6 changes: 6 additions & 0 deletions src/menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface MenuModel {
path?: string
icon?: React.ReactNode
children?: Array<MenuModel>
redirect?: boolean
}

const menus: MenuModel[] = [
Expand All @@ -20,6 +21,11 @@ const menus: MenuModel[] = [
path: "cf-best/server"
}
]
},
{
name: "IT-Tools",
path: "https://it-tools.tech/",
redirect: true
}
];
export default menus
4 changes: 4 additions & 0 deletions src/util/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ interface URI {
path: string
}

export function validateForm(form: Promise<any>, successCallback: (value: any) => void, errorCallback?: (err: any) => void) {
form.then(value => successCallback(value)).catch(err => errorCallback && errorCallback(err))
}

export function matchUrl(url: string): URI {
let ret: any = urlPattern.exec(url)
console.log(ret)
Expand Down
40 changes: 25 additions & 15 deletions src/view/cf-best/cdn/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import stub from "@/init"
import {Form, Table, TreeSelect} from "antd";
import {Button, Form, Table, TreeSelect} from "antd";

const columns = [
{
Expand Down Expand Up @@ -40,6 +40,9 @@ const columns = [
},
];

const locationOnChange = (value: any, label: any, extra: any) => {
console.log(extra)
}
const CFBestCDN: React.FC = () => {

const [data, setData] = stub.ref.react.useState<any>({})
Expand All @@ -55,26 +58,33 @@ const CFBestCDN: React.FC = () => {
setQuery(q)
stub.api.post("cf-best/cdn/page", stub.ref.lodash.omit(q, "total")).then((t: any) => setData(t.data.data))
}

const [filter] = stub.ref.antd.Form.useForm();
return (
<div>
<Form
name="filter"
labelCol={{span: 8}}
wrapperCol={{span: 16}}
style={{maxWidth: 600}}
form={filter}
autoComplete="off"
layout={"inline"}
>
<TreeSelect
showSearch
style={{width: '50%'}}
dropdownStyle={{maxHeight: 400, overflow: 'auto'}}
allowClear
treeCheckable
showCheckedStrategy={"SHOW_PARENT"}
// onChange={onChange}
treeData={countryTree}
/>
<Form.Item label={"位置"} name={"location"} style={{width: "20%"}}>
<TreeSelect
showSearch
dropdownStyle={{maxHeight: 400, overflow: 'auto'}}
allowClear
treeCheckable
showCheckedStrategy={"SHOW_PARENT"}
onChange={locationOnChange}
treeData={countryTree}
/>
</Form.Item>
<Form.Item>
<Button type="primary" onClick={() => {
console.log(filter.getFieldValue("location"))
}}>
查询
</Button>
</Form.Item>
</Form>
<Table dataSource={data.list} columns={columns}
pagination={{
Expand Down

0 comments on commit 409af1d

Please sign in to comment.