12 changed files with 228 additions and 31 deletions
-
11package-lock.json
-
1package.json
-
35src/components/LoginForm.vue
-
9src/components/Progress.vue
-
59src/components/SimpleKeyboard.vue
-
33src/components/Test.vue
-
1src/pages/Home.vue
-
35src/pages/Login.vue
-
8src/store/modules/operator.js
-
62src/store/modules/websocket.js
-
0src/utils/index.js
-
5yarn.lock
@ -0,0 +1,59 @@ |
|||
<template> |
|||
<div :class="keyboardClass"></div> |
|||
</template> |
|||
|
|||
<script> |
|||
import Keyboard from 'simple-keyboard' |
|||
import 'simple-keyboard/build/css/index.css' |
|||
|
|||
export default { |
|||
name: 'SimpleKeyboard', |
|||
props: { |
|||
keyboardClass: { |
|||
default: 'simple-keyboard', |
|||
type: String, |
|||
}, |
|||
input: { |
|||
type: String, |
|||
}, |
|||
}, |
|||
data: () => ({ |
|||
keyboard: null, |
|||
}), |
|||
mounted() { |
|||
this.keyboard = new Keyboard(this.keyboardClass, { |
|||
onChange: this.onChange, |
|||
onKeyPress: this.onKeyPress, |
|||
}) |
|||
}, |
|||
methods: { |
|||
onChange(input) { |
|||
this.$emit('onChange', input) |
|||
}, |
|||
onKeyPress(button) { |
|||
this.$emit('onKeyPress', button) |
|||
|
|||
/** |
|||
* If you want to handle the shift and caps lock buttons |
|||
*/ |
|||
if (button === '{shift}' || button === '{lock}') this.handleShift() |
|||
}, |
|||
handleShift() { |
|||
let currentLayout = this.keyboard.options.layoutName |
|||
let shiftToggle = currentLayout === 'default' ? 'shift' : 'default' |
|||
|
|||
this.keyboard.setOptions({ |
|||
layoutName: shiftToggle, |
|||
}) |
|||
}, |
|||
}, |
|||
watch: { |
|||
input(input) { |
|||
this.keyboard.setInput(input) |
|||
}, |
|||
}, |
|||
} |
|||
</script> |
|||
|
|||
<!-- Add "scoped" attribute to limit CSS to this component only --> |
|||
<style lang="scss" scoped></style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue