From 9860e221460a0a4ac1903dad2c97160d0eed0e63 Mon Sep 17 00:00:00 2001
From: long <515897141@qq.com>
Date: 星期五, 03 三月 2023 10:59:42 +0800
Subject: [PATCH] 初始化

---
 src/utils/jun_httpInstall.js |   71 +++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/src/utils/jun_httpInstall.js b/src/utils/jun_httpInstall.js
new file mode 100644
index 0000000..76b5ac1
--- /dev/null
+++ b/src/utils/jun_httpInstall.js
@@ -0,0 +1,71 @@
+// 鍒涘缓 http 瀹炰緥
+import Http from './jun_http'
+import config from '../config'
+// var switchConfig = require('../../config/jun_switchConfig')
+import httpEvent from './jun_httpEvent'
+
+// import Upload from './jun_upload'
+
+// baseConfig key
+// var keys = [
+// 	'baseUrl', 'testBaseUrl', 'testOnlineBaseUrl'
+// ]
+// var baseUrlkey = switchConfig.istest ? keys[1]
+// 			: switchConfig.istestonline ? keys[2]
+// 			: keys[0]
+
+// 鏍规嵁閰嶇疆鐢熸垚 httpEvent
+function createHttpEvent(option){
+	let opt = {...httpEvent}
+	if (!option) {
+		return opt
+	} else {
+		if (option.ignores && option.ignores.length) {
+			option.ignores.forEach((key, idx)=>{
+				if (opt[key]) {
+					delete opt[key]
+				}
+			})
+		}
+		return opt
+	}
+}
+
+var http = new Http({
+	baseUrl: config.domain,
+	// 浣跨敤鍏ㄩ儴 httpEvent
+	...createHttpEvent(),
+	...config,
+})
+
+// 闈欐�乯son鐢�
+var http2 = new Http({
+	// 鍙互鏇存敼baseUrl
+	baseUrl: config.domain,
+	// 涓嶄娇鐢� afterFlow
+	...createHttpEvent({
+		ignores: ['afterFlow']
+	}),
+	...config,
+})
+
+// 鐧诲綍鐢�
+var http3 = new Http({
+	baseUrl: config.domain,
+	// 涓嶄娇鐢� afterFlow
+	...createHttpEvent({
+		ignores: ['beforeFlow']
+	}),
+	...config,
+})
+
+// vue 瀹夎
+function install(Vue){
+	Vue.prototype.Req = this
+}
+export default {
+	http,
+	http2,
+	http3,
+	install,
+}
\ No newline at end of file

--
Gitblit v1.8.0