Setting.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <a-list id="set" itemLayout="horizontal">
  3. <a-list-item style="text-align: left;">
  4. <a-list-item-meta>
  5. <template v-slot:title>
  6. <a>启动</a>
  7. </template>
  8. <template v-slot:description>
  9. <span>
  10. 开机自动启动
  11. </span>
  12. </template>
  13. </a-list-item-meta>
  14. <template v-slot:actions>
  15. <a-switch checkedChildren="开" unCheckedChildren="关" v-model="autoLaunchChecked" @change="autoLaunchChange(autoLaunchChecked)" />
  16. </template>
  17. </a-list-item>
  18. </a-list>
  19. </template>
  20. <script>
  21. import { localApi } from '@/api/main'
  22. export default {
  23. data () {
  24. return {
  25. autoLaunchChecked: false
  26. }
  27. },
  28. mounted () {
  29. this.autoLaunchInit()
  30. },
  31. methods: {
  32. autoLaunchInit () {
  33. localApi('autoLaunchIsEnabled', {}).then(res => {
  34. if (res.code !== 0) {
  35. return false
  36. }
  37. this.autoLaunchChecked = res.data.isEnabled;
  38. }).catch(err => {
  39. console.log('err:', err)
  40. })
  41. },
  42. autoLaunchChange (checkStatus) {
  43. const params = {
  44. 'checkStatus': checkStatus
  45. }
  46. if (checkStatus) {
  47. localApi('autoLaunchEnable', params).then(res => {
  48. if (res.code !== 0) {
  49. return false
  50. }
  51. this.autoLaunchChecked = res.data.isEnabled;
  52. }).catch(err => {
  53. console.log('err:', err)
  54. })
  55. } else {
  56. localApi('autoLaunchDisable', 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. }
  65. },
  66. }
  67. }
  68. </script>
  69. <style lang="less" scoped>
  70. // 嵌套
  71. #set {
  72. .ant-list-item:last-child {
  73. border-bottom: 1px solid #e8e8e8;
  74. }
  75. }
  76. </style>