|
|
|
@ -21,8 +21,8 @@ |
|
|
|
|
>运行</el-button> |
|
|
|
|
</div> |
|
|
|
|
<div class="code-right answer"> |
|
|
|
|
<!-- <p class="text-wrapper" v-html="modifys"></p> --> |
|
|
|
|
<p class="text-wrapper">{{modifys}}</p> |
|
|
|
|
<p class="text-wrapper" v-html="modifys"></p> |
|
|
|
|
<!-- <p class="text-wrapper">{{modifys}}</p> --> |
|
|
|
|
<div class="pic-wrap" v-if="picSrc"> |
|
|
|
|
<div style="margin-bottom: 5px;text-align: center"> |
|
|
|
|
<img class="pic" :src="picSrc" alt=""> |
|
|
|
@ -95,6 +95,8 @@ import "codemirror/theme/monokai.css"; |
|
|
|
|
import "codemirror/theme/base16-light.css"; |
|
|
|
|
import * as $ from "jquery"; |
|
|
|
|
import { Loading } from 'element-ui'; |
|
|
|
|
import axios from 'axios'; |
|
|
|
|
const CANCEL_TOKEN = axios.CancelToken |
|
|
|
|
export default { |
|
|
|
|
props: ["workbench1", "code", "codeid", "projectId"], |
|
|
|
|
data() { |
|
|
|
@ -147,7 +149,13 @@ export default { |
|
|
|
|
showCursorWhenSelecting: true, |
|
|
|
|
theme: "monokai", // 主题 |
|
|
|
|
extraKeys: { Ctrl: "autocomplete" } // 可以用于为编辑器指定额外的键绑定,以及keyMap定义的键绑定 |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
inputTextReg: /^((?!#).*?(,|\(|\[|\{|\s)+)?input(?!\w)\(['|"]([\s\S]+?)['|"]\)/m, |
|
|
|
|
inputReg: /^((?!#).*?(,|\(|\[|\{|\s)+)?(input(?!\w)\(['|"][\s\S]*?['|"]\))/m, |
|
|
|
|
exitTextReg: /exit(?!\w)\(['|"]([\s\S]+?)['|"]\)/m, |
|
|
|
|
exitNotValidReg: /exit(?!\w)\(['|"]([\s\S]+?)['|"]\)/m, |
|
|
|
|
requestList: [], |
|
|
|
|
sourceCode: '' |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
components: { |
|
|
|
@ -245,19 +253,55 @@ export default { |
|
|
|
|
} |
|
|
|
|
x.send() |
|
|
|
|
}, |
|
|
|
|
AnswerTips() { |
|
|
|
|
// this.$post(this.api.AddCode, { |
|
|
|
|
// // headers: {code: "#-*-coding:utf-8-*-↵发动机开始"}, |
|
|
|
|
// code: "#-*-coding:utf-8-*-↵发动机开始", |
|
|
|
|
// codeId: this.codeId, |
|
|
|
|
// submit: this.submit //是否点击运行(0未运行,1已运行) |
|
|
|
|
// }) |
|
|
|
|
// .then(res => { |
|
|
|
|
confirmInput(msg){ |
|
|
|
|
let receiveResult = msg.replace('validing:','') |
|
|
|
|
// console.log('进入函数:',receiveResult) |
|
|
|
|
this.modifys += receiveResult |
|
|
|
|
this.$prompt(receiveResult, "提示", { |
|
|
|
|
confirmButtonText: "确定" |
|
|
|
|
}).then(({ value }) => { |
|
|
|
|
this.modifys += `${value}<br>` |
|
|
|
|
console.log('替换前:',this.sourceCode,`exit('validing:${receiveResult.replace(/[\r\n]*/g,'')}')`) |
|
|
|
|
this.sourceCode = this.sourceCode.replace(`exit('validing:${receiveResult.replace(/[\r\n]*/g,'')}')`,val => { |
|
|
|
|
return `'${value}'` |
|
|
|
|
}) |
|
|
|
|
this.sourceCode = this.sourceCode.replace(`exit("validing:${receiveResult.replace(/[\r\n]*/g,'')}")`,val => { |
|
|
|
|
return `'${value}'` |
|
|
|
|
}) |
|
|
|
|
console.log('替换后:',this.sourceCode) |
|
|
|
|
|
|
|
|
|
// }) |
|
|
|
|
// .catch(err => {}); |
|
|
|
|
this.$post(this.api.UpdateCode,{ |
|
|
|
|
code: this.sourceCode, |
|
|
|
|
codeId: this.codeId, |
|
|
|
|
submit: this.submit //是否点击运行(0未运行,1已运行) |
|
|
|
|
}).then(res => { |
|
|
|
|
let result = res.message.result |
|
|
|
|
if(result.includes('File ')){ |
|
|
|
|
let modify = res.message.result |
|
|
|
|
this.modifys = modify |
|
|
|
|
this.after = modify.substring( |
|
|
|
|
modify.indexOf("line") + 4, |
|
|
|
|
modify.length |
|
|
|
|
); |
|
|
|
|
this.num = parseInt(this.after) |
|
|
|
|
this.isError = res.message.isError |
|
|
|
|
}else if(result.includes('validing:')){ |
|
|
|
|
this.isError = 0 |
|
|
|
|
this.confirmInput(result) |
|
|
|
|
}else if(!res.message.isError){ |
|
|
|
|
this.isError = 0 |
|
|
|
|
this.modifys += result |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// return false |
|
|
|
|
// if(!res.message.isError){ |
|
|
|
|
// this.modifys += res.message.result |
|
|
|
|
// }else if(res.message.result.includes('validing:')){ |
|
|
|
|
// this.confirmInput(res.message.result) |
|
|
|
|
// } |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}, |
|
|
|
|
AnswerTips() { |
|
|
|
|
if (this.isSubmit == "") { |
|
|
|
|
this.submit = 1; |
|
|
|
|
if (this.codeid == "") { |
|
|
|
@ -266,73 +310,41 @@ export default { |
|
|
|
|
type: "warning" |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
if(this.projectId == 1110 && this.exampleData.includes('您好!请问您需要什么帮助呢?1 存取款;2 货币兑换;3 咨询')){ |
|
|
|
|
let inputTextReg = this.inputTextReg |
|
|
|
|
let inputFuncReg = /input\(['|"]/g |
|
|
|
|
if (inputTextReg.test(this.exampleData)) { |
|
|
|
|
let sourceCode = this.exampleData |
|
|
|
|
sourceCode = sourceCode.replace(inputTextReg,val => { |
|
|
|
|
return val.replace(/[\r\n]/g,'') |
|
|
|
|
}) |
|
|
|
|
// return console.log(11,sourceCode) |
|
|
|
|
|
|
|
|
|
sourceCode = sourceCode.replace(inputFuncReg,val => { |
|
|
|
|
return `exit(${val[val.length - 1]}validing:` |
|
|
|
|
}) |
|
|
|
|
this.sourceCode = sourceCode |
|
|
|
|
|
|
|
|
|
this.modifys = '' |
|
|
|
|
this.$post(this.api.UpdateCode, { |
|
|
|
|
code: sourceCode, |
|
|
|
|
codeId: this.codeId, |
|
|
|
|
submit: this.submit |
|
|
|
|
}).then(res => { |
|
|
|
|
let result = res.message.result |
|
|
|
|
if(result.includes('File ')){ |
|
|
|
|
let modify = res.message.result |
|
|
|
|
this.modifys = modify |
|
|
|
|
this.after = modify.substring( |
|
|
|
|
modify.indexOf("line") + 4, |
|
|
|
|
modify.length |
|
|
|
|
); |
|
|
|
|
this.num = parseInt(this.after) |
|
|
|
|
this.isError = res.message.isError |
|
|
|
|
}else if(result.includes('validing:')){ |
|
|
|
|
this.isError = 0 |
|
|
|
|
let msg = `您好!请问您需要什么帮助呢?1 存取款;2 货币兑换;3 咨询` |
|
|
|
|
this.modifys = msg |
|
|
|
|
this.$prompt(msg, "提示", { |
|
|
|
|
confirmButtonText: "确定" |
|
|
|
|
}).then(({ value }) => { |
|
|
|
|
if(value == 1){ |
|
|
|
|
msg = `建议您去线下银行办理` |
|
|
|
|
this.modifys += `<br>${msg}` |
|
|
|
|
// this.$message.success(msg) |
|
|
|
|
}else if(value == 2){ |
|
|
|
|
msg = `目前可选择兑换的货币为澳币,是否继续?是or否` |
|
|
|
|
this.modifys += `<br>${msg}` |
|
|
|
|
this.$prompt(msg, "提示", { |
|
|
|
|
confirmButtonText: "确定" |
|
|
|
|
}).then(({ value }) => { |
|
|
|
|
if(value == '是'){ |
|
|
|
|
msg = `澳币和人民币的兑换率为1:4.7,即一澳币=4.7元人民币。请问您需要兑换多少澳币呢?` |
|
|
|
|
this.modifys += `<br>${msg}` |
|
|
|
|
this.$prompt(msg, "提示", { |
|
|
|
|
confirmButtonText: "确定" |
|
|
|
|
}).then(({ value }) => { |
|
|
|
|
if(isNaN(value)){ |
|
|
|
|
msg = `请输入数字` |
|
|
|
|
this.modifys += `<br>${msg}` |
|
|
|
|
// this.$message.error(msg) |
|
|
|
|
}else{ |
|
|
|
|
let rmb = (Number(value) * 4.72).toFixed(2) |
|
|
|
|
msg = `好的,确认兑换澳币${value}。依据当前汇率,一共需要${rmb}元人民币。` |
|
|
|
|
this.modifys += `<br>${msg}` |
|
|
|
|
// this.$message.success(msg) |
|
|
|
|
} |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}else if(value == '否'){ |
|
|
|
|
msg = `好的,感谢您使用本次服务。` |
|
|
|
|
this.modifys += `<br>${msg}` |
|
|
|
|
// this.$message.success(msg) |
|
|
|
|
} |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}else if(value == 3){ |
|
|
|
|
msg = `您的问题请咨询在线人工客服` |
|
|
|
|
this.modifys += `<br>${msg}` |
|
|
|
|
// this.$message.success(msg) |
|
|
|
|
this.confirmInput(result) |
|
|
|
|
} |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
// if (/^((?!#).*?(,|\(|\[|\{|\s)+)?input(?!\w)(,|\(|\)|\[|\]|\{|\}|\s)?/m.test(this.exampleData)) { |
|
|
|
|
if (false) { |
|
|
|
|
this.isError = 0 |
|
|
|
|
this.$prompt("请输入...", "提示", { |
|
|
|
|
confirmButtonText: "确定" |
|
|
|
|
}).then(({ value }) => { |
|
|
|
|
this.datas = []; |
|
|
|
|
this.datas.push(value); |
|
|
|
|
this.$post(this.api.ChangeCode, { |
|
|
|
|
datas: this.datas, |
|
|
|
|
code: this.exampleData |
|
|
|
|
}) |
|
|
|
|
.then(res => { |
|
|
|
|
this.exampleData = res.message; |
|
|
|
|
}) |
|
|
|
|
.catch(err => { |
|
|
|
|
console.log(err); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
this.loadIns = Loading.service({ |
|
|
|
|
background: 'transparent' |
|
|
|
@ -545,6 +557,7 @@ export default { |
|
|
|
|
font-size: 18px; |
|
|
|
|
margin: 10px; |
|
|
|
|
position: absolute; |
|
|
|
|
width: calc(100% - 14px); |
|
|
|
|
height: calc(100vh - 230px); |
|
|
|
|
overflow: auto; |
|
|
|
|
} |
|
|
|
|