import { useClipboard } from '@vueuse/core';
import { sendMessage } from '#/store/tools'

const { copy, copied } = useClipboard();
export async function copyText(text) {
  if (isStringEmpty(text)) {
    sendMessage('内容为空', 'warning');
    return;
  }
  await copy(text);
  if (copied.value) {
    sendMessage('复制成功');
  }
};

export function isStringEmpty(value:any): boolean {
  if (value == null) return true;
  if (typeof value === 'string') return value.trim() === '';
  return false;
}

export function isEmpty(value: any):boolean {
  if (value === undefined || value === null) return true;
  if (typeof value === 'string' || Array.isArray(value)) return value.length === 0;
  if (typeof value === 'object') return Object.keys(value).length === 0;
  return !value;
}


