Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vue/src/components/SLCopy.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<Tippy trigger="click">
<template v-slot="{ hide }">
<div class="flex gap-2 items-center">
<div class="flex gap-2 items-center cursor-pointer">
<SLIcon icon="copy" :class="iconClass" @click="copy(hide)" />
<slot></slot>
</div>
Expand All @@ -23,7 +23,7 @@ import { copyTextToClipboard } from '@swanlab-vue/utils/browser'
const props = defineProps({
text: {
// 复制到剪切板的文字
type: String,
type: [String, Number],
required: true
},
iconClass: {
Expand Down
40 changes: 37 additions & 3 deletions vue/src/views/experiment/pages/environment/components/EnvItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
<div class="w-full flex" v-if="envValue">
<!-- key -->
<span class="text-dimmer w-44 shrink-0">{{ $t(`experiment.env.keys.${envKey}`) }}</span>
<span class="break-all" :class="highLight ? 'text-dimmer bg-higher px-2' : ''">
<span
class="break-all relative"
:class="[highLight ? 'high-light' : '', copy ? 'copy' : '']"
@mouseenter="hover = true"
@mouseleave="hover = false"
>
<span v-if="!link">{{ envValue }}</span>
<a :href="envValue" target="_blank" class="hover:underline underline-offset-2" v-else>{{ envValue }}</a>
<SLCopy
:text="envValue"
class="absolute top-1 right-1 transition-all opacity-0"
:class="hover ? 'copy-button' : ''"
v-show="hover"
/>
</span>
</div>
</template>
Expand All @@ -16,9 +27,11 @@
* @since: 2024-01-09 19:44:16
**/

import { ref } from 'vue'

defineProps({
envKey: {
type: String,
type: [String, Number],
default: ''
},
envValue: {
Expand All @@ -32,8 +45,29 @@ defineProps({
link: {
type: Boolean,
default: false
},
copy: {
type: Boolean,
default: true
}
})

const hover = ref(false)
</script>

<style lang="scss" scoped></style>
<style lang="scss" scoped>
.high-light {
@apply text-dimmer bg-higher px-2;
}

.copy {
@apply transition-all overflow-hidden;
&:hover {
@apply bg-higher pr-8;
}
}

.copy-button {
@apply opacity-100;
}
</style>