Skip to content

Commit 0d32dc5

Browse files
committed
界面优化
1 parent cfc9718 commit 0d32dc5

25 files changed

+1359
-42
lines changed

README.md

+4-16
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,8 @@
22

33
> Teaching python editor
44
5-
## Build Setup
5+
### Teaching对接说明
66

7-
``` bash
8-
# install dependencies
9-
npm install
10-
11-
# serve with hot reload at localhost:8080
12-
npm run dev
13-
14-
# build for production with minification
15-
npm run build
16-
17-
# build for production and view the bundle analyzer report
18-
npm run build --report
19-
```
20-
21-
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
7+
1. 解压覆盖升级包
8+
2. 数据字典的作业类型(work_type)新增Python,值为4
9+
3. 配置菜单,新增Python菜单 (仿照scratch)

build/webpack.prod.conf.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ const webpackConfig = merge(baseWebpackConfig, {
2424
devtool: config.build.productionSourceMap ? config.build.devtool : false,
2525
output: {
2626
path: config.build.assetsRoot,
27-
filename: utils.assetsPath('js/[name].[chunkhash].js'),
28-
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
27+
// filename: utils.assetsPath('js/[name].[chunkhash].js'),
28+
// chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
29+
filename: utils.assetsPath('js/[name].js'),
30+
chunkFilename: utils.assetsPath('js/[id].js')
2931
},
3032
plugins: [
3133
// http://vuejs.github.io/vue-loader/en/workflow/production.html
@@ -43,7 +45,8 @@ const webpackConfig = merge(baseWebpackConfig, {
4345
}),
4446
// extract css into its own file
4547
new ExtractTextPlugin({
46-
filename: utils.assetsPath('css/[name].[contenthash].css'),
48+
// filename: utils.assetsPath('css/[name].[contenthash].css'),
49+
filename: utils.assetsPath('css/[name].css'),
4750
// Setting the following option to `false` will not extract CSS from codesplit chunks.
4851
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
4952
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,

src/components/JCodeEditor.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ export default {
355355
});
356356
357357
//自动提示
358-
this.coder.on("keyHandled", (e) => {
359-
console.log(e);
360-
this.coder.showHint();
361-
});
358+
// this.coder.on("keyHandled", (e) => {
359+
// console.log(e);
360+
// this.coder.showHint();
361+
// });
362362
},
363363
getCodeContent() {
364364
return this.code;

src/components/PythonEditor.vue

+67-19
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,46 @@
11
<template>
22
<div>
33
<a-layout>
4-
<a-layout-header>
5-
欢迎使用Python在线编辑器
4+
<a-layout-header style="padding: 0; height: 50px">
5+
<!-- 控制按钮 -->
6+
<a-menu mode="horizontal" style="color: black; height: 100%">
7+
<a-sub-menu>
8+
<span slot="title" class="submenu-title-wrapper">
9+
<a-icon type="file" />文件
10+
</span>
11+
<a-menu-item-group>
12+
<a-menu-item key="setting:1">
13+
<a type="primary" @click="openFile">打开</a>
14+
</a-menu-item>
15+
<a-menu-item key="setting:2">
16+
<a type="primary" @click="saveFile">保存</a>
17+
</a-menu-item>
18+
</a-menu-item-group>
19+
</a-sub-menu>
20+
21+
<a-menu-item>
22+
<a-input
23+
v-model="projectName"
24+
placeholder="请输入项目名称"
25+
style="width: 200px"
26+
></a-input>
27+
</a-menu-item>
28+
<a-menu-item>
29+
<a-button type="primary" @click="submitCode">提交</a-button>
30+
</a-menu-item>
31+
32+
<a-menu-item>
33+
<a-button type="primary" @click="runit"
34+
><a-icon type="play-circle" />运行</a-button
35+
>
36+
</a-menu-item>
37+
<a-menu-item>
38+
<a-button type="primary" @click="clear"
39+
><a-icon type="delete" />清空</a-button
40+
>
41+
</a-menu-item>
42+
</a-menu>
43+
<input type="file" id="fileinput" style="display: none" />
644
</a-layout-header>
745
<a-layout>
846
<a-layout-content>
@@ -17,15 +55,6 @@
1755
</a-form-item>
1856
</a-layout-content>
1957
<a-layout-sider :collapsible="false" :width="500" :theme="'light'">
20-
<!-- 控制按钮 -->
21-
<div class="control">
22-
<input type="file" id="fileinput" style="display: none" />
23-
<a-button type="primary" @click="runit">运行</a-button>
24-
<a-button type="primary" @click="clear">清空</a-button>
25-
<a-button type="primary" @click="openFile">打开</a-button>
26-
<a-button type="primary" @click="saveFile">下载</a-button>
27-
<a-button type="primary" @click="submitCode">提交</a-button>
28-
</div>
2958
<!-- 画布 -->
3059
<div id="mycanvas"></div>
3160
<!-- 代码输出 -->
@@ -56,14 +85,26 @@ export default {
5685
return {
5786
code: "",
5887
out: "",
88+
projectName: "",
5989
};
6090
},
6191
mounted() {},
6292
created() {
93+
var that = this
94+
//载入网络项目
6395
var url = this.urlParam("url");
6496
if (url) {
6597
this.downloadFile(url);
98+
} else {
99+
this.downloadFile("./static/defaultPython.py");
66100
}
101+
//兼容载入项目事件
102+
window.document.addEventListener('loadPorject', function(e) {
103+
console.log("load project:"+e.detail.projectName);
104+
console.log(e.detail.url);
105+
that.projectName = e.detail.projectName
106+
that.downloadFile(e.detail.url)
107+
});
67108
},
68109
methods: {
69110
runit() {
@@ -105,14 +146,21 @@ export default {
105146
fileInput.click();
106147
},
107148
saveFile() {
108-
var n = new File([this.code], "python项目.py", {
109-
type: "text/plain;charset=utf-8",
110-
});
149+
var n = new File(
150+
[this.code],
151+
(this.projectName ? this.projectName : "未命名") + ".py",
152+
{
153+
type: "text/plain;charset=utf-8",
154+
}
155+
);
111156
saveAs(n);
112157
},
113158
submitCode() {
159+
if (this.code == "") {
160+
that.$message.info("没有代码可以提交");
161+
}
114162
if (window.submitCode) {
115-
window.submitCode(this.code);
163+
window.submitCode(this.projectName, this.code);
116164
}
117165
},
118166
setCode(code) {
@@ -171,14 +219,14 @@ export default {
171219
}
172220
.control {
173221
margin: 10px;
174-
button{
222+
button {
175223
margin: 10px 0;
176224
}
177225
}
178-
.ant-layout-header{
179-
background: #dfefff;
226+
.ant-layout-header {
227+
background: #dfefff !important;
180228
}
181-
.ant-layout-sider{
229+
.ant-layout-sider {
182230
padding: 10px;
183231
}
184232
</style>
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
window.urlParams = function(paramName) {
2+
var reg = new RegExp('[?&]' + paramName + '=([^&]*)[&]?', 'i')
3+
var paramVal = window.location.search.match(reg)
4+
return paramVal == null ? '' : decodeURIComponent(paramVal[1])
5+
}
6+
7+
window.uuid = function() {
8+
var s = []
9+
var hexDigits = '0123456789abcdef'
10+
for (var i = 0; i < 36; i++) {
11+
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1)
12+
}
13+
s[14] = '4' // bits 12-15 of the time_hi_and_version field to 0010
14+
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1) // bits 6-7 of the clock_seq_hi_and_reserved to 01
15+
s[8] = s[13] = s[18] = s[23] = '-'
16+
var uuid = s.join('')
17+
return uuid
18+
}
19+
20+
21+
window.getUserInfo = function() {
22+
userInfo = localStorage.getItem('pro__Login_Userinfo')
23+
if(userInfo){
24+
userInfo = JSON.parse(userInfo).value
25+
console.log(userInfo)
26+
return userInfo
27+
}
28+
}
29+
30+
window.getUserToken = function() {
31+
var token = JSON.parse(localStorage.getItem("pro__Access-Token"))
32+
return token==null?null:token.value
33+
}
34+
35+
window.getWorkInfo = function(workId, cb) {
36+
$.ajax({
37+
url: '/api/teaching/teachingWork/studentWorkInfo',
38+
data: { workId: workId },
39+
success: function (res) {
40+
if (res.code == 0) {
41+
cb(res.result)
42+
}
43+
},
44+
error: function (e) {
45+
}
46+
})
47+
}
48+
49+
window.getQiniuToken = function() {
50+
var qn_token;
51+
$.ajax({
52+
url: '/api/common/qiniu/getToken',
53+
beforeSend: function(request) {
54+
request.setRequestHeader('X-Access-Token', $.cookie('ACCESS_TOKEN'))
55+
},
56+
async: false,
57+
success: function(res) {
58+
console.log(res)
59+
if (res.code == 200) {
60+
qn_token = res.result
61+
} else {
62+
//alert(res.message)
63+
}
64+
},
65+
error: function(e) {
66+
if (e.responseJSON.status == 500) {
67+
//alert(e.responseJSON.message);
68+
location.href = '/'
69+
}
70+
console.log(e)
71+
}
72+
});
73+
return qn_token;
74+
}
75+
76+
function createCode(id, src) {
77+
$('#' + id).html('')
78+
var qrcode = new QRCode(document.getElementById(id), {
79+
width: 250,
80+
height: 250
81+
})
82+
qrcode.makeCode(src)
83+
}
84+
85+
function dataURLtoBlob(dataurl) {
86+
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
87+
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
88+
while (n--) {
89+
u8arr[n] = bstr.charCodeAt(n);
90+
}
91+
return new Blob([u8arr], { type: mime });
92+
}
93+
94+
95+
window.dataLayer = window.dataLayer || [];
96+
function gtag(){dataLayer.push(arguments);}
97+
gtag('js', new Date());
98+
99+
gtag('config', 'UA-155190299-2');

0 commit comments

Comments
 (0)