|
@@ -4,6 +4,7 @@ import { ElMessage } from 'element-plus'
|
|
export { ls } from './vueStorage'
|
|
export { ls } from './vueStorage'
|
|
import { get, set } from 'lodash-unified'
|
|
import { get, set } from 'lodash-unified'
|
|
import i18n from '@/lang/index'
|
|
import i18n from '@/lang/index'
|
|
|
|
+import { useClipboard } from '@vueuse/core'
|
|
|
|
|
|
// 多语言翻译
|
|
// 多语言翻译
|
|
export const t = (key: string, ...args: any[]) => {
|
|
export const t = (key: string, ...args: any[]) => {
|
|
@@ -117,7 +118,7 @@ export const objDeepMerge = (...objs: any[]) => {
|
|
* @param sucTxt
|
|
* @param sucTxt
|
|
* @returns {boolean}
|
|
* @returns {boolean}
|
|
*/
|
|
*/
|
|
-export function copyText(val: string, sucTxt = '复制成功~') {
|
|
|
|
|
|
+export function copyText_native(val: string, sucTxt = '复制成功~') {
|
|
const textarea: any = document.createElement('textarea')
|
|
const textarea: any = document.createElement('textarea')
|
|
// 将该 textarea 设为 readonly 防止 iOS 下自动唤起键盘,同时将 textarea 移出可视区域
|
|
// 将该 textarea 设为 readonly 防止 iOS 下自动唤起键盘,同时将 textarea 移出可视区域
|
|
textarea.readOnly = 'readonly'
|
|
textarea.readOnly = 'readonly'
|
|
@@ -250,6 +251,24 @@ export const millisecondsToMinutesAndSeconds = (milliseconds: number) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * 复制文字
|
|
|
|
+ * @param text
|
|
|
|
+ */
|
|
|
|
+export async function copyText(text: string) {
|
|
|
|
+ const { copy, copied, isSupported } = useClipboard(/*{ source: text }*/)
|
|
|
|
+ if (!isSupported) {
|
|
|
|
+ // 复制失败
|
|
|
|
+ ElMessage.error(t('le.message.CopyFailure'))
|
|
|
|
+ } else {
|
|
|
|
+ await copy(text)
|
|
|
|
+ if (copied.value) {
|
|
|
|
+ // message.success('复制成功~')
|
|
|
|
+ ElMessage.success(t('le.message.CopiedSuccessfully'))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
// 静态图标
|
|
// 静态图标
|
|
export const ImageArr = [
|
|
export const ImageArr = [
|
|
'approval',
|
|
'approval',
|