Commit c3c69987 authored by 范雪寒's avatar 范雪寒

feat:

parent d4c5cd1b
No preview for this file type
...@@ -128,5 +128,8 @@ ...@@ -128,5 +128,8 @@
} }
} }
}, },
"defaultProject": "ng-template-generator" "defaultProject": "ng-template-generator",
} "cli": {
"analytics": false
}
}
\ No newline at end of file
This diff is collapsed.
...@@ -55,4 +55,4 @@ ...@@ -55,4 +55,4 @@
"tslint": "~5.18.0", "tslint": "~5.18.0",
"typescript": "~3.7.5" "typescript": "~3.7.5"
} }
} }
\ No newline at end of file
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
border-style: dashed; border-style: dashed;
padding: 20px; padding: 20px;
margin: 20px; margin: 20px;
/*width: 500px; */ width: 500px;
/*//border-radius: 20px;*/ border-radius: 20px;
/*//border-width: 2px;*/ border-width: 2px;
/*//border-color: #000000;*/ border-color: #000000;
} }
......
<div class="model-content"> <div class="model-content">
<div style="padding: 10px;">
<div style="width: 300px;" align='center'>
<span>图1: </span>
<app-upload-image-with-preview
[picUrl]="item.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url')">
</app-upload-image-with-preview>
</div>
<div style="width: 300px; margin-top: 5px;" align='center'>
<span>图2: </span>
<app-upload-image-with-preview
[picUrl]="item.pic_url_2"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url_2')">
</app-upload-image-with-preview>
</div>
<div style="width: 300px; margin-top: 15px;"> <div class="border" style="width: 800px;">
<span>文本: </span> <div *ngFor="let question of item.questions; let i = index">
<input type="text" nz-input [(ngModel)]="item.text" (blur)="save()"> <div class="border" style="width: 700px;">
</div> <span style="font-size: 20px;">第{{i + 1}}题:</span>
<br>
<input type="text" style="width: 200px;" nz-input [(ngModel)]="question.text" (blur)="save()">
<app-audio-recorder [audioUrl]="question.audio" (audioUploaded)="onAudioUploadSuccess($event, question)">
</app-audio-recorder>
<app-upload-dragon-bone [btnName]="[['配置骨骼动画']]" [animaNames]="[[['normal']]]"
[skeJsonData]=question.dragonBoneData.skeJsonData [texJsonData]=question.dragonBoneData.texJsonData
[texPngData]=question.dragonBoneData.texPngData (save)="saveAnima($event, question.dragonBoneData)"
(refreshEmitter)="refresh()">
</app-upload-dragon-bone>
<div style="margin-top: 5px"> <button (click)="deleteQuestion(i);"> delete question</button>
<span>音频: </span> </div>
<app-audio-recorder
[audioUrl]="item.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')"
></app-audio-recorder>
</div> </div>
<button (click)="addQuestion();"> add question</button>
</div> </div>
</div>
<!-- <div style="position: absolute; left: 200px; top: 100px; width: 800px;">
<input type="text" nz-input [(ngModel)]="item.text" (blur)="save()">
<app-upload-image-with-preview
[picUrl]="item.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url')"
></app-upload-image-with-preview>
<app-audio-recorder
[audioUrl]="item.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')"
></app-audio-recorder>
<app-custom-hot-zone></app-custom-hot-zone>
<app-upload-video></app-upload-video>
<app-lesson-title-config></app-lesson-title-config>
</div> -->
</div>
\ No newline at end of file
import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core'; import {
import { JsonPipe } from '@angular/common'; Component,
EventEmitter,
Input,
OnDestroy,
OnChanges,
OnInit,
Output,
ApplicationRef,
ChangeDetectorRef,
} from "@angular/core";
@Component({ @Component({
selector: 'app-form', selector: "app-form",
templateUrl: './form.component.html', templateUrl: "./form.component.html",
styleUrls: ['./form.component.css'] styleUrls: ["./form.component.css"],
}) })
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "test_001"; saveKey = "developer_test";
// 储存对象 // 储存对象
item; item;
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) { constructor(
private appRef: ApplicationRef,
} private changeDetectorRef: ChangeDetectorRef
) {}
createShell() {
this.item.wordList.push({
word: '',
audio: '',
backWord: '',
backWordAudio: '',
});
this.save();
}
removeShell(idx) {
this.item.wordList.splice(idx, 1);
this.save();
}
ngOnInit() { ngOnInit() {
this.item = {
this.item = {}; questions: [],
};
// 获取存储的数据 // 获取存储的数据
(<any>window).courseware.getData((data) => { (<any>window).courseware.getData((data) => {
if (data) { if (data) {
this.item = data; this.item = data;
} }
...@@ -48,27 +41,20 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -48,27 +41,20 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges(); this.changeDetectorRef.detectChanges();
this.refresh(); this.refresh();
}, this.saveKey); }, this.saveKey);
} }
ngOnChanges() { ngOnChanges() {}
}
ngOnDestroy() {
}
init() { ngOnDestroy() {}
}
init() {}
/** /**
* 储存图片数据 * 储存图片数据
* @param e * @param e
*/ */
onImageUploadSuccess(e, key) { onImageUploadSuccess(e, key) {
this.item[key] = e.url; this.item[key] = e.url;
this.save(); this.save();
} }
...@@ -77,18 +63,33 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -77,18 +63,33 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存音频数据 * 储存音频数据
* @param e * @param e
*/ */
onAudioUploadSuccess(e, key) { onAudioUploadSuccess(e, question) {
this.item[key] = e.url; question.audio = e.url;
this.save(); this.save();
} }
onWordAudioUploadSuccess(e, idx) { addQuestion() {
this.item.wordList[idx].audio = e.url; this.item.questions.push({
text: "",
audio: "",
dragonBoneData: {
skeJsonData: {},
texJsonData: {},
texPngData: {},
},
});
this.save();
}
deleteQuestion(idx) {
this.item.questions.splice(idx, 1);
this.save(); this.save();
} }
onBackWordAudioUploadSuccess(e, idx) { saveAnima(event, data) {
this.item.wordList[idx].backWordAudio = e.url; data.skeJsonData = event.skeJsonData;
data.texJsonData = event.texJsonData;
data.texPngData = event.texPngData;
this.save(); this.save();
} }
...@@ -97,9 +98,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -97,9 +98,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
*/ */
save() { save() {
(<any>window).courseware.setData(this.item, null, this.saveKey); (<any>window).courseware.setData(this.item, null, this.saveKey);
console.log(JSON.stringify(this.item));
this.refresh(); this.refresh();
console.log('this.item = ' + JSON.stringify(this.item));
} }
/** /**
...@@ -110,5 +110,4 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -110,5 +110,4 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.appRef.tick(); this.appRef.tick();
}, 1); }, 1);
} }
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment