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

View File

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