2 lines
1.9 KiB
JavaScript
2 lines
1.9 KiB
JavaScript
|
|
import{_ as t,i as e,h as s,r as o,o as a,b as n,g as r,t as l,e as i,a as c,w as u,p as d,f as p}from"./index-ea5b20ee.js";import{a as h}from"./index-1ef15d1b.js";import{s as v}from"./store2-204267a2.js";const m={data:()=>({currentStatus:"关闭",servicAddress:"无"}),mounted(){this.init()},methods:{init(){e.invoke(s.checkHttpServer,{}).then((t=>{t.enable&&(this.currentStatus="开启",this.servicAddress=t.server,v.set("httpServiceConfig",t))}))},sendRequest(t){"关闭"!=this.currentStatus?this.requestHttp(s.doHttpRequest,{id:t}).then((t=>{})):this.$message.error("http服务未开启")},requestHttp(t,e){const s=v.get("httpServiceConfig").server||"http://localhost:7071";let o=t.split(".").join("/");return o=s+"/"+o,console.log("url:",o),h({url:o,method:"post",data:e,timeout:6e4})},backendRequest(){console.log("GO_URL:","http://www.test.com");h({baseURL:"http://www.test.com",method:"get",url:"/hello",timeout:6e4}).then((t=>{console.log("res:",t);const e=t.data||null;this.$message.info(`go服务返回: ${e}`)}))}}},b=t=>(d("data-v-3508e997"),t=t(),p(),t),f={id:"app-base-httpserver"},g=b((()=>r("div",{class:"one-block-1"},[r("span",null," 1. 使用http与主进程通信 ")],-1))),k={class:"one-block-2"},q=b((()=>r("div",{class:"one-block-1"},[r("span",null," 2. 使用http与服务端通信 ")],-1))),w={class:"one-block-2"};const R=t(m,[["render",function(t,e,s,d,p,h){const v=o("a-button");return a(),n("div",f,[g,r("div",k,[r("p",null,"* 状态:"+l(p.currentStatus),1),r("p",null,"* 地址:"+l(p.servicAddress),1),r("p",null,[i("* 发送请求: "),c(v,{onClick:e[0]||(e[0]=t=>h.sendRequest("pictures"))},{default:u((()=>[i(" 打开【我的图片】 ")])),_:1})])]),q,r("div",w,[r("p",null,[c(v,{onClick:e[1]||(e[1]=t=>h.backendRequest())},{default:u((()=>[i(" 发送请求 ")])),_:1}),i(" (请自行创建服务) ")])])])}],["__scopeId","data-v-3508e997"]]);export{R as default};
|