fix: SaaS Admin + Tauri 一致性审查修复
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

- 删除 webhook 死代码模块 (4 文件 + worker,未注册未挂载)
- 删除孤立组件 StatusTag.tsx (从未被导入)
- authStore 权限模型补全 (scheduler/knowledge/billing 6+ permission key)
- authStore 硬编码 logout URL 改为 env 变量
- 清理未使用 service 方法 (agent-templates/billing/roles)
- Logs.tsx 代码重复消除 (本地常量 → @/constants/status)
- TRUTH.md 数字校准 (Tauri 177→183, SaaS API 131→130)
This commit is contained in:
iven
2026-04-07 01:53:54 +08:00
parent ae55ad6dc4
commit 2fd6d08899
12 changed files with 16 additions and 787 deletions

View File

@@ -1,15 +0,0 @@
import { Tag } from 'antd'
interface StatusTagProps {
status: string
labels: Record<string, string>
colors: Record<string, string>
}
export function StatusTag({ status, labels, colors }: StatusTagProps) {
return (
<Tag color={colors[status] || 'default'}>
{labels[status] || status}
</Tag>
)
}

View File

@@ -8,32 +8,11 @@ import { Tag, Select, Typography } from 'antd'
import type { ProColumns } from '@ant-design/pro-components'
import { ProTable } from '@ant-design/pro-components'
import { logService } from '@/services/logs'
import { actionLabels, actionColors } from '@/constants/status'
import type { OperationLog } from '@/types'
const { Title } = Typography
const actionLabels: Record<string, string> = {
login: '登录', logout: '登出',
create_account: '创建账号', update_account: '更新账号', delete_account: '删除账号',
create_provider: '创建服务商', update_provider: '更新服务商', delete_provider: '删除服务商',
create_model: '创建模型', update_model: '更新模型', delete_model: '删除模型',
create_token: '创建密钥', revoke_token: '撤销密钥',
update_config: '更新配置',
create_prompt: '创建提示词', update_prompt: '更新提示词', archive_prompt: '归档提示词',
desktop_audit: '桌面端审计',
}
const actionColors: Record<string, string> = {
login: 'green', logout: 'default',
create_account: 'blue', update_account: 'orange', delete_account: 'red',
create_provider: 'blue', update_provider: 'orange', delete_provider: 'red',
create_model: 'blue', update_model: 'orange', delete_model: 'red',
create_token: 'blue', revoke_token: 'red',
update_config: 'orange',
create_prompt: 'blue', update_prompt: 'orange', archive_prompt: 'red',
desktop_audit: 'default',
}
const actionOptions = Object.entries(actionLabels).map(([value, label]) => ({ value, label }))
export default function Logs() {

View File

@@ -5,11 +5,7 @@ export const agentTemplateService = {
list: (params?: Record<string, unknown>, signal?: AbortSignal) =>
request.get<PaginatedResponse<AgentTemplate>>('/agent-templates', withSignal({ params }, signal)).then((r) => r.data),
get: (id: string, signal?: AbortSignal) =>
request.get<AgentTemplate>(`/agent-templates/${id}`, withSignal({}, signal)).then((r) => r.data),
getFull: (id: string, signal?: AbortSignal) =>
request.get<AgentTemplate>(`/agent-templates/${id}/full`, withSignal({}, signal)).then((r) => r.data),
create: (data: {
name: string; description?: string; category?: string; source?: string

View File

@@ -80,18 +80,10 @@ export const billingService = {
request.get<BillingPlan[]>('/billing/plans', withSignal({}, signal))
.then((r) => r.data),
getPlan: (id: string, signal?: AbortSignal) =>
request.get<BillingPlan>(`/billing/plans/${id}`, withSignal({}, signal))
.then((r) => r.data),
getSubscription: (signal?: AbortSignal) =>
request.get<SubscriptionInfo>('/billing/subscription', withSignal({}, signal))
.then((r) => r.data),
getUsage: (signal?: AbortSignal) =>
request.get<UsageQuota>('/billing/usage', withSignal({}, signal))
.then((r) => r.data),
createPayment: (data: { plan_id: string; payment_method: 'alipay' | 'wechat' }) =>
request.post<PaymentResult>('/billing/payments', data).then((r) => r.data),

View File

@@ -1,7 +1,3 @@
// ============================================================
// 角色与权限模板 服务层
// ============================================================
import request, { withSignal } from './request'
import type {
Role,
@@ -16,9 +12,6 @@ export const roleService = {
list: (signal?: AbortSignal) =>
request.get<Role[]>('/roles', withSignal({}, signal)).then((r) => r.data),
get: (id: string, signal?: AbortSignal) =>
request.get<Role>(`/roles/${id}`, withSignal({}, signal)).then((r) => r.data),
create: (data: CreateRoleRequest, signal?: AbortSignal) =>
request.post<Role>('/roles', data, withSignal({}, signal)).then((r) => r.data),
@@ -36,9 +29,6 @@ export const roleService = {
listTemplates: (signal?: AbortSignal) =>
request.get<PermissionTemplate[]>('/permission-templates', withSignal({}, signal)).then((r) => r.data),
getTemplate: (id: string, signal?: AbortSignal) =>
request.get<PermissionTemplate>(`/permission-templates/${id}`, withSignal({}, signal)).then((r) => r.data),
createTemplate: (data: CreateTemplateRequest, signal?: AbortSignal) =>
request.post<PermissionTemplate>('/permission-templates', data, withSignal({}, signal)).then((r) => r.data),

View File

@@ -9,17 +9,21 @@
import { create } from 'zustand'
import type { AccountPublic } from '@/types'
/** 权限常量 — 与后端 db.rs SEED_ROLES 保持同步 */
/** 权限常量 — 与后端 db.rs seed_roles 保持同步 */
const ROLE_PERMISSIONS: Record<string, string[]> = {
super_admin: [
'admin:full', 'account:admin', 'provider:manage', 'model:manage',
'relay:admin', 'config:write', 'prompt:read', 'prompt:write',
'prompt:publish', 'prompt:admin',
'model:read', 'relay:admin', 'relay:use', 'config:write', 'config:read',
'prompt:read', 'prompt:write', 'prompt:publish', 'prompt:admin',
'scheduler:read', 'knowledge:read', 'knowledge:write',
'billing:read', 'billing:write',
],
admin: [
'account:read', 'account:admin', 'provider:manage', 'model:read',
'model:manage', 'relay:use', 'config:read',
'model:manage', 'relay:use', 'relay:admin', 'config:read',
'config:write', 'prompt:read', 'prompt:write', 'prompt:publish',
'scheduler:read', 'knowledge:read', 'knowledge:write',
'billing:read',
],
user: ['model:read', 'relay:use', 'config:read', 'prompt:read'],
}
@@ -73,7 +77,7 @@ export const useAuthStore = create<AuthState>((set, get) => {
localStorage.removeItem(ACCOUNT_KEY)
set({ isAuthenticated: false, account: null, permissions: [] })
// 调用后端 logout 清除 HttpOnly cookiesfire-and-forget
fetch('/api/v1/auth/logout', { method: 'POST', credentials: 'include' }).catch(() => {})
fetch(`${import.meta.env.VITE_API_BASE_URL || '/api/v1'}/auth/logout`, { method: 'POST', credentials: 'include' }).catch(() => {})
},
hasPermission: (permission: string) => {