Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

feat: Enhance KnowledgeBaseEditorModal and KnowledgeBaseList with tdesign icons and improved styles

wizardchenb8f58edc8aa7
diff --git a/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue b/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue
index 9b3e5fc54..8ff2bdc47 100644
--- a/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue
+++ b/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue
@@ -23,7 +23,7 @@
:class="['nav-item', { 'active': currentSection === item.key }]"
@click="currentSection = item.key"
>
- <span class="nav-icon">{{ item.icon }}</span>
+ <t-icon :name="item.icon" class="nav-icon" />
<span class="nav-label">{{ item.label }}</span>
</div>
</div>
@@ -143,10 +143,10 @@ const allModels = ref<any[]>([])
const hasFiles = ref(false)
const navItems = [
- { key: 'basic', icon: 'ℹ️', label: '基本信息' },
- { key: 'models', icon: '🤖', label: '模型配置' },
- { key: 'chunking', icon: '📄', label: '分块设置' },
- { key: 'advanced', icon: '⚙️', label: '高级设置' }
+ { key: 'basic', icon: 'info-circle', label: '基本信息' },
+ { key: 'models', icon: 'control-platform', label: '模型配置' },
+ { key: 'chunking', icon: 'file-copy', label: '分块设置' },
+ { key: 'advanced', icon: 'setting', label: '高级设置' }
]
// 模型配置引用
@@ -638,7 +638,11 @@ watch(() => props.visible, async (newVal) => {
.nav-icon {
margin-right: 8px;
- font-size: 16px;
+ font-size: 18px;
+ flex-shrink: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
}
.nav-label {
diff --git a/frontend/src/views/knowledge/KnowledgeBaseList.vue b/frontend/src/views/knowledge/KnowledgeBaseList.vue
index f3cb95654..eab62b403 100644
--- a/frontend/src/views/knowledge/KnowledgeBaseList.vue
+++ b/frontend/src/views/knowledge/KnowledgeBaseList.vue
@@ -3,7 +3,10 @@
<!-- 头部 -->
<div class="header">
<h2>知识库</h2>
- <button class="create-btn" @click="openCreateModal">新建知识库</button>
+ <button class="create-btn" @click="openCreateModal">
+ <t-icon name="add" size="16px" class="btn-icon" />
+ <span>新建知识库</span>
+ </button>
</div>
<!-- 未初始化知识库提示 -->
@@ -274,12 +277,15 @@ const handleKBEditorSuccess = (kbId: string) => {
}
.create-btn {
+ display: flex;
+ align-items: center;
+ gap: 6px;
padding: 8px 20px;
height: 36px;
background: #07c05f;
color: #fff;
border: none;
- border-radius: 6px;
+ border-radius: 8px;
font-family: "PingFang SC";
font-size: 14px;
font-weight: 500;
@@ -293,6 +299,10 @@ const handleKBEditorSuccess = (kbId: string) => {
&:active {
background: #048f45;
}
+
+ .btn-icon {
+ flex-shrink: 0;
+ }
}
.warning-banner {
diff --git a/frontend/src/views/settings/ApiInfo.vue b/frontend/src/views/settings/ApiInfo.vue
new file mode 100644
index 000000000..7c7e95415
--- /dev/null
+++ b/frontend/src/views/settings/ApiInfo.vue
@@ -0,0 +1,317 @@
+<template>
+ <div class="api-info">
+ <div class="section-header">
+ <h2>API 信息</h2>
+ <p class="section-description">查看和管理您的 API 密钥</p>
+ </div>
+
+ <!-- 加载状态 -->
+ <div v-if="loading" class="loading-inline">
+ <t-loading size="small" />
+ <span>正在加载信息...</span>
+ </div>
+
+ <!-- 错误状态 -->
+ <div v-else-if="error" class="error-inline">
+ <t-alert theme="error" :message="error">
+ <template #operation>
+ <t-button size="small" @click="loadInfo">重试</t-button>
+ </template>
+ </t-alert>
+ </div>
+
+ <!-- 信息内容 -->
+ <div v-else class="settings-group">
+ <!-- API Key -->
+ <div class="setting-row">
+ <div class="setting-info">
+ <label>API Key</label>
+ <p class="desc">用于 API 调用的密钥,请妥善保管</p>
+ </div>
+ <div class="setting-control">
+ <div class="api-key-control">
+ <t-input
+ v-model="displayApiKey"
+ readonly
+ :type="showApiKey ? 'text' : 'password'"
+ style="width: 100%; font-family: monospace; font-size: 12px;"
+ />
+ <t-button
+ size="small"
+ variant="text"
+ @click="showApiKey = !showApiKey"
+ >
+ <t-icon :name="showApiKey ? 'browse-off' : 'browse'" />
+ </t-button>
+ <t-button
+ size="small"
+ variant="text"
+ @click="copyApiKey"
+ title="复制 API Key"
+ >
+ <t-icon name="file-copy" />
+ </t-button>
+ </div>
+ </div>
+ </div>
+
+ <!-- API 文档 -->
+ <div class="setting-row">
+ <div class="setting-info">
+ <label>API 文档</label>
+ <p class="desc">查看完整的 API 调用文档和示例</p>
+ </div>
+ <div class="setting-control">
+ <t-button
+ size="small"
+ theme="default"
+ variant="outline"
+ @click="openApiDoc"
+ >
+ 查看文档
+ </t-button>
+ </div>
+ </div>
+
+ <!-- 用户信息 -->
+ <div class="info-section-title">用户信息</div>
+
+ <!-- 用户 ID -->
+ <div class="setting-row">
+ <div class="setting-info">
+ <label>用户 ID</label>
+ <p class="desc">您的唯一用户标识</p>
+ </div>
+ <div class="setting-control">
+ <span class="info-value">{{ userInfo?.id || '-' }}</span>
+ </div>
+ </div>
+
+ <!-- 用户名 -->
+ <div class="setting-row">
+ <div class="setting-info">
+ <label>用户名</label>
+ <p class="desc">您的登录用户名</p>
+ </div>
+ <div class="setting-control">
+ <span class="info-value">{{ userInfo?.username || '-' }}</span>
+ </div>
+ </div>
+
+ <!-- 邮箱 -->
+ <div class="setting-row">
+ <div class="setting-info">
+ <label>邮箱</label>
+ <p class="desc">您的注册邮箱地址</p>
+ </div>
+ <div class="setting-control">
+ <span class="info-value">{{ userInfo?.email || '-' }}</span>
+ </div>
+ </div>
+
+ <!-- 用户创建时间 -->
+ <div class="setting-row">
+ <div class="setting-info">
+ <label>注册时间</label>
+ <p class="desc">账户创建的时间</p>
+ </div>
+ <div class="setting-control">
+ <span class="info-value">{{ formatDate(userInfo?.created_at) }}</span>
+ </div>
+ </div>
+
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { ref, computed, onMounted } from 'vue'
+import { getCurrentUser, type TenantInfo, type UserInfo } from '@/api/auth'
+import { MessagePlugin } from 'tdesign-vue-next'
+
+// 响应式数据
+const tenantInfo = ref<TenantInfo | null>(null)
+const userInfo = ref<UserInfo | null>(null)
+const loading = ref(true)
+const error = ref('')
+const showApiKey = ref(false)
+
+// 计算属性
+const displayApiKey = computed(() => {
+ if (!tenantInfo.value?.api_key) return ''
+ return tenantInfo.value.api_key
+})
+
+// 方法
+const loadInfo = async () => {
+ try {
+ loading.value = true
+ error.value = ''
+
+ const userResponse = await getCurrentUser()
+
+ if (userResponse.success && userResponse.data) {
+ userInfo.value = userResponse.data.user
+ tenantInfo.value = userResponse.data.tenant
+ } else {
+ error.value = userResponse.message || '获取用户信息失败'
+ }
+ } catch (err: any) {
+ error.value = err.message || '网络错误,请稍后重试'
+ } finally {
+ loading.value = false
+ }
+}
+
+const openApiDoc = () => {
+ window.open('https://github.com/Tencent/WeKnora/blob/main/docs/API.md', '_blank')
+}
+
+const copyApiKey = async () => {
+ if (!displayApiKey.value) {
+ MessagePlugin.warning('暂无 API Key')
+ return
+ }
+
+ try {
+ await navigator.clipboard.writeText(displayApiKey.value)
+ MessagePlugin.success('API Key 已复制到剪贴板')
+ } catch (err) {
+ MessagePlugin.error('复制失败,请手动复制')
+ }
+}
+
+const formatDate = (dateStr: string | undefined) => {
+ if (!dateStr) return '未知'
+
+ try {
+ const date = new Date(dateStr)
+ return date.toLocaleString('zh-CN', {
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit',
+ hour: '2-digit',
+ minute: '2-digit'
+ })
+ } catch {
+ return '格式错误'
+ }
+}
+
+// 生命周期
+onMounted(() => {
+ loadInfo()
+})
+</script>
+
+<style lang="less" scoped>
+.api-info {
+ width: 100%;
+}
+
+.section-header {
+ margin-bottom: 32px;
+
+ h2 {
+ font-size: 20px;
+ font-weight: 600;
+ color: #333333;
+ margin: 0 0 8px 0;
+ }
+
+ .section-description {
+ font-size: 14px;
+ color: #666666;
+ margin: 0;
+ line-height: 1.5;
+ }
+}
+
+.loading-inline {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 40px 0;
+ justify-content: center;
+ color: #666666;
+ font-size: 14px;
+}
+
+.error-inline {
+ padding: 20px 0;
+}
+
+.settings-group {
+ display: flex;
+ flex-direction: column;
+ gap: 0;
+}
+
+.setting-row {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ padding: 20px 0;
+ border-bottom: 1px solid #e5e7eb;
+
+ &:last-child {
+ border-bottom: none;
+ }
+}
+
+.setting-info {
+ flex: 1;
+ max-width: 65%;
+ padding-right: 24px;
+
+ label {
+ font-size: 15px;
+ font-weight: 500;
+ color: #333333;
+ display: block;
+ margin-bottom: 4px;
+ }
+
+ .desc {
+ font-size: 13px;
+ color: #666666;
+ margin: 0;
+ line-height: 1.5;
+ }
+}
+
+.setting-control {
+ flex-shrink: 0;
+ min-width: 280px;
+ display: flex;
+ justify-content: flex-end;
+ align-items: center;
+
+ .info-value {
+ font-size: 14px;
+ color: #333333;
+ text-align: right;
+ word-break: break-word;
+ }
+}
+
+.api-key-control {
+ width: 100%;
+ display: flex;
+ gap: 8px;
+ align-items: center;
+}
+
+.info-section-title {
+ font-size: 14px;
+ font-weight: 600;
+ color: #333333;
+ margin-top: 24px;
+ margin-bottom: 12px;
+
+ &:first-child {
+ margin-top: 0;
+ }
+}
+</style>
+
diff --git a/frontend/src/views/settings/Settings.vue b/frontend/src/views/settings/Settings.vue
index ee17c8b7d..de1ca9f51 100644
--- a/frontend/src/views/settings/Settings.vue
+++ b/frontend/src/views/settings/Settings.vue
@@ -87,6 +87,16 @@
<div v-if="currentSection === 'system'" class="section">
<SystemInfo />
</div>
+
+ <!-- 租户信息 -->
+ <div v-if="currentSection === 'tenant'" class="section">
+ <TenantInfo />
+ </div>
+
+ <!-- API 信息 -->
+ <div v-if="currentSection === 'api'" class="section">
+ <ApiInfo />
+ </div>
</div>
</div>
</div>
@@ -102,6 +112,8 @@ import { useRoute, useRouter } from 'vue-router'
import { useUIStore } from '@/stores/ui'
import AgentSettings from './AgentSettings.vue'
import SystemInfo from './SystemInfo.vue'
+import TenantInfo from './TenantInfo.vue'
+import ApiInfo from './ApiInfo.vue'
import GeneralSettings from './GeneralSettings.vue'
import ModelSettings from './ModelSettings.vue'
import KnowledgeBaseSettings from './KnowledgeBaseSettings.vue'
@@ -131,7 +143,9 @@ const navItems = [
{ key: 'ollama', icon: 'server', label: 'Ollama' },
{ key: 'knowledge', icon: 'folder-open', label: '知识库' },
{ key: 'agent', icon: 'chat', label: 'Agent 配置' },
- { key: 'system', icon: 'info-circle', label: '系统信息' }
+ { key: 'system', icon: 'info-circle', label: '系统信息' },
+ { key: 'tenant', icon: 'user-circle', label: '租户信息' },
+ { key: 'api', icon: 'secured', label: 'API 信息' }
]
// 导航项点击处理
diff --git a/frontend/src/views/settings/SystemInfo.vue b/frontend/src/views/settings/SystemInfo.vue
index 258e9b962..424780b28 100644
--- a/frontend/src/views/settings/SystemInfo.vue
+++ b/frontend/src/views/settings/SystemInfo.vue
@@ -22,9 +22,6 @@
<!-- 信息内容 -->
<div v-else class="settings-group">
- <!-- 系统信息分组 -->
- <div class="info-section-title">系统信息</div>
-
<!-- 系统版本 -->
<div class="setting-row">
<div class="setting-info">
@@ -63,240 +60,18 @@
</div>
</div>
- <!-- 用户信息分组 -->
- <div class="info-section-title">用户信息</div>
-
- <!-- 用户 ID -->
- <div class="setting-row">
- <div class="setting-info">
- <label>用户 ID</label>
- <p class="desc">您的唯一用户标识</p>
- </div>
- <div class="setting-control">
- <span class="info-value">{{ userInfo?.id || '-' }}</span>
- </div>
- </div>
-
- <!-- 用户名 -->
- <div class="setting-row">
- <div class="setting-info">
- <label>用户名</label>
- <p class="desc">您的登录用户名</p>
- </div>
- <div class="setting-control">
- <span class="info-value">{{ userInfo?.username || '-' }}</span>
- </div>
- </div>
-
- <!-- 邮箱 -->
- <div class="setting-row">
- <div class="setting-info">
- <label>邮箱</label>
- <p class="desc">您的注册邮箱地址</p>
- </div>
- <div class="setting-control">
- <span class="info-value">{{ userInfo?.email || '-' }}</span>
- </div>
- </div>
-
- <!-- 用户创建时间 -->
- <div class="setting-row">
- <div class="setting-info">
- <label>注册时间</label>
- <p class="desc">账户创建的时间</p>
- </div>
- <div class="setting-control">
- <span class="info-value">{{ formatDate(userInfo?.created_at) }}</span>
- </div>
- </div>
-
- <!-- 租户信息分组 -->
- <div class="info-section-title">租户信息</div>
-
- <!-- 租户 ID -->
- <div class="setting-row">
- <div class="setting-info">
- <label>租户 ID</label>
- <p class="desc">您所属租户的唯一标识</p>
- </div>
- <div class="setting-control">
- <span class="info-value">{{ tenantInfo?.id || '-' }}</span>
- </div>
- </div>
-
- <!-- 租户名称 -->
- <div class="setting-row">
- <div class="setting-info">
- <label>租户名称</label>
- <p class="desc">您所属的租户名称</p>
- </div>
- <div class="setting-control">
- <span class="info-value">{{ tenantInfo?.name || '-' }}</span>
- </div>
- </div>
-
- <!-- 租户描述 -->
- <div v-if="tenantInfo?.description" class="setting-row">
- <div class="setting-info">
- <label>租户描述</label>
- <p class="desc">租户的详细描述信息</p>
- </div>
- <div class="setting-control">
- <span class="info-value">{{ tenantInfo.description }}</span>
- </div>
- </div>
-
- <!-- 租户业务 -->
- <div v-if="tenantInfo?.business" class="setting-row">
- <div class="setting-info">
- <label>租户业务</label>
- <p class="desc">租户所属的业务类型</p>
- </div>
- <div class="setting-control">
- <span class="info-value">{{ tenantInfo.business }}</span>
- </div>
- </div>
-
- <!-- 租户状态 -->
- <div class="setting-row">
- <div class="setting-info">
- <label>租户状态</label>
- <p class="desc">租户当前的运行状态</p>
- </div>
- <div class="setting-control">
- <t-tag
- :theme="getStatusTheme(tenantInfo?.status)"
- variant="light"
- size="small"
- >
- {{ getStatusText(tenantInfo?.status) }}
- </t-tag>
- </div>
- </div>
-
- <!-- 租户创建时间 -->
- <div class="setting-row">
- <div class="setting-info">
- <label>租户创建时间</label>
- <p class="desc">租户创建的时间</p>
- </div>
- <div class="setting-control">
- <span class="info-value">{{ formatDate(tenantInfo?.created_at) }}</span>
- </div>
- </div>
-
- <!-- API 信息分组 -->
- <div class="info-section-title">API 信息</div>
-
- <!-- API Key -->
- <div class="setting-row">
- <div class="setting-info">
- <label>API Key</label>
- <p class="desc">用于 API 调用的密钥,请妥善保管</p>
- </div>
- <div class="setting-control">
- <div class="api-key-control">
- <t-input
- v-model="displayApiKey"
- readonly
- :type="showApiKey ? 'text' : 'password'"
- style="width: 100%; font-family: monospace; font-size: 12px;"
- />
- <t-button
- size="small"
- variant="text"
- @click="showApiKey = !showApiKey"
- >
- <t-icon :name="showApiKey ? 'browse-off' : 'browse'" />
- </t-button>
- </div>
- </div>
- </div>
-
- <!-- 存储配额 -->
- <div v-if="tenantInfo?.storage_quota !== undefined" class="setting-row">
- <div class="setting-info">
- <label>存储配额</label>
- <p class="desc">租户的总存储空间配额</p>
- </div>
- <div class="setting-control">
- <span class="info-value">{{ formatBytes(tenantInfo.storage_quota) }}</span>
- </div>
- </div>
-
- <!-- 已使用存储 -->
- <div v-if="tenantInfo?.storage_quota !== undefined" class="setting-row">
- <div class="setting-info">
- <label>已使用存储</label>
- <p class="desc">已经使用的存储空间</p>
- </div>
- <div class="setting-control">
- <span class="info-value">{{ formatBytes(tenantInfo.storage_used || 0) }}</span>
- </div>
- </div>
-
- <!-- 存储使用率 -->
- <div v-if="tenantInfo?.storage_quota !== undefined" class="setting-row">
- <div class="setting-info">
- <label>存储使用率</label>
- <p class="desc">存储空间的使用百分比</p>
- </div>
- <div class="setting-control">
- <div class="usage-control">
- <span class="usage-text">{{ getUsagePercentage() }}%</span>
- <t-progress
- :percentage="getUsagePercentage()"
- :show-info="false"
- size="small"
- :theme="getUsagePercentage() > 80 ? 'warning' : 'success'"
- style="flex: 1;"
- />
- </div>
- </div>
- </div>
-
- <!-- 开发文档分组 -->
- <div class="info-section-title">开发文档</div>
-
- <!-- API 文档 -->
- <div class="setting-row">
- <div class="setting-info">
- <label>API 开发文档</label>
- <p class="desc">查看完整的 API 文档和示例代码</p>
- </div>
- <div class="setting-control">
- <t-button
- theme="primary"
- size="small"
- @click="openApiDoc"
- >
- <t-icon name="link" />
- 查看文档
- </t-button>
- </div>
- </div>
</div>
</div>
</template>
<script setup lang="ts">
-import { ref, computed, onMounted } from 'vue'
-import { getCurrentUser, type TenantInfo, type UserInfo } from '@/api/auth'
+import { ref, onMounted } from 'vue'
import { getSystemInfo, type SystemInfo } from '@/api/system'
// 响应式数据
-const tenantInfo = ref<TenantInfo | null>(null)
-const userInfo = ref<UserInfo | null>(null)
const systemInfo = ref<SystemInfo | null>(null)
const loading = ref(true)
const error = ref('')
-const showApiKey = ref(false)
-
-// 计算属性
-const displayApiKey = computed(() => {
- if (!tenantInfo.value?.api_key) return ''
- return tenantInfo.value.api_key
-})
// 方法
const loadInfo = async () => {
@@ -304,21 +79,12 @@ const loadInfo = async () => {
loading.value = true
error.value = ''
- // 并行获取用户信息和系统信息
- const [userResponse, systemResponse] = await Promise.all([
- getCurrentUser(),
- getSystemInfo().catch(() => ({ data: null }))
- ])
-
- if (userResponse.success && userResponse.data) {
- userInfo.value = userResponse.data.user
- tenantInfo.value = userResponse.data.tenant
- } else {
- error.value = userResponse.message || '获取用户信息失败'
- }
+ const systemResponse = await getSystemInfo()
if (systemResponse.data) {
systemInfo.value = systemResponse.data
+ } else {
+ error.value = '获取系统信息失败'
}
} catch (err: any) {
error.value = err.message || '网络错误,请稍后重试'
@@ -327,73 +93,6 @@ const loadInfo = async () => {
}
}
-const openApiDoc = () => {
- window.open('https://github.com/Tencent/WeKnora/blob/main/docs/API.md', '_blank')
-}
-
-const getStatusText = (status: string | undefined) => {
- switch (status) {
- case 'active':
- return '活跃'
- case 'inactive':
- return '未激活'
- case 'suspended':
- return '已暂停'
- default:
- return '未知'
- }
-}
-
-const getStatusTheme = (status: string | undefined) => {
- switch (status) {
- case 'active':
- return 'success'
- case 'inactive':
- return 'warning'
- case 'suspended':
- return 'danger'
- default:
- return 'default'
- }
-}
-
-const formatDate = (dateStr: string | undefined) => {
- if (!dateStr) return '未知'
-
- try {
- const date = new Date(dateStr)
- return date.toLocaleString('zh-CN', {
- year: 'numeric',
- month: '2-digit',
- day: '2-digit',
- hour: '2-digit',
- minute: '2-digit'
- })
- } catch {
- return '格式错误'
- }
-}
-
-const formatBytes = (bytes: number) => {
- if (bytes === 0) return '0 B'
-
- const k = 1024
- const sizes = ['B', 'KB', 'MB', 'GB', 'TB']
- const i = Math.floor(Math.log(bytes) / Math.log(k))
-
- return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
-}
-
-const getUsagePercentage = () => {
- if (!tenantInfo.value?.storage_quota || tenantInfo.value.storage_quota === 0) {
- return 0
- }
-
- const used = tenantInfo.value.storage_used || 0
- const percentage = (used / tenantInfo.value.storage_quota) * 100
- return Math.min(Math.round(percentage * 100) / 100, 100)
-}
-
// 生命周期
onMounted(() => {
loadInfo()
@@ -496,38 +195,4 @@ onMounted(() => {
}
}
}
-
-.api-key-control {
- width: 100%;
- display: flex;
- gap: 8px;
- align-items: center;
-}
-
-.usage-control {
- width: 100%;
- display: flex;
- align-items: center;
- gap: 12px;
-
- .usage-text {
- font-size: 14px;
- font-weight: 500;
- color: #333333;
- min-width: 50px;
- text-align: right;
- }
-}
-
-.info-section-title {
- font-size: 14px;
- font-weight: 600;
- color: #333333;
- margin-top: 24px;
- margin-bottom: 12px;
-
- &:first-child {
- margin-top: 0;
- }
-}
</style>
diff --git a/frontend/src/views/settings/TenantInfo.vue b/frontend/src/views/settings/TenantInfo.vue
new file mode 100644
index 000000000..80276dcdb
--- /dev/null
+++ b/frontend/src/views/settings/TenantInfo.vue
@@ -0,0 +1,347 @@
+<template>
+ <div class="tenant-info">
+ <div class="section-header">
+ <h2>租户信息</h2>
+ <p class="section-description">查看租户的详细配置信息</p>
+ </div>
+
+ <!-- 加载状态 -->
+ <div v-if="loading" class="loading-inline">
+ <t-loading size="small" />
+ <span>正在加载信息...</span>
+ </div>
+
+ <!-- 错误状态 -->
+ <div v-else-if="error" class="error-inline">
+ <t-alert theme="error" :message="error">
+ <template #operation>
+ <t-button size="small" @click="loadInfo">重试</t-button>
+ </template>
+ </t-alert>
+ </div>
+
+ <!-- 信息内容 -->
+ <div v-else class="settings-group">
+ <!-- 租户 ID -->
+ <div class="setting-row">
+ <div class="setting-info">
+ <label>租户 ID</label>
+ <p class="desc">您所属租户的唯一标识</p>
+ </div>
+ <div class="setting-control">
+ <span class="info-value">{{ tenantInfo?.id || '-' }}</span>
+ </div>
+ </div>
+
+ <!-- 租户名称 -->
+ <div class="setting-row">
+ <div class="setting-info">
+ <label>租户名称</label>
+ <p class="desc">您所属的租户名称</p>
+ </div>
+ <div class="setting-control">
+ <span class="info-value">{{ tenantInfo?.name || '-' }}</span>
+ </div>
+ </div>
+
+ <!-- 租户描述 -->
+ <div v-if="tenantInfo?.description" class="setting-row">
+ <div class="setting-info">
+ <label>租户描述</label>
+ <p class="desc">租户的详细描述信息</p>
+ </div>
+ <div class="setting-control">
+ <span class="info-value">{{ tenantInfo.description }}</span>
+ </div>
+ </div>
+
+ <!-- 租户业务 -->
+ <div v-if="tenantInfo?.business" class="setting-row">
+ <div class="setting-info">
+ <label>租户业务</label>
+ <p class="desc">租户所属的业务类型</p>
+ </div>
+ <div class="setting-control">
+ <span class="info-value">{{ tenantInfo.business }}</span>
+ </div>
+ </div>
+
+ <!-- 租户状态 -->
+ <div class="setting-row">
+ <div class="setting-info">
+ <label>租户状态</label>
+ <p class="desc">租户当前的运行状态</p>
+ </div>
+ <div class="setting-control">
+ <t-tag
+ :theme="getStatusTheme(tenantInfo?.status)"
+ variant="light"
+ size="small"
+ >
+ {{ getStatusText(tenantInfo?.status) }}
+ </t-tag>
+ </div>
+ </div>
+
+ <!-- 租户创建时间 -->
+ <div class="setting-row">
+ <div class="setting-info">
+ <label>租户创建时间</label>
+ <p class="desc">租户创建的时间</p>
+ </div>
+ <div class="setting-control">
+ <span class="info-value">{{ formatDate(tenantInfo?.created_at) }}</span>
+ </div>
+ </div>
+
+ <!-- 存储配额 -->
+ <div v-if="tenantInfo?.storage_quota !== undefined" class="setting-row">
+ <div class="setting-info">
+ <label>存储配额</label>
+ <p class="desc">租户的总存储空间配额</p>
+ </div>
+ <div class="setting-control">
+ <span class="info-value">{{ formatBytes(tenantInfo.storage_quota) }}</span>
+ </div>
+ </div>
+
+ <!-- 已使用存储 -->
+ <div v-if="tenantInfo?.storage_quota !== undefined" class="setting-row">
+ <div class="setting-info">
+ <label>已使用存储</label>
+ <p class="desc">已经使用的存储空间</p>
+ </div>
+ <div class="setting-control">
+ <span class="info-value">{{ formatBytes(tenantInfo.storage_used || 0) }}</span>
+ </div>
+ </div>
+
+ <!-- 存储使用率 -->
+ <div v-if="tenantInfo?.storage_quota !== undefined" class="setting-row">
+ <div class="setting-info">
+ <label>存储使用率</label>
+ <p class="desc">存储空间的使用百分比</p>
+ </div>
+ <div class="setting-control">
+ <div class="usage-control">
+ <span class="usage-text">{{ getUsagePercentage() }}%</span>
+ <t-progress
+ :percentage="getUsagePercentage()"
+ :show-info="false"
+ size="small"
+ :theme="getUsagePercentage() > 80 ? 'warning' : 'success'"
+ style="flex: 1;"
+ />
+ </div>
+ </div>
+ </div>
+
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { ref, onMounted } from 'vue'
+import { getCurrentUser, type TenantInfo } from '@/api/auth'
+
+// 响应式数据
+const tenantInfo = ref<TenantInfo | null>(null)
+const loading = ref(true)
+const error = ref('')
+
+// 方法
+const loadInfo = async () => {
+ try {
+ loading.value = true
+ error.value = ''
+
+ const userResponse = await getCurrentUser()
+
+ if (userResponse.success && userResponse.data) {
+ tenantInfo.value = userResponse.data.tenant
+ } else {
+ error.value = userResponse.message || '获取租户信息失败'
+ }
+ } catch (err: any) {
+ error.value = err.message || '网络错误,请稍后重试'
+ } finally {
+ loading.value = false
+ }
+}
+
+const getStatusText = (status: string | undefined) => {
+ switch (status) {
+ case 'active':
+ return '活跃'
+ case 'inactive':
+ return '未激活'
+ case 'suspended':
+ return '已暂停'
+ default:
+ return '未知'
+ }
+}
+
+const getStatusTheme = (status: string | undefined) => {
+ switch (status) {
+ case 'active':
+ return 'success'
+ case 'inactive':
+ return 'warning'
+ case 'suspended':
+ return 'danger'
+ default:
+ return 'default'
+ }
+}
+
+const formatDate = (dateStr: string | undefined) => {
+ if (!dateStr) return '未知'
+
+ try {
+ const date = new Date(dateStr)
+ return date.toLocaleString('zh-CN', {
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit',
+ hour: '2-digit',
+ minute: '2-digit'
+ })
+ } catch {
+ return '格式错误'
+ }
+}
+
+const formatBytes = (bytes: number) => {
+ if (bytes === 0) return '0 B'
+
+ const k = 1024
+ const sizes = ['B', 'KB', 'MB', 'GB', 'TB']
+ const i = Math.floor(Math.log(bytes) / Math.log(k))
+
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
+}
+
+const getUsagePercentage = () => {
+ if (!tenantInfo.value?.storage_quota || tenantInfo.value.storage_quota === 0) {
+ return 0
+ }
+
+ const used = tenantInfo.value.storage_used || 0
+ const percentage = (used / tenantInfo.value.storage_quota) * 100
+ return Math.min(Math.round(percentage * 100) / 100, 100)
+}
+
+// 生命周期
+onMounted(() => {
+ loadInfo()
+})
+</script>
+
+<style lang="less" scoped>
+.tenant-info {
+ width: 100%;
+}
+
+.section-header {
+ margin-bottom: 32px;
+
+ h2 {
+ font-size: 20px;
+ font-weight: 600;
+ color: #333333;
+ margin: 0 0 8px 0;
+ }
+
+ .section-description {
+ font-size: 14px;
+ color: #666666;
+ margin: 0;
+ line-height: 1.5;
+ }
+}
+
+.loading-inline {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 40px 0;
+ justify-content: center;
+ color: #666666;
+ font-size: 14px;
+}
+
+.error-inline {
+ padding: 20px 0;
+}
+
+.settings-group {
+ display: flex;
+ flex-direction: column;
+ gap: 0;
+}
+
+.setting-row {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ padding: 20px 0;
+ border-bottom: 1px solid #e5e7eb;
+
+ &:last-child {
+ border-bottom: none;
+ }
+}
+
+.setting-info {
+ flex: 1;
+ max-width: 65%;
+ padding-right: 24px;
+
+ label {
+ font-size: 15px;
+ font-weight: 500;
+ color: #333333;
+ display: block;
+ margin-bottom: 4px;
+ }
+
+ .desc {
+ font-size: 13px;
+ color: #666666;
+ margin: 0;
+ line-height: 1.5;
+ }
+}
+
+.setting-control {
+ flex-shrink: 0;
+ min-width: 280px;
+ display: flex;
+ justify-content: flex-end;
+ align-items: center;
+
+ .info-value {
+ font-size: 14px;
+ color: #333333;
+ text-align: right;
+ word-break: break-word;
+ }
+}
+
+.usage-control {
+// width: 100%;
+// display: flex;
+// align-items: center;
+// gap: 12px;
+
+ .usage-text {
+ font-size: 14px;
+ font-weight: 500;
+ color: #333333;
+ min-width: 50px;
+ text-align: right;
+ }
+}
+</style>
+