mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-14 19:52:10 +08:00
add http api
This commit is contained in:
@@ -69,8 +69,8 @@ module.exports = (appInfo) => {
|
||||
|
||||
/* 内置socket服务 */
|
||||
config.socketServer = {
|
||||
port: 7070, // 默认端口
|
||||
isDynamic: false, // 如果值为false,框架默认使用port端口(如果默认端口被使用,则随机获取一个);如果为true,默认端口无效,框架随机生成
|
||||
enable: true, // 是否启用
|
||||
port: 7070, // 默认端口(如果端口被使用,则随机获取一个)
|
||||
path: "/socket.io/", // 默认路径名称
|
||||
connectTimeout: 45000, // 客户端连接超时时间
|
||||
pingTimeout: 30000, // 心跳检测超时时间
|
||||
@@ -82,6 +82,18 @@ module.exports = (appInfo) => {
|
||||
}
|
||||
};
|
||||
|
||||
/* 内置http服务*/
|
||||
config.httpServer = {
|
||||
enable: true, // 是否启用
|
||||
port: 7071, // 默认端口(如果端口被使用,则随机获取一个)
|
||||
};
|
||||
|
||||
/* 主进程 */
|
||||
config.mainServer = {
|
||||
host: '127.0.0.1',
|
||||
port: 7072, // 默认端口(如果端口被使用,则随机获取一个)
|
||||
};
|
||||
|
||||
/* 应用自动升级 (可选) */
|
||||
config.autoUpdate = {
|
||||
windows: false, // windows平台
|
||||
|
||||
@@ -41,6 +41,8 @@ class ExampleController extends Controller {
|
||||
let tmpDir = Utils.getLogDir();
|
||||
console.log('tmpDir:', tmpDir);
|
||||
|
||||
console.log('this.app.request:', this.app.request.query);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,22 @@ const specialIpcRoute = {
|
||||
appUpdater: 'app.updater' // 此频道在后端也有相同定义
|
||||
}
|
||||
|
||||
/**
|
||||
* 访问http服务
|
||||
*/
|
||||
const requestHttp = (uri, parameter) => {
|
||||
const url = uri.split('.').join('/');
|
||||
console.log('url:', url);
|
||||
return request({
|
||||
url: url,
|
||||
method: 'post',
|
||||
data: parameter, // body
|
||||
params: {}, // URL 参数
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
ipcApiRoute,
|
||||
specialIpcRoute
|
||||
specialIpcRoute,
|
||||
requestHttp
|
||||
}
|
||||
@@ -6,8 +6,9 @@ import { VueAxios } from './axios'
|
||||
// 创建 axios 实例
|
||||
const request = axios.create({
|
||||
// API 请求的默认前缀
|
||||
baseURL: process.env.VUE_APP_API_BASE_URL,
|
||||
timeout: 60000 // 请求超时时间
|
||||
baseURL: process.env.VUE_APP_API_BASE_URL || 'http://127.0.0.1:7071',
|
||||
timeout: 60000, // 请求超时时间
|
||||
//headers: {'Content-Type': 'multipart/form-data'}
|
||||
})
|
||||
|
||||
// 异常拦截处理器
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
</div>
|
||||
<div class="one-block-2">
|
||||
<a-button @click="exec(1)"> 点击 </a-button>
|
||||
<a-button @click="exec2(1)"> 点击2 </a-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { ipcApiRoute } from '@/api/main'
|
||||
import { ipcApiRoute, requestHttp } from '@/api/main'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -28,6 +29,14 @@ export default {
|
||||
console.log('res:', res)
|
||||
})
|
||||
},
|
||||
exec2 (id) {
|
||||
const params = {
|
||||
id: id
|
||||
}
|
||||
requestHttp(ipcApiRoute.test, params).then(res => {
|
||||
console.log('res2:', res)
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user