feat(industry): Phase 3 Tauri 行业配置加载 — SaaS API mixin + industryStore + 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
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
- 新增 saas-industry.ts mixin: listIndustries/getIndustryFullConfig/getMyIndustries - 新增 saas-types 行业类型: IndustryInfo/IndustryFullConfig/AccountIndustryItem - 新增 industryStore.ts: Zustand store + localStorage persist + Rust 注入 - 新增 viking_load_industry_keywords Tauri 命令: 接收 JSON configs → 全局存储 - 前端 bootstrap 后自动拉取行业配置并推送到 ButlerRouter
This commit is contained in:
@@ -67,6 +67,9 @@ export type {
|
||||
AgentTemplateAvailable,
|
||||
AgentTemplateFull,
|
||||
AgentConfigFromTemplate,
|
||||
IndustryInfo,
|
||||
IndustryFullConfig,
|
||||
AccountIndustryItem,
|
||||
} from './saas-types';
|
||||
|
||||
export { SaaSApiError } from './saas-errors';
|
||||
@@ -110,6 +113,7 @@ import { installRelayMethods } from './saas-relay';
|
||||
import { installPromptMethods } from './saas-prompt';
|
||||
import { installTelemetryMethods } from './saas-telemetry';
|
||||
import { installBillingMethods } from './saas-billing';
|
||||
import { installIndustryMethods } from './saas-industry';
|
||||
export type { UsageIncrementResult } from './saas-billing';
|
||||
|
||||
// Re-export billing types for convenience
|
||||
@@ -443,6 +447,7 @@ installRelayMethods(SaaSClient);
|
||||
installPromptMethods(SaaSClient);
|
||||
installTelemetryMethods(SaaSClient);
|
||||
installBillingMethods(SaaSClient);
|
||||
installIndustryMethods(SaaSClient);
|
||||
export { installBillingMethods };
|
||||
|
||||
// === API Method Type Declarations ===
|
||||
@@ -500,6 +505,12 @@ export interface SaaSClient {
|
||||
getSubscription(): Promise<import('./saas-types').SubscriptionInfo>;
|
||||
createPayment(data: import('./saas-types').CreatePaymentRequest): Promise<import('./saas-types').PaymentResult>;
|
||||
getPaymentStatus(paymentId: string): Promise<import('./saas-types').PaymentStatus>;
|
||||
|
||||
// --- Industry (saas-industry.ts) ---
|
||||
listIndustries(opts?: { page?: number; page_size?: number; status?: string }): Promise<import('./saas-types').PaginatedResponse<import('./saas-types').IndustryInfo>>;
|
||||
getIndustryFullConfig(industryId: string): Promise<import('./saas-types').IndustryFullConfig>;
|
||||
getMyIndustries(): Promise<import('./saas-types').AccountIndustryItem[]>;
|
||||
getAccountIndustries(accountId: string): Promise<import('./saas-types').AccountIndustryItem[]>;
|
||||
}
|
||||
|
||||
// === Singleton ===
|
||||
|
||||
61
desktop/src/lib/saas-industry.ts
Normal file
61
desktop/src/lib/saas-industry.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* SaaS Industry Methods — Mixin
|
||||
*
|
||||
* Installs industry-related methods onto SaaSClient.prototype.
|
||||
* Covers listing industries, fetching full configs, and account-industry associations.
|
||||
*/
|
||||
|
||||
import type {
|
||||
IndustryInfo,
|
||||
IndustryFullConfig,
|
||||
AccountIndustryItem,
|
||||
PaginatedResponse,
|
||||
} from './saas-types';
|
||||
|
||||
export function installIndustryMethods(ClientClass: { prototype: any }): void {
|
||||
const proto = ClientClass.prototype;
|
||||
|
||||
/**
|
||||
* List available industries.
|
||||
*/
|
||||
proto.listIndustries = async function (
|
||||
this: { request<T>(method: string, path: string, body?: unknown): Promise<T> },
|
||||
opts?: { page?: number; page_size?: number; status?: string },
|
||||
): Promise<PaginatedResponse<IndustryInfo>> {
|
||||
const params = new URLSearchParams();
|
||||
if (opts?.page) params.set('page', String(opts.page));
|
||||
if (opts?.page_size) params.set('page_size', String(opts.page_size));
|
||||
if (opts?.status) params.set('status', opts.status);
|
||||
const qs = params.toString();
|
||||
return this.request('GET', `/api/v1/industries${qs ? '?' + qs : ''}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get full industry config (keywords, prompts, etc.).
|
||||
*/
|
||||
proto.getIndustryFullConfig = async function (
|
||||
this: { request<T>(method: string, path: string, body?: unknown): Promise<T> },
|
||||
industryId: string,
|
||||
): Promise<IndustryFullConfig> {
|
||||
return this.request('GET', `/api/v1/industries/${industryId}/full-config`);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current user's authorized industries.
|
||||
*/
|
||||
proto.getMyIndustries = async function (
|
||||
this: { request<T>(method: string, path: string, body?: unknown): Promise<T> },
|
||||
): Promise<AccountIndustryItem[]> {
|
||||
return this.request('GET', '/api/v1/accounts/me/industries');
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a specific account's authorized industries (admin).
|
||||
*/
|
||||
proto.getAccountIndustries = async function (
|
||||
this: { request<T>(method: string, path: string, body?: unknown): Promise<T> },
|
||||
accountId: string,
|
||||
): Promise<AccountIndustryItem[]> {
|
||||
return this.request('GET', `/api/v1/accounts/${accountId}/industries`);
|
||||
};
|
||||
}
|
||||
@@ -237,6 +237,41 @@ export interface PromptUpdatePayload {
|
||||
|
||||
// === Admin Types: Providers ===
|
||||
|
||||
// === Industry Types ===
|
||||
|
||||
/** Industry list item */
|
||||
export interface IndustryInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
description: string;
|
||||
status: string;
|
||||
source: string;
|
||||
}
|
||||
|
||||
/** Industry full config (with keywords, prompts, etc.) */
|
||||
export interface IndustryFullConfig {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
description: string;
|
||||
keywords: string[];
|
||||
system_prompt: string;
|
||||
cold_start_template: string;
|
||||
pain_seed_categories: string[];
|
||||
skill_priorities: Array<{ skill_id: string; priority: number }>;
|
||||
status: string;
|
||||
source: string;
|
||||
}
|
||||
|
||||
/** Account industry association */
|
||||
export interface AccountIndustryItem {
|
||||
industry_id: string;
|
||||
is_primary: boolean;
|
||||
industry_name: string;
|
||||
industry_icon: string;
|
||||
}
|
||||
|
||||
/** Provider info from GET /api/v1/providers */
|
||||
export interface ProviderInfo {
|
||||
id: string;
|
||||
|
||||
Reference in New Issue
Block a user