db7cef5f17
Replace all user-visible hardcoded Chinese strings in Vue/TS source files
with proper i18n function calls and add corresponding translation keys
to all 4 locale files (zh-CN, en-US, ko-KR, ru-RU).
Changes:
- Replace 80+ hardcoded Chinese strings across 30+ source files
- Add ~450 new translation keys per locale file
- Cover components, views, utils, hooks, and API modules
- Remove Chinese fallback patterns (|| '中文') from existing t() calls
- Add mermaid toolbar and ollama date format translations
Intentionally preserved (backend API values / backward compatibility):
- FAQ CSV column headers and parsing constants
- RelevanceLevel type and Record key mappings
- Graph database engine status comparison ('未启用')
- Language name labels ('简体中文')
87 lines
2.2 KiB
TypeScript
87 lines
2.2 KiB
TypeScript
import { get } from '@/utils/request'
|
|
import i18n from '@/i18n'
|
|
|
|
const t = (key: string) => i18n.global.t(key)
|
|
|
|
// 租户信息接口
|
|
export interface TenantInfo {
|
|
id: number
|
|
name: string
|
|
description?: string
|
|
api_key?: string
|
|
status?: string
|
|
business?: string
|
|
storage_quota?: number
|
|
storage_used?: number
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
// 搜索租户参数
|
|
export interface SearchTenantsParams {
|
|
keyword?: string
|
|
tenant_id?: number
|
|
page?: number
|
|
page_size?: number
|
|
}
|
|
|
|
// 搜索租户响应
|
|
export interface SearchTenantsResponse {
|
|
success: boolean
|
|
data?: {
|
|
items: TenantInfo[]
|
|
total: number
|
|
page: number
|
|
page_size: number
|
|
}
|
|
message?: string
|
|
}
|
|
|
|
/**
|
|
* 获取所有租户列表(需要跨租户访问权限)
|
|
* @deprecated 建议使用 searchTenants 代替,支持分页和搜索
|
|
*/
|
|
export async function listAllTenants(): Promise<{ success: boolean; data?: { items: TenantInfo[] }; message?: string }> {
|
|
try {
|
|
const response = await get('/api/v1/tenants/all')
|
|
return response as unknown as { success: boolean; data?: { items: TenantInfo[] }; message?: string }
|
|
} catch (error: any) {
|
|
return {
|
|
success: false,
|
|
message: error.message || t('error.tenant.listFailed')
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索租户(支持分页、关键词搜索和租户ID过滤)
|
|
*/
|
|
export async function searchTenants(params: SearchTenantsParams = {}): Promise<SearchTenantsResponse> {
|
|
try {
|
|
const queryParams = new URLSearchParams()
|
|
if (params.keyword) {
|
|
queryParams.append('keyword', params.keyword)
|
|
}
|
|
if (params.tenant_id) {
|
|
queryParams.append('tenant_id', String(params.tenant_id))
|
|
}
|
|
if (params.page) {
|
|
queryParams.append('page', String(params.page))
|
|
}
|
|
if (params.page_size) {
|
|
queryParams.append('page_size', String(params.page_size))
|
|
}
|
|
|
|
const queryString = queryParams.toString()
|
|
const url = `/api/v1/tenants/search${queryString ? '?' + queryString : ''}`
|
|
const response = await get(url)
|
|
return response as unknown as SearchTenantsResponse
|
|
} catch (error: any) {
|
|
return {
|
|
success: false,
|
|
message: error.message || t('error.tenant.searchFailed')
|
|
}
|
|
}
|
|
}
|
|
|