完成input交互(有while的情况下还不行)

ui
yujialong 3 years ago
parent 34daea3481
commit 336dcfdd48
  1. 173
      src/components/codemirror.vue
  2. 7
      src/config/index.js
  3. 8
      src/utils/api.js
  4. 2
      src/utils/http.js
  5. 14
      src/views/Home.vue

@ -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 => {
// })
// .catch(err => {});
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)
// return false
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
}
// 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 咨询')){
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)
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
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;
}

@ -1,8 +1,13 @@
const isHh = location.host.includes('10.196.131.73') //是否是河海版本
export default {
/**
* @description 域名切换liuwan职站测试环境occupationlab.com职站正式环境10.196.131.73河海版本
*/
host: (process.env.NODE_ENV === 'development' || location.host.includes('liuwanr.cn')) ? 'http://www.liuwanr.cn/' : (location.host.includes('10.196.131.73') ? 'http://10.196.131.73/' : 'http://www.occupationlab.com/'),
/**
* @description 配置显示在浏览器标签的title
*/
title: 'Python程序设计教学系统',
title: isHh ? '智信云Python程序设计教学系统' : 'Python程序设计教学系统',
/**
* @description 是否使用国际化默认为false
* 如果不使用则需要在路由中给需要在菜单中展示的路由设置meta: {title: 'xxx'}

@ -1,11 +1,7 @@
import config from '@/config'
// let host = 'http://192.168.31.125:8081/python'//林
// let host = 'http://192.168.31.152:8081/python'//榕
let host = ''
if(location.host.includes('liuwanr.cn') || process.env.NODE_ENV === 'development'){
host = 'http://www.liuwanr.cn/python'
}else{
host = 'http://www.occupationlab.com/python'
}
let host = `${config.host}python`
export default {
QueryProject: `${host}/python/queryProject`, //项目选择下拉框+项目信息+判分点信息展示

@ -172,7 +172,7 @@ export function get(url, params) {
*/
export function post(url, params) {
return new Promise((resolve, reject) => {
axios.post(url, params,{headers: {code: "fsfsdff"}})
axios.post(url, params)
.then(res => {
if (res.data.status) {
switch (res.data.status) {

@ -111,7 +111,7 @@ export default {
? parseInt(sessionStorage.getItem("timer"))
: 0,
codeKey: 1,
host: location.host.includes('liuwanr.cn') ? 'http://www.liuwanr.cn/' : 'http://www.occupationlab.com/'
host: this.$config.host
};
},
components: {
@ -187,17 +187,9 @@ export default {
back() {
this.leavePage()
if(this.projectPermissions){
if(location.host.includes('liuwanr.cn')){
location.href = `http://www.liuwanr.cn/#/dashboard#2`
}else{
location.href = `http://www.occupationlab.com/#/dashboard#2`
}
location.href = `${this.host}#/dashboard#2`
}else{
if(location.host.includes('liuwanr.cn')){
location.href = `http://www.liuwanr.cn/#/dashboard#1`
}else{
location.href = `http://www.occupationlab.com/#/dashboard#1`
}
location.href = `${this.host}#/dashboard#1`
}
this.$refs.mainindex.getClearTime();
},

Loading…
Cancel
Save