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

---
 src/config/index.js |   87 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/src/config/index.js b/src/config/index.js
new file mode 100644
index 0000000..83c3735
--- /dev/null
+++ b/src/config/index.js
@@ -0,0 +1,87 @@
+/**
+ * ismock 0涓嶇敤mock 1鐢╩ock
+ * istest 0绾夸笂 1鏈湴
+ *
+ * 鍙戝竷鏃惰璁剧疆3涓彉閲忎负0
+ */
+
+import appId from './appid.js'
+
+var ismock = 0// 铏氭嫙鏁版嵁 0涓嶄娇鐢� 1浣跨敤
+var istest = 2// 0绾夸笂 1鏈湴 2娴嬭瘯鐜
+var isConsole = 1// 鏄惁灞忚斀console 0灞忚斀 1寮�鏀�
+var debug = isConsole
+var isWxLoginType = 0 // 寰俊鐧诲綍 0鏃� 1闈欓粯寰俊鐧诲綍snsapi_base 2鎵嬪姩寰俊鐧诲綍snsapi_userinfo
+var is_use_test_server = 0 // 鏄惁閮ㄧ讲鍦ㄦ祴璇曟湇
+
+// 鎵撳寘鍚庣殑鐜
+if (process.env && process.env.NODE_ENV !== 'development') {
+  istest = 0
+  ismock = 0
+}
+
+let pdomain = 'http://chatgpt.phiskin.com/' // 绾夸笂
+if (is_use_test_server) pdomain = 'https://test5.phiskin.com/' // 娴嬭瘯鏈�
+
+const mock_domain = ''
+// api_local 鏈湴 http://192.168.1.106:8080
+// api_test 娴嬭瘯鐜
+const tdomain = '/api_local/' // 鏈湴
+const pdomain_test = '/api_test/' // 娴嬭瘯鐜
+
+// 寰俊闀块摼
+const appid = appId
+let scope = ''
+if (isWxLoginType === 1) scope = 'snsapi_base' // snsapi_base 闈欓粯鎺堟潈銆愬彧鏈塷penid銆�
+if (isWxLoginType === 2) scope = 'snsapi_userinfo' // snsapi_userinfo 鎵嬪姩鎺堟潈銆愭湁鐢ㄦ埛淇℃伅銆�
+const long = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid={{appid}}&redirect_uri={{url}}&response_type=code&scope={{scope}}&state=1&connect_redirect=1#wechat_redirect'
+
+// 鐢熸垚寰俊閲嶅畾鍚戦摼鎺�
+function createCodeUrl() {
+  // 棣栭〉閾炬帴
+  let indexUrl = location.origin + location.pathname
+  const search = location.search
+  // 鍙傛暟鏁扮粍
+  let querys = []
+  if (search && search.indexOf('?') > -1) {
+    querys = search.split('?')[1].split('&').filter((str) => {
+      const key = str.split('=')[0]
+      const value = str.split('=')[1]
+      return (key != 'code' && key != 'state')
+    })
+  }
+
+  console.log(querys)
+
+  // 琛ュ厖鍙傛暟
+  if (querys.length) {
+    indexUrl += '?' + querys.join('&')
+  }
+
+  return long.replace('{{appid}}', appid).replace('{{scope}}', scope).replace('{{url}}', encodeURIComponent(indexUrl))
+}
+
+// 灞忚斀console.log
+if (!isConsole) {
+  console.log = () => {}
+}
+
+var domain
+
+if (istest == 0) domain = pdomain // 绾夸笂
+if (istest == 1) domain = tdomain // 鏈湴
+if (istest == 2) domain = pdomain_test // 娴嬭瘯鐜
+if (ismock == 1) domain = mock_domain // 鏈湴妯℃嫙
+
+export default {
+  ismock,
+  istest,
+  isWxLoginType,
+  isConsole,
+  debug,
+  domain,
+  devtools: !!debug,
+  is_use_test_server,
+
+  createCodeUrl
+}

--
Gitblit v1.8.0