Initial import of weiyuan frontend

This commit is contained in:
qiubaishen
2026-10-15 16:33:46 +08:00
commit d8f3aee261
774 changed files with 374914 additions and 0 deletions
+229
View File
@@ -0,0 +1,229 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
export const CHANNEL_OPTIONS = [
{ value: 1, color: 'green', label: 'OpenAI' },
{
value: 2,
color: 'light-blue',
label: 'Midjourney Proxy',
},
{
value: 5,
color: 'blue',
label: 'Midjourney Proxy Plus',
},
{
value: 36,
color: 'purple',
label: 'Suno API',
},
{ value: 4, color: 'grey', label: 'Ollama' },
{
value: 14,
color: 'indigo',
label: 'Anthropic Claude',
},
{
value: 33,
color: 'indigo',
label: 'AWS Claude',
},
{ value: 41, color: 'blue', label: 'Vertex AI' },
{
value: 3,
color: 'teal',
label: 'Azure OpenAI',
},
{
value: 34,
color: 'purple',
label: 'Cohere',
},
{ value: 39, color: 'grey', label: 'Cloudflare' },
{ value: 43, color: 'blue', label: 'DeepSeek' },
{
value: 15,
color: 'blue',
label: '百度文心千帆',
},
{
value: 46,
color: 'blue',
label: '百度文心千帆V2',
},
{
value: 17,
color: 'orange',
label: '阿里通义千问',
},
{
value: 18,
color: 'blue',
label: '讯飞星火认知',
},
{
value: 16,
color: 'violet',
label: '智谱 ChatGLM(已经弃用,请使用智谱 GLM-4V)',
},
{
value: 26,
color: 'purple',
label: '智谱 GLM-4V',
},
{
value: 27,
color: 'blue',
label: 'Perplexity',
},
{
value: 24,
color: 'orange',
label: 'Google Gemini',
},
{
value: 11,
color: 'orange',
label: 'Google PaLM2',
},
{
value: 47,
color: 'blue',
label: 'Xinference',
},
{ value: 25, color: 'green', label: 'Moonshot' },
{ value: 20, color: 'green', label: 'OpenRouter' },
{ value: 19, color: 'blue', label: '360 智脑' },
{ value: 23, color: 'teal', label: '腾讯混元' },
{ value: 31, color: 'green', label: '零一万物' },
{ value: 35, color: 'green', label: 'MiniMax' },
{ value: 37, color: 'teal', label: 'Dify' },
{ value: 38, color: 'blue', label: 'Jina' },
{ value: 40, color: 'purple', label: 'SiliconCloud' },
{ value: 42, color: 'blue', label: 'Mistral AI' },
{ value: 8, color: 'pink', label: '自定义渠道' },
{
value: 22,
color: 'blue',
label: '知识库:FastGPT',
},
{
value: 21,
color: 'purple',
label: '知识库:AI Proxy',
},
{
value: 44,
color: 'purple',
label: '嵌入模型:MokaAI M3E',
},
{
value: 45,
color: 'blue',
label: '字节火山方舟、豆包通用',
},
{
value: 48,
color: 'blue',
label: 'xAI',
},
{
value: 49,
color: 'blue',
label: 'Coze',
},
{
value: 50,
color: 'green',
label: '可灵',
},
{
value: 51,
color: 'blue',
label: '即梦',
},
{
value: 52,
color: 'purple',
label: 'Vidu',
},
{
value: 53,
color: 'blue',
label: 'SubModel',
},
{
value: 54,
color: 'blue',
label: '豆包视频',
},
{
value: 55,
color: 'green',
label: 'Sora',
},
{
value: 56,
color: 'blue',
label: 'Replicate',
},
{
// 腾讯云视频(点播 VOD AIGC 生视频:VS/seedance + 可灵);value 对应后端 ChannelTypeTencentVideo=57
// 密钥格式:SecretId|SecretKey|SubAppId[|Region]
value: 57,
color: 'teal',
label: '腾讯云视频',
},
{
// Tezign(特赞)视频网关(seedance 2.0);value 对应后端 ChannelTypeTezignVideo=58
// 密钥格式:上游 Bearer 令牌(sk-gw-...)
value: 58,
color: 'orange',
label: 'Tezign 视频',
},
{
// 腾讯云生图(点播 VOD AIGC:GEM / nano banana);value 对应后端 ChannelTypeTencentImage=59
// 密钥格式:SecretId|SecretKey|SubAppId[|Region]
value: 59,
color: 'cyan',
label: '腾讯云生图',
},
{
// Dreamina 视频(海外版 Seedance);value 对应后端 ChannelTypeDreaminaVideo=60
// 密钥格式:上游 API Key(Bearer 鉴权)
value: 60,
color: 'pink',
label: 'Dreamina 视频',
},
{
// TokenPony Seedance 2.0/2.5;value 对应后端 ChannelTypeTokenPonyVideo=61
// 密钥格式:上游 API Key(Bearer 鉴权)
value: 61,
color: 'cyan',
label: 'TokenPony 视频',
},
{
value: 62,
color: 'green',
label: '百度 Seedance 视频',
},
];
export const MODEL_TABLE_PAGE_SIZE = 10;
+47
View File
@@ -0,0 +1,47 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
export const ITEMS_PER_PAGE = 10; // this value must keep same as the one defined in backend!
export const DEFAULT_ENDPOINT = '/api/ratio_config';
export const TABLE_COMPACT_MODES_KEY = 'table_compact_modes';
export const API_ENDPOINTS = [
'/v1/chat/completions',
'/v1/responses',
'/v1/messages',
'/v1beta/models',
'/v1/embeddings',
'/v1/rerank',
'/v1/images/generations',
'/v1/images/edits',
'/v1/images/variations',
'/v1/audio/speech',
'/v1/audio/transcriptions',
'/v1/audio/translations',
];
export const TASK_ACTION_GENERATE = 'generate';
export const TASK_ACTION_TEXT_GENERATE = 'textGenerate';
export const TASK_ACTION_FIRST_TAIL_GENERATE = 'firstTailGenerate';
export const TASK_ACTION_REFERENCE_GENERATE = 'referenceGenerate';
// 图像任务动作(与后端 constant/task.go 对齐)
export const IMAGE_ACTION_GENERATE = 'image_generate';
export const IMAGE_ACTION_EDIT = 'image_edit';
+49
View File
@@ -0,0 +1,49 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import dayjs from 'dayjs';
// ========== 日期预设常量 ==========
export const DATE_RANGE_PRESETS = [
{
text: '今天',
start: () => dayjs().startOf('day').toDate(),
end: () => dayjs().endOf('day').toDate(),
},
{
text: '近 7 天',
start: () => dayjs().subtract(6, 'day').startOf('day').toDate(),
end: () => dayjs().endOf('day').toDate(),
},
{
text: '本周',
start: () => dayjs().startOf('week').toDate(),
end: () => dayjs().endOf('week').toDate(),
},
{
text: '近 30 天',
start: () => dayjs().subtract(29, 'day').startOf('day').toDate(),
end: () => dayjs().endOf('day').toDate(),
},
{
text: '本月',
start: () => dayjs().startOf('month').toDate(),
end: () => dayjs().endOf('month').toDate(),
},
];
+68
View File
@@ -0,0 +1,68 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
// ISO 3166-1 alpha-2 全表 + XK(科索沃)。须与后端 setting/language_setting/countries.go
// 一致(Go 契约测试比对);国家名称由浏览器 Intl.DisplayNames 按界面语言本地化,无需翻译词条。
const RAW_COUNTRY_CODES = `
AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ
BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ
CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ
DE DJ DK DM DO DZ
EC EE EG EH ER ES ET
FI FJ FK FM FO FR
GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY
HK HM HN HR HT HU
ID IE IL IM IN IO IQ IR IS IT
JE JM JO JP
KE KG KH KI KM KN KP KR KW KY KZ
LA LB LC LI LK LR LS LT LU LV LY
MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ
NA NC NE NF NG NI NL NO NP NR NU NZ
OM
PA PE PF PG PH PK PL PM PN PR PS PT PW PY
QA
RE RO RS RU RW
SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ
TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ
UA UG UM US UY UZ
VA VC VE VG VI VN VU
WF WS
XK
YE YT
ZA ZM ZW
`;
export const COUNTRY_CODES = RAW_COUNTRY_CODES.trim().split(/\s+/);
const displayNamesCache = new Map();
export const getCountryName = (code, language) => {
if (!code) return '';
try {
if (!displayNamesCache.has(language)) {
displayNamesCache.set(
language,
new Intl.DisplayNames([language, 'en'], { type: 'region' }),
);
}
return displayNamesCache.get(language).of(code) || code;
} catch {
return code;
}
};
+82
View File
@@ -0,0 +1,82 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
// ========== UI 配置常量 ==========
export const CHART_CONFIG = { mode: 'desktop-browser' };
export const CARD_PROPS = {
shadows: '',
bordered: true,
headerLine: true,
};
export const FORM_FIELD_PROPS = {
className: 'w-full mb-2 !rounded-lg',
size: 'large',
};
export const ICON_BUTTON_CLASS = 'text-white hover:bg-opacity-80 !rounded-full';
export const FLEX_CENTER_GAP2 = 'flex items-center gap-2';
export const ILLUSTRATION_SIZE = { width: 96, height: 96 };
// ========== 时间相关常量 ==========
export const TIME_OPTIONS = [
{ label: '小时', value: 'hour' },
{ label: '天', value: 'day' },
{ label: '周', value: 'week' },
];
export const DEFAULT_TIME_INTERVALS = {
hour: { seconds: 3600, minutes: 60 },
day: { seconds: 86400, minutes: 1440 },
week: { seconds: 604800, minutes: 10080 },
};
// ========== 公告图例数据 ==========
export const ANNOUNCEMENT_LEGEND_DATA = [
{ color: 'grey', label: '默认', type: 'default' },
{ color: 'blue', label: '进行中', type: 'ongoing' },
{ color: 'green', label: '成功', type: 'success' },
{ color: 'orange', label: '警告', type: 'warning' },
{ color: 'red', label: '异常', type: 'error' },
];
// ========== Uptime 状态映射 ==========
// 走 Semi 状态语义变量,跟随主题与暗色模式;info 蓝保持 accent-blue 与品牌色独立
export const UPTIME_STATUS_MAP = {
1: { color: 'var(--semi-color-success)', label: '正常', text: '可用率' }, // UP
0: { color: 'var(--semi-color-danger)', label: '异常', text: '有异常' }, // DOWN
2: { color: 'var(--semi-color-warning)', label: '高延迟', text: '高延迟' }, // PENDING
3: { color: 'var(--accent-blue)', label: '维护中', text: '维护中' }, // MAINTENANCE
};
// ========== 本地存储键名 ==========
export const STORAGE_KEYS = {
DATA_EXPORT_DEFAULT_TIME: 'data_export_default_time',
MJ_NOTIFY_ENABLED: 'mj_notify_enabled',
};
// ========== 默认值 ==========
export const DEFAULTS = {
PAGE_SIZE: 20,
CHART_HEIGHT: 96,
MODEL_TABLE_PAGE_SIZE: 10,
MAX_TREND_POINTS: 7,
};
+180
View File
@@ -0,0 +1,180 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
export const HEADER_NAV_AUTH_MODULES = [
'experienceCenter',
'keyManagement',
'userCenter',
'pricing',
'skillMarket',
'docs',
];
// 说明:以下导出统一使用「函数声明」而非 const 箭头函数。
// 函数声明会被提升到模块工厂顶部,可避免在 esbuild/rollup 压缩 + manualChunks
// 分包的某些版本下出现 “getHeaderModuleRequireAuth is not defined” 这类
// 导出被误删 / 引用未正确链接的运行时 ReferenceError。
export function getDefaultHeaderNavModules() {
return {
home: true,
experienceCenter: {
enabled: true,
requireAuth: false,
},
keyManagement: {
enabled: true,
requireAuth: false,
},
userCenter: {
enabled: true,
requireAuth: false,
},
console: true,
pricing: {
enabled: true,
requireAuth: false,
},
skillMarket: {
enabled: true,
requireAuth: false,
},
docs: {
enabled: true,
requireAuth: false,
},
// WeyAi 网页端入口(外链,固定需要登录;是否显示还取决于开放范围)
weyai: true,
about: true,
rightActions: {
tutorial: true,
promotion: true,
recharge: true,
notifications: true,
theme: true,
newYear: true,
userSettings: true,
keyManagement: true,
orgCenter: true,
},
};
}
function parseConfig(config) {
if (!config) {
return {};
}
if (typeof config === 'string') {
return JSON.parse(config);
}
return config;
}
// 企业员工(org_only)顶栏硬性默认:隐藏 C 端入口,仅保留企业相关。
// 这是「开箱即生效」的基线;管理员在运营设置里的配置会覆盖于其上。
export function getOrgUserDefaultNavModules() {
return {
home: { enabled: false },
experienceCenter: { enabled: false, requireAuth: false },
keyManagement: { enabled: false, requireAuth: false },
userCenter: { enabled: false, requireAuth: false },
console: { enabled: true },
pricing: { enabled: false, requireAuth: false },
// 技能超市是这条基线里唯一保留的「C 端」入口(方案决策点 3,已拍板默认开)。
// 刻意偏离「隐藏全部 C 端入口」的原因:它是员工理解「我有哪些技能可用」的
// 唯一途径,且纯只读、不产生任何 C 端消费行为。
// ⚠️ 默认开就必须同步放行路由:见 App.jsx 的 ORG_USER_NAV_PATHS,
// 少加一处就会出现「按钮显示了、点了却被踢回 /org」的死按钮。
skillMarket: { enabled: true, requireAuth: false },
docs: { enabled: true, requireAuth: false },
// WeyAi 网页端对企业员工同样默认开放(可在「企业员工顶栏」里关闭)
weyai: { enabled: true },
about: { enabled: false },
rightActions: {
tutorial: false,
promotion: false,
recharge: false,
// 桌面端下载按钮:与 weyai 网页端入口一样默认对企业员工开放
weyaiDownload: true,
notifications: true,
theme: true,
newYear: true,
userSettings: true,
keyManagement: false,
orgCenter: true,
},
};
}
export function normalizeHeaderNavModules(config, baseOverride) {
const defaults = baseOverride || getDefaultHeaderNavModules();
let modules;
try {
modules = parseConfig(config);
} catch (_error) {
modules = {};
}
const normalized = {
...defaults,
...modules,
rightActions: {
...defaults.rightActions,
...(modules?.rightActions || {}),
},
};
HEADER_NAV_AUTH_MODULES.forEach((key) => {
const current = modules?.[key];
if (typeof current === 'boolean') {
normalized[key] = {
enabled: current,
requireAuth: false,
};
return;
}
normalized[key] = {
...defaults[key],
...(current || {}),
};
});
return normalized;
}
// 企业员工顶栏归一化:以企业默认预设为基线,叠加管理员保存的覆盖配置。
export function normalizeOrgUserNavModules(config) {
return normalizeHeaderNavModules(config, getOrgUserDefaultNavModules());
}
export function isHeaderModuleEnabled(modules, key) {
const module = modules?.[key];
if (typeof module === 'object') {
return module.enabled !== false;
}
return module === true;
}
export function getHeaderModuleRequireAuth(modules, key) {
const module = modules?.[key];
if (typeof module === 'object') {
return module.requireAuth === true;
}
return false;
}
+221
View File
@@ -0,0 +1,221 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
// 图像生成模型族能力注册表
// 新增模型族(如阿里云万相)只需在 FAMILIES 中追加一条
// 表单和 hook 都从这里读,确保单一事实源
const FAMILIES = [
{
key: 'gpt-image',
label: 'GPT Image',
// gpt-image-1 / gpt-image-2 / gpt-image-2-2026-04-21 ...
match: (m) => /(^|[^a-z])gpt-image(-|$)/i.test(m),
sizes: [
{
value: '1024x1024',
label: '1:1 (1024×1024)',
width: 1024,
height: 1024,
},
{
value: '1536x1024',
label: '3:2 (1536×1024)',
width: 1536,
height: 1024,
},
{
value: '1024x1536',
label: '2:3 (1024×1536)',
width: 1024,
height: 1536,
},
],
qualities: [
{ value: 'auto', label: '自动' },
{ value: 'high', label: '高' },
{ value: 'medium', label: '中' },
{ value: 'low', label: '低' },
],
defaultQuality: 'auto',
maxN: 1,
supportsI2I: true,
supportsNegativePrompt: false,
sendQuality: true,
sendResponseFormat: false,
customSize: false,
sizeHint: 'gpt-image 仅支持 1024×1024 / 1536×1024 / 1024×1536',
},
{
key: 'gemini-image',
label: 'Gemini Image',
// gemini-3-pro-image-preview / gemini-3.1-flash-image-preview / nano-banana
match: (m) => /gemini[\w.-]*image/i.test(m) || /nano-banana/i.test(m),
sizes: [
{
value: '1024x1024',
label: '1:1 (1024×1024)',
width: 1024,
height: 1024,
},
{ value: '1280x720', label: '16:9 (1280×720)', width: 1280, height: 720 },
{ value: '720x1280', label: '9:16 (720×1280)', width: 720, height: 1280 },
{ value: '1024x768', label: '4:3 (1024×768)', width: 1024, height: 768 },
{ value: '768x1024', label: '3:4 (768×1024)', width: 768, height: 1024 },
],
qualities: [],
defaultQuality: null,
maxN: 1,
supportsI2I: true,
supportsNegativePrompt: false,
sendQuality: false,
sendResponseFormat: false,
customSize: true,
sizeHint: '',
},
{
key: 'wanx',
label: '阿里云万相',
// wanx-* / qwen-image / qwen-image-*
match: (m) => /^(wanx|qwen-image)/i.test(m),
sizes: [
{
value: '1024x1024',
label: '1:1 (1024×1024)',
width: 1024,
height: 1024,
},
{ value: '1280x720', label: '16:9 (1280×720)', width: 1280, height: 720 },
{ value: '720x1280', label: '9:16 (720×1280)', width: 720, height: 1280 },
{
value: '1920x1080',
label: '16:9 HD (1920×1080)',
width: 1920,
height: 1080,
},
{
value: '1080x1920',
label: '9:16 HD (1080×1920)',
width: 1080,
height: 1920,
},
],
qualities: [],
defaultQuality: null,
maxN: 4,
supportsI2I: true,
supportsNegativePrompt: true,
sendQuality: false,
sendResponseFormat: true,
customSize: false,
sizeHint: '',
},
// 兜底:dall-e / flux / 未识别模型走默认能力
{
key: 'default',
label: 'Default',
match: () => true,
sizes: [
{
value: '1024x1024',
label: '1:1 (1024×1024)',
width: 1024,
height: 1024,
},
{ value: '1280x720', label: '16:9 (1280×720)', width: 1280, height: 720 },
{ value: '720x1280', label: '9:16 (720×1280)', width: 720, height: 1280 },
{ value: '1024x768', label: '4:3 (1024×768)', width: 1024, height: 768 },
{ value: '768x1024', label: '3:4 (768×1024)', width: 768, height: 1024 },
],
qualities: [],
defaultQuality: null,
maxN: 4,
supportsI2I: true,
supportsNegativePrompt: false,
sendQuality: false,
sendResponseFormat: true,
customSize: true,
sizeHint: '',
},
];
export const getImageCapability = (modelName) =>
FAMILIES.find((f) => f.match(modelName || '')) ||
FAMILIES[FAMILIES.length - 1];
// 从 width/height/size 推断该家族下应发送的合法 size 字符串
const resolveSize = (cap, width, height, sizeStr) => {
// 优先:调用方已给好 sizeStr
if (sizeStr && cap.sizes.some((s) => s.value === sizeStr)) return sizeStr;
const w = Number(width) || null;
const h = Number(height) || null;
// customSize=true:直接拼,没拼上就回退到第一个预设
if (cap.customSize) {
if (w && h) return `${w}x${h}`;
if (sizeStr && /^\d+x\d+$/.test(sizeStr)) return sizeStr;
return cap.sizes[0]?.value || '1024x1024';
}
// customSize=false:必须吸附到预设
if (w && h) {
const exact = cap.sizes.find((s) => s.width === w && s.height === h);
if (exact) return exact.value;
// 按宽高比方向吸附
if (w === h) {
const square = cap.sizes.find((s) => s.width === s.height);
if (square) return square.value;
}
const portrait = h > w;
const candidate = cap.sizes.find((s) =>
portrait ? s.height > s.width : s.width > s.height,
);
if (candidate) return candidate.value;
}
return cap.sizes[0]?.value || '1024x1024';
};
// 把表单 raw 参数清洗成发送给 /api/images/generations 的合法 payload
// raw 字段:prompt, model, mode, width, height, size, quality, n, negativePrompt, image, source
export const buildImageRequestBody = (modelName, raw = {}) => {
const cap = getImageCapability(modelName);
const body = {
prompt: raw.prompt,
model: modelName,
n: Math.min(Math.max(1, Number(raw.n) || 1), cap.maxN || 1),
size: resolveSize(cap, raw.width, raw.height, raw.size),
mode: raw.mode || 'text-to-image',
};
if (cap.sendResponseFormat) {
body.response_format = raw.response_format || 'url';
}
if (cap.sendQuality) {
body.quality =
raw.quality && cap.qualities.some((q) => q.value === raw.quality)
? raw.quality
: cap.defaultQuality || 'auto';
}
if (cap.supportsNegativePrompt && raw.negativePrompt) {
body.negative_prompt = raw.negativePrompt;
}
if (raw.image) body.image = raw.image;
if (raw.source) body.source = raw.source;
return body;
};
+28
View File
@@ -0,0 +1,28 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
export * from './channel.constants';
export * from './user.constants';
export * from './toast.constants';
export * from './common.constant';
export * from './dashboard.constants';
export * from './playground.constants';
export * from './redemption.constants';
export * from './model-category.constant';
export * from './invoice.constants';
+47
View File
@@ -0,0 +1,47 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
export const INVOICE_STATUS = {
PENDING: 1,
APPROVED: 2,
REJECTED: 3,
INVOICING: 4,
INVOICED: 5,
CANCELLED: 6,
FAILED: 7,
};
export const INVOICE_STATUS_TEXT = {
1: '待审核',
2: '审核通过',
3: '已拒绝',
4: '开票中',
5: '已开票',
6: '已取消',
7: '开票失败',
};
export const INVOICE_STATUS_COLOR = {
1: 'orange',
2: 'blue',
3: 'red',
4: 'cyan',
5: 'green',
6: 'grey',
7: 'red',
};
+231
View File
@@ -0,0 +1,231 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
/**
* 模型分类常量
* 用于在体验中心按照用途对模型进行分类
*/
// 模型分类枚举
export const MODEL_CATEGORY = {
// 文本生成类
TEXT_GENERATION: 'text_generation',
// 图像生成类(通用)
IMAGE_GENERATION: 'image_generation',
// 图像生成类(细分)
TEXT_TO_IMAGE: 't_g_i', // 文生图
IMAGE_TO_IMAGE: 'i_g_i', // 图生图
// 视频生成类(通用)
VIDEO_GENERATION: 'video_generation',
// 视频生成类(细分)
TEXT_TO_VIDEO: 't_g_v', // 文生视频
IMAGE_TO_VIDEO: 'i_g_v', // 图生视频
// 语音相关类
AUDIO_TTS: 'audio_tts', // 文本转语音
AUDIO_STT: 'audio_stt', // 语音转文本
AUDIO_GENERATION: 'audio_generation', // 音频生成
// 向量嵌入类
EMBEDDING: 'embedding',
// 多模态类
MULTIMODAL: 'multimodal',
// 重排序类
RERANK: 'rerank',
// 其他
OTHER: 'other',
};
// 模型分类显示名称(多语言支持)
export const MODEL_CATEGORY_NAMES = {
[MODEL_CATEGORY.TEXT_GENERATION]: '文本生成',
[MODEL_CATEGORY.IMAGE_GENERATION]: '图像生成',
[MODEL_CATEGORY.TEXT_TO_IMAGE]: '文生图',
[MODEL_CATEGORY.IMAGE_TO_IMAGE]: '图生图',
[MODEL_CATEGORY.VIDEO_GENERATION]: '视频生成',
[MODEL_CATEGORY.TEXT_TO_VIDEO]: '文生视频',
[MODEL_CATEGORY.IMAGE_TO_VIDEO]: '图生视频',
[MODEL_CATEGORY.AUDIO_TTS]: '文本转语音',
[MODEL_CATEGORY.AUDIO_STT]: '语音转文本',
[MODEL_CATEGORY.AUDIO_GENERATION]: '音频生成',
[MODEL_CATEGORY.EMBEDDING]: '向量嵌入',
[MODEL_CATEGORY.MULTIMODAL]: '多模态',
[MODEL_CATEGORY.RERANK]: '重排序',
[MODEL_CATEGORY.OTHER]: '其他',
};
// 根据模型名称或端点类型推断模型分类
export const inferModelCategory = (modelName = '', endpointType = '') => {
const lowerModelName = modelName.toLowerCase();
const lowerEndpoint = endpointType.toLowerCase();
// 图像生成相关
if (
lowerModelName.includes('dall-e') ||
lowerModelName.includes('dalle') ||
lowerModelName.includes('midjourney') ||
lowerModelName.includes('stable-diffusion') ||
lowerModelName.includes('sd-') ||
lowerModelName.includes('flux') ||
lowerModelName.includes('jimeng') ||
lowerModelName.includes('sora_image') ||
lowerModelName.includes('wanx') ||
lowerModelName.includes('cogview') ||
lowerEndpoint.includes('image')
) {
return MODEL_CATEGORY.IMAGE_GENERATION;
}
// 视频生成相关
if (
lowerModelName.includes('sora') ||
lowerModelName.includes('runway') ||
lowerModelName.includes('pika') ||
lowerModelName.includes('gen-2') ||
lowerModelName.includes('video') ||
lowerModelName.includes('kling') ||
lowerModelName.includes('hailuo')
) {
return MODEL_CATEGORY.VIDEO_GENERATION;
}
// 语音相关
if (
lowerModelName.includes('tts') ||
lowerModelName.includes('speech') ||
lowerEndpoint.includes('speech')
) {
return MODEL_CATEGORY.AUDIO_TTS;
}
if (
lowerModelName.includes('whisper') ||
lowerModelName.includes('transcription') ||
lowerEndpoint.includes('transcription')
) {
return MODEL_CATEGORY.AUDIO_STT;
}
// 向量嵌入
if (
lowerModelName.includes('embedding') ||
lowerModelName.includes('text-embedding') ||
lowerEndpoint.includes('embedding')
) {
return MODEL_CATEGORY.EMBEDDING;
}
// 重排序
if (lowerModelName.includes('rerank') || lowerEndpoint.includes('rerank')) {
return MODEL_CATEGORY.RERANK;
}
// 多模态
if (
lowerModelName.includes('gpt-4-vision') ||
lowerModelName.includes('gpt-4v') ||
lowerModelName.includes('claude-3') ||
lowerModelName.includes('gemini-pro-vision') ||
lowerModelName.includes('qwen-vl')
) {
return MODEL_CATEGORY.MULTIMODAL;
}
// 默认为文本生成
if (
lowerModelName.includes('gpt') ||
lowerModelName.includes('claude') ||
lowerModelName.includes('gemini') ||
lowerModelName.includes('llama') ||
lowerModelName.includes('mistral') ||
lowerModelName.includes('qwen') ||
lowerModelName.includes('glm') ||
lowerModelName.includes('ernie') ||
lowerEndpoint.includes('chat') ||
lowerEndpoint.includes('completion')
) {
return MODEL_CATEGORY.TEXT_GENERATION;
}
// 其他
return MODEL_CATEGORY.OTHER;
};
// 定义分类的父子关系(子分类可以匹配父分类的模型)
const CATEGORY_PARENTS = {
[MODEL_CATEGORY.TEXT_TO_IMAGE]: MODEL_CATEGORY.IMAGE_GENERATION,
[MODEL_CATEGORY.IMAGE_TO_IMAGE]: MODEL_CATEGORY.IMAGE_GENERATION,
[MODEL_CATEGORY.TEXT_TO_VIDEO]: MODEL_CATEGORY.VIDEO_GENERATION,
[MODEL_CATEGORY.IMAGE_TO_VIDEO]: MODEL_CATEGORY.VIDEO_GENERATION,
};
// 获取指定分类的所有模型
export const getModelsByCategory = (models, category) => {
if (!Array.isArray(models)) return [];
// 获取父分类(如果有的话)
const parentCategory = CATEGORY_PARENTS[category];
return models.filter((model) => {
// 支持后端返回的 categories 数组格式
if (Array.isArray(model.categories) && model.categories.length > 0) {
// 精确匹配或父分类匹配
if (model.categories.includes(category)) {
return true;
}
// 如果请求的是子分类(如 t_g_i),也匹配父分类(如 image_generation)的模型
if (parentCategory && model.categories.includes(parentCategory)) {
return true;
}
return false;
}
// 兼容单个 category 字符串格式
if (model.category) {
if (model.category === category) {
return true;
}
if (parentCategory && model.category === parentCategory) {
return true;
}
return false;
}
// 如果没有分类信息,则通过模型名称和端点类型推断
const inferredCategory = inferModelCategory(
model.model_name,
model.endpoint_type,
);
if (inferredCategory === category) {
return true;
}
// 推断出的是父分类时也匹配
if (parentCategory && inferredCategory === parentCategory) {
return true;
}
return false;
});
};
+146
View File
@@ -0,0 +1,146 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { getServerURL } from '../helpers/config';
export const MESSAGE_STATUS = {
LOADING: 'loading',
INCOMPLETE: 'incomplete',
COMPLETE: 'complete',
ERROR: 'error',
};
export const MESSAGE_ROLES = {
USER: 'user',
ASSISTANT: 'assistant',
SYSTEM: 'system',
};
// 默认消息示例 - 使用函数生成以支持 i18n
export const getDefaultMessages = (t) => [
{
role: MESSAGE_ROLES.USER,
id: '2',
createAt: 1715676751919,
content: t('默认用户消息'),
},
{
role: MESSAGE_ROLES.ASSISTANT,
id: '3',
createAt: 1715676751919,
content: t('默认助手消息'),
reasoningContent: '',
isReasoningExpanded: false,
},
];
// 保留旧的导出以保持向后兼容
export const DEFAULT_MESSAGES = [
{
role: MESSAGE_ROLES.USER,
id: '2',
createAt: 1715676751919,
content: 'Hello',
},
{
role: MESSAGE_ROLES.ASSISTANT,
id: '3',
createAt: 1715676751919,
content: 'Hello! How can I help you today?',
reasoningContent: '',
isReasoningExpanded: false,
},
];
// ========== UI 相关常量 ==========
export const DEBUG_TABS = {
PREVIEW: 'preview',
REQUEST: 'request',
RESPONSE: 'response',
};
// ========== API 相关常量 ==========
export const API_ENDPOINTS = {
get CHAT_COMPLETIONS() {
return `${getServerURL()}/pg/chat/completions`;
},
get USER_MODELS() {
return `${getServerURL()}/api/user/models`;
},
get EXPERIENCE_USER_MODELS() {
return `${getServerURL()}/api/user/self/models`;
},
get USER_GROUPS() {
return `${getServerURL()}/api/user/self/groups`;
},
get IMAGE_GENERATIONS() {
return `${getServerURL()}/api/images/generations`;
},
};
// ========== 配置默认值 ==========
export const DEFAULT_CONFIG = {
inputs: {
model: 'gpt-4o',
group: '',
temperature: 0.7,
top_p: 1,
max_tokens: 4096,
frequency_penalty: 0,
presence_penalty: 0,
seed: null,
stream: true,
imageEnabled: false,
imageUrls: [''],
enableWebSearch: false,
},
parameterEnabled: {
temperature: true,
top_p: true,
max_tokens: false,
frequency_penalty: true,
presence_penalty: true,
seed: false,
},
systemPrompt: '',
showDebugPanel: false,
customRequestMode: false,
customRequestBody: '',
};
// ========== 正则表达式 ==========
export const THINK_TAG_REGEX = /<think>([\s\S]*?)<\/think>/g;
// ========== 错误消息 ==========
export const ERROR_MESSAGES = {
NO_TEXT_CONTENT: '此消息没有可复制的文本内容',
INVALID_MESSAGE_TYPE: '无法复制此类型的消息内容',
COPY_FAILED: '复制失败,请手动选择文本复制',
COPY_HTTPS_REQUIRED: '复制功能需要 HTTPS 环境,请手动复制',
BROWSER_NOT_SUPPORTED: '浏览器不支持复制功能,请手动复制',
JSON_PARSE_ERROR: '自定义请求体格式错误,请检查JSON格式',
API_REQUEST_ERROR: '请求发生错误',
NETWORK_ERROR: '网络连接失败或服务器无响应',
};
// ========== 存储键名 ==========
export const STORAGE_KEYS = {
CONFIG: 'playground_config',
MESSAGES: 'playground_messages',
};
+47
View File
@@ -0,0 +1,47 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
export const REDEMPTION_STATUS = {
UNUSED: 1, // Unused
DISABLED: 2, // Disabled
USED: 3, // Used
};
// Redemption code status display mapping
export const REDEMPTION_STATUS_MAP = {
[REDEMPTION_STATUS.UNUSED]: {
color: 'green',
text: '未使用',
},
[REDEMPTION_STATUS.DISABLED]: {
color: 'red',
text: '已禁用',
},
[REDEMPTION_STATUS.USED]: {
color: 'grey',
text: '已使用',
},
};
// Action type constants
export const REDEMPTION_ACTIONS = {
DELETE: 'delete',
ENABLE: 'enable',
DISABLE: 'disable',
};
+56
View File
@@ -0,0 +1,56 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
/*
* 系统设置(/console/setting)页面 tab 的单一数据源。
* 供 Setting/index.jsx 与运营设置中的「下放管理员」勾选 UI 共用,避免两处 tab 列表漂移。
* labelKey 为传入 t() 的 i18n 键(本项目使用中文作为键)。
*/
export const SETTING_TABS = [
{ key: 'operation', labelKey: '运营设置' },
{ key: 'data-security', labelKey: '数据安全' },
{ key: 'content-guard', labelKey: '大模型内容防护' },
{ key: 'dashboard', labelKey: '仪表盘设置' },
{ key: 'chats', labelKey: '聊天设置' },
{ key: 'drawing', labelKey: '绘图设置' },
{ key: 'payment', labelKey: '支付设置' },
{ key: 'amount-options', labelKey: '充值档位管理' },
{ key: 'org-amount-options', labelKey: '企业充值档位' },
{ key: 'membership', labelKey: '会员管理' },
{ key: 'ratio', labelKey: '分组与模型定价设置' },
{ key: 'level_policy', labelKey: '等级与模型访问' },
{ key: 'ratelimit', labelKey: '速率限制设置' },
{ key: 'models', labelKey: '模型相关设置' },
{ key: 'customer-service', labelKey: '客服设置' },
{ key: 'tutorial-video', labelKey: '教程视频管理' },
{ key: 'system', labelKey: '系统设置' },
{ key: 'other', labelKey: '其他设置' },
];
// 会员管理本就对普通管理员开放,无需通过下放配置即可见。
export const ALWAYS_ADMIN_VISIBLE_TABS = ['membership'];
// 可下放给普通管理员的 tab(排除本就对管理员开放的 membership)。
export const ROOT_ONLY_SETTING_TABS = ['content-guard'];
export const DELEGATABLE_SETTING_TABS = SETTING_TABS.filter(
(t) =>
!ALWAYS_ADMIN_VISIBLE_TABS.includes(t.key) &&
!ROOT_ONLY_SETTING_TABS.includes(t.key),
);
+205
View File
@@ -0,0 +1,205 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
export const getDefaultSidebarModulesAdmin = () => ({
experienceCenter: {
enabled: true,
cloudBrain: true,
imageGeneration: true,
videoGeneration: true,
},
userCenter: {
enabled: true,
dashboard: true,
usageRecord: true,
serviceDashboard: true,
topup: true,
invoice: true,
invite: true,
settings: true,
},
chat: {
enabled: true,
playground: true,
chat: true,
},
console: {
enabled: true,
detail: true,
token: true,
log: true,
midjourney: true,
task: true,
monitor: true,
},
personal: {
enabled: true,
topup: true,
personal: true,
},
admin: {
enabled: true,
analytics: true,
channel: true,
models: true,
redemption: true,
user: true,
subscription: true,
'admin-token': true,
organizations: true,
'skill-platform': true,
'expert-platform': true,
order: true,
invoice: true,
setting: true,
},
analytics: {
enabled: true,
operations: true,
quality: true,
risk: true,
org: true,
audit: true,
},
orgCenter: {
enabled: true,
workbench: true,
cloudBrain: true,
knowledge: true,
mySkills: true,
// 企业侧「技能市场」页已并入平台技能超市(/skill-market)。该 key 未被删除,
// 而是改为控制超市页上「为企业启用」这一治理面:运营此前关掉它的意图是
// "不允许企业管理员自助启用技能",删掉 key 会让该抑制在升级后静默解除。
skillMarket: true,
skillLibrary: true,
privateSkills: true,
effectiveness: true,
skillAssignments: true,
experts: true,
agentAudit: true,
connectors: true,
myConnectors: true,
dashboard: true,
quality: true,
members: true,
memberAccounts: true,
departments: true,
projects: true,
deptManage: true,
projectManage: true,
budgets: true,
analytics: true,
requests: true,
tokens: true,
logs: true,
audit: true,
recharge: true,
settings: true,
},
});
export const ORG_CENTER_MODULE_KEYS = [
'workbench',
'cloudBrain',
'knowledge',
'mySkills',
'skillMarket',
'skillLibrary',
'privateSkills',
'effectiveness',
'skillAssignments',
'experts',
'agentAudit',
'connectors',
'myConnectors',
'dashboard',
'quality',
'members',
'memberAccounts',
'departments',
'projects',
'deptManage',
'projectManage',
'budgets',
'analytics',
'requests',
'tokens',
'logs',
'audit',
'recharge',
'settings',
];
export const hasEnabledOrgCenterModule = (orgCenterConfig) => {
if (!orgCenterConfig) return true;
return (
orgCenterConfig.enabled !== false &&
ORG_CENTER_MODULE_KEYS.some((key) => orgCenterConfig[key] !== false)
);
};
const parseConfig = (config) => {
if (!config) {
return {};
}
if (typeof config === 'string') {
return JSON.parse(config);
}
return config;
};
export const normalizeSidebarModulesAdmin = (config) => {
const defaults = getDefaultSidebarModulesAdmin();
let modules;
try {
modules = parseConfig(config);
} catch (_error) {
modules = {};
}
const normalized = {};
Object.keys(defaults).forEach((sectionKey) => {
normalized[sectionKey] = {
...defaults[sectionKey],
...(modules?.[sectionKey] || {}),
};
});
Object.keys(modules || {}).forEach((sectionKey) => {
if (!normalized[sectionKey]) {
normalized[sectionKey] = modules[sectionKey];
}
});
const ucFromDb = modules?.userCenter || {};
const needsUsageRecordMigration =
ucFromDb.usageRecord === undefined &&
ucFromDb.usageLog === false &&
ucFromDb.taskLog === false;
if (needsUsageRecordMigration) {
normalized.userCenter.usageRecord = false;
}
delete normalized.userCenter.usageLog;
delete normalized.userCenter.taskLog;
return normalized;
};
+138
View File
@@ -0,0 +1,138 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
// 技能分类标签的展示名映射(技能超市 + 平台管理台共用)。
//
// 标签在数据层是版本 frontmatter 里的英文 slug(skill_versions.tags_json),
// 是过滤与统计的稳定键,绝不能翻译后写回数据库——这里只做**展示层**映射:
// 中文界面显示中文名,未收录的 slug(含本就是中文的标签)原样展示,
// 过滤请求仍然携带原始 slug。
//
// 新导入技能包引入新 slug 时在此补充即可;漏补不会出错,只是该分类
// 暂以英文 slug 展示。
const SKILL_CATEGORY_ZH = {
// ===== 来源/合集类 =====
'awesome-skills': '社区精选',
'super-code': '编码进阶',
andruia: 'Andru.ia 系列',
monopoly: 'Monopoly 系列',
'workflow-bundle': '工作流套件',
'granular-workflow-bundle': '工作流套件·细分',
'agent-squad': '智能体编队',
meta: '元技能',
uncategorized: '未分类',
general: '通用',
// ===== 办公与经营 =====
office: '办公协同',
business: '商业职能',
'business-strategy': '商业战略',
strategy: '战略规划',
planning: '规划',
reporting: '报告输出',
documentation: '文档写作',
collaboration: '协作',
communication: '沟通表达',
productivity: '效率提升',
'project-management': '项目管理',
operations: '运营',
workflow: '工作流',
automation: '自动化',
// ===== 市场与增长 =====
marketing: '市场营销',
copywriting: '文案创作',
content: '内容创作',
writing: '写作',
growth: '增长',
sales: '销售',
pr: '公关传播',
media: '媒体',
ecommerce: '电商',
trade: '外贸',
'customer-service': '客户服务',
// ===== 行业 =====
finance: '金融财务',
legal: '法务',
compliance: '合规',
hr: '人力资源',
recruiting: '招聘',
healthcare: '医疗健康',
health: '健康',
education: '教育',
training: '培训',
government: '政务',
manufacturing: '制造业',
science: '科学研究',
it: 'IT 支持',
// ===== 研发 =====
development: '软件开发',
'web-development': 'Web 开发',
'game-development': '游戏开发',
frontend: '前端',
'front-end': '前端',
backend: '后端',
mobile: '移动端',
code: '编码',
'code-quality': '代码质量',
engineering: '工程实践',
architecture: '架构设计',
framework: '框架',
devops: 'DevOps',
cloud: '云服务',
testing: '测试',
'test-automation': '自动化测试',
quality: '质量保障',
security: '安全',
reliability: '可靠性',
database: '数据库',
'database-processing': '数据库处理',
'app-builder': '应用搭建',
'media-processing': '媒体处理',
'graphics-processing': '图形处理',
// ===== 数据与 AI =====
'ai-ml': 'AI 与机器学习',
'ai-agents': 'AI 智能体',
'agent-behavior': '智能体行为',
'data-ai': '数据与 AI',
data: '数据',
'data-science': '数据科学',
analytics: '数据分析',
analysis: '分析研判',
memory: '记忆管理',
// ===== 设计与产品 =====
design: '设计',
'design-it': '设计',
product: '产品',
'personal-development': '个人成长',
};
// 返回标签在指定语言下的展示名。
// language 取值 {zh, en}(与 NormalizeBrainLocale 同语义);en 界面直接
// 展示原始 slug——slug 本身就是英文,强行再造一套英文标题反而增加维护面。
export const skillTagLabel = (tag, language = 'zh') => {
if (language !== 'zh') return tag;
return SKILL_CATEGORY_ZH[tag] || tag;
};
export default SKILL_CATEGORY_ZH;
+26
View File
@@ -0,0 +1,26 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
export const toastConstants = {
SUCCESS_TIMEOUT: 1500,
INFO_TIMEOUT: 3000,
ERROR_TIMEOUT: 5000,
WARNING_TIMEOUT: 10000,
NOTICE_TIMEOUT: 20000,
};
+18
View File
@@ -0,0 +1,18 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
@@ -0,0 +1,83 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
// 提示词模板
export const PROMPT_TEMPLATES = [
{
label: '科幻场景',
prompt: '科幻未来城市,霓虹灯闪烁,飞行汽车穿梭,高楼林立,夜景壮观',
},
{
label: '动漫风格',
prompt: '动漫风格,可爱的角色,柔和的色彩,流畅的动作,日系画风',
},
{
label: '广告宣传',
prompt: '产品展示,专业摄影,简洁背景,商业质感,高端大气',
},
{
label: '自然风景',
prompt: '自然风景,山川湖海,阳光明媚,绿意盎然,宁静优美',
},
{
label: '纪录片',
prompt: '纪实风格,真实记录,专业拍摄,故事性强,画面稳定',
},
{
label: '运动镜头',
prompt: '运动镜头,快速移动,动感十足,追踪拍摄,流畅顺滑',
},
{
label: '慢镜头',
prompt: '慢动作,细节展现,优雅流畅,时间凝固,唯美浪漫',
},
{
label: '水下场景',
prompt: '水下世界,阳光穿透,色彩斑斓,鱼群游动,梦幻唯美',
},
];
// 默认表单数据
export const DEFAULT_FORM_DATA = {
mode: 'text2video', // text2video | image2video
selectedTemplate: '', // 选中的模板
prompt: '',
negative_prompt: '',
image: null,
imageFile: null,
resolution: '1080P',
duration: 5,
fps: 30,
ratio: '16:9',
audio: false,
seed: -1,
prompt_extend: false,
watermark: false,
};
// 视频状态 - 与后端保持一致(后端返回大写,前端统一转小写处理)
export const VIDEO_STATUS = {
QUEUED: 'queued',
IN_PROGRESS: 'in_progress',
SUCCESS: 'success', // 后端返回 'SUCCESS'
COMPLETED: 'completed', // 兼容
FAILURE: 'failure', // 后端返回 'FAILURE'
FAILED: 'failed', // 兼容
CANCELED: 'canceled',
};