|
@@ -0,0 +1,172 @@
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
+import {
|
|
|
+ IonHeader,
|
|
|
+ IonToolbar,
|
|
|
+ IonTitle,
|
|
|
+ IonContent,
|
|
|
+ IonButtons,
|
|
|
+ IonButton,
|
|
|
+ IonIcon,
|
|
|
+ IonTextarea,
|
|
|
+ IonSpinner,
|
|
|
+ IonBadge,
|
|
|
+ NavController
|
|
|
+} from '@ionic/angular/standalone';
|
|
|
+import { addIcons } from 'ionicons';
|
|
|
+import { sparkles, bulbOutline, starOutline, arrowBack, closeOutline } from 'ionicons/icons';
|
|
|
+import { FormsModule } from '@angular/forms';
|
|
|
+import { CommonModule } from '@angular/common';
|
|
|
+import { RouterModule } from '@angular/router';
|
|
|
+import { Observable } from 'rxjs';
|
|
|
+
|
|
|
+// 模拟的 FmodeChatCompletion 类
|
|
|
+class FmodeChatCompletion {
|
|
|
+ constructor(private messages: any[]) {}
|
|
|
+
|
|
|
+ sendCompletion() {
|
|
|
+ return new Observable(observer => {
|
|
|
+ setTimeout(() => {
|
|
|
+ observer.next({
|
|
|
+ content: `## 智能日程安排建议 🌟
|
|
|
+
|
|
|
+**根据您的需求,我为您创建了一个高效的日程安排:**
|
|
|
+
|
|
|
+1. **上午 8:30-9:00** - 晨间规划
|
|
|
+ - 回顾今日目标
|
|
|
+ - 整理待办事项
|
|
|
+
|
|
|
+2. **上午 9:00-10:30** - 深度工作时段
|
|
|
+ - 专注处理核心任务
|
|
|
+ - 避免会议和干扰
|
|
|
+
|
|
|
+3. **上午 10:30-11:00** - 休息与恢复
|
|
|
+ - 短暂休息
|
|
|
+ - 补充水分
|
|
|
+
|
|
|
+4. **上午 11:00-12:30** - 会议与协作
|
|
|
+ - 团队同步会议
|
|
|
+ - 项目讨论
|
|
|
+
|
|
|
+5. **下午 12:30-13:30** - 午餐与休息
|
|
|
+ - 健康饮食
|
|
|
+ - 短暂散步
|
|
|
+
|
|
|
+6. **下午 13:30-15:30** - 创意工作时段
|
|
|
+ - 脑力激荡
|
|
|
+ - 创新项目开发
|
|
|
+
|
|
|
+7. **下午 15:30-16:00** - 茶歇与放松
|
|
|
+ - 伸展运动
|
|
|
+ - 整理思绪
|
|
|
+
|
|
|
+8. **下午 16:00-18:00** - 执行与收尾
|
|
|
+ - 完成当日任务
|
|
|
+ - 准备次日计划
|
|
|
+
|
|
|
+**建议调整:**
|
|
|
+- 每工作50分钟休息10分钟
|
|
|
+- 优先处理高价值任务
|
|
|
+- 保持工作与休息的平衡`,
|
|
|
+ complete: true
|
|
|
+ });
|
|
|
+ observer.complete();
|
|
|
+ }, 2000);
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'app-ai-assistant',
|
|
|
+ templateUrl: './ai-assistant.page.html',
|
|
|
+ styleUrls: ['./ai-assistant.page.scss'],
|
|
|
+ standalone: true,
|
|
|
+ imports: [
|
|
|
+ IonHeader,
|
|
|
+ IonToolbar,
|
|
|
+ IonTitle,
|
|
|
+ IonContent,
|
|
|
+ IonButtons,
|
|
|
+ IonButton,
|
|
|
+ IonIcon,
|
|
|
+ IonTextarea,
|
|
|
+ IonSpinner,
|
|
|
+ IonBadge,
|
|
|
+ FormsModule,
|
|
|
+ CommonModule,
|
|
|
+ RouterModule
|
|
|
+ ]
|
|
|
+})
|
|
|
+export class AiAssistantPage implements OnInit {
|
|
|
+ aiContent: string = "正在分析您的日程需求,请稍候...";
|
|
|
+ userInput: string = '';
|
|
|
+ isLoading: boolean = true;
|
|
|
+ suggestions: string[] = [
|
|
|
+ "帮我规划一个高效的工作日安排",
|
|
|
+ "创建包含会议、开发和休息的日程",
|
|
|
+ "设计一个平衡工作和生活的日程表",
|
|
|
+ "为明天的重要会议做日程规划"
|
|
|
+ ];
|
|
|
+
|
|
|
+ constructor(private navCtrl: NavController) {
|
|
|
+ addIcons({
|
|
|
+ sparkles,
|
|
|
+ bulbOutline,
|
|
|
+ starOutline,
|
|
|
+ arrowBack,
|
|
|
+ closeOutline
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ ngOnInit() {
|
|
|
+ this.getAIMessage();
|
|
|
+ }
|
|
|
+
|
|
|
+ goBack() {
|
|
|
+ // 使用NavController进行导航返回
|
|
|
+ this.navCtrl.back();
|
|
|
+ }
|
|
|
+
|
|
|
+ useSuggestion(suggestion: string) {
|
|
|
+ this.userInput = suggestion;
|
|
|
+ this.getAIMessage();
|
|
|
+ }
|
|
|
+
|
|
|
+ getAIMessage() {
|
|
|
+ this.isLoading = true;
|
|
|
+ this.aiContent = "正在为您生成智能日程建议...";
|
|
|
+
|
|
|
+ let now = new Date();
|
|
|
+ let timeParams = `当前时间:${now.toLocaleString()}`;
|
|
|
+
|
|
|
+ const PromptTemplate = `你是一个专业的日程规划助手,用户正在制定日程安排。
|
|
|
+ 请根据以下信息为用户创建一个合理、高效的日程计划:
|
|
|
+ ${this.userInput || "用户未提供具体信息,请创建一个通用的高效工作日安排"}
|
|
|
+
|
|
|
+ 要求:
|
|
|
+ 1. 包含6-8个时间段
|
|
|
+ 2. 每个时间段有明确的任务和时长
|
|
|
+ 3. 合理安排工作、休息和用餐时间
|
|
|
+ 4. 使用Markdown格式返回
|
|
|
+ `;
|
|
|
+
|
|
|
+ const completion = new FmodeChatCompletion([
|
|
|
+ {role: "system", content: timeParams},
|
|
|
+ {role: "user", content: PromptTemplate}
|
|
|
+ ]);
|
|
|
+
|
|
|
+ completion.sendCompletion().subscribe({
|
|
|
+ next: (message: any) => {
|
|
|
+ if (message.content) {
|
|
|
+ this.aiContent = message.content;
|
|
|
+ }
|
|
|
+ if (message.complete) {
|
|
|
+ this.isLoading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: () => {
|
|
|
+ this.aiContent = "无法连接到AI服务,请稍后再试";
|
|
|
+ this.isLoading = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|