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 @@
+
- 15100000000
+ {{ userInfo.userName }}
-
立即认证
+
{{ getCertifyName(userInfo.certificationStatus).name }}
+
-
+
账户设置
@@ -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 @@
-
@@ -10,7 +9,7 @@
-
-
+
查看
删除
@@ -42,6 +40,10 @@
可用
不可用
+
+ 公开
+ 不公开
+
暂无数据
@@ -62,13 +64,11 @@
import editDialog from './editDialog.vue';
import { ref, reactive, onMounted, computed, } from 'vue';
import {
- Table,
- Pagination,
- Progress,
message,
- Button
} from 'ant-design-vue';
import apis from '@/apis';
+import { getImageList } from '@/apis/admin';
+import { on } from 'events';
// 表格列定义
interface ImageItem {
uid: string;
@@ -87,10 +87,7 @@ const imageList = ref([]);
const editDialogRef = ref(null);
// 存储容量
const storageUsed = ref('12.5GB');
-const storagePeak = ref('13.2GB');
-const expectedFee = ref('0元');
-const freeStorage = ref('30.00GB');
-const paidStorage = ref('0GB');
+
// 计算进度百分比
const storagePercent = computed(() => {
@@ -103,25 +100,21 @@ const storagePercent = computed(() => {
const pagination = reactive({
current: 1,
pageSize: 10,
- total: imageList.value.length,
+ total: 0,
});
-// 加载状态
-const loading = ref(false);
// 定义列
const columns = [
{ title: '名称', dataIndex: 'name', key: 'name', width: 150 },
- { title: 'cpu类型', dataIndex: 'cpu_type', key: 'cpu_type', width: 150 },
- { title: 'cuda版本', dataIndex: 'cuda_version', key: 'cuda_version', width: 100 },
- { title: 'gpu类型', dataIndex: 'gpu_type', key: 'gpu_type', width: 100 },
- { title: '镜像hash', dataIndex: 'image_hash', key: 'image_hash', width: 100 },
- { title: '镜像是否公开', dataIndex: 'image_is_public', key: 'image_is_public', width: 130 },
- { title: '镜像路径', dataIndex: 'image_path', key: 'image_path', width: 120 },
- { title: '镜像大小', dataIndex: 'image_size', key: 'image_size', width: 180 },
- { title: '镜像类型', dataIndex: 'image_type', key: 'image_type', width: 180 },
+ { title: '镜像hash', dataIndex: 'imageHash', key: 'imageHash', width: 100 },
+ { title: '镜像是否公开', dataIndex: 'imageIsPublic', key: 'imageIsPublic', width: 130 },
+ { title: '镜像路径', dataIndex: 'imagePath', key: 'imagePath', width: 120 },
+ { title: '镜像大小', dataIndex: 'imageSize', key: 'imageSize', width: 180 },
+ { title: '镜像类型', dataIndex: 'imageType', key: 'imageType', width: 180 },
+ { title: '镜像版本', dataIndex: 'imageVersion', key: 'imageVersion', width: 150 },
{ title: '状态', dataIndex: 'status', key: 'status', width: 80 },
- { title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: 160 },
+ // { title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: 160 },
{
title: '操作',
key: 'action',
@@ -160,12 +153,28 @@ const getCurrentPageData = computed(() => {
const end = start + pagination.pageSize;
return imageList.value.slice(start, end);
});
-
+// 加载状态
+const loading = ref(false);
+const getDataList = async () => {
+ loading.value = true;
+ try {
+ console.log('获取镜像列表');
+ const res: any = await getImageList({ page_num: pagination.current, page_size: pagination.pageSize });
+ console.log('镜像列表响应:', res);
+ imageList.value = res.data;
+ pagination.total = res.total;
+ } catch (error) {
+ console.error('获取镜像列表错误:', error);
+ message.error('获取镜像列表失败');
+ } finally {
+ loading.value = false;
+ }
+};
onMounted(() => {
- apis.imgs.fetchImageList({ pageNum: pagination.current, pageSize: pagination.pageSize }).then((response: any) => {
- imageList.value = response.list;
- });
+ getDataList();
});
+// getDataList()
+