lvkun996 3 سال پیش
والد
کامیت
0e6e40ace0
6فایلهای تغییر یافته به همراه167 افزوده شده و 375 حذف شده
  1. 2 2
      config/proxy.ts
  2. 3 1
      src/App.vue
  3. 17 0
      src/hooks/effect.ts
  4. 1 1
      src/hooks/index.ts
  5. 2 3
      src/router/before.ts
  6. 142 368
      yarn.lock

+ 2 - 2
config/proxy.ts

@@ -5,11 +5,11 @@
 
 module.exports = {
   dev: {
-    '/rts-api': {
+    '/rts': {
       // target: 'http://ugknfjq1tyqbshsh3.neiwangyun.net',
       target: 'http://124.222.113.37:8080',
       changeOrigin: true,
-      pathRewrite: { '^/rts-api': '' }
+      pathRewrite: { '^/rts': '' }
     },
     '/api': {
       target: 'http://124.222.113.37:8888',

+ 3 - 1
src/App.vue

@@ -1,5 +1,4 @@
 <template>
-
     <a-config-provider :locale="zhCN">
       <router-view/>
     </a-config-provider>
@@ -9,6 +8,9 @@ import zhCN from 'ant-design-vue/es/locale/zh_CN'
 import dayjs from 'dayjs'
 import 'dayjs/locale/zh-cn'
 dayjs.locale('zh-cn')
+
+console.log('process.env:', process.env)
+
 </script>
 <style lang="less">
 @import '~@/styles/theme.less';

+ 17 - 0
src/hooks/effect.ts

@@ -1,5 +1,6 @@
 import { Emitter } from '@/enum/emitter'
 import mitt from 'mitt'
+import { setBaseUrl } from '@/service/request'
 
 import { ref, onUnmounted } from 'vue'
 
@@ -49,3 +50,19 @@ export const useSchedulerOnce = (callback: () => void, delay: number) => {
     clearTimeout(timeId.value)
   })
 }
+
+export const usePort = (title: string) => {
+  if (process.env.NODE_ENV === 'development') {
+    if (title === '物联网') {
+      setBaseUrl('/api')
+    } else {
+      setBaseUrl('/rts')
+    }
+  } else {
+    if (title === '物联网') {
+      setBaseUrl('/api')
+    } else {
+      setBaseUrl('/rts')
+    }
+  }
+}

+ 1 - 1
src/hooks/index.ts

@@ -1,4 +1,4 @@
-export { useEmitter, useScheduler, useSchedulerOnce } from './effect'
+export { useEmitter, useScheduler, useSchedulerOnce, usePort } from './effect'
 
 export { useId } from './state'
 

+ 2 - 3
src/router/before.ts

@@ -1,15 +1,14 @@
-
 import router from './index'
 import { setBaseUrl } from '@/service/request'
+import { usePort } from '@/hooks/index'
 
 router.beforeEach((to, from, next) => {
-  console.log('触发了路由守卫')
   console.log(to.meta.title)
   if (to.meta.title === '物联网') {
-    console.log('233')
     setBaseUrl('/api')
   } else {
     setBaseUrl('/rts-api')
   }
+  usePort(to.meta.title as string)
   next()
 })

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 142 - 368
yarn.lock


برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است