|
@@ -1,79 +1,97 @@
|
|
import { CommonModule } from '@angular/common';
|
|
import { CommonModule } from '@angular/common';
|
|
-import { Component, OnInit } from '@angular/core';
|
|
|
|
-import { IonicModule } from '@ionic/angular';
|
|
|
|
|
|
+import { Component, input, OnInit } from '@angular/core';
|
|
|
|
+import { Router } from '@angular/router';
|
|
|
|
+import { IonicModule, NavController } from '@ionic/angular';
|
|
import { addIcons } from 'ionicons';
|
|
import { addIcons } from 'ionicons';
|
|
-import { pause } from 'ionicons/icons';
|
|
|
|
-
|
|
|
|
|
|
+import { arrowBackOutline } from 'ionicons/icons';
|
|
|
|
+import { FormsModule } from '@angular/forms';
|
|
|
|
+addIcons({ 'arrow-back-outline':arrowBackOutline });
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-generate-option',
|
|
selector: 'app-generate-option',
|
|
templateUrl: './generate-option.component.html',
|
|
templateUrl: './generate-option.component.html',
|
|
styleUrls: ['./generate-option.component.scss'],
|
|
styleUrls: ['./generate-option.component.scss'],
|
|
standalone: true,
|
|
standalone: true,
|
|
- imports: [ IonicModule,CommonModule ],
|
|
|
|
|
|
+ imports: [IonicModule, CommonModule, FormsModule],
|
|
})
|
|
})
|
|
-export class GenerateOptionComponent implements OnInit {
|
|
|
|
-
|
|
|
|
|
|
+export class GenerateOptionComponent implements OnInit {
|
|
|
|
+ //构造器
|
|
|
|
+ constructor(private router:Router,private navCtrl:NavController) { }
|
|
|
|
+ //初始化
|
|
|
|
+ ngOnInit() {
|
|
|
|
+ }
|
|
|
|
+ //返回按钮事件
|
|
|
|
+ goBack() {
|
|
|
|
+ this.navCtrl.back();
|
|
|
|
+ }
|
|
|
|
+ //选项卡结构配置数据
|
|
cards = [
|
|
cards = [
|
|
{
|
|
{
|
|
- id: 'gender',
|
|
|
|
|
|
+ id: '性别',
|
|
chips: [
|
|
chips: [
|
|
- { id: 1, isElected: false ,label:'男'},
|
|
|
|
- { id: 2, isElected: false ,label:'女'},
|
|
|
|
|
|
+ { id: 1, isElected: false, label: '男' },
|
|
|
|
+ { id: 2, isElected: false, label: '女' },
|
|
],
|
|
],
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- id: 'season',
|
|
|
|
|
|
+ id: '季节',
|
|
chips: [
|
|
chips: [
|
|
- { id: 1, isElected: false ,label:'春季'},
|
|
|
|
- { id: 2, isElected: false ,label:'夏季'},
|
|
|
|
- { id: 3, isElected: false ,label:'秋季'},
|
|
|
|
- { id: 4, isElected: false ,label:'冬季'},
|
|
|
|
|
|
+ { id: 1, isElected: false, label: '春季' },
|
|
|
|
+ { id: 2, isElected: false, label: '夏季' },
|
|
|
|
+ { id: 3, isElected: false, label: '秋季' },
|
|
|
|
+ { id: 4, isElected: false, label: '冬季' },
|
|
],
|
|
],
|
|
},
|
|
},
|
|
];
|
|
];
|
|
-
|
|
|
|
-
|
|
|
|
- constructor() { }
|
|
|
|
-
|
|
|
|
- ngOnInit() {
|
|
|
|
- addIcons({pause})
|
|
|
|
|
|
+ //变量初始化
|
|
|
|
+ //性别
|
|
|
|
+ gender: string = '';
|
|
|
|
+ setGender(gender: string) {
|
|
|
|
+ this.gender = gender;
|
|
}
|
|
}
|
|
-
|
|
|
|
- toggleChip(cardId: string, chipId: number):void {
|
|
|
|
|
|
+ //季节
|
|
|
|
+ season: string = '';
|
|
|
|
+ setSeason(season: string) {
|
|
|
|
+ this.season = season;
|
|
|
|
+ }
|
|
|
|
+ //补充说明
|
|
|
|
+ suppleInput: string = '';
|
|
|
|
+ //用户提示词
|
|
|
|
+ userPrompt: string = '';
|
|
|
|
+ //点击选项卡事件
|
|
|
|
+ toggleChip(cardId: string, chipId: number): void {
|
|
this.cards.forEach((card) => {
|
|
this.cards.forEach((card) => {
|
|
if (card.id === cardId) {
|
|
if (card.id === cardId) {
|
|
card.chips.forEach((chip) => {
|
|
card.chips.forEach((chip) => {
|
|
chip.isElected = chip.id === chipId; // 当前点击的 chip 设为 active,其他设为 false
|
|
chip.isElected = chip.id === chipId; // 当前点击的 chip 设为 active,其他设为 false
|
|
-
|
|
|
|
|
|
+
|
|
});
|
|
});
|
|
switch (cardId) {
|
|
switch (cardId) {
|
|
- case 'gender':
|
|
|
|
- this.setGender(card.chips[chipId-1].label)
|
|
|
|
|
|
+ case '性别':
|
|
|
|
+ this.setGender(card.chips[chipId - 1].label)
|
|
break;
|
|
break;
|
|
- case 'season':
|
|
|
|
- this.setSeason(card.chips[chipId-1].label)
|
|
|
|
|
|
+ case '季节':
|
|
|
|
+ this.setSeason(card.chips[chipId - 1].label)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- //性别
|
|
|
|
- gender: string='';
|
|
|
|
- setGender(gender: string){
|
|
|
|
- this.gender = gender;
|
|
|
|
- }
|
|
|
|
- //季节
|
|
|
|
- season: string='';
|
|
|
|
- setSeason(season: string){
|
|
|
|
- this.season = season;
|
|
|
|
|
|
+ //生成传递提示词事件
|
|
|
|
+ sendMsg() {
|
|
|
|
+ this.userPrompt = "生成一位" + this.gender + "的" + this.season + "休闲穿搭图像,场景设定在公园的步道上。" +
|
|
|
|
+ "她穿着一件宽松的针织毛衣,搭配修身的黑色打底裤和白色运动鞋。配饰包括一条简约的手链和一顶时尚的帽子。" +
|
|
|
|
+ "背景是绿树成荫的公园,体现出轻松愉快的氛围。请注意色彩搭配和整体风格的协调。\n"+
|
|
|
|
+ "补充:"+this.suppleInput;
|
|
|
|
+ console.log(this.userPrompt)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ goGenerateResult() {
|
|
|
|
+ this.router.navigate(['/generate-result']);
|
|
|
|
+ }
|
|
|
|
|
|
- //生成结果
|
|
|
|
- generateResult(){
|
|
|
|
- console.log(this.gender)
|
|
|
|
- console.log(this.season)
|
|
|
|
- console.log("开始生成!")
|
|
|
|
|
|
+ sendMsgAndGoGenerateResult() {
|
|
|
|
+ this.sendMsg();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|