Skip to content

Commit

Permalink
fix: 修复页面缓存时,函数调试页快捷键重复绑定问题;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Aug 6, 2021
1 parent f8a94c8 commit 1a26cf3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
14 changes: 1 addition & 13 deletions packages/devops-admin/src/components/FunctionEditor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ export default {
// 加载必要的类型文件
autoImportTypings.loadDefaults()
// listen Ctrl+S
document.addEventListener('keydown', this.save, false)
},
beforeDestroy() {
document.removeEventListener('keydown', this.save, false)
},
methods: {
getValue() {
Expand All @@ -86,13 +80,7 @@ export default {
/**
* 当代码变化时,尝试解析是否有新 import 的依赖,并加载其类型文件
*/
parseImports: _.debounce(autoImportTypings.parse, 2000, { leading: true }).bind(autoImportTypings),
save(e) {
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
this.$emit('save', this.getValue())
e.preventDefault()
}
}
parseImports: _.debounce(autoImportTypings.parse, 2000, { leading: true }).bind(autoImportTypings)
}
}
</script>
Expand Down
17 changes: 12 additions & 5 deletions packages/devops-admin/src/views/development/function.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<div style="display: flex;">
<div class="editor-container">
<function-editor v-model="value" :height="700" :dark="false" @save="updateFunc" />
<function-editor v-model="value" :height="700" :dark="false" />
</div>
<div class="lastest-logs">
<el-card shadow="never" :body-style="{ padding: '20px' }">
Expand Down Expand Up @@ -172,10 +172,10 @@ export default {
this.getLatestLogs()
this.setTagViewTitle()
},
mounted() {
activated() {
document.addEventListener('keydown', this.bindShortKey, false)
},
beforeDestroy() {
deactivated() {
document.removeEventListener('keydown', this.bindShortKey, false)
},
methods: {
Expand Down Expand Up @@ -336,13 +336,20 @@ export default {
return param
},
// 快捷键绑定
bindShortKey(e) {
// Ctrl + b 为调试运行,并弹出
async bindShortKey(e) {
// Ctrl + s 为保存
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
this.updateFunc()
e.preventDefault()
}
// Ctrl + j 弹出/隐藏调试框
if ((e.ctrlKey || e.metaKey) && e.key === 'j') {
this.showDebugPanel = !this.showDebugPanel
e.preventDefault()
}
// Ctrol + 为调试运行,并弹出调试框
if ((e.ctrlKey || e.metaKey) && e.key === 'b') {
this.showDebugPanel = true
this.launch()
Expand Down

0 comments on commit 1a26cf3

Please sign in to comment.