http demo

This commit is contained in:
gsx
2022-04-12 15:27:57 +08:00
parent 77262f5c4f
commit ecbab7e451
4 changed files with 17 additions and 4 deletions

View File

@@ -11,7 +11,7 @@
"ant-design-vue": "^1.7.8",
"axios": "^0.21.1",
"core-js": "^3.6.5",
"store": "^2.0.12",
"store2": "^2.13.2",
"vue": "^2.6.11",
"vue-quill-editor": "^3.0.6",
"vue-router": "^3.4.9",

View File

@@ -1,3 +1,4 @@
import storage from 'store2'
import request from '@/utils/request'
const ipcApiRoute = {
@@ -37,12 +38,17 @@ const specialIpcRoute = {
*/
const requestHttp = (uri, parameter) => {
// url转换
const url = uri.split('.').join('/');
const config = storage.get('httpServiceConfig');
const host = config.server || 'http://127.0.0.1:7071';
let url = uri.split('.').join('/');
url = host + '/' + url;
console.log('url:', url);
return request({
url: url,
method: 'post',
data: parameter, // body
params: {}, // URL 参数
timeout: 60000,
})
}

View File

@@ -1,12 +1,12 @@
import axios from 'axios'
import storage from 'store'
import storage from 'store2'
import notification from 'ant-design-vue/es/notification'
import { VueAxios } from './axios'
// 创建 axios 实例
const request = axios.create({
// API 请求的默认前缀
baseURL: process.env.VUE_APP_API_BASE_URL || 'http://127.0.0.1:7071',
baseURL: process.env.VUE_APP_API_BASE_URL,
timeout: 60000, // 请求超时时间
//headers: {'Content-Type': 'multipart/form-data'}
})

View File

@@ -24,6 +24,7 @@
</div>
</template>
<script>
import storage from 'store2'
import { ipcApiRoute, requestHttp } from '@/api/main'
export default {
@@ -43,10 +44,16 @@ export default {
if (r.enable) {
self.currentStatus = '开启';
self.servicAddress = r.server;
storage.set('httpServiceConfig', r);
}
})
},
sendRequest (id) {
if (this.currentStatus == '关闭') {
this.$message.error('http服务未开启');
return;
}
const params = {
id: id
}