Skip to content

Commit

Permalink
fix: perfect copy componet
Browse files Browse the repository at this point in the history
  • Loading branch information
chansee97 committed Jun 26, 2024
1 parent 8981f42 commit eb82842
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@
"searchPlaceholder": "Search icon",
"clearIcon": "Clear icon",
"selectorTitle": "Icon selection"
},
"copyText": {
"message": "Copied successfully",
"tooltip": "Copy"
}
}
}
4 changes: 4 additions & 0 deletions locales/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
"inputPlaceholder": "选择目标图标",
"searchPlaceholder": "搜索图标",
"clearIcon": "清除图标"
},
"copyText":{
"tooltip":"复制",
"message":"复制成功"
}
},
"login": {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"echarts": "^5.5.0",
"md-editor-v3": "^4.15.2",
"pinia": "^2.1.7",
"pinia-plugin-persist": "^1.0.0",
"pinia-plugin-persistedstate": "^3.2.1",
"quill": "^2.0.2",
"radash": "^12.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/HelpInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const props = defineProps<Props>()
<template>
<n-tooltip :show-arrow="false" trigger="hover">
<template #trigger>
<icon-park-outline-help />
<icon-park-outline-help class="op-50 cursor-help"/>
</template>
{{ props.message }}
</n-tooltip>
Expand Down
11 changes: 8 additions & 3 deletions src/components/custom/CopyText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ const modelValue = defineModel<string>('value')
<n-ellipsis :style="{ 'max-width': props.maxLength || '12em' }">
{{ modelValue }}
</n-ellipsis>
<span v-copy="modelValue" class="cursor-pointer">
<icon-park-outline-copy />
</span>
<n-tooltip trigger="hover">
<template #trigger>
<span v-copy="modelValue" class="cursor-pointer">
<icon-park-outline-copy />
</span>
</template>
{{ $t('components.copyText.tooltip') }}
</n-tooltip>
</div>
</template>
3 changes: 2 additions & 1 deletion src/directives/copy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { App, Directive } from 'vue'
import { $t } from '@/utils'

interface CopyHTMLElement extends HTMLElement {
_copyText: string
Expand All @@ -25,7 +26,7 @@ export function install(app: App) {
if (!clipboardEnable())
return
copy(this._copyText)
window.$message.success('复制成功')
window.$message.success($t('components.copyText.message'))
}

function updataClipboard(el: CopyHTMLElement, text: string) {
Expand Down

0 comments on commit eb82842

Please sign in to comment.