Skip to content

Commit

Permalink
fix: ui: fix copy text from term
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <[email protected]>
  • Loading branch information
zhaojh329 committed Jul 31, 2022
1 parent 25e9fad commit 6cd4093
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 31 deletions.
83 changes: 83 additions & 0 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"view-design": "^4.7.0-beta.9",
"vue": "^2.6.11",
"vue-axios": "^3.3.7",
"vue-clipboard2": "^0.3.3",
"vue-i18n": "^8.25.1",
"vue-router": "^3.2.0",
"xterm": "^4.14.1",
Expand Down
4 changes: 3 additions & 1 deletion ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,7 @@
"Delete success": "Delete success",
"Delete offline devices": "Delete offline devices",
"There are no offline devices in selected devices": "There are no offline devices in selected devices",
"Invalid address": "Invalid address"
"Invalid address": "Invalid address",
"Already copied to clipboard": "Already copied to clipboard",
"Please use shortcut \"Shift+Insert\"": "Please use shortcut \"Shift+Insert\""
}
4 changes: 3 additions & 1 deletion ui/src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,7 @@
"Delete success": "删除成功",
"Delete offline devices": "删除离线设备",
"There are no offline devices in selected devices": "所选设备中无离线设备",
"Invalid address": "无效的地址"
"Invalid address": "无效的地址",
"Already copied to clipboard": "已复制到剪切板",
"Please use shortcut \"Shift+Insert\"": "请使用快捷键 \"Shift+Insert\""
}
2 changes: 2 additions & 0 deletions ui/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import App from './App.vue'
import router from './router'
import axios from 'axios'
import VueAxios from 'vue-axios'
import VueClipboard from 'vue-clipboard2'
import i18n from './plugins/vue-i18n'
import './plugins/view-design'
import './assets/iconfont/iconfont.css'

Vue.config.productionTip = false

Vue.use(VueClipboard)
Vue.use(VueAxios, axios);

new Vue({
Expand Down
19 changes: 0 additions & 19 deletions ui/src/plugins/clipboard.js

This file was deleted.

18 changes: 8 additions & 10 deletions ui/src/views/Rtty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<script>
import Contextmenu from '@/components/ContextMenu'
import ClipboardEx from '@/plugins/clipboard'
import { Terminal } from 'xterm'
import { FitAddon } from 'xterm-addon-fit'
import OverlayAddon from '@/plugins/xterm-addon-overlay'
Expand Down Expand Up @@ -71,9 +69,14 @@ export default {
},
onContextmenuClick(name) {
if (name === 'copy') {
ClipboardEx.write(this.term.getSelection() || '');
const text = this.term.getSelection();
if (text) {
this.$copyText(text).then(() => {
this.$Message.info(this.$t('Already copied to clipboard').toString());
})
}
} else if (name === 'paste') {
ClipboardEx.read().then(text => this.term.paste(text));
this.$Message.info(this.$t('Please use shortcut "Shift+Insert"').toString());
} else if (name === 'clear') {
this.term.clear();
} else if (name === 'font+') {
Expand All @@ -85,12 +88,7 @@ export default {
if (size && size > 12)
this.updateFontSize(size - 1);
} else if (name === 'file') {
this.$Modal.info({
content: this.$t('Please execute command "rtty -R" or "rtty -S" in current terminal!'),
onOk: () => {
this.term.focus();
}
});
this.$Message.info(this.$t('Please execute command "rtty -R" or "rtty -S" in current terminal!').toString());
} else if (name === 'about') {
window.open('https://github.com/zhaojh329/rtty');
}
Expand Down

0 comments on commit 6cd4093

Please sign in to comment.