Commit 3747dd67 authored by limingzhe's avatar limingzhe

first commit

parent a4d93283
<div class="courseware-container d-flex"> <div class="courseware-container d-flex row" #videoContainer>
<div class="col-8">
<div class="gutter" style="width: 100%;"> <!--crossorigin="anonymous"-->
<app-lesson-title-config <video class="courseware-video"
(titleUpdated)="updateTitleObjSuccess($event)" crossorigin="anonymous"
[withIcon]="false" *ngIf="item.contentObj.video_url "
[titleObj]="titleObj"> [src]="item.contentObj.video_url | resource" controls
</app-lesson-title-config> (loadeddata)="videoLoaded($event,item)"
(error)="videoError($event)"
(seeked)="videoSeeked($event, false)"
<nz-divider></nz-divider> #videoNode ></video>
<!--&& item.contentObj.video_url.constructor.name === 'String'-->
<div *ngIf="!item.contentObj.video_url">
<div class="p-video-box d-flex align-items-center">
<div class="p-upload-icon">
<!--<i class="anticon anticon-caret-right"></i>-->
<i nz-icon type="caret-right" theme="outline"></i>
<div class="m-3"></div>
</div>
</div>
</div> </div>
</div>
<div class="col-4">
<app-upload-video
(videoUploaded)="onVideoUploadSuccess($event)"
[item]="item"
[videoUrl]="item.contentObj.video_url"></app-upload-video>
</div>
</div>
<div class="row" style="margin-top: 1rem"
*ngIf="item.contentObj.video_id && item.contentObj.video_url && item.contentObj.video_url.constructor.name === 'String'">
<div class="col-8">
<button nz-button nzType="primary"
style="margin-bottom: 1rem"
(click)="setVideoCover()">
Set Video Cover
</button>
<!--crossOrigin="anonymous"-->
<img *ngIf="item.contentObj.pic_id"
[src]="item.contentObj.pic_id | resource"
style="width:100%;overflow: hidden;box-shadow: 0 0 20px 0px #444;"/>
<app-upload-image-with-preview
[picUrl]="item.contentObj.video_cover_url"
(imageUploaded)="onCoverUploadSuccess($event)"
[picItem]="coverImg"
[disableUpload]="true"
[TIP]="' '"
[iconSize]="0"
style="width:100%;overflow: hidden;box-shadow: 0 0 20px 0px #444;">
</app-upload-image-with-preview>
</div>
</div> </div>
@import '../style/common_mixin'; .p-video-box{
bottom: 0;
.tw{ border: 2px dashed #ddd;
display: flex; border-radius: 0.5rem;
.t{ background-color: #fafafa;
flex: 1 1 auto; text-align: center;
margin-right: 2rem; color: #aaa;
} padding-top: 56.25%;
.a{ font-size: 4rem;
.p-upload-icon{
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50% ,-50%);
} }
} }
.aud-w{ .courseware-container{
width: 100%; .courseware-video{
display: flex; //position: absolute;
justify-content: center; width: 95%;
margin-top: 1.5rem; max-height: calc(100vh - 5rem);
}
} }
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef} from '@angular/core'; import {
import * as _ from 'lodash'; ApplicationRef,
Component,
ElementRef,
EventEmitter,
Input,
OnChanges,
OnInit,
Output,
ViewChild
} from '@angular/core';
import {NzMessageDataFilled, NzMessageService} from 'ng-zorro-antd';
@Component({ @Component({
// providers:[UploadImageWithPreviewComponent ],
selector: 'app-form', selector: 'app-form',
templateUrl: './form.component.html', templateUrl: './form.component.html',
styleUrls: ['./form.component.scss'] styleUrls: ['./form.component.scss']
}) })
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges {
// @Input()
item;
@ViewChild('videoContainer')
videoContainer: ElementRef;
@ViewChild('videoNode')
videoNode: ElementRef;
@Output()
update = new EventEmitter();
newVideoCover = true;
coverImg: any = null;
// titleObj = {
// audio_url: 'http://iplayabc-courseware.oss-cn-beijing.aliyuncs.com/dev/imman/audios/d108d5d06105fda0526059a3e372f926.mp3',
// content: 'what is this?&nbsp;',
// icons: [],
// type: 'a'
// };
titleObj = { KEY = 'dfzx_03';
audio_url: '',
content: '',
icons: [],
type: ''
};
teststr = ""; private tooBigError: NzMessageDataFilled = null;
constructor(private appRef: ApplicationRef) {
} constructor(private nzMessageService: NzMessageService,
private appRef: ApplicationRef) {
ngOnInit() {
let _this = this;
(<any>window).courseware.getData(function(data){
if(data){
_this.titleObj = data;
setTimeout(() => {
_this.appRef.tick();
}, 1);
} }
}); safeVideoUrl(url) {
if (url && url.constructor.name === 'SafeUrlImpl') {
this.videoNode && this.videoNode.nativeElement.removeAttribute('crossorigin');
return url;
}
this.videoNode && this.videoNode.nativeElement.setAttribute('crossorigin', 'anonymous');
// console.log('safeVideoUrl', url)
return `${url}?t=${Math.random()}`;
// const d = this.sanitization.bypassSecurityTrustResourceUrl(url);
return `${url}`; // ?t=${Math.random() //this.sanitization.bypassSecurityTrustHtml(url);
}
ngOnChanges() {
console.log(1, 'ngOnChanges');
// if (typeof this.item.contentObj.video_url !== 'string') {
// // this.item.contentObj.video_url = '';
// setTimeout(() => {
// this.item.contentObj.video_url = '';
// });
// }
}
ngOnInit() {
console.log(2, 'ngOnInit');
// if (typeof this.item.contentObj.video_url !== 'string') {
// // this.item.contentObj.video_url = '';
// setTimeout(() => {
// this.item.contentObj.video_url = '';
// });
// }
const getData = (<any> window).courseware.getData;
getData((data) => {
if (data) {
this.item = data;
} else {
this.item = {};
this.item.contentObj = {};
} }
ngOnChanges() { console.log('data:', data);
// this.init();
// this.refresh();
}, this.KEY);
} }
ngOnDestroy() { videoLoaded(evt, item) {
// console.log(111, 'video loaded', item);
const video = evt.target;
if (video.src.startsWith('blob:') && video.videoWidth > 1280 && video.videoHeight > 720) {
this.tooBigError = this.nzMessageService.error('视频分辨率过大,请调整分辨率后上传,建议 1280x720', {nzDuration: 10 * 1000});
// video.src = null;
return ;
} else {
if (this.tooBigError && this.tooBigError.messageId) {
this.nzMessageService.remove(this.tooBigError.messageId);
this.tooBigError = null;
}
} }
updateTitleObjSuccess(titleObj) { if (video.src && video.src.startsWith('blob:')) {
this.titleObj = titleObj; return;
this.save();
} }
if ( item.contentObj.origin_video_url && item.contentObj.origin_video_url.startsWith('http') ) {
item.video_preview_thumb = null;
return;
}
// item.video_preview_thumb = null;
this.newVideoCover = true;
video.currentTime = .1;
// setTimeout(() => {
// this.setVideoCover();
// }, 1500);
// this.videoSeeked(evt, item);
}
videoError(evt) {
this.nzMessageService.error('video error');
}
videoSeeked(evt) {
const video = evt.target;
if (video.src && video.src.startsWith('blob:')) {
return;
}
if (!this.item.contentObj.video_cover_url) {
this.setVideoCover();
this.newVideoCover = false;
}
}
setVideoCover() {
// console.log(111)
// (seeked)="videoSeeked($event, item)"
// if (!item.video_preview_thumb) {
if (!this.videoNode) {
return;
}
const video = this.videoNode.nativeElement;
if (!video.src) { return; }
// console.log(222, video.currentTime)
const canvas = document.createElement('canvas');
canvas.setAttribute('crossorigin', "anonymous");
canvas.width = video.videoWidth ;
canvas.height = video.videoHeight ;
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
// item.video_preview_thumb = canvas.toDataURL();
const video_preview_thumb = canvas.toDataURL();
// console.log(video_preview_thumb.substr(0, 100));
// console.log('%c ', `font-size: 100px; background: url(${video_preview_thumb}) no-repeat;`);
canvas.remove();
// video.currentTime = 0;
// }
const img: any = this.convertImageToBlob(video_preview_thumb);
img.name = `video_${this.item.sid}_${Date.now()}_cover.png`;
this.coverImg = img;
onTitleAudioUploadSuccess(res) { // this.coverComponent.customUpload(img);
this.titleObj.audio_url = res.url; /*
const formData = new FormData();
formData.append('file', img);
this.coursewareService.uploadResource(formData).then(res => {
// console.log(res);
// console.log(1, this.item.contentObj.video_url);
this.item.contentObj.pic_id = res.res_id;
// const ndata = JSON.parse(JSON.stringify(this.item)); // Object.assign({}, this.item);
// if (typeof ndata.contentObj.video_url !== 'string') {
// delete ndata.contentObj.video_url;
// }
//
// console.log(2, ndata.contentObj.video_url);
// console.log(3, this.item.contentObj.video_url);
this.update.emit(this.item);
});
*/
}
onCoverUploadSuccess(e) {
this.coverImg = null;
this.item.contentObj.video_cover_id = e.res_id;
this.item.contentObj.video_cover_url = e.url;
this.update.emit(this.item);
}
convertImageToBlob(data) {
const imgType = data.substring(data.indexOf(':') + 1, data.indexOf(';'));
const binary = atob(data.split(',')[1]);
const array = [];
let i = 0;
while (i < binary.length) {
array.push (binary.charCodeAt(i));
i++;
}
return new Blob([ new Uint8Array(array) ], {type: imgType});
}
onVideoUploadSuccess(e) {
this.item.contentObj.video_url = e.url;
this.save(); this.save();
} }
save() { save() {
(<any>window).courseware.setData(this.titleObj); (<any> window).courseware.setData(this.item, null, this.KEY);
this.refresh();
} }
refresh() {
setTimeout(() => {
this.appRef.tick();
}, 1);
}
} }
<div
class="p-courseware-video"
[style.background-image]="hasVideo ? '' : 'url(assets/default/video-not-upload.jpg)'"
>
<video *ngIf="hasVideo"
<div class="player-preview-content" [ngStyle]="{'background-color': this.data.contentObj?.titleObj?.type === 'a' ? '#fce5e9' : '#d8eefb'}"> [src]="data.contentObj.video_url"
<app-player-content-wrapper> width="100%" height="100%"
<div [innerHTML]="data.contentObj.titleObj.content" style=" #videoNode (click)="playVideo()">
position: absolute;z-index:99; </video>
display: inline-block; <div class="video-cover" *ngIf="initCover && !isPlaying">
left: 55px; <!--<img crossOrigin="anonymous" *ngIf="initCover" [src]="initCover | resource: sid"-->
top: 20px; <!--style="width:100%;height:100%;"/>-->
cursor: pointer" (click)="playTitleAudio()"></div> <img *ngIf="initCover" [src]="initCover"
<div class="content" style = 'position: relative;width: 100%;height: 100%;display: flex; style="width:100%;height:100%;"/>
justify-content: center;
align-items: flex-end;'>
<div class="letter-box">
<div class="letters" >
<div class="letter" *ngFor="let a of letters; let i = index"
[ngStyle]="{top: row(i) +'%', left: (10 + (i % 13) * 6.05) +'%'}">
<div class="l-box" (click)="clickItem($event, a)">
<img [src]="'assets/all-letters/letter-imgs/'+a +'.png'" alt="">
<div style="display: none">
<audio [src]="'assets/all-letters/letter-audios/'+fromCharCode(a)+'.mp3'" preload="auto"> </audio>
</div>
</div> </div>
</div> <div class="bg-mask" *ngIf="!isPlaying && hasVideo" >
</div>
</div>
<div class="show-item-content" </div>
*ngIf="showDetailFlag"
(click)="clickBg()">
<div style="width: 50%; height: 80%; margin-top: 2rem"> <div class="k-play-btn" *ngIf="!isPlaying && hasVideo" (click)="playVideo()"
<img [src]="curItemUrl" style="height: 100%; width: auto;" style="background: none;width:100%;height:100%;">
(click)="clickBigItem($event)"> <img [src]="playBtnImg" style="width: 12%; height: auto">
<!--<i class="anticon anticon-play-circle-o"></i>-->
</div> </div>
<div class="k-video-control" *ngIf="hasVideo">
<div class="k-video-control-bg"></div>
<div class="k-video-control-time-past">{{currentTime | time}}</div>
<div #videoProgress class="k-video-control-progress"
(mousedown)="onProgressMouseDown($event)"
(mousemove)="onProgressMouseMove($event)"
(mouseup)="onProgressMouseUp($event)">
<div class="i-bg"></div>
<div class="i-before-progress" [style.width]="progress + '%'"></div>
<div class="i-cursor" [style.left]="progress + '%'"></div>
</div> </div>
<div class="k-video-control-time-total">{{duration | time}}</div>
<!--<div class="k-video-control-tool">-->
<!--<div class="i-tool-btn" (tap)="onBtnQuickSeek(-10)">-10</div>-->
<!--<div class="i-tool-btn" (tap)="onBtnQuickSeek(-5)">-5</div>-->
<!--<div class="i-tool-btn" (tap)="onBtnQuickSeek(5)">+5</div>-->
<!--<div class="i-tool-btn" (tap)="onBtnQuickSeek(10)">+10</div>-->
<!--</div>-->
</div> </div>
</app-player-content-wrapper>
</div>
<div style="display: none">
<audio *ngIf="data.contentObj?.titleObj?.audio_url" #audioElement
[src]="data.contentObj?.titleObj?.audio_url" preload="auto"> </audio>
</div> </div>
@import '../style/common_mixin'; @import '../style/common_mixin';
.p-courseware-video {
.player-preview-content { height: 100%;
overflow: hidden;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
background-color: #333;
@include k-img-bg();
.video-cover{
//position: absolute;
//left: 0;
//right: 0;
//top: 0;
//bottom: 0;
//width: 100%;
//height: 100%;
}
video {
width: 100%; width: 100%;
height: 100%; height: 100%;
}
}
.k-play-btn {
position: absolute;
//width: 12%;
top: 35%;
left: 44%;
font-size: 12vh;
color: #444;
background-color: white; background-color: white;
.lesson-header{ border-radius: 50%;
}
.bg-mask {
width: 100%; width: 100%;
height: 100%;
position: absolute; position: absolute;
top: 0; top: 0;
img{ background-color: rgba(0, 0, 0, 0.65);
}
.k-video-control {
position: absolute;
bottom: 1vh;
left: 0;
width: 100%; width: 100%;
height: auto; height: 7.5%;
} display: flex;
.title{ color: white;
font-family: 'BerlinSansFBDemi-Bold'; padding: 0 8vh;
color: #f5d11f; align-items: center;
font-size: 4vw; &-bg {
font-weight: 900;
width: 15%;
height: 70%;
position: absolute; position: absolute;
overflow: hidden; //width: 100%;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
line-height: 4vw;
}
}
.left-box{text-align: right;padding-right: 1rem}
.right-box{text-align: left;padding-left: 1rem}
.left-box, .right-box{
height: 100%;
position: relative;
.a, .b{
width: 30%;
height: 100%; height: 100%;
display: inline-block; background-color: #333;
position: relative; opacity: 0.5;
margin: 0 .5rem
}
.a{
width: 40%;
} }
&-time-past {
width: 3.5rem;
} }
.letter-box { &-progress {
//height: 100%;
position: relative; position: relative;
display: inline-block; flex: 1;
width: 100%;
height: 100%;
//margin-top: 5%;
//margin-left: 8%;
//margin-right: 8%;
img{
max-width: 100%;
max-height: 100%;
//position: absolute;
//left: 0;
height: 100%; height: 100%;
display: flex;
align-items: center;
margin: 0 3%;
& > * {
pointer-events: none; // Ken video seek
} }
.letters{ .i-bg {
position: absolute; position: absolute;
background-color: #aaa;
width: 100%; width: 100%;
height: 100%; height: 10%;
top: 0; border-radius: 1rem;
left: 0;
.letter{
position: absolute;
font-weight: 600;
//width: calc(100% / 13);
text-align: center;
--cw: calc(100% / 13);
width: var(--cw);
line-height: calc( var(--cw) * 13);
font-family: LiQiangXingShu;
padding: 0 1rem;
height: 20%;
font-size: 7vmin;
} }
.i-before-progress {
position: absolute;
height: 10%;
background-color: white;
border-radius: 1rem;
} }
.i-cursor {
position: absolute;
width: 1.5vh;
height: 1.5vh;
border-radius: 50%;
background-color: white;
} }
.l-box{
cursor: pointer;
width: 100%;
height: 100%;
display: flex;
flex-direction: column-reverse;
font-weight: 900;
img{
max-width: 100%;
max-height: 100%;
width: 100%;
height: auto;
} }
&-time-total {
margin-right: 3vh;
} }
&-tool {
display: flex;
.show-item-content { .i-tool-btn {
position: absolute; width: 4vh;
width: 100%; height: 4vh;
height: 100%; background-color: white;
//background-color:rgba(255,255,255,1); border-radius: 50%;
margin: 0 1vh;
color: black;
display: flex; display: flex;
justify-content: center;
align-items: center; align-items: center;
justify-content:center; font-size: 1.8vh;
font-weight: bold;
}
} }
} }
.anticon {
vertical-align: 0.25em !important;
}
import { import {AfterViewInit, Component, ElementRef, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
Component,
Input,
OnDestroy,
OnChanges,
OnInit,
AfterViewInit, ElementRef, ViewChild,
ApplicationRef
} from '@angular/core';
import * as _ from 'lodash';
@Component({ @Component({
selector: 'app-play', selector: 'app-play',
templateUrl: './play.component.html', templateUrl: './play.component.html',
styleUrls: ['./play.component.scss'] styleUrls: ['./play.component.scss']
// encapsulation: ViewEncapsulation.None,
}) })
export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewInit { export class PlayComponent implements AfterViewInit, OnInit, OnDestroy {
@Input() data;
@ViewChild('audioElement') @Input() sid;
audioElement: ElementRef; @ViewChild('videoNode')
videoNodeRef: ElementRef;
data = { @ViewChild('videoProgress')
contentObj:{titleObj:{ videoProgressRef: ElementRef;
audio_url: 'http://iplayabc-courseware.oss-cn-beijing.aliyuncs.com/dev/imman/audios/d108d5d06105fda0526059a3e372f926.mp3', player: any;
content: 'what is this?&nbsp;', progress = 0;
icons: [], currentTime = 0;
type: 'a' duration = 0;
}} isPlaying = false;
}; hasVideo = false;
touchSeeking = false;
letters = []; initCover = false;
lettersAscii = {};
titleAudio = null; KEY = 'dfzx_03';
showDetailFlag = false; playBtnImg = '';
curItemUrl = '';
curEvt; constructor() {
constructor(private appRef: ApplicationRef) {
}
range(start, end) {
return (new Array(end - start + 1)).fill(undefined).map((_, i) => i + start);
} }
ngOnInit() { ngOnInit() {
// console.log(this.data.contentObj)
// this.hasVideo = !!this.data.contentObj.video_url && typeof this.data.contentObj.video_url === 'string';
let _this = this;
(<any>window).courseware.getData(function(data){
if(data){
_this.data.contentObj.titleObj.content = data.content;
setTimeout(() => {
_this.appRef.tick();
}, 1);
}
});
// const letters = _.shuffle( [...this.range(97, 122), ...this.range(65, 90)]); const getData = (<any> window).courseware.getData;
[...this.range(97, 122), ...this.range(65, 90)].forEach(c => { getData((data) => {
this.lettersAscii[c] = String.fromCharCode(c);
});
this.letters = _.shuffle(Object.keys(this.lettersAscii));
if (data && typeof data == 'object') {
this.data = data;
} else {
this.data = {};
} }
ngOnDestroy() { console.log('data:' , data);
if (!this.data.contentObj) {
this.data.contentObj = {};
this.data.contentObj.video_url = 'assets/default/demo.mp4';
// this.initDefaultData();
} }
ngOnChanges(data) {
} this.hasVideo = !!this.data.contentObj.video_url && typeof this.data.contentObj.video_url === 'string';
this.playBtnImg = 'assets/play/btn-play.png';
ngAfterViewInit() {
}, this.KEY);
} }
playVideo() {
clickItem(e, a) { // console.log(333333)
if (!this.videoNodeRef) {
this.curEvt = e; return;
this.curItemUrl = 'assets/all-letters/letter-detail/' + a + '.png';
this.showDetailFlag = true;
} }
this.initCover = false;
if (this.player.paused) {
const playPromise = this.player.play();
clickBg() { if (playPromise !== undefined) {
playPromise.then(_ => {
this.showDetailFlag = false; // Automatic playback started!
// Show playing UI.
console.log('play', _);
})
.catch(error => {
// Auto-play was prevented
// Show paused UI.
console.log('error', error);
});
} }
clickBigItem(e) { this.playBtnImg = 'assets/play/btn-play.png';
e.cancelBubble = true; } else {
this.playLetterAudio(this.curEvt); this.player.pause();
} }
caseFolder(c) {
let folder = 'upper';
if (c.toLowerCase() === c) {
folder = 'lower';
} }
return `${folder}/${c}.png`;
} ngAfterViewInit() {
row(i) { if (!this.videoNodeRef) {
const r = Math.floor(i / 13); return;
let y = (r * 20);
switch (r) {
case 0:
case 1:
y += 13;
break;
case 2:
case 3:
y += 15;
break;
}
return y ;
}
lower(c) {
return c.toLowerCase();
} }
fromCharCode(c) { this.player = this.videoNodeRef.nativeElement;
return String.fromCharCode(c).toLowerCase(); this.player.ontimeupdate = (event) => {
this.onTimeUpdate(event);
};
this.player.onloadedmetadata = () => {
this.currentTime = 0;
this.duration = this.player.duration;
};
this.player.onseeking = () => {
this.player.pause();
};
this.player.onseeked = () => {
this.player.play();
this.touchSeeking = false;
};
this.player.onplay = () => {
this.isPlaying = true;
};
this.player.onpause = () => {
this.isPlaying = false;
};
this.player.addEventListener("ended", () => {
this.playBtnImg = 'assets/play/btn-replay.png';
})
setTimeout(() => {
this.initCover = this.data.contentObj.video_cover_url;
});
} }
allLetters() {
ngOnDestroy() {
} }
playTitleAudio() {
this.titleAudio = this.audioElement ? this.audioElement.nativeElement : null; onTimeUpdate(event) {
if (!this.titleAudio) { const player = event.target;
return; this.currentTime = player.currentTime;
this.progress = Math.floor((player.currentTime / player.duration) * 100);
} }
this.titleAudio.pause();
this.titleAudio.currentTime = 0; onBtnQuickSeek(delta: number) {
this.titleAudio.play(); this.player.currentTime += delta;
} }
playLetterAudio(evt) {
const audios = document.querySelectorAll('audio'); onProgressMouseDown(event) {
for (let i = 0; i < audios.length; i++) { this.player.pause();
audios[i].pause(); this.touchSeeking = true;
audios[i].currentTime = 0;
} }
const a = evt.target.parentNode.querySelector('audio');
// a.play();
const playPromise = a.play();
if (playPromise !== undefined) { onProgressMouseMove(event) {
playPromise.then(_ => { if (this.touchSeeking) {
// Automatic playback started! const {target, offsetX} = event;
// Show playing UI. this.progress = Math.floor(offsetX / target.clientWidth * 100);
console.log(1, _)
})
.catch(error => {
// Auto-play was prevented
// Show paused UI.
console.log(2, error)
});
} }
} }
onProgressMouseUp(event) {
const {target, offsetX} = event;
this.player.currentTime = this.player.duration * offsetX / target.clientWidth;
}
} }
import { TestBed } from '@angular/core/testing';
import { ConfigService } from './config.service';
describe('ConfigService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: ConfigService = TestBed.get(ConfigService);
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs";
@Injectable({
providedIn: 'root'
})
export class ConfigService {
configUrl = 'proxy.conf.json';
constructor( private http: HttpClient ) { }
getConfig() {
return this.http.get(this.configUrl)
.pipe(
);
}
showConfig() {
this.getConfig()
.subscribe((data) => {
console.log('data:', data);
});
}
test(data) {
// return new Promise<any> {
// return new Promise((resolve, reject) => {
// this.http.get(url).subscribe((res) => {
// resolve(res);
// }, reject);
// });
//
return this.get('/api/login');
// return this.http.post('/login', data);
}
get(url: string): Promise<any> {
return new Promise((resolve, reject) => {
this.http.get(url).subscribe((res) => {
resolve(res);
}, reject);
});
}
// login(user): Observable<any> {
//
//
// return this.http.post('/login', user).pipe(
// tap((data => {
// console.log('login', data)
// localStorage.setItem('token', _.get(data, 'token'));
// delete data['token'];
// localStorage.setItem('info', JSON.stringify(data));
// this.getInfoPromise = this.load('/user/getInfo');
// }))
// );
// }
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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