ContentProtection.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <script>
  2. import { getContentProtection } from '@/api/external'
  3. export default {
  4. name: 'ContentProtection',
  5. props: {
  6. device: {
  7. type: Object,
  8. required: true
  9. }
  10. },
  11. data () {
  12. return {
  13. loading: true,
  14. error: false,
  15. open: false
  16. }
  17. },
  18. created () {
  19. this.getContentProtection()
  20. },
  21. methods: {
  22. getContentProtection () {
  23. this.loading = true
  24. this.error = false
  25. getContentProtection(this.device.id, { custom: true }).then(
  26. ({ data }) => {
  27. this.open = data ? data.protect : false
  28. },
  29. () => {
  30. this.error = true
  31. }
  32. ).finally(() => {
  33. this.loading = false
  34. })
  35. }
  36. },
  37. render (h) {
  38. if (this.loading) {
  39. return h('i', {
  40. class: 'el-icon-loading u-font-size'
  41. })
  42. }
  43. if (this.error) {
  44. return h('el-link', {
  45. props: {
  46. type: 'warning'
  47. },
  48. on: {
  49. click: this.getContentProtection
  50. }
  51. }, ['获取失败,点击重试'])
  52. }
  53. return h('div', null, this.open ? '已启用' : '未启用')
  54. }
  55. }
  56. </script>