diff --git a/.env.dev b/.env.dev index e1c6fd4..acd81ba 100644 --- a/.env.dev +++ b/.env.dev @@ -2,5 +2,5 @@ NODE_ENV=development # api -VITE_API_BASIC="http://10.10.1.29:8888" +VITE_API_BASIC="http://10.10.1.20:8888" diff --git a/src/apis/admin.ts b/src/apis/admin.ts index ebd7ecf..68f6f1b 100644 --- a/src/apis/admin.ts +++ b/src/apis/admin.ts @@ -8,4 +8,6 @@ export const orderList = (params:any) => request.get('/v1/order/pay_list',{param export const useList = (params:any) => request.get('/v1/order/use_list',{params}) // 容器实例列表 -export const hostCaseList = (params:any) => request.get('/v1/hostCase/list',{params}) +export const hostCaseList = (params:any) => request.get('/v1/host_case/case_list',{params}) +// 镜像列表 +export const getImageList = (params:any) => request.get('/v1/image/image_list',{params}) \ No newline at end of file diff --git a/src/apis/home.ts b/src/apis/home.ts index 09d31ab..3a2148e 100644 --- a/src/apis/home.ts +++ b/src/apis/home.ts @@ -2,11 +2,14 @@ import request from '@/utils/index' // 轮播接口 -export const getBannerList = () => request.get('/v1/home/banner_list') +export const getBannerList = () => request.get('/v1/home/home_banners') // GPU说明列表 -export const getGpuList = () => request.get('/v1/home/gpu_list') +export const getGpuList = () => request.get('/v1/home/home_products') // 获取产品优势 -export const getAdvantage = () => request.get('/v1/home/p_advantages_list') +export const getAdvantage = () => request.get('/v1/home/home_product_advs') // 获取热门产品信息 export const getHotProduct = () => request.get('/v1/product/host_info') + +// 获取首页One列表 +export const getApiOneList = () => request.get('/v1/home/home_top_labels') \ No newline at end of file diff --git a/src/apis/market.ts b/src/apis/market.ts new file mode 100644 index 0000000..05f32b9 --- /dev/null +++ b/src/apis/market.ts @@ -0,0 +1,12 @@ + +import request from '@/utils/index' + +// 算力列表 +export const hostList = (params:any) => request.get('/v1/host/list',{params}) + +// 地区列表 +export const getAreaListApi = () => request.get('/v1/host/center_coll') + +// GPU型号列表 +export const hostCaseList = (params:any) => request.get('/v1/hostCase/list',{params}) +export const getGpuListApi = () => request.get('/v1/host/gpu_type_coll') \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index c6cde57..797577c 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -351,25 +351,25 @@ const router = createRouter({ routes, }); // ====== 添加全局前置守卫 ====== -// router.beforeEach((to, from, next) => { -// console.log("Navigating to:", to.path); -// const list = ["/layout/home","/document/introdution","/layout/admin/home"]; -// if (list.indexOf(to.path) != -1) { -// next(); -// return; -// } else { -// const token = localStorage.getItem("token"); // 或从 pinia/vuex 获取 -// const isLoginPage = to.path === "/login"; -// if (!token && !isLoginPage) { -// // 没有 token 且不是去登录页 → 跳转登录 -// next({ path: "/login" }); -// } else if (token && isLoginPage) { -// // 已登录却访问登录页 → 跳转首页(可选) -// next({ path: "/layout/home" }); -// } else { -// // 正常访问 -// next(); -// } -// } -// }); +router.beforeEach((to, from, next) => { + console.log("Navigating to:", to.path); + const list = ["/layout/home","/document/introdution"]; + if (list.indexOf(to.path) != -1) { + next(); + return; + } else { + const token = localStorage.getItem("token"); // 或从 pinia/vuex 获取 + const isLoginPage = to.path === "/login"; + if (!token && !isLoginPage) { + // 没有 token 且不是去登录页 → 跳转登录 + next({ path: "/login" }); + } else if (token && isLoginPage) { + // 已登录却访问登录页 → 跳转首页(可选) + next({ path: "/layout/home" }); + } else { + // 正常访问 + next(); + } + } +}); export default router; diff --git a/src/utils/index.ts b/src/utils/index.ts index 1f5c2b7..03612ca 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -9,7 +9,7 @@ console.log('All env:', import.meta.env); const request: AxiosInstance = axios.create({ baseURL: BASE_URL, timeout: 10000, // 10 秒超时 - withCredentials: true, // 跨域请求时发送 cookies + withCredentials: false, // 跨域请求时发送 cookies headers: { 'Content-Type': 'application/json', }, @@ -36,6 +36,7 @@ request.interceptors.response.use( // 假设后端返回格式为 { code: 200, data: ..., message: '' } const { code, data, message } = response.data; + console.log('Response Data:', response.data); if (code === 1) { return data; } else { diff --git a/src/views/admin/home/index.vue b/src/views/admin/home/index.vue index 6931e0f..77b9c56 100644 --- a/src/views/admin/home/index.vue +++ b/src/views/admin/home/index.vue @@ -105,15 +105,17 @@ - + 账户设置 @@ -128,8 +130,8 @@
我的余额
-
- {{ formatAmount(balance) }} +
+ {{ formatAmount(userInfo.balance) }} 去充值
@@ -153,7 +155,7 @@ 算力点
- {{ computingPoints }} + {{ userInfo.computingPowerPoint}}
@@ -167,7 +169,7 @@ 可用算力券
- {{ availableCoupons }} + {{ userInfo.voucherNum }}
@@ -208,16 +210,16 @@ import { PlusOutlined, QuestionCircleOutlined // 新增图标 } from '@ant-design/icons-vue' -import router from '@/router' +import { useRouter } from 'vue-router' import { message } from 'ant-design-vue' - +const router = useRouter() // 实例卡片的开关状态 const switch1 = ref(true) const switch2 = ref(false) const userInfo = ref({}) // 资产数据 -const balance = ref(128.50) // 余额 +const balance = ref(0) // 余额 const computingPoints = ref(5000) // 算力点 const availableCoupons = ref(3) // 可用算力券数量 @@ -231,7 +233,16 @@ onBeforeMount(() => { const formatAmount = (amount: number): string => { return amount.toFixed(2) } +const certificationStatus = new Map([ + ['PENDING_CERTIFICATION', { name: '待认证', color: '#faad14' }], + ['CERTIFICATION_DFFILED', { name: '已提交', color: '#d9d9d9' }], // 注意拼写:DFFILED → FAILED? + ['CERTIFICATION_PASSED', { name: '认证通过', color: '#52c41a' }], + ['CERTIFICATION_FAILED', { name: '认证失败', color: '#ff4d4f' }], +]); +const getCertifyName = (status: string): { name: string; color: string } => { + return certificationStatus.get(status) ?? { name: '未认证', color: 'gray' }; +}; // 格式化算力点显示(添加千分位) const formatComputingPoints = (points: number): string => { return points.toLocaleString() diff --git a/src/views/admin/image/index.vue b/src/views/admin/image/index.vue index 6c7832c..47eff66 100644 --- a/src/views/admin/image/index.vue +++ b/src/views/admin/image/index.vue @@ -1,4 +1,3 @@ -