export function toJson(data: any) {
    return JSON.parse(JSON.stringify(data));
}

import { getCommon } from '@/api/main';
import { IOptions } from '@/types/newsManagement';
export function outTypeList(type: string) {
    const typeList: Array<IOptions> = [];
    return getCommon(type).then((res: any) => {
        res.rows.forEach((item: any) => {
            if (item.dictValue === '1') {
                item.color = '#4084F9';
            } else if (item.dictValue === '2') {
                item.color = '#20C261';
            } else if (item.dictValue === '3') {
                item.color = '#FA996C';
            } else if (item.dictValue === '4') {
                item.color = '#7822DC';
            } else if (item.dictValue === '5') {
                item.color = '#ffafaf';
            } else if (item.dictValue === '6') {
                item.color = '#909399';
            }
            typeList.push({
                label: item.dictLabel,
                value: item.dictValue,
                color: item.color,
            });
        });
        return typeList;
    });
}

export function simulateCopyText(text) {
    const tempInput = document.createElement('input');
    tempInput.value = text;
    document.body.appendChild(tempInput);
    tempInput.select();
    document.execCommand('copy');
    document.body.removeChild(tempInput);
    console.log('文本已复制');
    ElMessage({
        type: 'success',
        message: '文本已复制',
    });
}