import './connection.css' import { useId, Button, FieldProps, useToastController, Toast, ToastTitle, ToastIntent, Toaster } from "@fluentui/react-components"; import {Field, Input} from "@fluentui/react-components"; import {useNavigate} from "react-router-dom"; import {useState} from "react"; import {Dial} from "../../api"; const Connection = (props: Partial) => { const toasterId = useId("toaster"); const {dispatchToast} = useToastController(toasterId); const navigate = useNavigate(); const [value, setValue] = useState<{ name: string, endpoint: string, access: string, key: string }>({ name: '', endpoint: '', access: '', key: '' }) function test() { const val = JSON.stringify(value); console.log('[DEBUG] connection.test: value =', val) Dial("/api/connection/test", value).then(res => { if (res.status === 200) { dispatchToast( 连接成功! , {position: "top-end", intent: "success"} ) } }) } return
{ setValue({...value, name: e.target.value}); }}/>
{ setValue({...value, endpoint: e.target.value}); }}/>
{ setValue({...value, access: e.target.value}); }}/>
{ setValue({...value, key: e.target.value}); }}/>
} export default Connection;