Emperor_Shun_Reading/public/dist/assets/HttpServer-142b588f.js

2 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

2024-08-22 08:50:01 +00:00
import{_ as t,i as e,a as s,l as o,b as a,o as n,c as r,f as l,t as i,h as c,e as u,w as d,p,k as h}from"./index-f69ca7de.js";import{s as v}from"./store2-491cc7ac.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 a=t.split(".").join("/");return a=s+"/"+a,console.log("url:",a),o({url:a,method:"post",data:e,timeout:6e4})},backendRequest(){console.log("GO_URL:","http://www.test.com");o({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=>(p("data-v-3508e997"),t=t(),h(),t),k={id:"app-base-httpserver"},f=b((()=>l("div",{class:"one-block-1"},[l("span",null," 1. 使用http与主进程通信 ")],-1))),g={class:"one-block-2"},w=b((()=>l("div",{class:"one-block-1"},[l("span",null," 2. 使用http与服务端通信 ")],-1))),q={class:"one-block-2"};const R=t(m,[["render",function(t,e,s,o,p,h){const v=a("a-button");return n(),r("div",k,[f,l("div",g,[l("p",null,"* 状态:"+i(p.currentStatus),1),l("p",null,"* 地址:"+i(p.servicAddress),1),l("p",null,[c("* 发送请求: "),u(v,{onClick:e[0]||(e[0]=t=>h.sendRequest("pictures"))},{default:d((()=>[c(" 打开【我的图片】 ")])),_:1})])]),w,l("div",q,[l("p",null,[u(v,{onClick:e[1]||(e[1]=t=>h.backendRequest())},{default:d((()=>[c(" 发送请求 ")])),_:1}),c(" (请自行创建服务) ")])])])}],["__scopeId","data-v-3508e997"]]);export{R as default};