Skip to content

Commit 0653e75

Browse files
committed
课程名和用户信息
1 parent bca32b2 commit 0653e75

File tree

3 files changed

+76
-17
lines changed

3 files changed

+76
-17
lines changed

index.html

+44-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,46 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<meta charset="utf-8">
5-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
6-
<title>teaching-python</title>
7-
<script>
8-
window.submitCode = function(code){
9-
console.log(code);
10-
}
11-
</script>
12-
</head>
13-
<body>
14-
<div id="app"></div>
15-
<!-- built files will be auto injected -->
16-
</body>
17-
</html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<title>teaching-python</title>
8+
<script>
9+
window.submitCode = function (code) {
10+
console.log(code);
11+
}
12+
13+
function loadPorject() {
14+
var myEvent = new CustomEvent('loadPorject', {
15+
detail: {
16+
projectName: info.workName,
17+
courseName: "自由创作",
18+
language: typeLanguages[info.workType],
19+
url: info.workFileUrl
20+
}
21+
});
22+
setTimeout(() => {
23+
window.document.dispatchEvent(myEvent);
24+
}, 500)
25+
}
26+
27+
function setUserInfo() {
28+
var myEvent = new CustomEvent('setUserInfo', {
29+
detail: {
30+
username: "未登录",
31+
avatar: "./static/avatar.png",
32+
}
33+
});
34+
setTimeout(() => {
35+
window.document.dispatchEvent(myEvent);
36+
}, 500)
37+
}
38+
</script>
39+
</head>
40+
41+
<body>
42+
<div id="app"></div>
43+
<!-- built files will be auto injected -->
44+
</body>
45+
46+
</html>

src/components/PythonEditor.vue

+32-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
><a-icon type="delete" />清空</a-button
4040
>
4141
</a-menu-item>
42+
<a-menu-item style="float: right">
43+
<div class="right-menu">
44+
<a-input :value="courseName" disabled=""></a-input>
45+
<img :src="avatar" alt="">
46+
<span>{{username}}</span>
47+
</div>
48+
</a-menu-item>
4249
</a-menu>
4350
<input type="file" id="fileinput" style="display: none" />
4451
</a-layout-header>
@@ -102,6 +109,9 @@ export default {
102109
code: "",
103110
out: "",
104111
projectName: "",
112+
courseName: "自由创作",
113+
username: "未登录",
114+
avatar: "./static/avatar.png"
105115
};
106116
},
107117
mounted() {},
@@ -116,11 +126,19 @@ export default {
116126
}
117127
//兼容载入项目事件
118128
window.document.addEventListener("loadPorject", function (e) {
119-
console.log("load project:" + e.detail.projectName);
120-
console.log(e.detail.url);
129+
console.log("load project:");
130+
console.log(e.detail);
121131
that.projectName = e.detail.projectName;
132+
that.courseName = e.detail.courseName;
122133
that.downloadFile(e.detail.url);
123134
});
135+
window.document.addEventListener("setUserInfo", function(e){
136+
console.log("set user info:");
137+
console.log(e.detail);
138+
that.username = e.detail.username;
139+
if(e.detail.avatar)
140+
that.avatar = e.detail.avatar;
141+
});
124142
},
125143
methods: {
126144
runit() {
@@ -249,4 +267,16 @@ export default {
249267
.ant-layout-sider {
250268
padding: 10px;
251269
}
270+
.right-menu {
271+
// float: right;
272+
padding: 5px 10px;
273+
input{
274+
width: 200px;
275+
margin-right: 20px;
276+
}
277+
img{
278+
height: 30px;
279+
width: auto;
280+
}
281+
}
252282
</style>

static/avatar.png

2.9 KB
Loading

0 commit comments

Comments
 (0)