Browse Source

增加测试 生产环境

zjs_project 4 days ago
parent
commit
63b78c986e
5 changed files with 46 additions and 6 deletions
  1. 6 0
      .env.test
  2. 2 0
      .gitignore
  3. 2 0
      package.json
  4. 32 2
      src/views/error/403.vue
  5. 4 4
      src/views/material/index.vue

+ 6 - 0
.env.test

@@ -0,0 +1,6 @@
+# 测试环境配置
+VITE_APP_TITLE=点餐系统(测试)
+VITE_APP_ENV=test
+VITE_APP_BASE_API=/test-api
+VITE_APP_BASE_URL=https://gatewaytest1.elab-plus.com
+VITE_ALLOWED_DOMAINS=https://test.static.elab-plus.com/web/damai/index.html#/pages/loginPage/index

+ 2 - 0
.gitignore

@@ -33,3 +33,5 @@ components.d.ts
 # .env
 .env.development
 .env.production
+# 测试环境构建目录
+dist-test/

+ 2 - 0
package.json

@@ -5,7 +5,9 @@
   "scripts": {
     "dev": "vite",
     "preview": "vite preview --port 4173",
+    "preview:test": "vite preview --mode test --port 4173",
     "build": "node ./scripts/build.mjs",
+    "build:test": "vite build --mode test",
     "type-check": "vue-tsc --noEmit",
     "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
   },

+ 32 - 2
src/views/error/403.vue

@@ -1,15 +1,45 @@
 <template>
     <div class="error404">
-        <error code="403" title="您的账号权限不足,请联系管理员添加权限!" :show-btn="false">
+        <!-- <error code="403" title="您的账号权限不足,请联系管理员添加权限!" :show-btn="false">
             <template #content>
                 <div class="flex justify-center">
                     <img class="w-[150px] h-[150px]" src="@/assets/images/no_perms.png" alt="" />
                 </div>
             </template>
-        </error>
+        </error> -->
     </div>
 </template>
 
 <script lang="ts" setup>
 import Error from './components/error.vue'
+import { onMounted } from 'vue'
+import { useRoute } from 'vue-router'
+
+const route = useRoute()
+
+// 从环境变量获取白名单
+const allowedDomains = import.meta.env.VITE_ALLOWED_DOMAINS?.split(',') || []
+console.warn("***allowedDomains***",allowedDomains)
+onMounted(() => {
+    const redirectUrl = allowedDomains[0]
+    // const redirectUrl = route.query.redirect as string
+    if (redirectUrl) {
+        try {
+            const url = new URL(decodeURIComponent(redirectUrl))
+            // const isAllowed = allowedDomains.some((domain: string) => 
+            //     url.hostname.endsWith(domain)
+            // )
+            
+            if (url) {
+                setTimeout(() => {
+                    window.location.href = url.toString()
+                }, 1500)
+            } else {
+                console.error(`不安全的跳转地址:`, redirectUrl)
+            }
+        } catch (e) {
+            console.error('URL 解析错误:', e)
+        }
+    }
+})
 </script>

+ 4 - 4
src/views/material/index.vue

@@ -29,10 +29,10 @@ const tabsMap = [
         type: 'image',
         name: '图片'
     },
-    {
-        type: 'video',
-        name: '视频'
-    }
+    // {
+    //     type: 'video',
+    //     name: '视频'
+    // }
 ]
 const activeTab = ref('image')
 </script>