HttpServer.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. 发送请求
  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 storage from 'store2'
  28. import { ipcApiRoute, requestHttp } from '@/api/main'
  29. export default {
  30. data() {
  31. return {
  32. currentStatus: '关闭',
  33. servicAddress: '无'
  34. };
  35. },
  36. mounted () {
  37. this.init();
  38. },
  39. methods: {
  40. init () {
  41. const self = this;
  42. this.$ipcCall(ipcApiRoute.checkHttpServer, {}).then(r => {
  43. if (r.enable) {
  44. self.currentStatus = '开启';
  45. self.servicAddress = r.server;
  46. storage.set('httpServiceConfig', r);
  47. }
  48. })
  49. },
  50. sendRequest (id) {
  51. if (this.currentStatus == '关闭') {
  52. this.$message.error('http服务未开启');
  53. return;
  54. }
  55. const params = {
  56. id: id
  57. }
  58. requestHttp(ipcApiRoute.doHttpRequest, params).then(res => {
  59. //console.log('res:', res)
  60. })
  61. },
  62. }
  63. };
  64. </script>
  65. <style lang="less" scoped>
  66. #app-base-httpserver {
  67. padding: 0px 10px;
  68. text-align: left;
  69. width: 100%;
  70. .one-block-1 {
  71. font-size: 16px;
  72. padding-top: 10px;
  73. }
  74. .one-block-2 {
  75. padding-top: 10px;
  76. }
  77. }
  78. </style>