| | |
| | | import { ElMessage } from "element-plus/es"; |
| | | import { Local } from "@/utils/storage"; |
| | | import type { DeviceLoginRecord } from './type/user.type'; |
| | | import { logoutForSubScreen } from "@/utils/httpApi"; |
| | | |
| | | export const useBedsideAuxiliaryScreenStore = defineStore( |
| | | "bedsideAuxiliaryScreen", |
| | |
| | | |
| | | |
| | | /** 退出登录 */ |
| | | const logout = () => { |
| | | |
| | | const logout = async (deviceCode: string) => { |
| | | await logoutForSubScreen(deviceCode); |
| | | setUserInfo(null); |
| | | }; |
| | | |
| | | // SSE 相关状态 |
| | |
| | | throw error; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 推出登录 |
| | | * @param deviceCode |
| | | * @returns |
| | | */ |
| | | export const logoutForSubScreen = async(deviceCode: string) => { |
| | | try { |
| | | const response = await axios.post(`${apiBaseUrl}/user/info/logoutForSubScreen`, { deviceCode }, { |
| | | headers: { |
| | | 'Content-Type': 'application/x-www-form-urlencoded' |
| | | } |
| | | }); |
| | | return response.data |
| | | } catch (error) { |
| | | throw error; |
| | | } |
| | | } |
| | |
| | | !bedsideAuxiliaryScreenStore.deviceData.deviceCode |
| | | ) |
| | | return ElMessage.warning("未初始化或正在进行初始化操作中"); |
| | | console.log(loginDialogRef) |
| | | loginDialogRef.value.openDialog(); |
| | | }; |
| | | |
| | |
| | | }); |
| | | |
| | | const isLoginng = computed(() => { |
| | | return !!bedsideAuxiliaryScreenStore.userInfo.code; |
| | | return !!bedsideAuxiliaryScreenStore.userInfo?.code; |
| | | }); |
| | | |
| | | const qrCodeData = computed(() => { |
| | |
| | | }; |
| | | |
| | | const onLogout = () => { |
| | | if (state.loading) return ElMessage.warning('正在退出中...') |
| | | ElMessageBox.confirm("是否确认退出当前登录用户?", "提示", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | bedsideAuxiliaryScreenStore.logout(); |
| | | .then(async() => { |
| | | state.loading = true |
| | | try { |
| | | await bedsideAuxiliaryScreenStore.logout(bedsideAuxiliaryScreenStore.deviceCode); |
| | | handleCancel(); |
| | | ElMessage.success('退出登录成功') |
| | | } catch (error) { |
| | | ElMessage.success('退出登录失败') |
| | | } finally { |
| | | state.loading = false; |
| | | } |
| | | ElMessage({ |
| | | type: "success", |
| | | message: "退出成功!", |