config.ts 3.29 KB
Newer Older
hcyhuchaoyue's avatar
hcyhuchaoyue committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
import DATA from './auth.json';

export const getData = function () {
  const myMap1 = new Map();
  const myMap2 = new Map();
  const rowData = DATA.map((item: any) => {
    const data = item.i18n;

    // Map1
    const nameArr1 = item.name.split('/');
    const key1 = nameArr1[0] + '/' + nameArr1[1];
    const title1 = data['zh-TW'].split('/');
    const origin1 = data['en-US'].split('/');
    const type1 = data['zh-CN'].split('/');
    const obj1 = {
      title: title1[1],
      origin: origin1[1],
      type: [type1[0], type1[1]],
    };

    if (!myMap1.has(key1)) {
      myMap1.set(key1, obj1);
    }

    // Map2
    const key2 = nameArr1[0];
    const obj2 = {
      title: title1[0],
      origin: origin1[0],
      type: [type1[0]],
    };

    if (!myMap2.has(key2)) {
      myMap1.set(key2, obj2);
    }

    return {
      title: data['zh-TW'].split('/')[2],
      origin: data['en-US'].split('/')[2],
      type: data['zh-CN'].split('/'),
    };
  });

  for (const value of myMap1.values()) {
    rowData.push(value);
  }
  for (const value of myMap2.values()) {
    rowData.push(value);
  }
  return rowData;
  //   const rowData = [
  //     {
  //       title: '系統設置',
  //       origin: 'System Setting',
  //       type: ['系统设置'],
  //     },
  //     {
  //       title: '用戶管理',
  //       origin: 'User Management',
  //       type: ['系统设置', '用户管理'],
  //     },
  //     {
  //       title: '查看',
  //       origin: 'Read',
  //       type: ['系统设置', '用户管理', '查看'],
  //     },
  //     {
  //       title: '新建',
  //       origin: 'Create',
  //       type: ['系统设置', '用户管理', '新建'],
  //     },
  //   ];
};
hcyhuchaoyue's avatar
hcyhuchaoyue committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153

export const getData2 = function () {
  const rowData = [
    {
      id: 1,
      filePath: ['Documents'],
    },
    {
      id: 2,
      filePath: ['Documents', 'txt'],
    },
    {
      id: 3,
      filePath: ['Documents', 'txt', 'notes.txt'],
      dateModified: 'May 21 2017 01:50:00 PM',
      size: 14.7,
    },
    {
      id: 4,
      filePath: ['Documents', 'pdf'],
    },
    {
      id: 5,
      filePath: ['Documents', 'pdf', 'book.pdf'],
      dateModified: 'May 20 2017 01:50:00 PM',
      size: 2.1,
    },
    {
      id: 6,
      filePath: ['Documents', 'pdf', 'cv.pdf'],
      dateModified: 'May 20 2016 11:50:00 PM',
      size: 2.4,
    },
    {
      id: 7,
      filePath: ['Documents', 'xls'],
    },
    {
      id: 8,
      filePath: ['Documents', 'xls', 'accounts.xls'],
      dateModified: 'Aug 12 2016 10:50:00 AM',
      size: 4.3,
    },
    {
      id: 9,
      filePath: ['Documents', 'stuff'],
    },
    {
      id: 10,
      filePath: ['Documents', 'stuff', 'xyz.txt'],
      dateModified: 'Jan 17 2016 08:03:00 PM',
      size: 1.1,
    },
    {
      id: 11,
      filePath: ['Music', 'mp3', 'pop'],
      dateModified: 'Sep 11 2016 08:03:00 PM',
      size: 14.3,
    },
    {
      id: 12,
      filePath: ['temp.txt'],
      dateModified: 'Aug 12 2016 10:50:00 PM',
      size: 101,
    },
    {
      id: 13,
      filePath: ['Music', 'mp3', 'pop', 'theme.mp3'],
      dateModified: 'Aug 12 2016 10:50:00 PM',
      size: 101,
    },
    {
      id: 14,
      filePath: ['Music', 'mp3', 'jazz'],
      dateModified: 'Aug 12 2016 10:50:00 PM',
      size: 101,
    },
  ];
  return rowData;
};