feat: 新增AI创作中心场景,支持改写/续写/创作
This commit is contained in:
@@ -144,4 +144,38 @@ export default class StoryManager {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AI续写故事
|
||||
*/
|
||||
async continueStory(storyId, prompt) {
|
||||
try {
|
||||
const result = await post(`/stories/${storyId}/continue`, {
|
||||
current_node_key: this.currentNodeKey,
|
||||
prompt: prompt
|
||||
});
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('AI续写失败:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AI创作新故事
|
||||
*/
|
||||
async createStory(params) {
|
||||
try {
|
||||
const result = await post('/stories/ai-create', {
|
||||
genre: params.genre,
|
||||
keywords: params.keywords,
|
||||
protagonist: params.protagonist,
|
||||
conflict: params.conflict
|
||||
});
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('AI创作失败:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,4 +131,40 @@ export default class UserManager {
|
||||
if (!this.isLoggedIn) return [];
|
||||
return await get('/user/collections', { userId: this.userId });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最近游玩的故事
|
||||
*/
|
||||
async getRecentPlayed() {
|
||||
if (!this.isLoggedIn) return [];
|
||||
try {
|
||||
return await get('/user/recent-played', { userId: this.userId, limit: 10 });
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取AI创作历史
|
||||
*/
|
||||
async getAIHistory() {
|
||||
if (!this.isLoggedIn) return [];
|
||||
try {
|
||||
return await get('/user/ai-history', { userId: this.userId, limit: 20 });
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取AI配额
|
||||
*/
|
||||
async getAIQuota() {
|
||||
if (!this.isLoggedIn) return { daily: 3, used: 0, purchased: 0 };
|
||||
try {
|
||||
return await get('/user/ai-quota', { userId: this.userId });
|
||||
} catch (e) {
|
||||
return { daily: 3, used: 0, purchased: 0 };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user