|
|
@ -15,32 +15,35 @@ import { updateUser } from "../store/features/contextSlice"; |
|
|
|
import "./bluetooth.scss"; |
|
|
|
import { loginUser } from "../services/wsTypes"; |
|
|
|
export default function Header() { |
|
|
|
const navigate = useNavigate(); |
|
|
|
const dispatch = useAppDispatch(); |
|
|
|
const navigate = useNavigate(); |
|
|
|
const dispatch = useAppDispatch(); |
|
|
|
const deviceInfo = useAppSelector(store => store.context.device); |
|
|
|
//@ts-ignoref
|
|
|
|
const deviceState = useSelector(store => store.deviceState); |
|
|
|
let [isConnect, setIsConnect] = useState(deviceState.isConnect) |
|
|
|
const [bluetoothInfo, setBluetoothInfo] = useState(deviceState) |
|
|
|
//获取当前websocet的状态
|
|
|
|
const showBlueImg = () => { |
|
|
|
if(isConnect){ |
|
|
|
return <Popover content={getBtContent()} title=""> |
|
|
|
<img src={icon_usb} onClick={onDisconnectBt} alt="" className="ext-base ml-2 h-6" /> |
|
|
|
</Popover> |
|
|
|
} |
|
|
|
return null; |
|
|
|
// if(!isConnect){
|
|
|
|
// return <Popover content={getBtList()} title="可连接设备">
|
|
|
|
// <div ></div>
|
|
|
|
// <img src={bluetooth_nc} alt="" className="ext-base ml-2 h-6" />
|
|
|
|
// </Popover>
|
|
|
|
// }else {
|
|
|
|
// return <Popover content={getBtContent()} title="">
|
|
|
|
// <img src={icon_usb} onClick={onDisconnectBt} alt="" className="ext-base ml-2 h-6" />
|
|
|
|
// </Popover>
|
|
|
|
// }
|
|
|
|
const deviceState = useAppSelector(store => store.deviceState); |
|
|
|
let [isConnect, setIsConnect] = useState(true); |
|
|
|
const [bluetoothInfo, setBluetoothInfo] = useState(deviceState); |
|
|
|
//获取当前websocet的状态
|
|
|
|
const showBlueImg = () => { |
|
|
|
if (isConnect) { |
|
|
|
return ( |
|
|
|
<Popover content={getBtContent()} title=""> |
|
|
|
<section className="bg-white rounded-md h-9 w-10 flex justify-center items-center mr-3"> |
|
|
|
<img src={icon_usb} alt="" className="h-6" /> |
|
|
|
</section> |
|
|
|
</Popover> |
|
|
|
); |
|
|
|
} |
|
|
|
return null; |
|
|
|
// if(!isConnect){
|
|
|
|
// return <Popover content={getBtList()} title="可连接设备">
|
|
|
|
// <div ></div>
|
|
|
|
// <img src={bluetooth_nc} alt="" className="ext-base ml-2 h-6" />
|
|
|
|
// </Popover>
|
|
|
|
// }else {
|
|
|
|
// return <Popover content={getBtContent()} title="">
|
|
|
|
// <img src={icon_usb} onClick={onDisconnectBt} alt="" className="ext-base ml-2 h-6" />
|
|
|
|
// </Popover>
|
|
|
|
// }
|
|
|
|
}; |
|
|
|
|
|
|
|
let list = [ |
|
|
|
{ |
|
|
@ -112,34 +115,35 @@ export default function Header() { |
|
|
|
if (!isConnect) { |
|
|
|
Dom = ( |
|
|
|
<div> |
|
|
|
{bluetoothList.map(item => { |
|
|
|
{bluetoothList.map(item => { |
|
|
|
return ( |
|
|
|
<div className="mt-[1rem]" onClick={connectBt}> |
|
|
|
<Button type="link">{item.name}</Button> |
|
|
|
</div> |
|
|
|
<Button type="link">{item.name}</Button> |
|
|
|
</div> |
|
|
|
); |
|
|
|
})} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
} |
|
|
|
return Dom; |
|
|
|
}; |
|
|
|
|
|
|
|
//设备已连接
|
|
|
|
const getBtContent = ()=> { |
|
|
|
return <div> |
|
|
|
const getBtContent = () => { |
|
|
|
return ( |
|
|
|
<div> |
|
|
|
<div className="bluetooth_c"> |
|
|
|
<img src={check_mark} alt="" className="ext-base ml-2 h-4" /> |
|
|
|
<div className="ml-[10px]">设备已连接</div> |
|
|
|
</div> |
|
|
|
<div className="pl-[15px]"> |
|
|
|
<div className="mt-[1rem]">sn码:{bluetoothInfo.sn}</div> |
|
|
|
<div className="mt-[1rem]">设备描述:{bluetoothInfo.descriptivePortName}</div> |
|
|
|
{/* <div className="mt-[1rem]">电量:{bluetoothInfo.power}</div> */} |
|
|
|
<div> |
|
|
|
<div className="bluetooth_c"> |
|
|
|
<img src={check_mark} alt="" className="ext-base ml-2 h-4" /> |
|
|
|
<div className="ml-[10px]">设备已连接</div> |
|
|
|
</div> |
|
|
|
<div className="pl-[15px]"> |
|
|
|
<div className="mt-[1rem]">sn码:{bluetoothInfo.sn}</div> |
|
|
|
<div className="mt-[1rem]">设备描述:{bluetoothInfo.descriptivePortName}</div> |
|
|
|
{/* <div className="mt-[1rem]">电量:{bluetoothInfo.power}</div> */} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
@ -170,13 +174,11 @@ export default function Header() { |
|
|
|
/> |
|
|
|
<p className="text-primary text-xs">{deviceInfo.power.toFixed()}%</p> |
|
|
|
</section> |
|
|
|
<section className="bg-white rounded-md h-9 w-10 flex justify-center items-center mr-3"> |
|
|
|
{/* <section className="bg-white rounded-md h-9 w-10 flex justify-center items-center mr-3"> |
|
|
|
<img src={icon_usb} className="w-6" alt="icon" /> |
|
|
|
</section> |
|
|
|
|
|
|
|
<div className="mr-8 flex items-center w-[5rem]"> |
|
|
|
{showBlueImg()} |
|
|
|
</div> |
|
|
|
</section> */} |
|
|
|
{showBlueImg()} |
|
|
|
<div className="mr-8 flex items-center min-w-[5rem]"> |
|
|
|
<Dropdown menu={{ items }} trigger={["click"]}> |
|
|
|
<section className="flex items-center"> |
|
|
|
<img src={icon_avatar} alt="" className="h-8" /> |
|
|
|