Skip to content

Commit 000a9c5

Browse files
committed
fix(frontend): 优化整站复制功能 TencentBlueKing#9221
1 parent 1e009e9 commit 000a9c5

File tree

97 files changed

+452
-461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+452
-461
lines changed

dbm-ui/frontend/src/components/cluster-selector/Index.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@
156156
import { getTendbsingleList } from '@services/source/tendbsingle';
157157
import type { ListBase } from '@services/types';
158158
159-
import { useCopy, useSelectorDialogWidth } from '@hooks';
159+
import { useSelectorDialogWidth } from '@hooks';
160160
161161
import { ClusterTypes } from '@common/const';
162162
163-
import { messageWarn } from '@utils';
163+
import { execCopy, messageWarn } from '@utils';
164164
165165
import ResultPreview from './components/common/result-preview/Index.vue';
166166
import type { SearchSelectList } from './components/common/SearchBar.vue';
@@ -232,7 +232,6 @@
232232
});
233233
234234
const slots = useSlots();
235-
const copy = useCopy();
236235
const { dialogWidth } = useSelectorDialogWidth();
237236
const { t } = useI18n();
238237
@@ -564,8 +563,7 @@
564563
messageWarn(t('没有可复制集群'));
565564
return;
566565
}
567-
568-
copy(copyValues.join('\n'));
566+
execCopy(copyValues.join('\n'), t('复制成功,共n条', { n: copyValues.length }));
569567
};
570568
571569
const handleConfirm = () => {

dbm-ui/frontend/src/components/db-member-selector/index.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
4747
import { getUserList } from '@services/source/user';
4848
49-
import { useCopy } from '@hooks';
49+
import { execCopy } from '@utils';
5050
5151
const emits = defineEmits<{
5252
(e: 'change', value: string[]): void;
@@ -57,7 +57,6 @@
5757
});
5858
5959
const { t } = useI18n();
60-
const copy = useCopy();
6160
6261
const userSelectorRef = ref();
6362
const isHover = ref(false);
@@ -133,7 +132,7 @@
133132
};
134133
135134
const handleCopy = () => {
136-
copy(modelValue.value.join(';'));
135+
execCopy(modelValue.value.join(';'), t('复制成功,共n条', { n: modelValue.value.length }));
137136
};
138137
</script>
139138

dbm-ui/frontend/src/components/editable-info/index.vue

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<i
7777
v-if="config.isCopy"
7878
class="base-info__icon db-icon-copy"
79-
@click.stop="handleCopy(data[config.key])" />
79+
@click.stop="execCopy(data[config.key], t('复制成功,共n条', { n: 1 }))" />
8080
</div>
8181
</template>
8282
</div>
@@ -88,9 +88,7 @@
8888
<script lang="tsx">
8989
import type { VNode } from 'vue';
9090
91-
import { useCopy } from '@hooks';
92-
93-
import { generateId } from '@utils';
91+
import { execCopy, generateId } from '@utils';
9492
9593
import { t } from '@locales/index';
9694
@@ -226,11 +224,6 @@
226224
}
227225
}
228226
};
229-
230-
/**
231-
* 复制信息
232-
*/
233-
const handleCopy = useCopy();
234227
</script>
235228

236229
<style lang="less" scoped>

dbm-ui/frontend/src/components/host-preview/HostPreview.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<BkButton
2929
class="mr-8"
3030
@click="handleCopyIps">
31-
{{ $t('复制全部IP') }}
31+
{{ $t('复制所有IP') }}
3232
</BkButton>
3333
<BkInput
3434
v-model="state.keyword"
@@ -65,10 +65,12 @@
6565
6666
import type { HostNode } from '@services/types';
6767
68-
import { useCopy, useDefaultPagination } from '@hooks';
68+
import { useDefaultPagination } from '@hooks';
6969
7070
import DbStatus from '@components/db-status/index.vue';
7171
72+
import { execCopy } from '@utils';
73+
7274
interface Props {
7375
fetchParams: Record<string, any>,
7476
fetchNodes: (params: any) => Promise<HostNode[]>,
@@ -83,7 +85,6 @@
8385
});
8486
8587
const { t } = useI18n();
86-
const copy = useCopy();
8788
8889
/**
8990
* 预览表格配置
@@ -161,14 +162,16 @@
161162
162163
function handleCopyAbnormalIps() {
163164
const abnormalIps = state.data.filter(item => item.status === 0).map(item => item.bk_host_innerip);
164-
if (abnormalIps.length === 0) return;
165-
copy(abnormalIps.join('\n'));
165+
if (abnormalIps.length > 0) {
166+
execCopy(abnormalIps.join('\n'), t('复制成功,共n条', { n: abnormalIps.length }));
167+
}
166168
}
167169
168170
function handleCopyIps() {
169171
const ips = state.data.map(item => item.bk_host_innerip);
170-
if (ips.length === 0) return;
171-
copy(ips.join('\n'));
172+
if (ips.length > 0) {
173+
execCopy(ips.join('\n'), t('复制成功,共n条', { n: ips.length }));
174+
}
172175
}
173176
174177
/**

dbm-ui/frontend/src/components/instance-selector/components/common/preview-result/Index.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@
6868
<script setup lang="ts" generic="T extends IValue">
6969
import { useI18n } from 'vue-i18n';
7070
71-
import { useCopy } from '@hooks';
72-
73-
import { messageWarn } from '@utils';
71+
import { execCopy, messageWarn } from '@utils';
7472
7573
import type { InstanceSelectorValues, IValue } from '../../../Index.vue';
7674
@@ -99,7 +97,6 @@
9997
const emits = defineEmits<Emits>();
10098
10199
const { t } = useI18n();
102-
const copy = useCopy();
103100
104101
const keys = computed(() => Object.keys(props.lastValues) as Keys[]);
105102
const isEmpty = computed(() => keys.value.every((key) => props.lastValues[key].length < 1));
@@ -133,7 +130,8 @@
133130
for (const key of keys.value) {
134131
instances.push(...props.lastValues[key]);
135132
}
136-
copy(instances.map((item) => item[mainKey.value]).join('\n'));
133+
const copyData = instances.map((item) => item[mainKey.value]);
134+
execCopy(copyData.join('\n'), t('复制成功,共n条', { n: copyData.length }));
137135
};
138136
</script>
139137
<style lang="less">

dbm-ui/frontend/src/components/ip-selector/IpSelector.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,15 @@
118118
import { getWhitelist } from '@services/source/whitelist';
119119
import type { HostInfo } from '@services/types';
120120
121-
import { useCopy, useFormItem } from '@hooks';
121+
import { useFormItem } from '@hooks';
122122
123123
import { OSTypes } from '@common/const';
124124
125125
import DBCollapseTable from '@components/db-collapse-table/DBCollapseTable.vue';
126126
import DbStatus from '@components/db-status/index.vue';
127127
128+
import { execCopy } from '@utils';
129+
128130
import { t } from '@locales/index';
129131
130132
import PreviewWhitelist from './components/PreviewWhitelist.vue';
@@ -192,7 +194,6 @@
192194
default: false,
193195
});
194196
195-
const copy = useCopy();
196197
const formItem = useFormItem();
197198
198199
const cloudTips = computed(() => {
@@ -369,15 +370,15 @@
369370
label: t('复制所有IP'),
370371
onClick: () => {
371372
const ips = selectorState.selected.host_list.map((item: any) => item.ip);
372-
copy(ips.join('\n'));
373+
copy(ips);
373374
},
374375
},
375376
{
376377
label: t('复制异常IP'),
377378
onClick: () => {
378379
const abnormalHosts = selectorState.selected.host_list.filter((item: any) => item.alive === 0);
379380
const abnormalIps = abnormalHosts.map((item: any) => item.ip);
380-
copy(abnormalIps.join('\n'));
381+
copy(abnormalIps);
381382
},
382383
}];
383384
@@ -392,6 +393,10 @@
392393
deep: true,
393394
});
394395
396+
const copy = (list: string[]) => {
397+
execCopy(list.join('\n'), t('复制成功,共n条', { n: list.length }))
398+
}
399+
395400
/**
396401
* ip 选择器预览表默认配置
397402
*/

dbm-ui/frontend/src/components/ip-selector/components/PreviewWhitelist.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
3939
import { getWhitelist } from '@services/source/whitelist';
4040
41-
import { useCopy } from '@hooks';
42-
4341
import DBCollapseTable from '@components/db-collapse-table/DBCollapseTable.vue';
4442
import RenderRow from '@components/render-row/index.vue';
4543
44+
import { execCopy } from '@utils';
45+
4646
type WhitelistItem = ServiceReturnType<typeof getWhitelist>['results'][number]
4747
4848
interface Props {
@@ -59,7 +59,6 @@
5959
const emits = defineEmits<Emits>();
6060
6161
const { t } = useI18n();
62-
const copy = useCopy();
6362
6463
const totals = computed(() => {
6564
const ips = props.data.reduce((result, item) => result.concat(item.ips || []), [] as string[]);
@@ -114,7 +113,7 @@
114113
label: t('复制'),
115114
onClick: () => {
116115
const ips = props.data.reduce((result: string[], item: WhitelistItem) => result.concat(item.ips), []);
117-
copy(ips.join('\n'));
116+
execCopy(ips.join('\n'), t('复制成功,共n条', { n: ips.length }));
118117
},
119118
}];
120119

dbm-ui/frontend/src/components/tag-block/Index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
);
167167
168168
const handleCopy = () => {
169-
execCopy(props.data.join('\n'), t('复制成功'));
169+
execCopy(props.data.join('\n'), t('复制成功,共n条', { n: props.data.length }));
170170
};
171171
172172
let resizeObserver: any;

dbm-ui/frontend/src/hooks/useLinkQueryColumnSerach.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export const useLinkQueryColumnSerach = (config: {
7373
return [];
7474
});
7575

76+
const isFilter = computed(() => searchValue.value.length > 0);
77+
7678
const resourceTypes = ['spotty_host', 'resource_record'];
7779

7880
const sortValue: {
@@ -342,6 +344,7 @@ export const useLinkQueryColumnSerach = (config: {
342344
sortValue,
343345
columnCheckedMap,
344346
batchSearchIpInatanceList,
347+
isFilter,
345348
columnFilterChange,
346349
columnSortChange,
347350
clearSearchValue,

dbm-ui/frontend/src/locales/zh-cn.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@
514514
"请输入IP搜索": "请输入 IP 搜索",
515515
"复制已选IP": "复制已选 IP",
516516
"复制异常IP": "复制异常 IP",
517-
"复制全部IP": "复制全部 IP",
517+
"复制全部IP": "复制所有 IP",
518518
"替换": "替换",
519519
"节点列表": "节点列表",
520520
"当前集群有xx暂时不能进行其他操作跳转xx查看进度": "当前集群有 {0} 暂时不能进行其他操作跳转 {1} 查看进度",
@@ -965,7 +965,7 @@
965965
"数据版本": "数据版本",
966966
"没有可复制实例": "没有可复制实例",
967967
"请输入实例_enter进行搜索": "请输入实例,enter 进行搜索",
968-
"复制全部实例": "复制全部实例",
968+
"复制全部实例": "复制所有实例",
969969
"复制异常实例": "复制异常实例",
970970
"xx预览": "{name} 预览",
971971
"查看更多": "查看更多",
@@ -1443,7 +1443,7 @@
14431443
"消费主机": "消费主机",
14441444
"请选择操作时间": "请选择操作时间",
14451445
"请选择匹配规格": "请选择匹配规格",
1446-
"复制全部 IP": "复制全部 IP",
1446+
"复制全部 IP": "复制所有 IP",
14471447
"请选择切换模式": "请选择切换模式",
14481448
"目标台数不能为空": "目标台数不能为空",
14491449
"确认整机替换n台主机?": "确认整机替换 {n} 台主机?",
@@ -3940,5 +3940,6 @@
39403940
"展示我作为主 DBA 的业务,当日所产生的巡检异常,一般每日更新一次": "展示我作为主 DBA 的业务,当日所产生的巡检异常,一般每日更新一次",
39413941
"展示我作为备 DBA、二线 DBA 的业务,当日所产生的巡检异常,一般每日更新一次": "展示我作为备 DBA、二线 DBA 的业务,当日所产生的巡检异常,一般每日更新一次",
39423942
"主DBA": "主 DBA",
3943+
"复制成功,共n条": "复制成功,共 {n} 条",
39433944
"这行勿动!新增翻译请在上一行添加!": ""
39443945
}

dbm-ui/frontend/src/views/db-manage/common/RenderPassword.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,17 @@
110110
111111
import { getPulsarPassword } from '@services/source/pulsar';
112112
113-
import { useCopy } from '@hooks';
114-
115113
import type { DBTypes } from '@common/const';
116114
115+
import { execCopy } from '@utils';
116+
117117
interface Props {
118118
clusterId: number;
119119
dbType?: DBTypes;
120120
}
121121
122122
const props = defineProps<Props>();
123123
124-
const copy = useCopy();
125124
const { t } = useI18n();
126125
127126
const isLoading = ref(true);
@@ -194,6 +193,10 @@
194193
}
195194
};
196195
196+
const copy = (value: string) => {
197+
execCopy(value, t('复制成功,共n条', { n: 1 }));
198+
};
199+
197200
const handlePasswordToggle = () => {
198201
isShowPassword.value = !isShowPassword.value;
199202
};

dbm-ui/frontend/src/views/db-manage/common/big-data-host-table/HdfsHostTable.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@
8686
8787
import type { HostInfo } from '@services/types';
8888
89-
import { useCopy } from '@hooks';
90-
9189
import DbStatus from '@components/db-status/index.vue';
9290
91+
import { execCopy } from '@utils';
92+
9393
import tableSetting from './common/tableSetting';
9494
import useLocalPagination from './hook/useLocalPagination';
9595
@@ -105,7 +105,6 @@
105105
const props = defineProps<Props>();
106106
const emits = defineEmits<Emits>();
107107
108-
const copy = useCopy();
109108
const { t } = useI18n();
110109
111110
const isLoading = ref(false);
@@ -344,7 +343,7 @@
344343
// 复制所有主机IP
345344
const handleCopyAll = () => {
346345
const ipList = props.data.map(_ => _.ip);
347-
copy(ipList.join('\n'));
346+
execCopy(ipList.join('\n'), t('复制成功,共n条', { n: ipList.length }));
348347
};
349348
// 复制异常主机IP
350349
const handleCopyAbnormal = () => {
@@ -354,7 +353,7 @@
354353
}
355354
return result;
356355
}, [] as Array<string>);
357-
copy(abnormalList.join('\n'));
356+
execCopy(abnormalList.join('\n'), t('复制成功,共n条', { n: abnormalList.length }));
358357
};
359358
</script>
360359
<style lang="less" scoped>

0 commit comments

Comments
 (0)