AutoCommit/src/views/autoCommit.html

83 lines
2.2 KiB
HTML
Raw Normal View History

2019-12-26 17:47:37 +08:00
<!DOCTYPE html>
<html>
2019-12-27 16:02:37 +08:00
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Github自动提交commit工具</title>
<link href="../assets/styles/element-ui2.13.min.css" rel="stylesheet" />
<link href="../assets/styles/base.css" rel="stylesheet" />
<link href="../assets/styles/autoCommit.css" rel="stylesheet" />
</head>
2019-12-26 17:47:37 +08:00
2019-12-27 16:02:37 +08:00
<body>
<div id="app">
<el-container>
<el-header>Header</el-header>
<el-main>Main</el-main>
</el-container>
2019-12-26 17:47:37 +08:00
</div>
</div>
2019-12-27 16:02:37 +08:00
</body>
2019-12-26 17:47:37 +08:00
<script src="../assets/scripts/vue.min.js"></script>
2019-12-27 16:02:37 +08:00
<script src="../assets/scripts/element2.13.min.js"></script>
2019-12-26 17:47:37 +08:00
<script>
2019-12-27 16:02:37 +08:00
const vscode = acquireVsCodeApi();
2019-12-26 17:47:37 +08:00
new Vue({
2019-12-27 16:02:37 +08:00
el: '#app',
2019-12-26 17:47:37 +08:00
data() {
return {
// userName: 18850985993,
// password: 'HgbOBKoro1'
2019-12-27 16:02:37 +08:00
};
2019-12-26 17:47:37 +08:00
},
mounted() {
2019-12-27 16:02:37 +08:00
this.initListener();
2019-12-26 17:47:37 +08:00
},
methods: {
// 登录
login() {
2019-12-27 16:02:37 +08:00
const { elUserName, elPassword } = this.$refs;
const { userName, password } = this.$data;
2019-12-26 17:47:37 +08:00
const formData = {
username: String(userName),
password: String(password)
2019-12-27 16:02:37 +08:00
};
2019-12-26 17:47:37 +08:00
if (!userName) {
2019-12-27 16:02:37 +08:00
this.postMessage('用户名不能为空');
elUserName.focus();
return;
2019-12-26 17:47:37 +08:00
}
if (!password) {
2019-12-27 16:02:37 +08:00
this.postMessage('密码不能为空');
elPassword.focus();
return;
2019-12-26 17:47:37 +08:00
}
2019-12-27 16:02:37 +08:00
this.postMessage('user-login-message', 'event', formData);
2019-12-26 17:47:37 +08:00
},
// 发送消息到插件
postMessage(text, command = 'alert', params) {
vscode.postMessage({
command,
text,
params
2019-12-27 16:02:37 +08:00
});
2019-12-26 17:47:37 +08:00
},
// 注册
initListener() {
window.addEventListener('message', event => {
2019-12-27 16:02:37 +08:00
console.log('event', event);
const { command, data } = event.data;
console.log('登录成功 addEventListener', event);
2019-12-26 17:47:37 +08:00
if (command === 'success') {
// 登录成功
}
2019-12-27 16:02:37 +08:00
});
}
2019-12-26 17:47:37 +08:00
}
2019-12-27 16:02:37 +08:00
}).$mount('#xpLogin');
2019-12-26 17:47:37 +08:00
</script>
2019-12-27 16:02:37 +08:00
</html>