chore: 全中文界面 + 中国区API (api.minimaxi.com)

This commit is contained in:
zwbcc
2026-03-25 23:53:02 +08:00
parent 2837bc1a85
commit aa48e293a3
2 changed files with 37 additions and 37 deletions

10
app.js
View File

@@ -19,7 +19,7 @@ function loadConfig() {
try {
return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
} catch {
return { apiKey: '', baseUrl: 'https://api.minimax.io' };
return { apiKey: '', baseUrl: 'https://api.minimaxi.com' };
}
}
@@ -48,7 +48,7 @@ app.get('/api/config', (req, res) => {
app.post('/api/config', (req, res) => {
const { apiKey, baseUrl } = req.body;
if (typeof apiKey !== 'string' || typeof baseUrl !== 'string') {
return res.status(400).json({ error: 'Invalid fields' });
return res.status(400).json({ error: '参数格式错误' });
}
const cfg = { apiKey: apiKey.trim(), baseUrl: baseUrl.trim() || 'https://api.minimax.io' };
saveConfig(cfg);
@@ -61,12 +61,12 @@ app.post('/api/generate', async (req, res) => {
const { prompt, aspect_ratio, model } = req.body;
if (!prompt || typeof prompt !== 'string' || !prompt.trim()) {
return res.status(400).json({ error: 'prompt is required' });
return res.status(400).json({ error: '请输入图片描述内容' });
}
const cfg = loadConfig();
if (!cfg.apiKey) {
return res.status(400).json({ error: 'API key not configured. Please set your MiniMax API key in settings.' });
return res.status(400).json({ error: '未配置 API Key,请先在设置中填写 MiniMax API Key' });
}
const baseUrl = cfg.baseUrl || 'https://api.minimax.io';
@@ -101,7 +101,7 @@ app.post('/api/generate', async (req, res) => {
res.json({ images });
} catch (err) {
console.error('[generate] error:', err.message);
res.status(500).json({ error: 'Failed to reach MiniMax API: ' + err.message });
res.status(500).json({ error: '无法连接 MiniMax API' + err.message });
}
});