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

feat:

parent d4c5cd1b
No preview for this file type
......@@ -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.
......@@ -20,10 +20,10 @@
border-style: dashed;
padding: 20px;
margin: 20px;
/*width: 500px; */
/*//border-radius: 20px;*/
/*//border-width: 2px;*/
/*//border-color: #000000;*/
width: 500px;
border-radius: 20px;
border-width: 2px;
border-color: #000000;
}
......
<div class="model-content">
<div style="padding: 10px;">
<div class="border" style="width: 800px;">
<div *ngFor="let question of item.questions; let i = index">
<div class="border" style="width: 700px;">
<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="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>
<button (click)="deleteQuestion(i);"> delete question</button>
</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;">
<span>文本: </span>
<input type="text" nz-input [(ngModel)]="item.text" (blur)="save()">
<button (click)="addQuestion();"> add question</button>
</div>
<div style="margin-top: 5px">
<span>音频: </span>
<!-- <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>
</div>
</div>
<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 { JsonPipe } from '@angular/common';
import {
Component,
EventEmitter,
Input,
OnDestroy,
OnChanges,
OnInit,
Output,
ApplicationRef,
ChangeDetectorRef,
} from "@angular/core";
@Component({
selector: 'app-form',
templateUrl: './form.component.html',
styleUrls: ['./form.component.css']
selector: "app-form",
templateUrl: "./form.component.html",
styleUrls: ["./form.component.css"],
})
export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用
saveKey = "test_001";
saveKey = "developer_test";
// 储存对象
item;
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();
}
constructor(
private appRef: ApplicationRef,
private changeDetectorRef: ChangeDetectorRef
) {}
ngOnInit() {
this.item = {};
this.item = {
questions: [],
};
// 获取存储的数据
(<any>window).courseware.getData((data) => {
if (data) {
this.item = data;
}
......@@ -48,27 +41,20 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}, this.saveKey);
}
ngOnChanges() {
}
ngOnDestroy() {
}
ngOnChanges() {}
init() {
}
ngOnDestroy() {}
init() {}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
this.item[key] = e.url;
this.save();
}
......@@ -77,18 +63,33 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url;
onAudioUploadSuccess(e, question) {
question.audio = e.url;
this.save();
}
onWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].audio = e.url;
addQuestion() {
this.item.questions.push({
text: "",
audio: "",
dragonBoneData: {
skeJsonData: {},
texJsonData: {},
texPngData: {},
},
});
this.save();
}
deleteQuestion(idx) {
this.item.questions.splice(idx, 1);
this.save();
}
onBackWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].backWordAudio = e.url;
saveAnima(event, data) {
data.skeJsonData = event.skeJsonData;
data.texJsonData = event.texJsonData;
data.texPngData = event.texPngData;
this.save();
}
......@@ -97,9 +98,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
*/
save() {
(<any>window).courseware.setData(this.item, null, this.saveKey);
console.log(JSON.stringify(this.item));
this.refresh();
console.log('this.item = ' + JSON.stringify(this.item));
}
/**
......@@ -110,5 +110,4 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.appRef.tick();
}, 1);
}
}
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