12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import { Component, OnInit } from '@angular/core';
- import { Router } from '@angular/router';
- import { CloudObject, CloudQuery, CloudUser } from '../lib/ncloud';
- import { IonHeader, IonToolbar, IonTitle, IonContent, IonButton,IonIcon, ModalController, IonTextarea, IonInput, IonCard, IonCardHeader, IonCardTitle, IonThumbnail, IonCardContent, IonCardSubtitle, IonItem, IonList, IonLabel, IonAvatar, IonSelect, IonSelectOption, AlertController, IonButtons, IonProgressBar, IonText } from '@ionic/angular/standalone';
- import { CommonModule } from '@angular/common';
- import { AvatarModule, ChatPanelOptions, DalleOptions, FmodeChat, FmodeChatCompletion, FmodeChatMessage, ImagineWork, openChatPanelModal } from 'fmode-ng';
- import { CompUploaderHwobsComponent } from '../comp-uploader-hwobs/comp-uploader-hwobs.component';
- @Component({
- selector: 'app-atest',
- templateUrl: './atest.page.html',
- styleUrls: ['./atest.page.scss'],
- standalone: true,
- imports: [
- IonHeader, IonToolbar, IonTitle, IonContent, IonButton,IonTextarea,IonInput,
- IonIcon,IonCard,IonCardHeader,IonCardTitle,
- IonCardSubtitle,IonCardContent, IonThumbnail, IonItem,IonList,CommonModule,IonLabel,
- IonAvatar, IonSelect, IonSelectOption,IonButtons,IonProgressBar,
- IonText, IonCardHeader, IonCardSubtitle,CompUploaderHwobsComponent
- ]
- })
- export class AtestPage implements OnInit {
- currentUser: CloudUser;
- constructor(
- private modalCtrl:ModalController,
- private router:Router,
- private alertController: AlertController,
- ) {
- this.currentUser = new CloudUser();
- // 示例任务,自己生成图片后请存储新的ID
- }
- images:Array<string> = []
- back:string = "<";
- backhome() {
- this.router.navigate(['/tab1']);
- }
- ngOnInit() {
- }
- name: string = ''
- nameInput(e:any) {
- this.name = e.detail.value;
- }
- // 上传组件
- uploadUrl:string = ""
- onUrlChange(ev:any){
- console.log(ev);
- this.uploadUrl=ev;
- }
- age: number = 25
- ageInput(e:any) {
- this.age = e.detail.value;
- }
- gender: string = 'male'
- genderChange(e:any) {
- this.gender = e.detail.value;}
- genderCancel(){}
- genderDismiss(){}
- desc: string = ''
- descInput(e:any) {
- this.desc = e.detail.value;}
- PictureDescResult:string = `` // 画面描述结果
- isConsultSet: boolean = false;
- async createAgent() {
- // localStorage.setItem("company","E4KpGvTEto")
- let consult = new CloudObject("test")
- let now = new Date();
- let dateStr = `${now.getFullYear()}-${now.getMonth()+1}-${now.getDate()}`
- // 对象权限的精确指定
- let completion = new FmodeChatCompletion([
- {role:"system",content:""},
- ])
-
- completion.sendCompletion().subscribe((message:any)=>{
- // 打印消息体
- console.log(message.content)
- // 赋值消息内容给组件内属性
- if (message?.complete && !this.isConsultSet) {
- this.isConsultSet = true; // 标记为已设置
-
- consult.set({
- name: `${this.name}`,
- age: `${this.age}`,
- gender: `${this.gender}`,
- desc: `${this.desc}`,
- user: this.currentUser.toPointer(),
- avatar: this.uploadUrl
- });
- consult.save();
- console.log(consult);
- }
- })
-
-
- }
- }
|