Index.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <div id="app-base-httpserver">
  3. <div class="one-block-1">
  4. <span>
  5. 1. 内置http server服务
  6. </span>
  7. </div>
  8. <div class="one-block-2">
  9. <a-space>
  10. <p>* 状态:{{ currentStatus }}</p>
  11. </a-space>
  12. <p>* 地址:{{ servicAddress }}</p>
  13. </div>
  14. <div class="one-block-1">
  15. <span>
  16. 2. 发送http请求
  17. </span>
  18. </div>
  19. <div class="one-block-2">
  20. <a-space>
  21. <a-button @click="sendRequest('pictures')"> 打开【我的图片】 </a-button>
  22. </a-space>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import { ipcApiRoute, requestHttp } from '@/api/main'
  28. export default {
  29. data() {
  30. return {
  31. currentStatus: '关闭',
  32. servicAddress: '无'
  33. };
  34. },
  35. mounted () {
  36. this.init();
  37. },
  38. methods: {
  39. init () {
  40. const self = this;
  41. this.$ipcCall(ipcApiRoute.checkHttpServer, {}).then(r => {
  42. if (r.enable) {
  43. self.currentStatus = '开启';
  44. self.servicAddress = r.server;
  45. }
  46. })
  47. },
  48. sendRequest (id) {
  49. const params = {
  50. id: id
  51. }
  52. requestHttp(ipcApiRoute.doHttpRequest, params).then(res => {
  53. //console.log('res:', res)
  54. })
  55. },
  56. }
  57. };
  58. </script>
  59. <style lang="less" scoped>
  60. #app-base-httpserver {
  61. padding: 0px 10px;
  62. text-align: left;
  63. width: 100%;
  64. .one-block-1 {
  65. font-size: 16px;
  66. padding-top: 10px;
  67. }
  68. .one-block-2 {
  69. padding-top: 10px;
  70. }
  71. }
  72. </style>