CzRger 6 months ago
parent
commit
a7f0304abf
3 changed files with 21 additions and 26 deletions
  1. 1 3
      src/api/interceptors.ts
  2. 18 2
      src/views/global/index.vue
  3. 2 21
      vite.config.ts

+ 1 - 3
src/api/interceptors.ts

@@ -1,12 +1,11 @@
 import axios from 'axios';
 import {ElMessage} from "element-plus";
-import {toLogin} from "@/utils/permissions";
 export class Interceptors {
   public instance: any
 
   constructor() {
     this.instance = axios.create({
-      baseURL: '/ssw-api', // api base_url
+      baseURL: '/test-api', // api base_url
       timeout: 1000 * 300})
     this.initInterceptors()
   }
@@ -72,7 +71,6 @@ export class Interceptors {
     switch (res.status) {
       case 401:
         ElMessage.warning(res.data.msg);
-        toLogin()
         break;
       case 403:
         break;

+ 18 - 2
src/views/global/index.vue

@@ -5,17 +5,23 @@
     <el-button @click="routerToLink('/b')">路由跳转到{{state.val}}</el-button><br/>
     <el-button @click="windowToLink('/b')">window打开{{state.val}}</el-button><br/>
     <el-button @click="locationToLink('/b')">重定向到{{state.val}}</el-button><br/>
+    <div style="width: 200px;height: 100px;" v-loading="state.loadingCode">
+      <img style="width: 100%;height: 100%;" class="__hover" :src="state.codeBase64" @click="getCode"/>
+    </div>
   </div>
 </template>
 
 <script setup lang="ts">
-import {getCurrentInstance, reactive} from "vue";
+import {getCurrentInstance, onMounted, reactive} from "vue";
 import {useRouter} from "vue-router";
+import {captcha} from "@/api/modules/manage/user";
 
 const router = useRouter()
 const {proxy} = getCurrentInstance()
 const state: any = reactive({
-  val: ''
+  codeBase64: '',
+  loadingCode: false,
+  val: '',
 })
 const routerToLink = (url) => {
   router.push(url)
@@ -27,6 +33,16 @@ const locationToLink = (url) => {
   window.location.replace(url);
 
 }
+const getCode = () => {
+  state.loadingCode = true
+  captcha().then(res => {
+    state.codeBase64 = res.data.captcherImg
+    state.loadingCode = false
+  })
+}
+onMounted(() => {
+  getCode()
+})
 </script>
 
 <style lang="scss" scoped>

+ 2 - 21
vite.config.ts

@@ -52,30 +52,11 @@ export default defineConfig({
     open: true,
     strictPort: false,
     proxy: {
-      '/mock-api': {
-        target: 'http://localhost:18061/',
-        changeOrigin: true,
-        rewrite: (path) => {
-          return path.replace(/^\/mock-api/, 'mock-api')
-        }
-      },
-      '/ssw-api/api': {
-        // target: 'http://10.110.45.26:18069/',
+      '/test-api/api': {
         target: 'http://8.130.72.63:18068/',
         changeOrigin: true,
         rewrite: (path) => {
-          return path.replace(/^\/ssw-api\/api/, '')
-          // console.log(path)
-          // return path
-        }
-      },
-      '/ws-api': {
-        target: 'ws://8.130.72.63:18073/',
-        // target: 'ws://10.110.45.26:18069/ws-api',
-        ws: true,
-        changeOrigin: true,
-        rewrite: path => {
-          return path.replace(/^\/ws-api/, '')
+          return path.replace(/^\/test-api\/api/, '')
         }
       },
     }