Files
czzj-app/src/pages/device/index.vue
2026-11-05 13:54:05 +08:00

88 lines
2.1 KiB
Vue

<template>
<view class="device-page" :class="{ 'device-page--scroll-lock': homePickerOpen }">
<device-header
:home-name="homeName"
:home-id="homeId"
:homes="homes"
@select-home="onSelectHome"
@manage="onHomeManage"
@notify="onNotify"
@add-device="onStartBind"
@scan="onScan"
@picker-open-change="homePickerOpen = $event"
/>
<room-tabs
:rooms="rooms"
:active-id="activeRoomId"
@select="selectRoom"
@add="onAddRoom"
/>
<device-list
v-if="hasDevices"
:devices="devices"
:online-count="onlineCount"
@select="onSelectDevice"
/>
<view v-else-if="loading" class="device-page__loading">
<text class="device-page__loading-text">加载中...</text>
</view>
<device-empty
v-else
:step-hint="bindStepHint"
@bind="onStartBind"
/>
<room-location-dialog
v-model:visible="roomDialogVisible"
@confirm="onConfirmAddRoom"
/>
<operation-success-toast v-model:visible="successToastVisible" />
<app-tab-bar :current="tabCurrent" />
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useTabPage } from '@/hooks/use-tab-page'
import DeviceEmpty from './components/device-empty/index.vue'
import DeviceHeader from './components/device-header/index.vue'
import DeviceList from './components/device-list/index.vue'
import OperationSuccessToast from './components/operation-success-toast/index.vue'
import RoomLocationDialog from './components/room-location-dialog/index.vue'
import RoomTabs from './components/room-tabs/index.vue'
import { useDevice } from './use-device'
const { tabCurrent } = useTabPage('device')
const homePickerOpen = ref(false)
const {
homeName,
homeId,
homes,
rooms,
activeRoomId,
devices,
onlineCount,
hasDevices,
loading,
bindStepHint,
roomDialogVisible,
successToastVisible,
selectRoom,
onAddRoom,
onConfirmAddRoom,
onStartBind,
onScan,
onNotify,
onHomeManage,
onSelectHome,
onSelectDevice,
} = useDevice()
</script>
<style lang="scss" scoped>
@import './device.scss';
</style>