feat(web): add reusable admin form dialog

This commit is contained in:
2026-05-09 20:15:35 +08:00
parent c0335bd5d0
commit a5e66e79cd
49 changed files with 6013 additions and 1108 deletions
+23
View File
@@ -0,0 +1,23 @@
const AUTH_TOKEN_STORAGE_KEY = 'easyai_ai_gateway_access_token';
export function readStoredAccessToken() {
if (typeof window === 'undefined') return '';
try {
return window.localStorage.getItem(AUTH_TOKEN_STORAGE_KEY) ?? '';
} catch {
return '';
}
}
export function persistAccessToken(value: string) {
if (typeof window === 'undefined') return;
try {
if (value) {
window.localStorage.setItem(AUTH_TOKEN_STORAGE_KEY, value);
} else {
window.localStorage.removeItem(AUTH_TOKEN_STORAGE_KEY);
}
} catch {
// Ignore storage failures so private browsing or quota issues do not break login.
}
}
+32
View File
@@ -0,0 +1,32 @@
import type { GatewayTask } from '@easyai-ai-gateway/contracts';
import { createChatTask, createImageEditTask, createImageGenerationTask } from '../api';
import type { TaskForm } from '../types';
export function runTask(token: string, task: TaskForm): Promise<{ task: GatewayTask; next: Record<string, string> }> {
if (task.kind === 'images.generations') {
return createImageGenerationTask(token, {
model: task.model,
prompt: task.prompt,
quality: 'medium',
runMode: 'simulation',
simulation: true,
size: '1024x1024',
});
}
if (task.kind === 'images.edits') {
return createImageEditTask(token, {
model: task.model,
prompt: task.prompt,
image: task.image,
mask: task.mask,
runMode: 'simulation',
simulation: true,
});
}
return createChatTask(token, {
model: task.model,
runMode: 'simulation',
simulation: true,
messages: [{ role: 'user', content: task.prompt }],
});
}
+6
View File
@@ -0,0 +1,6 @@
import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}