style: 修复lint报错

This commit is contained in:
马琦钧 2021-08-08 01:45:11 +08:00
parent e48a7653c7
commit a340136f8c
2 changed files with 29 additions and 26 deletions

View File

@ -107,14 +107,13 @@ import { saveAsFile } from '../../js/utils.js'
//
const isLocal = false
function get (url, cb, config={}) {
function get (url, cb, config = {}) {
query('GET', url, '', cb, config)
}
function post (url, data, cb, config={}) {
function post (url, data, cb, config = {}) {
query('POST', url, data, cb, config)
}
function query (method, url, data = '', cb, config = {}) {
console.log('config',config);
function query (method, url, data = '', cb, config = {}) {
config.tryTimes = config.tryTimes || 0
config.isDirect = config.isDirect || false
@ -127,13 +126,12 @@ function query (method, url, data = '', cb, config = {}) {
return cb(xhr.responseText) //
}
const result = JSON.parse(xhr.responseText)
console.log('result',result);
if (result.errCode !== 0) {
if (config.tryTimes >= 2) {
alert(result.errMsg)
} else {
setTimeout(() => {
config.tryTimes += 1;
config.tryTimes += 1
query(method, url, data = '', cb, config)
}, 200)
}
@ -338,10 +336,11 @@ export default {
* @param 类型
*/
setType: function (type, ev) {
if (this.projectType === '命名识别识别')
if (this.projectType === '命名识别识别') {
this.$set(this, 'nowType', type)
}
if (this.projectType === '文本分类') {
let typeIdx = -1;
let typeIdx = -1
this.ners.some((ner, idx) => {
if (ner.type === type) {
typeIdx = idx
@ -446,7 +445,7 @@ export default {
this.$set(this, 'wordsOutType', this.wordsOutType)
},
startSelect: function (idx, event) {
if (this.projectType !== '命名实体识别') return;
if (this.projectType !== '命名实体识别') return
if (event.which === 3) {
event.preventDefault()
//
@ -534,12 +533,14 @@ export default {
outAllNers () {
if (!isLocal) {
// url
if (this.projectType === '命名实体识别')
if (this.projectType === '命名实体识别') {
window.open(`/v1/files/get_json?projectName=${this.projectName}`, '_self')
if (this.projectType === '文本分类')
get(`/v1/files/get_labels?projectName=${this.projectName}`, function(text){
saveAsFile(text, 'labels.json');
}, {isDirect : true})
}
if (this.projectType === '文本分类') {
get(`/v1/files/get_labels?projectName=${this.projectName}`, (text) => {
saveAsFile(text, 'labels.json')
}, {isDirect: true})
}
return true
}
this.nersCache[this.nowFile] = this.ners
@ -584,13 +585,15 @@ export default {
updateType2Server(that.projectName, that.typeList, that.types)
},
//
isTypeSelected: function(type) {
if (this.projectType === '命名实体识别')
return this.nowType === type;
if (this.projectType === '文本分类')
return this.ners.some((ner)=>{
isTypeSelected (type) {
if (this.projectType === '命名实体识别') {
return this.nowType === type
}
if (this.projectType === '文本分类') {
return this.ners.some((ner) => {
return ner.type === type
})
}
}
},
watch: {

View File

@ -1,8 +1,8 @@
export function saveAsFile(data, name) {
var urlObject = window.URL || window.webkitURL || window;
var export_blob = new Blob([data]);
var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
save_link.href = urlObject.createObjectURL(export_blob);
save_link.download = name;
save_link.click();
export function saveAsFile (data, name) {
const urlObject = window.URL || window.webkitURL || window
const exportBlob = new Blob([data])
const saveLink = document.createElementNS('http://www.w3.org/1999/xhtml', 'a')
saveLink.href = urlObject.createObjectURL(exportBlob)
saveLink.download = name
saveLink.click()
}