|
|
@@ -1,8 +1,7 @@
|
|
|
<template>
|
|
|
<div
|
|
|
- class="o-device has-padding"
|
|
|
- :class="{ 'u-pointer': isOnline }"
|
|
|
- @click="askStatus"
|
|
|
+ class="o-device has-padding u-pointer"
|
|
|
+ @click="onClick"
|
|
|
>
|
|
|
<div class="l-flex__none l-flex--row o-device__block o-device__header">
|
|
|
<i
|
|
|
@@ -79,39 +78,6 @@
|
|
|
class="l-flex__none o-device__block o-device__footer"
|
|
|
:text="address"
|
|
|
/>
|
|
|
- <el-dialog
|
|
|
- :title="name"
|
|
|
- :visible.sync="show"
|
|
|
- custom-class="c-dialog"
|
|
|
- :before-close="handleClose"
|
|
|
- append-to-body
|
|
|
- >
|
|
|
- <div class="u-text-center">
|
|
|
- <i
|
|
|
- v-if="loading"
|
|
|
- class="el-icon-loading"
|
|
|
- />
|
|
|
- <template v-else>
|
|
|
- <div class="has-bottom-padding">
|
|
|
- <button
|
|
|
- class="c-sibling-item o-button"
|
|
|
- @click="ask"
|
|
|
- >
|
|
|
- 检测状态
|
|
|
- </button>
|
|
|
- <button
|
|
|
- class="c-sibling-item o-button"
|
|
|
- @click="restart"
|
|
|
- >
|
|
|
- 重启
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- <template v-if="message">
|
|
|
- <div v-if="message.type === 's'">{{ message.value }}</div>
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -135,9 +101,6 @@ export default {
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
- show: false,
|
|
|
- loading: false,
|
|
|
- message: null,
|
|
|
isShotting: false,
|
|
|
shot: null,
|
|
|
timeline: [],
|
|
|
@@ -196,32 +159,21 @@ export default {
|
|
|
beforeDestroy () {
|
|
|
if (this.isActivated) {
|
|
|
unlisten(this.onMessage)
|
|
|
- if (this.show) {
|
|
|
- this.handleClose()
|
|
|
- }
|
|
|
}
|
|
|
clearTimeout(this.$timer)
|
|
|
},
|
|
|
methods: {
|
|
|
- askStatus () {
|
|
|
- if (!this.isOnline) {
|
|
|
- return
|
|
|
- }
|
|
|
- this.show = true
|
|
|
- },
|
|
|
- handleClose () {
|
|
|
- this.loading = false
|
|
|
- this.message = null
|
|
|
- this.show = false
|
|
|
+ onClick () {
|
|
|
+ this.$router.push({
|
|
|
+ name: 'device-detail',
|
|
|
+ params: { id: this.device.id }
|
|
|
+ })
|
|
|
},
|
|
|
onMessage (topic, message) {
|
|
|
if (message) {
|
|
|
const result = new RegExp(`${this.device.productId}/${this.device.id}/(.+)`).exec(topic)
|
|
|
if (result) {
|
|
|
switch (result[1]) {
|
|
|
- case 'status/reply':
|
|
|
- this.onAskReply(message)
|
|
|
- break
|
|
|
case 'screenshot/reply':
|
|
|
this.onScreenshotReply(message)
|
|
|
break
|
|
|
@@ -234,44 +186,8 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- publish (invoke) {
|
|
|
- return publish(`${this.device.productId}/${this.device.id}/${invoke}/ask`, JSON.stringify({ timestamp: Date.now() }))
|
|
|
- },
|
|
|
- ask () {
|
|
|
- this.publish('status').then(() => {
|
|
|
- this.loading = true
|
|
|
- this.message = null
|
|
|
- }, () => {
|
|
|
- this.$message({
|
|
|
- type: 'warning',
|
|
|
- message: '正在连接,请稍后再试'
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
- onAskReply (message) {
|
|
|
- this.loading = false
|
|
|
- try {
|
|
|
- message = JSON.parse(message)
|
|
|
- switch (message.status) {
|
|
|
- case 1:
|
|
|
- this.message = { type: 's', value: '未播放节目,处于默认状态' }
|
|
|
- break
|
|
|
- case 2:
|
|
|
- this.message = { type: 's', value: '正在播放节目' }
|
|
|
- break
|
|
|
- case 3:
|
|
|
- this.message = { type: 's', value: '解析节目异常,请重新发布' }
|
|
|
- break
|
|
|
- default:
|
|
|
- this.message = { type: 's', value: '未知' }
|
|
|
- break
|
|
|
- }
|
|
|
- } catch {
|
|
|
- this.message = { type: 's', value: '解析异常,请重试' }
|
|
|
- }
|
|
|
- },
|
|
|
screenshot () {
|
|
|
- this.publish('screenshot').then(() => {
|
|
|
+ publish(`${this.device.productId}/${this.device.id}/screenshot/ask`, JSON.stringify({ timestamp: Date.now() }))('screenshot').then(() => {
|
|
|
this.isShotting = true
|
|
|
this.shot = null
|
|
|
}, () => {
|
|
|
@@ -285,20 +201,6 @@ export default {
|
|
|
this.isShotting = false
|
|
|
this.shot = `data:image/jpeg;base64,${message.replace(/\s/g, '')}`
|
|
|
},
|
|
|
- restart () {
|
|
|
- this.publish('restart').then(() => {
|
|
|
- this.loading = true
|
|
|
- this.message = null
|
|
|
- }, () => {
|
|
|
- this.$message({
|
|
|
- type: 'warning',
|
|
|
- message: '正在连接,请稍后再试'
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
- onRestartReply () {
|
|
|
- this.loading = false
|
|
|
- },
|
|
|
onCalendarUpdate (message) {
|
|
|
clearTimeout(this.$timer)
|
|
|
try {
|