This commit is contained in:
qiuyuan 2026-02-09 17:34:29 +08:00
parent f5826a889f
commit 22ea512030
2 changed files with 45 additions and 12 deletions

View File

@ -35,7 +35,7 @@
<!-- 表格 --> <!-- 表格 -->
<div class="table-container"> <div class="table-container">
<a-table :dataSource="mockData" :columns="columns" bordered :pagination="paginationState" :loading="loading" <a-table :dataSource="mockData" :columns="columns" bordered :pagination="paginationState" :loading="loading"
@change="onTableChange"> @change="onTableChange" :scroll="{ x: 'max-content' }">
<!-- 状态列 --> <!-- 状态列 -->
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'"> <template v-if="column.key === 'status'">
@ -80,6 +80,13 @@
<a-dropdown :trigger="['click']"> <a-dropdown :trigger="['click']">
<template #overlay> <template #overlay>
<a-menu @click="({ key }) => handleMenuClick(key, record)"> <a-menu @click="({ key }) => handleMenuClick(key, record)">
<a-menu-item key="jupyterlab">
<template #icon>
<CheckCircleOutlined />
</template>
jupyterlab
</a-menu-item>
<a-menu-item key="reset"> <a-menu-item key="reset">
<template #icon> <template #icon>
<redo-outlined /> <redo-outlined />
@ -170,7 +177,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref, onMounted, computed } from 'vue' import { ref, onMounted, computed } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { ExclamationCircleOutlined, ReloadOutlined, EyeOutlined, DownOutlined, RedoOutlined, DeleteOutlined } from '@ant-design/icons-vue' import { ExclamationCircleOutlined, ReloadOutlined, EyeOutlined, DownOutlined, RedoOutlined, DeleteOutlined,CheckCircleOutlined } from '@ant-design/icons-vue'
import type { TableColumnType } from 'ant-design-vue' import type { TableColumnType } from 'ant-design-vue'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { hostCaseList } from '@/apis/admin' import { hostCaseList } from '@/apis/admin'
@ -212,16 +219,16 @@ const mockData = ref([])
// //
const columns = ref<TableColumnType[]>([ const columns = ref<TableColumnType[]>([
{ title: '实例ID', dataIndex: 'id', key: 'id', width: 150 }, { title: '实例ID', dataIndex: 'id', key: 'id', width: 100,fixed: 'left' },
{ title: '名称', dataIndex: 'name', key: 'name', width: 180 }, { title: '名称', dataIndex: 'name', key: 'name', width: 200 },
{ title: '状态', dataIndex: 'status', key: 'status', width: 100 }, { title: '状态', dataIndex: 'status', key: 'status', width: 200 },
{ title: '规格详情', dataIndex: 'spec', key: 'spec', width: 200 }, { title: '规格详情', dataIndex: 'spec', key: 'spec', width: 250 },
{ title: '健康状态', dataIndex: 'health_status', key: 'health_status', width: 120 }, { title: '健康状态', dataIndex: 'health_status', key: 'health_status', width: 250 },
{ title: '付费方式', dataIndex: 'price_type', key: 'price_type', width: 120 }, { title: '付费方式', dataIndex: 'price_type', key: 'price_type', width: 250 },
{ title: '释放时间', dataIndex: 'release_at', key: 'release_at', width: 120 }, { title: '释放时间', dataIndex: 'release_at', key: 'release_at', width: 250 },
{ title: '停机时间', dataIndex: 'down_at', key: 'down_at', width: 120 }, { title: '停机时间', dataIndex: 'down_at', key: 'down_at', width: 250 },
{ title: 'SSH登录', dataIndex: 'ssh_link', key: 'ssh_link', width: 150 }, { title: 'SSH登录', dataIndex: 'ssh_link', key: 'ssh_link', width: 250 },
{ title: '操作', key: 'actions', width: 150 } { title: '操作', key: 'actions', width: 150,fixed:'right' }
]) ])
const getDataList = async () => { const getDataList = async () => {
@ -309,6 +316,10 @@ const handleMenuClick = (key: string, record: any) => {
case 'log': case 'log':
message.info('跳转到日志页面') message.info('跳转到日志页面')
break break
case 'jupyterlab':
handleJupyterLab(record)
break
} }
} }
@ -371,6 +382,25 @@ const handleRent = () => {
router.push('/layout/market') router.push('/layout/market')
} }
const handleJupyterLab = async (record: any) => {
try {
if(record.ssh_link){
const linkObj = JSON.parse(record.ssh_link)
if(linkObj.proxy_host && linkObj.jupyter_token){
const baseUrl = `http://${linkObj.proxy_host}:5784/jupyter?token=${linkObj.jupyter_token}`
console.log("====",baseUrl)
// window.open(baseUrl, '_blank', 'noopener,noreferrer')
}
}
} catch (error) {
console.error('打开 JupyterLab 失败:', error)
message.error('打开 JupyterLab 失败,请稍后重试')
}
}
onMounted(() => { onMounted(() => {
paginationState.value.total = mockData.value.length paginationState.value.total = mockData.value.length
}) })

View File

@ -328,6 +328,9 @@ const handleCreate = async () => {
return false; return false;
} else { } else {
message.success('实例创建成功!') message.success('实例创建成功!')
setTimeout(()=>{
router.push('/layout/admin/instance')
},1500)
creating.value = false creating.value = false
} }