AutoLaunch.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div id="app-demo-system-launch">
  3. <!-- <div class="one-block-1">
  4. <span>
  5. 开机启动
  6. </span>
  7. </div> -->
  8. <div class="one-block-2">
  9. <a-list class="set-auto" itemLayout="horizontal">
  10. <a-list-item style="text-align: left;">
  11. <a-list-item-meta>
  12. <template v-slot:title>
  13. <a>启动</a>
  14. </template>
  15. <template v-slot:description>
  16. <span>
  17. 开机自动启动
  18. </span>
  19. </template>
  20. </a-list-item-meta>
  21. <template v-slot:actions>
  22. <a-switch v-model="autoLaunchChecked" checkedChildren="开" unCheckedChildren="关" @change="autoLaunchChange(autoLaunchChecked)" />
  23. </template>
  24. </a-list-item>
  25. </a-list>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import { localApi } from '@/api/main'
  31. export default {
  32. data () {
  33. return {
  34. autoLaunchChecked: false
  35. }
  36. },
  37. mounted () {
  38. this.autoLaunchInit()
  39. },
  40. methods: {
  41. autoLaunchInit () {
  42. localApi('autoLaunchIsEnabled', {}).then(res => {
  43. if (res.code !== 0) {
  44. return false
  45. }
  46. this.autoLaunchChecked = res.data.isEnabled;
  47. }).catch(err => {
  48. console.log('err:', err)
  49. })
  50. },
  51. autoLaunchChange (checkStatus) {
  52. const params = {
  53. 'checkStatus': checkStatus
  54. }
  55. if (checkStatus) {
  56. localApi('autoLaunchEnable', params).then(res => {
  57. if (res.code !== 0) {
  58. return false
  59. }
  60. this.autoLaunchChecked = res.data.isEnabled;
  61. }).catch(err => {
  62. console.log('err:', err)
  63. })
  64. } else {
  65. localApi('autoLaunchDisable', params).then(res => {
  66. if (res.code !== 0) {
  67. return false
  68. }
  69. this.autoLaunchChecked = res.data.isEnabled;
  70. }).catch(err => {
  71. console.log('err:', err)
  72. })
  73. }
  74. },
  75. }
  76. }
  77. </script>
  78. <style lang="less" scoped>
  79. #app-demo-system-launch {
  80. padding: 0px 10px;
  81. text-align: center;
  82. width: 100%;
  83. .one-block-1 {
  84. font-size: 16px;
  85. padding-top: 10px;
  86. }
  87. .one-block-2 {
  88. padding-top: 10px;
  89. }
  90. .set-auto {
  91. .ant-list-item:last-child {
  92. border-bottom: 1px solid #e8e8e8;
  93. }
  94. }
  95. }
  96. </style>