Commit e94703df authored by starry_sky's avatar starry_sky

new

parent a0067027
......@@ -80,7 +80,6 @@ const runSpawn = async function (){
console.log(err);
reject();
}
console.log(files);
for(let i=0;i<files.length;i++){
tarStream.addEntry(zippath+"/"+files[i]);
}
......
......@@ -4,10 +4,16 @@
<h2>
标题
</h2>
<p style="margin: 5px 0;">标题:</p>
<input class="input_button" type="text" [(ngModel)]="item.contentObj.title.text" (ngModelChange)="save()">
<p style="margin: 5px 0;">题号:</p>
<input style="width: 100px;" type="text" [(ngModel)]="item.contentObj.title.number" (ngModelChange)="save()">
<div style="display: flex;position: relative;">
<div style="width: 30%;">
<p style="margin: 5px 0;">题号:</p>
<input style="width: 50%;" type="text" [(ngModel)]="item.contentObj.title.number" (ngModelChange)="save()">
</div>
<div style="width: 60%;position: absolute;right: 20px;">
<p style="margin: 5px 0;">标题:</p>
<input class="input_button" type="text" [(ngModel)]="item.contentObj.title.text" (ngModelChange)="save()">
</div>
</div>
<p style="margin: 5px 0;">标题-音频:</p>
<app-audio-recorder class="audio_load"
[audioUrl]="item.contentObj.title.audio_url"
......@@ -24,7 +30,7 @@
</div>
<div class="upload_items">
<div class="upload_items" (click)="save()">
<div class="load_values_item" *ngFor="let value of values; let i = index" style="display: block;">
<h3>第{{i + 1}}句</h3>
......@@ -34,15 +40,15 @@
<label nz-radio nzValue="false"></label>
</nz-radio-group>
<p style="margin: 5px 0;">句子文本</p>
<input class="input_button" type="text" [(ngModel)]="value.text" (ngModelChange)="sentence_handle(i)">
<input class="input_button" type="text" [(ngModel)]="value.text" (click)="save()" (ngModelChange)="sentence_handle(i)">
<p style="margin: 5px 0;">答案</p>
<nz-select nzMode="multiple" nzShowSearch nzAllowClear nzPlaceHolder="输入可快速查询" [(ngModel)]="value.answer" (ngModelChange)= "sentence_handle(i)">
<nz-select nzMode="multiple" nzShowSearch nzAllowClear nzPlaceHolder="输入可快速查询" [(ngModel)]="value.answer" (ngModelChange)= "sentence_handle(i)" (click)="save()">
<div *ngFor="let text of value.word;let j = index">
<nz-option [nzValue]="j" [nzLabel]= "j+1+ '-' + value.word[j]"></nz-option>
<nz-option [nzValue]="j" [nzLabel]= "j+1+ '-' + value.word[j]" (click)="save()"></nz-option>
</div>
</nz-select>
<p style="margin: 5px 0;">答案颜色</p>
<nz-select [(ngModel)]="value.answer_color" (ngModelChange)="save()">
<nz-select [(ngModel)]="value.answer_color" (ngModelChange)="save()" (click)="save()" >
<nz-option nzValue="C6161E" nzLabel="红色"></nz-option>
<nz-option nzValue="BACF41" nzLabel="绿色"></nz-option>
<nz-option nzValue="6D3E21" nzLabel="巧克力色"></nz-option>
......@@ -53,12 +59,14 @@
<app-audio-recorder
[audioUrl]="value.audio_url"
(audioUploaded)="onAudioUploadSuccessByItem($event, value)"
(click)="save()"
>
</app-audio-recorder>
<h5 style="margin-top: 10px;margin-bottom: 10px;">图片</h5>
<app-upload-image-with-preview class="img_load"
[picUrl]="value.img_url"
(imageUploaded)="onImageUploadSuccessByItem($event, value)"
(click)="save()"
></app-upload-image-with-preview>
<button style="margin-left: 10px;" class="button_remove" nz-button nzType="danger" (click)="deleteValue(value)">
......
......@@ -16,7 +16,7 @@ nz-select{
.body{
background-color: #C2D9FF;
height: 1200px;
min-height: 1000px
}
input{
......@@ -32,7 +32,7 @@ input{
width: 80%;
margin: 0 auto;
min-width: 1200px;
// min-width: 1200px;
padding-top: 20px;
.gruop_load{
......@@ -40,7 +40,7 @@ input{
}
.title{
width: 800px;
width: 80%;
background-color: #ffffff;
padding: 30px;
border-radius: 10px;
......@@ -48,18 +48,34 @@ input{
box-shadow: 5px 5px 10px #9DC3F1;
position: relative;
}
.button_add{
border: 2px solid #ddd;
margin: 20px;
width: 200px;
height: 100px;
border-radius: 5px;
background-color: #fafafa;
outline: none;
position: absolute;
right :50px;
top: 150px;
@media screen and (max-width: 760px){
.button_add{
border: 2px solid #ddd;
margin: 20px;
width: 100px;
height: 80px;
border-radius: 5px;
background-color: #fafafa;
font-size: 12px;
outline: none;
position: absolute;
right :50px;
top: 150px;
}
}
@media screen and (min-width: 760px){
.button_add{
border: 2px solid #ddd;
margin: 20px;
width: 200px;
height: 100px;
border-radius: 5px;
background-color: #fafafa;
outline: none;
position: absolute;
right :50px;
top: 150px;
}
}
}
......@@ -68,12 +84,15 @@ input{
display: flex;
flex-wrap: wrap;
margin-top: 20px;
justify-content: center;
.load_values_item{
border-radius: 10px;
width: 24%;
min-width: 300px;
padding: 30px;
margin: 0 0.5%;
margin-bottom: 20px;
box-sizing: border-box;
position: relative;
box-shadow: 5px 5px 20px #9DC3F1;
......
......@@ -12,6 +12,10 @@
}
@font-face {
font-family: 'MMTextBook-Bold';
src: url("../../assets/font/MMTextBook-Bold.otf");
}
@font-face
{
......@@ -19,3 +23,8 @@
src: url("../../assets/font/BRLNSDB.TTF") ;
}
@font-face
{
font-family: 'FUTURAB';
src: url("../../assets/font/FUTURAB.TTF") ;
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ import {
} from './Unit';
import {res, resAudio} from './resources';
import {Subject} from 'rxjs';
import {Subject, of} from 'rxjs';
import {debounceTime} from 'rxjs/operators';
import * as _ from 'lodash';
......@@ -25,6 +25,7 @@ import { THIS_EXPR } from '@angular/compiler/src/output/output_ast';
selector: 'app-play',
templateUrl: './play.component.html',
styleUrls: ['./play.component.scss']
})
export class PlayComponent implements OnInit, OnDestroy {
// 数据
......@@ -49,6 +50,8 @@ export class PlayComponent implements OnInit, OnDestroy {
mx;
my;
init_bool = true;
values_bool = [0,0,0,0];
//按钮
......@@ -60,6 +63,8 @@ export class PlayComponent implements OnInit, OnDestroy {
play_button;
label_title_top_bg;
audio_bool = false;
@ViewChild('canvas') canvas: ElementRef;
@ViewChild('wrap') wrap: ElementRef;
canvasWidth = 1280;
......@@ -99,6 +104,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
initListener() {
this.renderAfterResize();
this.winResizeEventStream
.pipe(debounceTime(500))
......@@ -211,7 +217,6 @@ export class PlayComponent implements OnInit, OnDestroy {
}
initDefaultData() {
console.log(this.data);
if ( !this.data.contentObj ) {
this.data.contentObj = {};
......@@ -395,7 +400,7 @@ export class PlayComponent implements OnInit, OnDestroy {
const getData = (<any> window).courseware.getData;
getData((data) => {
getData((data) => {
if (data && typeof data == 'object') {
this.data = data;
} else {
......@@ -407,6 +412,9 @@ export class PlayComponent implements OnInit, OnDestroy {
this.load_date();
this.initAudio();
this.initListener();
// this.initView();
}, this.KEY);
}
......@@ -470,9 +478,24 @@ export class PlayComponent implements OnInit, OnDestroy {
}
playAudio(key, now = false, callback = null) {
playAudio_init(){
for(let i = 0; i < this.data.contentObj.values.length;i++){
if(this.data.contentObj.values[i].audio_url){
let audio = this.audioObj[this.data.contentObj.values[i].audio_url];
audio.pause();
audio.currentTime = 0;
}
}
if(this.data.contentObj.title.audio_url)
{
let audio = this.audioObj[this.data.contentObj.title.audio_url];
audio.pause();
audio.currentTime = 0;
}
}
playAudio(key, now = false, callback = null) {
this.playAudio_init();
const audio = this.audioObj[key];
if (audio) {
if (now) {
......@@ -486,18 +509,20 @@ export class PlayComponent implements OnInit, OnDestroy {
};
}
audio.play();
}
console.log(this.audioObj);
}
playAudio_ps(bool,key){
const audio = this.audioObj[key];
if(!bool){
audio.currentTime = this.currentTime;
this.play_button.init(this.images.get('stop'));
audio.play();
this.play_button_bool = !bool;
}
else{
audio.pause();
......@@ -521,7 +546,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.initView();
window["air"].hideAirClassLoading("hw_006",this.data);
window["air"].hideAirClassLoading("hw_024",this.data);
}
......@@ -531,8 +556,9 @@ export class PlayComponent implements OnInit, OnDestroy {
this.canvas.nativeElement.width = this.canvasWidth;
this.canvas.nativeElement.height = this.canvasHeight;
window['curCtx'] = this.ctx;
this.ctx.font="64px MMTextBook-Bold";
window['curCtx'] = this.ctx;
}
addBlanks(item,text_value,as_v){
......@@ -565,6 +591,7 @@ export class PlayComponent implements OnInit, OnDestroy {
Answer.text = "";
Answer.fontColor = "#" + this.data.contentObj.values[index].answer_color;
Answer.textAlign = 'center';
Answer.fontName = "MMTextBook-Bold"
Answer.fontSize = item.fontSize;
Answer.width = this.ctx.measureText(Answer.text).width;
Answer.x = this.ctx.measureText(item.text).width;
......@@ -576,7 +603,6 @@ export class PlayComponent implements OnInit, OnDestroy {
addNumber(item,Arr,nu){
const Number = new Label();
Number.fontName = "MMTextBook-Bold";
console.log(item);
if(Arr[nu].number == "true"){
......@@ -598,6 +624,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
initView(){
let Bgx = document.body.clientWidth /this.bgWidth;
let Bgy = document.body.clientHeight /this.bgHeight;
// let Bgy = document.body.clientWidth /this.bgHeight;
......@@ -607,8 +634,19 @@ export class PlayComponent implements OnInit, OnDestroy {
bg_img.width = 0;
bg_img.height = 200;
bg_img.setScaleXY(1);
const sx = this.canvasWidth / this.canvasBaseW;
// const bgRect = new ShapeRect();
// bgRect.setSize(57, 65);
// bgRect.fillColor = '#f8c224';
// bgRect.setScaleXY(sx);
// bgRect.x = 65 * sx;
// this.renderArr.push(bgRect);
const play_button = new MySprite();
if(this.play_button_bool)
play_button.init(this.images.get('stop'));
else
play_button.init(this.images.get('play'));
play_button.setScaleXY(Math.max(Math.min(Bgx ,Bgy) * 0.8,0.2));
......@@ -622,35 +660,39 @@ export class PlayComponent implements OnInit, OnDestroy {
const label_title_top_bg = new MySprite();
label_title_top_bg.init(this.images.get('title_bg'));
label_title_top_bg.setScaleXY(Bgx * 0.4);
const sx = this.canvasWidth / this.canvasBaseW;
label_title_top_bg.x = 65 * sx + 105 * (document.body.clientWidth / 1600);
label_title_top_bg.y = Bgx * 26;
label_title_top_bg.setScaleXY(Bgx * 0.5);
label_title_top_bg.x = 65 * sx + 35 * (document.body.clientWidth / 1600);
label_title_top_bg.y = Bgx * 32;
const label_title_top = new Label();
label_title_top.text = this.data.contentObj.title.number.toUpperCase();
label_title_top.fontName = 'BRLNSDB';
label_title_top.setScaleXY(1);
label_title_top.fontSize = 110;
label_title_top.y = 0;
label_title_top.fontColor = '#FFDB84';
label_title_top.textAlign = 'center';
label_title_top.fontName = 'BRLNSDB';
label_title_top_bg.addChild(label_title_top);
const label_title = new Label();
label_title.text = this.data.contentObj.title.text;
label_title.fontName = 'BRLNSDB';
label_title.fontName = 'FUTURAB';
label_title.setMaxSize(1000);
label_title.fontSize = Math.min(Bgx * 50,55);
label_title.fontSize = Math.min(Bgx * 45,55);
label_title.width = this.ctx.measureText(label_title.text).width * 0.95;
// label_title.x = label_title_top_bg.x - 800 + label_title_top_bg.width / 2 * Bgx + this.ctx.measureText(label_title.text).width * Bgx;
label_title.x = label_title_top_bg.x + label_title_top_bg.width / 2 * Bgx + this.ctx.measureText(label_title.text).width * label_title.fontSize / 64 / 2;
label_title.y = label_title_top_bg.y;
label_title.x = label_title_top_bg.x + label_title_top_bg.width / 2 * Bgx + this.ctx.measureText(label_title.text).width * label_title.fontSize / 64 / 1.9;
label_title.y = label_title_top_bg.y + 5 * Bgx;
label_title.fontColor = '#000';
label_title.fontWeight = 300;
label_title.textAlign = 'center';
bg_img.addChild(label_title_top_bg);
this.label_title_top_bg = label_title_top_bg;
this.label_title = label_title;
......@@ -681,6 +723,7 @@ export class PlayComponent implements OnInit, OnDestroy {
items.fontName = 'MMTextBook-Bold';
items.fontSize = 64;
items.text = "";
items.fontWeight = 300;
c = true;
for(let j = 0; j < Arr[i].word.length; j++){
if(j != Arr[i].answer[as_v])
......@@ -696,7 +739,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.addAnswer(items,as_v,i,this.values_bool);
as_v++;
}
items.text += " ";
items.text += " ";
}
items.text += " ";
}
......@@ -721,7 +764,6 @@ export class PlayComponent implements OnInit, OnDestroy {
const img = new MySprite();
img.init(this.images.get(Arr[i].img_url));
console.log(img.height);
img.setScaleXY(Math.min(300 / img.width,140 / img.height) * Math.min(Math.max(Bgx,Bgy) * 0.6,0.7));
img.x = this.ctx.measureText(items.text).width + 100;
......@@ -732,7 +774,9 @@ export class PlayComponent implements OnInit, OnDestroy {
optionRect.addChild(items);
this.index_item++;
}
}
onclick_img(index){
......@@ -751,15 +795,27 @@ export class PlayComponent implements OnInit, OnDestroy {
mapDown(event) {
if(this.checkClickTarget(this.label_title)){
if(this.checkClickTarget(this.label_title) || this.checkClickTarget(this.label_title_top_bg)){
this.playAudio(this.data.contentObj.title.audio_url, true);
return;
}
if(this.checkClickTarget(this.play_button)){
this.playAudio_ps(this.play_button_bool,this.data.contentObj.audio_url);
}
if(this.data.contentObj.audio_url)
{
let _this = this;
this.audioObj[this.data.contentObj.audio_url].addEventListener('ended', function () {
_this.play_button.init(_this.images.get('play'));
_this.play_button_bool = false;
_this.currentTime = 0;
}, false);
}
for(let i = 0; i < this.data.contentObj.values.length; i++){
if(this.checkClickTarget(this.img_button[i])){
......@@ -776,11 +832,6 @@ export class PlayComponent implements OnInit, OnDestroy {
if(this.checkClickTarget(this.items_Text[i][j])){
this.onclick_items_text(this.item[i],i);
this.values_bool[i] = 1;
console.log(this.values_bool);
if(this.data.contentObj.values[i].audio_url)
this.playAudio(this.data.contentObj.values[i].audio_url, true);
else
this.playAudio('assets/play/default/click.mp3',true);
// this.onclick_items_text(this.items_Text);
......
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