mirror of
https://gitee.com/eolink_admin/postcat.git
synced 2024-12-02 19:57:45 +08:00
feat: only support to upload .json file
This commit is contained in:
parent
5cd80ab96a
commit
8160607473
@ -34,8 +34,8 @@
|
||||
</nz-radio-group>
|
||||
</div>
|
||||
|
||||
<div class="mt-4" *ngIf="allowDrag">
|
||||
<nz-upload *ngIf="extensionList.length" nzType="drag" [nzBeforeUpload]="parserFile">
|
||||
<div class="mt-4" *ngIf="allowDrag && extensionList.length">
|
||||
<nz-upload nzType="drag" [nzBeforeUpload]="parserFile">
|
||||
<p class="ant-upload-drag-icon">
|
||||
<i nz-icon nzType="inbox"></i>
|
||||
</p>
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { Observable, Observer } from 'rxjs';
|
||||
import { parserJsonFile } from '../../../utils';
|
||||
import { EoMessageService } from '../../../eoui/message/eo-message.service';
|
||||
|
||||
type optionType = {
|
||||
label: string;
|
||||
@ -22,6 +23,8 @@ export class ExtensionSelectComponent {
|
||||
@Output() uploadChange = new EventEmitter<any>();
|
||||
filename = '';
|
||||
|
||||
constructor(private message: EoMessageService) {}
|
||||
|
||||
selectExtension({ key, properties }) {
|
||||
this.extensionChange.emit(key);
|
||||
if (!properties) {
|
||||
@ -37,6 +40,10 @@ export class ExtensionSelectComponent {
|
||||
|
||||
parserFile = (file) =>
|
||||
new Observable((observer: Observer<boolean>) => {
|
||||
if (file.type !== 'application/json') {
|
||||
this.message.error('仅支持上传 JSON 格式的文件');
|
||||
observer.complete();
|
||||
}
|
||||
parserJsonFile(file).then((result: { name: string }) => {
|
||||
this.filename = result.name;
|
||||
this.uploadChange.emit(result);
|
||||
|
Loading…
Reference in New Issue
Block a user