-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(electron): copy button of connection page (#154)
Co-authored-by: arlo <[email protected]>
- Loading branch information
1 parent
8cd47f8
commit 96b6f2f
Showing
5 changed files
with
52 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,39 @@ | ||
import { showVueNotification } from '@vue/devtools-ui' | ||
|
||
interface CopyOptions { | ||
silent?: boolean | ||
type?: string | ||
} | ||
|
||
export function useCopy() { | ||
const clipboard = useClipboard() | ||
const { copy: _copy, copied } = useClipboard() | ||
|
||
const copy = (text: string, options: CopyOptions = {}) => { | ||
const { | ||
silent = false, | ||
type = '', | ||
} = options | ||
_copy(text).then(() => { | ||
if (!silent) { | ||
showVueNotification({ | ||
message: 'Copied to clipboard', | ||
type: 'success', | ||
duration: 3000, | ||
}) | ||
} | ||
}).catch(() => { | ||
if (!silent) { | ||
showVueNotification({ | ||
message: 'Failed to copy to clipboard', | ||
type: 'error', | ||
duration: 3000, | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
return (text: string, type?: string) => { | ||
clipboard.copy(text) | ||
return { | ||
copy, | ||
copied, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters