This commit is contained in:
Developer
2026-06-01 08:21:51 +08:00
parent bd083976c6
commit 287190a012
2 changed files with 109 additions and 77 deletions

View File

@@ -107,7 +107,7 @@ class ChatSession {
} }
} }
/// 系统会话ID常量与ChatSessionNotifier中保持一致 /// 系统会话ID常量唯一权威定义Provider层引用此处
class SystemSessionIds { class SystemSessionIds {
static const readlater = 'readlater'; static const readlater = 'readlater';
static const discover = 'discover'; static const discover = 'discover';
@@ -117,6 +117,7 @@ class SystemSessionIds {
static const readingReport = 'reading_report'; static const readingReport = 'reading_report';
static const weather = 'weather'; static const weather = 'weather';
static const poetry = 'poetry'; static const poetry = 'poetry';
static const countdown = 'countdown';
static const dailyFortune = 'daily_fortune'; static const dailyFortune = 'daily_fortune';
static const solarTerm = 'solar_term'; static const solarTerm = 'solar_term';
static const knowledgeGraph = 'knowledge_graph'; static const knowledgeGraph = 'knowledge_graph';
@@ -128,10 +129,24 @@ class SystemSessionIds {
static const leisure = 'leisure'; static const leisure = 'leisure';
static const all = { static const all = {
readlater, discover, footprint, dailyCard, template, readlater,
readingReport, weather, poetry, dailyFortune, solarTerm, discover,
knowledgeGraph, studyPlan, progress, fileTransfer, rssFeed, footprint,
translate, leisure, dailyCard,
template,
readingReport,
weather,
poetry,
countdown,
dailyFortune,
solarTerm,
knowledgeGraph,
studyPlan,
progress,
fileTransfer,
rssFeed,
translate,
leisure,
}; };
static bool isSystem(String id) => all.contains(id); static bool isSystem(String id) => all.contains(id);
@@ -163,47 +178,83 @@ extension ChatSessionL10n on ChatSession {
String? _resolveName(TDiscoverBase t) { String? _resolveName(TDiscoverBase t) {
switch (id) { switch (id) {
case SystemSessionIds.readlater: return t.sessionReadLater; case SystemSessionIds.readlater:
case SystemSessionIds.discover: return t.sessionInspiration; return t.sessionReadLater;
case SystemSessionIds.footprint: return t.sessionFootprint; case SystemSessionIds.discover:
case SystemSessionIds.dailyCard: return t.sessionDailyCard; return t.sessionInspiration;
case SystemSessionIds.template: return t.sessionTemplate; case SystemSessionIds.footprint:
case SystemSessionIds.readingReport: return t.sessionReadingReport; return t.sessionFootprint;
case SystemSessionIds.weather: return t.sessionWeather; case SystemSessionIds.dailyCard:
case SystemSessionIds.poetry: return t.sessionPoetry; return t.sessionDailyCard;
case SystemSessionIds.dailyFortune: return t.sessionDailyFortune; case SystemSessionIds.template:
case SystemSessionIds.solarTerm: return t.sessionSolarTerm; return t.sessionTemplate;
case SystemSessionIds.knowledgeGraph: return t.sessionKnowledgeGraph; case SystemSessionIds.readingReport:
case SystemSessionIds.studyPlan: return t.sessionStudyPlan; return t.sessionReadingReport;
case SystemSessionIds.progress: return t.sessionProgress; case SystemSessionIds.weather:
case SystemSessionIds.fileTransfer: return t.sessionFileTransfer; return t.sessionWeather;
case SystemSessionIds.rssFeed: return t.sessionRssFeed; case SystemSessionIds.poetry:
case SystemSessionIds.translate: return t.sessionTranslate; return t.sessionPoetry;
case SystemSessionIds.leisure: return t.sessionLeisure; case SystemSessionIds.dailyFortune:
default: return null; return t.sessionDailyFortune;
case SystemSessionIds.solarTerm:
return t.sessionSolarTerm;
case SystemSessionIds.knowledgeGraph:
return t.sessionKnowledgeGraph;
case SystemSessionIds.studyPlan:
return t.sessionStudyPlan;
case SystemSessionIds.progress:
return t.sessionProgress;
case SystemSessionIds.fileTransfer:
return t.sessionFileTransfer;
case SystemSessionIds.rssFeed:
return t.sessionRssFeed;
case SystemSessionIds.translate:
return t.sessionTranslate;
case SystemSessionIds.leisure:
return t.sessionLeisure;
default:
return null;
} }
} }
String? _resolveDesc(TDiscoverBase t) { String? _resolveDesc(TDiscoverBase t) {
switch (id) { switch (id) {
case SystemSessionIds.readlater: return t.sessionReadLaterDesc; case SystemSessionIds.readlater:
case SystemSessionIds.discover: return t.sessionInspirationDesc; return t.sessionReadLaterDesc;
case SystemSessionIds.footprint: return t.sessionFootprintDesc; case SystemSessionIds.discover:
case SystemSessionIds.dailyCard: return t.sessionDailyCardDesc; return t.sessionInspirationDesc;
case SystemSessionIds.template: return t.sessionTemplateDesc; case SystemSessionIds.footprint:
case SystemSessionIds.readingReport: return t.sessionReadingReportDesc; return t.sessionFootprintDesc;
case SystemSessionIds.weather: return t.sessionWeatherDesc; case SystemSessionIds.dailyCard:
case SystemSessionIds.poetry: return t.sessionPoetryDesc; return t.sessionDailyCardDesc;
case SystemSessionIds.dailyFortune: return t.sessionDailyFortuneDesc; case SystemSessionIds.template:
case SystemSessionIds.solarTerm: return t.sessionSolarTermDesc; return t.sessionTemplateDesc;
case SystemSessionIds.knowledgeGraph: return t.sessionKnowledgeGraphDesc; case SystemSessionIds.readingReport:
case SystemSessionIds.studyPlan: return t.sessionStudyPlanDesc; return t.sessionReadingReportDesc;
case SystemSessionIds.progress: return t.sessionProgressDesc; case SystemSessionIds.weather:
case SystemSessionIds.fileTransfer: return t.sessionFileTransferDesc; return t.sessionWeatherDesc;
case SystemSessionIds.rssFeed: return t.sessionRssFeedDesc; case SystemSessionIds.poetry:
case SystemSessionIds.translate: return t.sessionTranslateDesc; return t.sessionPoetryDesc;
case SystemSessionIds.leisure: return t.sessionLeisureDesc; case SystemSessionIds.dailyFortune:
default: return null; return t.sessionDailyFortuneDesc;
case SystemSessionIds.solarTerm:
return t.sessionSolarTermDesc;
case SystemSessionIds.knowledgeGraph:
return t.sessionKnowledgeGraphDesc;
case SystemSessionIds.studyPlan:
return t.sessionStudyPlanDesc;
case SystemSessionIds.progress:
return t.sessionProgressDesc;
case SystemSessionIds.fileTransfer:
return t.sessionFileTransferDesc;
case SystemSessionIds.rssFeed:
return t.sessionRssFeedDesc;
case SystemSessionIds.translate:
return t.sessionTranslateDesc;
case SystemSessionIds.leisure:
return t.sessionLeisureDesc;
default:
return null;
} }
} }
} }

View File

@@ -110,25 +110,6 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
static const _sessionsKey = 'chat_sessions_remarks'; static const _sessionsKey = 'chat_sessions_remarks';
static const _sessionTimeKey = 'chat_sessions_last_time'; static const _sessionTimeKey = 'chat_sessions_last_time';
static const kSessionReadlater = 'readlater';
static const kSessionDiscover = 'discover';
static const kSessionFootprint = 'footprint';
static const kSessionDailyCard = 'daily_card';
static const kSessionTemplate = 'template';
static const kSessionReadingReport = 'reading_report';
static const kSessionWeather = 'weather';
static const kSessionPoetry = 'poetry';
static const kSessionCountdown = 'countdown';
static const kSessionDailyFortune = 'daily_fortune';
static const kSessionSolarTerm = 'solar_term';
static const kSessionKnowledgeGraph = 'knowledge_graph';
static const kSessionStudyPlan = 'study_plan';
static const kSessionProgress = 'progress';
static const kSessionFileTransfer = 'file_transfer';
static const kSessionRssFeed = 'rss_feed';
static const kSessionTranslate = 'translate';
static const kSessionLeisure = 'leisure';
Future<void> _init() async { Future<void> _init() async {
await _buildSessions(); await _buildSessions();
_loadRemarks(); _loadRemarks();
@@ -141,7 +122,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
final systemSessions = <ChatSession>[ final systemSessions = <ChatSession>[
ChatSession( ChatSession(
id: kSessionReadlater, id: SystemSessionIds.readlater,
type: ChatSessionType.readlater, type: ChatSessionType.readlater,
emoji: '📖', emoji: '📖',
name: '稍后读', name: '稍后读',
@@ -153,7 +134,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/readlater-chat', route: '/readlater-chat',
), ),
ChatSession( ChatSession(
id: kSessionDiscover, id: SystemSessionIds.discover,
type: ChatSessionType.discover, type: ChatSessionType.discover,
emoji: '🔍', emoji: '🔍',
name: '灵感', name: '灵感',
@@ -164,7 +145,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: 'discover', route: 'discover',
), ),
ChatSession( ChatSession(
id: kSessionFootprint, id: SystemSessionIds.footprint,
type: ChatSessionType.footprint, type: ChatSessionType.footprint,
emoji: '👣', emoji: '👣',
name: '足迹', name: '足迹',
@@ -174,7 +155,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: 'footprint', route: 'footprint',
), ),
ChatSession( ChatSession(
id: kSessionDailyCard, id: SystemSessionIds.dailyCard,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '📅', emoji: '📅',
name: '日签卡片', name: '日签卡片',
@@ -184,7 +165,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/daily-card', route: '/daily-card',
), ),
ChatSession( ChatSession(
id: kSessionTemplate, id: SystemSessionIds.template,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '🎨', emoji: '🎨',
name: '壁纸模板', name: '壁纸模板',
@@ -194,7 +175,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/template-gallery', route: '/template-gallery',
), ),
ChatSession( ChatSession(
id: kSessionReadingReport, id: SystemSessionIds.readingReport,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '📊', emoji: '📊',
name: '阅读报告', name: '阅读报告',
@@ -204,7 +185,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/reading-report', route: '/reading-report',
), ),
ChatSession( ChatSession(
id: kSessionWeather, id: SystemSessionIds.weather,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '🌤️', emoji: '🌤️',
name: '情景诗词', name: '情景诗词',
@@ -214,7 +195,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/weather', route: '/weather',
), ),
ChatSession( ChatSession(
id: kSessionPoetry, id: SystemSessionIds.poetry,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '📜', emoji: '📜',
name: '今日诗词', name: '今日诗词',
@@ -224,7 +205,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/poetry', route: '/poetry',
), ),
ChatSession( ChatSession(
id: kSessionDailyFortune, id: SystemSessionIds.dailyFortune,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '🔮', emoji: '🔮',
name: '每日运势', name: '每日运势',
@@ -234,7 +215,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/daily-fortune', route: '/daily-fortune',
), ),
ChatSession( ChatSession(
id: kSessionSolarTerm, id: SystemSessionIds.solarTerm,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '🌿', emoji: '🌿',
name: '节气日历', name: '节气日历',
@@ -244,7 +225,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/solar-term', route: '/solar-term',
), ),
ChatSession( ChatSession(
id: kSessionKnowledgeGraph, id: SystemSessionIds.knowledgeGraph,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '🕸️', emoji: '🕸️',
name: '知识图谱', name: '知识图谱',
@@ -254,7 +235,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/knowledge-graph', route: '/knowledge-graph',
), ),
ChatSession( ChatSession(
id: kSessionStudyPlan, id: SystemSessionIds.studyPlan,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '📚', emoji: '📚',
name: '学习计划', name: '学习计划',
@@ -264,7 +245,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/study-plan', route: '/study-plan',
), ),
ChatSession( ChatSession(
id: kSessionProgress, id: SystemSessionIds.progress,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '📊', emoji: '📊',
name: '进度', name: '进度',
@@ -274,7 +255,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/progress', route: '/progress',
), ),
ChatSession( ChatSession(
id: kSessionFileTransfer, id: SystemSessionIds.fileTransfer,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '📁', emoji: '📁',
name: '文件传输助手', name: '文件传输助手',
@@ -284,7 +265,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/file-transfer', route: '/file-transfer',
), ),
ChatSession( ChatSession(
id: kSessionRssFeed, id: SystemSessionIds.rssFeed,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '📡', emoji: '📡',
name: 'RSS流', name: 'RSS流',
@@ -294,7 +275,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/rss-feed', route: '/rss-feed',
), ),
ChatSession( ChatSession(
id: kSessionTranslate, id: SystemSessionIds.translate,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '🌐', emoji: '🌐',
name: '翻译助手', name: '翻译助手',
@@ -305,7 +286,7 @@ class ChatSessionNotifier extends Notifier<ChatSessionState>
route: '/translate', route: '/translate',
), ),
ChatSession( ChatSession(
id: kSessionLeisure, id: SystemSessionIds.leisure,
type: ChatSessionType.custom, type: ChatSessionType.custom,
emoji: '🌸', emoji: '🌸',
name: '闲情逸致', name: '闲情逸致',