Skip to content

Commit

Permalink
optimization: 复制IP默认以换行符进行分隔 (closed TencentBlueKing#1140)
Browse files Browse the repository at this point in the history
  • Loading branch information
GONGONGONG committed Sep 26, 2022
1 parent bed82fc commit a3072ff
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 19 deletions.
4 changes: 4 additions & 0 deletions dev_log/2.2.26/daoqgong_202209261602.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
optimization:
- "复制IP默认以换行符进行分隔 (closed #1140)"

41 changes: 41 additions & 0 deletions frontend/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 frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"query-string": "~6.5.0",
"resize-detector": "^0.2.0",
"vue": "2.6.12",
"vue-clipboard2": "~0.3.3",
"vue-i18n": "^8.15.1",
"vue-router": "~3.0.6",
"vuex": "~3.1.1",
Expand Down
31 changes: 12 additions & 19 deletions frontend/src/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,26 +439,19 @@ export const transformDataKey = (data: Dictionary = {}, mode = 'camel'): Diction
* @param {String} text
*/
export const copyText = (text: string, successFn?: Function) => {
window.copyContentText = text || '';
let result = 'failed';
if (!window.copyContentText) {
window.bus.$bkMessage({
theme: 'error',
message: window.i18n.t('复制出错,再重新复制一遍吧'),
});
return result;
}
result = copyListener();
if (result === 'success' && successFn) {
successFn(result);
}
if (result === 'failed') {
window.copyFailedMsg = window.bus.$bkMessage({
theme: 'error',
message: getCopyBtn(successFn),
});
if (!text) {
window.bus.messageInfo(window.i18n.t('没有需要复制的内容'));
return;
}
return result;
window.bus.$copyText(text).then(() => {
if (successFn) {
successFn();
} else {
window.bus.messageSuccess(window.i18n.t('复制成功'));
}
}, () => {
window.copyFailedMsg = window.bus.messageError(getCopyBtn(successFn));
});
};

function copyListener() {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ export default {
节点来源: 'Node from',
请输入关键字: 'Please enter key words',
复制成功: 'Copied successfully',
没有需要复制的内容: 'Nothing to copy',
查看任务详情: 'View job details',

// 全局配置 - GSE-环境管理
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ export default {
节点来源: '节点来源',
请输入关键字: '请输入关键字',
复制成功: '复制成功',
没有需要复制的内容: '没有需要复制的内容',
查看任务详情: '查看任务详情',

// 全局配置 - GSE-环境管理
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/setup/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import cursor from '@/common/cursor';
import freezingPage from '@/common/freezing-page';
import authority from '@/common/authority';
import testAnchor from '@/common/test-anchor';
import VueClipboard from 'vue-clipboard2';

Vue.use(cursor);
Vue.use(freezingPage);
Vue.use(authority);
Vue.use(testAnchor);
VueClipboard.config.autoSetContainer = true;
Vue.use(VueClipboard);
3 changes: 3 additions & 0 deletions frontend/src/vue-proto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ declare module 'vue/types/vue' {
interactive?: boolean
}) => {}
$bkMessage: (options: { [prop: string]: any }) => {}
messageSuccess: (message: string, delay?: number) => {}
messageError: (message: string, delay?: number) => {}
messageInfo: (message: string, delay?: number) => {}
$bkInfo: (options: {
title: string | TranslateResult
subTitle?: string | TranslateResult
Expand Down

0 comments on commit a3072ff

Please sign in to comment.