feat: 实装AI改写结局功能 - 接入DeepSeek API - AI动态生成新结局名称 - 新增rewrite类型结局样式 - 修复请求超时问题

This commit is contained in:
2026-03-05 15:57:51 +08:00
parent 89b5a3b658
commit d47ccd7039
11 changed files with 513 additions and 15 deletions

View File

@@ -10,20 +10,18 @@ const BASE_URL = 'http://localhost:3000/api';
*/
export function request(options) {
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
reject(new Error('请求超时'));
}, 5000);
const timeoutMs = options.timeout || 30000;
wx.request({
url: BASE_URL + options.url,
method: options.method || 'GET',
data: options.data || {},
timeout: timeoutMs,
header: {
'Content-Type': 'application/json',
...options.header
},
success(res) {
clearTimeout(timeout);
if (res.data.code === 0) {
resolve(res.data.data);
} else {
@@ -31,7 +29,6 @@ export function request(options) {
}
},
fail(err) {
clearTimeout(timeout);
reject(err);
}
});
@@ -48,8 +45,8 @@ export function get(url, data) {
/**
* POST请求
*/
export function post(url, data) {
return request({ url, method: 'POST', data });
export function post(url, data, options = {}) {
return request({ url, method: 'POST', data, ...options });
}
export default { request, get, post };