Ver Fonte

feat(config): 更新生产环境API地址和站点配置

- 修改生产环境API地址从 /prod-api 到 https://apiyouyida.xiaoluwebsite.xyz
- 在ProductCard组件中添加点击跳转到商品详情页功能
- 在agreementSupply页面中为产品图片添加点击跳转功能
- 注释掉myFootprint页面中的分页组件
- 将主站域名从 www.xiaoluwebsite.xyz 更新为 index.xiaoluwebsite.xyz
- 恢复request.ts中的token认证逻辑并完善401错误处理
- 更新siteConfig.ts中的域名映射配置,passport域名为pass.xiaoluwebsite.xyz
- 修改vite.config.ts中的代理目标地址和允许的主机列表
肖路 há 1 mês atrás
pai
commit
438776ce7c

+ 1 - 1
.env.production

@@ -15,7 +15,7 @@ VITE_APP_MONITOR_ADMIN = '/admin/applications'
 VITE_APP_SNAILJOB_ADMIN = '/snail-job'
 
 # 生产环境
-VITE_APP_BASE_API = '/prod-api'
+VITE_APP_BASE_API = 'https://apiyouyida.xiaoluwebsite.xyz'
 
 # 是否在打包时开启压缩,支持 gzip 和 brotli
 VITE_BUILD_COMPRESS = gzip

+ 3 - 1
src/components/ProductCard/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="product-card">
+  <div class="product-card" @click="onPath(`/item?id=${product.id}`)">
     <div class="card-header" v-if="showCheckbox || showAction">
       <el-checkbox v-if="showCheckbox" v-model="checked" @change="handleCheck" />
       <slot name="action">
@@ -32,8 +32,10 @@
 <script setup lang="ts">
 import { ref, watch } from 'vue';
 import { Picture, Plus } from '@element-plus/icons-vue';
+import { onPath } from '@/utils/siteConfig';
 
 interface Product {
+  id?: string | number;
   image?: string;
   name: string;
   price: string | number;

+ 4 - 4
src/permission copy.ts

@@ -37,12 +37,12 @@ const isWhiteList = (path: string) => {
 // 获取主站完整 URL(用于跨域跳转)
 function getMainSiteUrl(path: string) {
   if (import.meta.env.PROD) {
-    return `https://www.xiaoluwebsite.xyz${path}`;
+    return `https://index.xiaoluwebsite.xyz${path}`;
   } else {
-    // 本地开发:指向 www.xiaoluwebsite.xyz 加上当前运行的端口
-    // 假设你启动 vite 后访问的是 http://www.xiaoluwebsite.xyz
+    // 本地开发:指向 index.xiaoluwebsite.xyz 加上当前运行的端口
+    // 假设你启动 vite 后访问的是 http://index.xiaoluwebsite.xyz
     const devPort = window.location.port || import.meta.env.VITE_APP_PORT;
-    return `http://www.xiaoluwebsite.xyz:${devPort}${path}`;
+    return `http://index.xiaoluwebsite.xyz:${devPort}${path}`;
   }
 }
 

+ 4 - 4
src/permission.ts

@@ -38,12 +38,12 @@ const isWhiteList = (path: string) => {
 // 获取主站完整 URL(用于跨域跳转)
 function getMainSiteUrl(path: string) {
   if (import.meta.env.PROD) {
-    return `https://www.xiaoluwebsite.xyz${path}`;
+    return `https://index.xiaoluwebsite.xyz${path}`;
   } else {
-    // 本地开发:指向 www.xiaoluwebsite.xyz 加上当前运行的端口
-    // 假设你启动 vite 后访问的是 http://www.xiaoluwebsite.xyz
+    // 本地开发:指向 index.xiaoluwebsite.xyz 加上当前运行的端口
+    // 假设你启动 vite 后访问的是 http://index.xiaoluwebsite.xyz
     const devPort = window.location.port || import.meta.env.VITE_APP_PORT;
-    return `https://www.xiaoluwebsite.xyz:${devPort}${path}`;
+    return `https://index.xiaoluwebsite.xyz:${devPort}${path}`;
   }
 }
 

+ 58 - 33
src/utils/request.ts

@@ -15,12 +15,12 @@ import router from '@/router';
 // 获取主站完整 URL(用于跨域跳转)
 function getMainSiteUrl(path: string) {
   if (import.meta.env.PROD) {
-    return `https://passport.xiaoluwebsite.xyz${path}`;
+    return `https://index.xiaoluwebsite.xyz${path}`;
   } else {
-    // 本地开发:指向 www.xiaoluwebsite.xyz 加上当前运行的端口
-    // 假设你启动 vite 后访问的是 http://www.xiaoluwebsite.xyz
+    // 本地开发:指向 index.xiaoluwebsite.xyz 加上当前运行的端口
+    // 假设你启动 vite 后访问的是 http://index.xiaoluwebsite.xyz
     const devPort = window.location.port || import.meta.env.VITE_APP_PORT;
-    return `https://passport.xiaoluwebsite.xyz:${devPort}${path}`;
+    return `https://index.xiaoluwebsite.xyz:${devPort}${path}`;
   }
 }
 
@@ -57,9 +57,9 @@ service.interceptors.request.use(
     // 是否需要加密
     const isEncrypt = config.headers?.isEncrypt === 'true';
 
-    // if (getToken() && !isToken) {
-    //   config.headers['Authorization'] = 'Bearer ' + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
-    // }
+    if (getToken() && !isToken) {
+      config.headers['Authorization'] = 'Bearer ' + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
+    }
     // get请求映射params参数
     if (config.method === 'get' && config.params) {
       let url = config.url + '?' + tansParams(config.params);
@@ -141,37 +141,62 @@ service.interceptors.response.use(
     if (code === 401) {
       if (!isRelogin.show) {
         isRelogin.show = true;
-        // ElMessageBox.confirm('登录状态已过期,请重新登录', '登录提示', {
-        //   confirmButtonText: '重新登录',
-        //   type: 'warning'
-        // })
-        //   .then(() => {
-        //     isRelogin.show = false;
-        //     useUserStore()
-        //       .logout()
-        //       .then(() => {
-        //         if (import.meta.env.VITE_DOMAIN_NAME == 'true') {
-        //           window.location.href = getMainSiteUrl('/login');
-        //         } else {
-        //           router.push('/login');
-        //         }
-        //       });
-        //   })
-        //   .catch(() => {
-        //     isRelogin.show = false;
-        //   });
-        useUserStore()
-          .logout()
+        ElMessageBox.confirm('登录状态已过期,请重新登录', '登录提示', {
+          confirmButtonText: '重新登录',
+          type: 'warning'
+        })
           .then(() => {
             isRelogin.show = false;
-            if (import.meta.env.VITE_DOMAIN_NAME == 'true') {
-              window.location.href = getMainSiteUrl('/login');
-            } else {
-              router.push('/login');
-            }
+            useUserStore()
+              .logout()
+              .then(() => {
+                if (import.meta.env.VITE_DOMAIN_NAME == 'true') {
+                  window.location.href = getMainSiteUrl('/login');
+                } else {
+                  router.push('/login');
+                }
+              });
+          })
+          .catch(() => {
+            isRelogin.show = false;
           });
       }
       return Promise.reject('无效的会话,或者会话已过期,请重新登录。');
+
+      // prettier-ignore
+      // if (!isRelogin.show) {
+      //   isRelogin.show = true;
+      //   useUserStore().logout().then(() => {
+      //     window.location.href = getMainSiteUrl('/index');
+      //   });
+
+      // ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
+      //   confirmButtonText: '重新登录',
+      //   cancelButtonText: '取消',
+      //   type: 'warning'
+      // }).then(() => {
+      //   isRelogin.show = false;
+      //   useUserStore().logout().then(() => {
+      //     router.replace({
+      //       path: '/login',
+      //       query: {
+      //         redirect: encodeURIComponent(router.currentRoute.value.fullPath || '/')
+      //       }
+      //     })
+      //   });
+      // }).catch(() => {
+      //   isRelogin.show = false;
+      // });
+      // }
+
+      // useUserStore().logout().then(() => {
+      //   if (import.meta.env.VITE_DOMAIN_NAME == 'true') {
+      //     window.location.href = getMainSiteUrl('/login');
+      //   }else{
+      //     router.push('/login');
+      //   }
+      // });
+      // return Promise.reject('无效的会话,或者会话已过期,请重新登录。');
     } else if (code === HttpStatus.SERVER_ERROR) {
       ElMessage({ message: msg, type: 'error' });
       // return Promise.reject(new Error(msg));

+ 6 - 6
src/utils/siteConfig.ts

@@ -71,14 +71,14 @@ export function getCurrentSite(): any {
 
   // 定义本地开发环境的域名映射关系
   // 确保你的 hosts 文件已经配置了这些域名指向 127.0.0.1
-  if (host === 'www.xiaoluwebsite.xyz' || host === 'localhost') return 'www'; // 兼容未配hosts的情况
+  if (host === 'index.xiaoluwebsite.xyz' || host === 'localhost') return 'www'; // 兼容未配hosts的情况
   if (host === 'b.xiaoluwebsite.xyz') return 'b';
   if (host === 'mro.xiaoluwebsite.xyz') return 'mro';
   if (host === 'fuli.xiaoluwebsite.xyz') return 'fuli';
   if (host === 'reg.xiaoluwebsite.xyz') return 'reg';
   if (host === 'breg.xiaoluwebsite.xyz') return 'breg';
   if (host === 'greg.xiaoluwebsite.xyz') return 'greg';
-  if (host === 'passport.xiaoluwebsite.xyz') return 'passport';
+  if (host === 'pass.xiaoluwebsite.xyz') return 'passport';
   if (host === 'search.xiaoluwebsite.xyz') return 'search';
   if (host === 'item.xiaoluwebsite.xyz') return 'item';
   if (host === 'cart.xiaoluwebsite.xyz') return 'cart';
@@ -86,7 +86,7 @@ export function getCurrentSite(): any {
   if (host === 'payc.xiaoluwebsite.xyz') return 'payc';
   if (host === 'order.xiaoluwebsite.xyz') return 'order';
   if (host === 'plan.xiaoluwebsite.xyz') return 'plan';
-  if (host === 'plan_info.xiaoluwebsite.xyz') return 'plan_info';
+  if (host === 'planinfo.xiaoluwebsite.xyz') return 'plan_info';
   if (host === 'i.xiaoluwebsite.xyz') return 'i';
   if (host === 'easybuv.xiaoluwebsite.xyz') return 'easybuv';
 
@@ -133,14 +133,14 @@ export function onPath(path: string) {
     let url = '';
     // 域名映射表 (保持不变)
     const domainMap: Record<string, string> = {
-      www: 'www.xiaoluwebsite.xyz',
+      www: 'index.xiaoluwebsite.xyz',
       b: 'b.xiaoluwebsite.xyz',
       mro: 'mro.xiaoluwebsite.xyz',
       fuli: 'fuli.xiaoluwebsite.xyz',
       reg: 'reg.xiaoluwebsite.xyz',
       breg: 'breg.xiaoluwebsite.xyz',
       greg: 'greg.xiaoluwebsite.xyz',
-      passport: 'passport.xiaoluwebsite.xyz',
+      passport: 'pass.xiaoluwebsite.xyz',
       search: 'search.xiaoluwebsite.xyz',
       item: 'item.xiaoluwebsite.xyz',
       cart: 'cart.xiaoluwebsite.xyz',
@@ -148,7 +148,7 @@ export function onPath(path: string) {
       payc: 'payc.xiaoluwebsite.xyz',
       order: 'order.xiaoluwebsite.xyz',
       plan: 'plan.xiaoluwebsite.xyz',
-      plan_info: 'plan_info.xiaoluwebsite.xyz',
+      plan_info: 'planinfo.xiaoluwebsite.xyz',
       i: 'i.xiaoluwebsite.xyz',
       easybuv: 'easybuv.xiaoluwebsite.xyz'
     };

+ 2 - 1
src/views/enterprise/agreementSupply/index.vue

@@ -61,7 +61,7 @@
       <div v-if=" productList.length > 0">
         <div class="product-grid">
           <div v-for="(item, index) in productList" :key="item.id || index" class="product-card">
-            <div class="product-image">
+            <div class="product-image" @click="onPath(`/item?id=${item.id}`)">
               <el-image :src="item.productImage" fit="contain">
                 <template #error
                   ><div class="image-placeholder">
@@ -111,6 +111,7 @@ import { ElMessage } from 'element-plus';
 import { PageTitle, TablePagination } from '@/components';
 import { getAgreementSupplyProductList, addProductShoppingCart } from '@/api/goods/index';
 import { getProductCategoryList } from '@/api/home/index';
+import { onPath } from '@/utils/siteConfig';
 
 const queryParams = reactive({
   pageNum: 1,

+ 7 - 7
src/views/enterprise/myFootprint/index.vue

@@ -18,13 +18,13 @@
       </div>
     </div>
     <el-empty v-if="footprintGroups.length === 0" description="暂无浏览足迹" />
-    <TablePagination
-      v-if="footprintGroups.length > 0"
-      v-model:page="queryParams.pageNum"
-      v-model:page-size="queryParams.pageSize"
-      :total="total"
-      @change="handleQuery"
-    />
+<!--    <TablePagination-->
+<!--      v-if="footprintGroups.length > 0"-->
+<!--      v-model:page="queryParams.pageNum"-->
+<!--      v-model:page-size="queryParams.pageSize"-->
+<!--      :total="total"-->
+<!--      @change="handleQuery"-->
+<!--    />-->
   </div>
 </template>
 

+ 4 - 4
vite.config.ts

@@ -21,14 +21,14 @@ export default defineConfig(({ mode, command }) => {
     server: {
       host: '0.0.0.0',
       allowedHosts: [
-        'www.xiaoluwebsite.xyz',
+        'index.xiaoluwebsite.xyz',
         'b.xiaoluwebsite.xyz',
         'mro.xiaoluwebsite.xyz',
         'fuli.xiaoluwebsite.xyz',
         'reg.xiaoluwebsite.xyz',
         'breg.xiaoluwebsite.xyz',
         'greg.xiaoluwebsite.xyz',
-        'passport.xiaoluwebsite.xyz',
+        'pass.xiaoluwebsite.xyz',
         'search.xiaoluwebsite.xyz',
         'item.xiaoluwebsite.xyz',
         'cart.xiaoluwebsite.xyz',
@@ -36,7 +36,7 @@ export default defineConfig(({ mode, command }) => {
         'payc.xiaoluwebsite.xyz',
         'order.xiaoluwebsite.xyz',
         'plan.xiaoluwebsite.xyz',
-        'plan_info.xiaoluwebsite.xyz',
+        'planinfo.xiaoluwebsite.xyz',
         'i.xiaoluwebsite.xyz',
         'easybuv.xiaoluwebsite.xyz'
       ],
@@ -47,7 +47,7 @@ export default defineConfig(({ mode, command }) => {
         [env.VITE_APP_BASE_API]: {
           // target: 'http://localhost:8080',
           // target: 'http://yp1.yingpaipay.com:9026',
-          target: 'https://jingyang.xiaoluwebsite.xyz',
+          target: 'https://one.xiaoluwebsite.xyz',
           // target: 'https://one.yoe365.com',
           // target: 'http://192.168.1.52:8080',
           changeOrigin: true,