From 02c8bdbba7b3a9195042b56d8a797b70b37ee436 Mon Sep 17 00:00:00 2001 From: caill <815519168@qq.com> Date: Wed, 22 Nov 2023 17:11:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=AE=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SimpleKeyboard.vue | 113 ++++++++++++++-------- src/components/keyboard-input.vue | 8 +- src/pages/modules/login/login.vue | 15 ++- src/pages/modules/systemmanage/role.vue | 31 +++++- src/pages/modules/systemmanage/system.vue | 37 +++++-- src/pages/modules/systemmanage/user.vue | 40 +++++++- src/style/common.styl | 11 ++- 7 files changed, 190 insertions(+), 65 deletions(-) diff --git a/src/components/SimpleKeyboard.vue b/src/components/SimpleKeyboard.vue index a9ac0e1..8268178 100644 --- a/src/components/SimpleKeyboard.vue +++ b/src/components/SimpleKeyboard.vue @@ -31,7 +31,41 @@ export default { '{space}': ' ', '{clear}': 'Clear', '{close}': 'Close' - } + }, + buttonTheme: [ + { + class: 'hg-gray', + buttons: '{bksp}' + }, + { + class: 'hg-gray', + buttons: '{tab}' + }, + { + class: 'hg-gray', + buttons: '{enter}' + }, + { + class: 'hg-gray', + buttons: '{clear}' + }, + { + class: 'hg-blue', + buttons: '{close}' + }, + { + class: 'hg-blue', + buttons: '{change}' + }, + { + class: 'hg-gray', + buttons: '{lock}' + }, + { + class: 'hg-gray', + buttons: '{shift}' + } + ] }), mounted () { this.keyboard = new Keyboard(this.keyboardClass, { @@ -58,40 +92,7 @@ export default { // 按钮展示文字 display: this.displayDefault, // 按钮样式 - buttonTheme: [ - { - class: 'hg-gray', - buttons: '{bksp}' - }, - { - class: 'hg-gray', - buttons: '{tab}' - }, - { - class: 'hg-gray', - buttons: '{lock}' - }, - { - class: 'hg-gray', - buttons: '{enter}' - }, - { - class: 'hg-gray', - buttons: '{shift}' - }, - { - class: 'hg-gray', - buttons: '{clear}' - }, - { - class: 'hg-blue', - buttons: '{close}' - }, - { - class: 'hg-blue', - buttons: '{change}' - } - ], + buttonTheme: this.buttonTheme, // 输入限制长度 maxLength: this.maxLength }) @@ -102,9 +103,8 @@ export default { }, onKeyPress (button, $event) { // 点击关闭 - if (button === '{close}') { - // debugger - // this.$parent.closekeyboard() + if (button === '{close}' || button === '{enter}') { + // this.keyboard.destroy() let arr = document.querySelectorAll('.hg-theme-default') arr.forEach((ele) => { ele.style.visibility = 'hidden' @@ -130,17 +130,30 @@ export default { } else if (button === '{clear}') { this.keyboard.clearInput() } else if (button === '{shift}' || button === '{lock}') { - this.handleShift() + this.handleShift(button) } this.$emit('onKeyPress', button) }, // 切换shift/默认布局 - handleShift () { + handleShift (button) { let currentLayout = this.keyboard.options.layoutName let shiftToggle = currentLayout === 'default' ? 'shift' : 'default' this.keyboard.setOptions({ layoutName: shiftToggle }) + let buttonTheme = [] + if (currentLayout === 'default') { + let addClass = button === '{shift}' ? {class: 'hg-blue2', buttons: '{shift}'} : {class: 'hg-blue2', buttons: '{lock}'} + buttonTheme = [...this.buttonTheme, addClass] + this.keyboard.setOptions({ + buttonTheme: buttonTheme + }) + } else if (currentLayout === 'shift') { + buttonTheme = [...this.buttonTheme] + this.keyboard.setOptions({ + buttonTheme: buttonTheme + }) + } } }, watch: { @@ -160,7 +173,7 @@ export default { right: 0; bottom: 0; z-index: 1000; - width 100% + width 100%; padding: 1em; background-color: #eee; box-shadow: 0 -3px 10px rgba(0,0,0,.3); @@ -195,6 +208,17 @@ export default { -ms-user-select: none; user-select: none; cursor: pointer; + padding: 0; + box-sizing: content-box; + &:hover + color: #333; + background-color: #d6d6d6; + border-color: #adadad; + &:active + transform: scale(.98); + color: #333; + background-color: #d4d4d4; + border-color: #8c8c8c; & .hg-button-bksp flex: 65 1 0%; background-image: url("../images/backspace.svg"); @@ -214,6 +238,10 @@ export default { color: #fff; background-color: #337ab7; border-color: #2e6da4; + & .hg-blue2 + color: #fff; + background-color: #5bc0de; + border-color: #46b8da; & .hg-button-tab flex: 60 1 0%; & .hg-button-lock, .hg-button-enter @@ -225,4 +253,7 @@ export default { & .font-s font-size .75em opacity 0.6 +/deep/ .hg-candidate-box + height 40px + color #000 diff --git a/src/components/keyboard-input.vue b/src/components/keyboard-input.vue index 1626794..e0c45c0 100644 --- a/src/components/keyboard-input.vue +++ b/src/components/keyboard-input.vue @@ -76,6 +76,7 @@ export default { this.$emit('input') }, focusInput (e) { + this.$emit('inputFocus') this.inputEle = e.srcElement // 关闭所有keyboard let arr = document.querySelectorAll('.hg-theme-default') @@ -113,7 +114,7 @@ export default { if (button === '{clear}') { this.inputValue = '' } - console.log('onKeyPress', button) + // console.log('onKeyPress', button) } } } @@ -122,12 +123,13 @@ export default {