menu.js 7.35 KB
Newer Older
xiaohu's avatar
xiaohu 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 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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
// TODO:remove
// import { isUrl } from '../utils/utils';

// const menuData = [
//   {
//     name: 'dashboard',
//     icon: 'dashboard',
//     path: 'dashboard',
//     children: [
//       {
//         name: 'ๅˆ†ๆž้กต',
//         path: 'analysis',
//       },
//       {
//         name: '็›‘ๆŽง้กต',
//         path: 'monitor',
//       },
//       {
//         name: 'ๅทฅไฝœๅฐ',
//         path: 'workplace',
//         // hideInBreadcrumb: true,
//         // hideInMenu: true,
//       },
//     ],
//   },
//   {
//     name: '่กจๅ•้กต',
//     icon: 'form',
//     path: 'form',
//     children: [
//       {
//         name: 'ๅŸบ็ก€่กจๅ•',
//         path: 'basic-form',
//       },
//       {
//         name: 'ๅˆ†ๆญฅ่กจๅ•',
//         path: 'step-form',
//       },
//       {
//         name: '้ซ˜็บง่กจๅ•',
//         authority: 'admin',
//         path: 'advanced-form',
//       },
//     ],
//   },
//   {
//     name: 'ๅˆ—่กจ้กต',
//     icon: 'table',
//     path: 'list',
//     children: [
//       {
//         name: 'ๆŸฅ่ฏข่กจๆ ผ',
//         path: 'table-list',
//       },
//       {
//         name: 'ๆ ‡ๅ‡†ๅˆ—่กจ',
//         path: 'basic-list',
//       },
//       {
//         name: 'ๅก็‰‡ๅˆ—่กจ',
//         path: 'card-list',
//       },
//       {
//         name: 'ๆœ็ดขๅˆ—่กจ',
//         path: 'search',
//         children: [
//           {
//             name: 'ๆœ็ดขๅˆ—่กจ๏ผˆๆ–‡็ซ ๏ผ‰',
//             path: 'articles',
//           },
//           {
//             name: 'ๆœ็ดขๅˆ—่กจ๏ผˆ้กน็›ฎ๏ผ‰',
//             path: 'projects',
//           },
//           {
//             name: 'ๆœ็ดขๅˆ—่กจ๏ผˆๅบ”็”จ๏ผ‰',
//             path: 'applications',
//           },
//         ],
//       },
//     ],
//   },
//   {
//     name: '่ฏฆๆƒ…้กต',
//     icon: 'profile',
//     path: 'profile',
//     children: [
//       {
//         name: 'ๅŸบ็ก€่ฏฆๆƒ…้กต',
//         path: 'basic',
//       },
//       {
//         name: '้ซ˜็บง่ฏฆๆƒ…้กต',
//         path: 'advanced',
//         authority: 'admin',
//       },
//     ],
//   },
//   {
//     name: '็ป“ๆžœ้กต',
//     icon: 'check-circle-o',
//     path: 'result',
//     children: [
//       {
//         name: 'ๆˆๅŠŸ',
//         path: 'success',
//       },
//       {
//         name: 'ๅคฑ่ดฅ',
//         path: 'fail',
//       },
//     ],
//   },
//   {
//     name: 'ๅผ‚ๅธธ้กต',
//     icon: 'warning',
//     path: 'exception',
//     children: [
//       {
//         name: '403',
//         path: '403',
//       },
//       {
//         name: '404',
//         path: '404',
//       },
//       {
//         name: '500',
//         path: '500',
//       },
//       {
//         name: '่งฆๅ‘ๅผ‚ๅธธ',
//         path: 'trigger',
//         hideInMenu: true,
//       },
//     ],
//   },
//   {
//     name: '่ดฆๆˆท',
//     icon: 'user',
//     path: 'user',
//     authority: 'guest',
//     children: [
//       {
//         name: '็™ปๅฝ•',
//         path: 'login',
//       },
//       {
//         name: 'ๆณจๅ†Œ',
//         path: 'register',
//       },
//       {
//         name: 'ๆณจๅ†Œ็ป“ๆžœ',
//         path: 'register-result',
//       },
//     ],
//   },
//   {
//     name: 'ไธชไบบ้กต',
//     icon: 'user',
//     path: 'account',
//     children: [
//       {
//         name: 'ไธชไบบไธญๅฟƒ',
//         path: 'center',
//       },
//       {
//         name: 'ไธชไบบ่ฎพ็ฝฎ',
//         path: 'settings',
//       },
//     ],
//   },
// ];

// function formatter(data, parentPath = '/', parentAuthority) {
//   return data.map(item => {
//     let { path } = item;
//     if (!isUrl(path)) {
//       path = parentPath + item.path;
//     }
//     const result = {
//       ...item,
//       path,
//       authority: item.authority || parentAuthority,
//     };
//     if (item.children) {
//       result.children = formatter(item.children, `${parentPath}${item.path}/`, item.authority);
//     }
//     return result;
//   });
// }

// export const getMenuData = () => formatter(menuData);

195 196
import { isUrl } from '../utils/utils';

xiaohu's avatar
xiaohu committed
197
// TODO: authority
jim's avatar
jim committed
198 199 200 201
const menuData = [
  {
    name: 'dashboard',
    icon: 'dashboard',
ๆ„š้“'s avatar
ๆ„š้“ committed
202
    path: 'dashboard',
jim's avatar
jim committed
203 204 205
    children: [
      {
        name: 'ๅˆ†ๆž้กต',
ๆ„š้“'s avatar
ๆ„š้“ committed
206
        path: 'analysis',
jim's avatar
jim committed
207 208 209
      },
      {
        name: '็›‘ๆŽง้กต',
ๆ„š้“'s avatar
ๆ„š้“ committed
210
        path: 'monitor',
jim's avatar
jim committed
211 212 213
      },
      {
        name: 'ๅทฅไฝœๅฐ',
ๆ„š้“'s avatar
ๆ„š้“ committed
214
        path: 'workplace',
xiaohu's avatar
xiaohu committed
215
        // hideInBreadcrumb: true,
jim's avatar
jim committed
216 217 218 219 220 221 222
        // hideInMenu: true,
      },
    ],
  },
  {
    name: '่กจๅ•้กต',
    icon: 'form',
ๆ„š้“'s avatar
ๆ„š้“ committed
223
    path: 'form',
jim's avatar
jim committed
224 225 226
    children: [
      {
        name: 'ๅŸบ็ก€่กจๅ•',
ๆ„š้“'s avatar
ๆ„š้“ committed
227
        path: 'basic-form',
jim's avatar
jim committed
228 229 230
      },
      {
        name: 'ๅˆ†ๆญฅ่กจๅ•',
ๆ„š้“'s avatar
ๆ„š้“ committed
231
        path: 'step-form',
jim's avatar
jim committed
232 233 234
      },
      {
        name: '้ซ˜็บง่กจๅ•',
xiaohu's avatar
xiaohu committed
235
        // authority: 'admin',
ๆ„š้“'s avatar
ๆ„š้“ committed
236
        path: 'advanced-form',
jim's avatar
jim committed
237 238 239 240 241 242
      },
    ],
  },
  {
    name: 'ๅˆ—่กจ้กต',
    icon: 'table',
ๆ„š้“'s avatar
ๆ„š้“ committed
243
    path: 'list',
jim's avatar
jim committed
244 245 246
    children: [
      {
        name: 'ๆŸฅ่ฏข่กจๆ ผ',
ๆ„š้“'s avatar
ๆ„š้“ committed
247
        path: 'table-list',
jim's avatar
jim committed
248 249 250
      },
      {
        name: 'ๆ ‡ๅ‡†ๅˆ—่กจ',
ๆ„š้“'s avatar
ๆ„š้“ committed
251
        path: 'basic-list',
jim's avatar
jim committed
252 253 254
      },
      {
        name: 'ๅก็‰‡ๅˆ—่กจ',
ๆ„š้“'s avatar
ๆ„š้“ committed
255
        path: 'card-list',
jim's avatar
jim committed
256 257 258
      },
      {
        name: 'ๆœ็ดขๅˆ—่กจ',
ๆ„š้“'s avatar
ๆ„š้“ committed
259
        path: 'search',
jim's avatar
jim committed
260 261 262
        children: [
          {
            name: 'ๆœ็ดขๅˆ—่กจ๏ผˆๆ–‡็ซ ๏ผ‰',
ๆ„š้“'s avatar
ๆ„š้“ committed
263
            path: 'articles',
jim's avatar
jim committed
264 265 266
          },
          {
            name: 'ๆœ็ดขๅˆ—่กจ๏ผˆ้กน็›ฎ๏ผ‰',
ๆ„š้“'s avatar
ๆ„š้“ committed
267
            path: 'projects',
jim's avatar
jim committed
268 269 270
          },
          {
            name: 'ๆœ็ดขๅˆ—่กจ๏ผˆๅบ”็”จ๏ผ‰',
ๆ„š้“'s avatar
ๆ„š้“ committed
271
            path: 'applications',
jim's avatar
jim committed
272 273 274 275 276 277 278 279
          },
        ],
      },
    ],
  },
  {
    name: '่ฏฆๆƒ…้กต',
    icon: 'profile',
ๆ„š้“'s avatar
ๆ„š้“ committed
280
    path: 'profile',
jim's avatar
jim committed
281 282 283
    children: [
      {
        name: 'ๅŸบ็ก€่ฏฆๆƒ…้กต',
ๆ„š้“'s avatar
ๆ„š้“ committed
284
        path: 'basic',
jim's avatar
jim committed
285 286 287
      },
      {
        name: '้ซ˜็บง่ฏฆๆƒ…้กต',
ๆ„š้“'s avatar
ๆ„š้“ committed
288
        path: 'advanced',
xiaohu's avatar
xiaohu committed
289
        // authority: 'admin',
jim's avatar
jim committed
290 291 292 293 294 295
      },
    ],
  },
  {
    name: '็ป“ๆžœ้กต',
    icon: 'check-circle-o',
ๆ„š้“'s avatar
ๆ„š้“ committed
296
    path: 'result',
jim's avatar
jim committed
297 298 299
    children: [
      {
        name: 'ๆˆๅŠŸ',
ๆ„š้“'s avatar
ๆ„š้“ committed
300
        path: 'success',
jim's avatar
jim committed
301 302 303
      },
      {
        name: 'ๅคฑ่ดฅ',
ๆ„š้“'s avatar
ๆ„š้“ committed
304
        path: 'fail',
jim's avatar
jim committed
305 306 307 308 309 310
      },
    ],
  },
  {
    name: 'ๅผ‚ๅธธ้กต',
    icon: 'warning',
ๆ„š้“'s avatar
ๆ„š้“ committed
311
    path: 'exception',
jim's avatar
jim committed
312 313 314 315 316 317 318 319 320 321 322 323 324
    children: [
      {
        name: '403',
        path: '403',
      },
      {
        name: '404',
        path: '404',
      },
      {
        name: '500',
        path: '500',
      },
ๆ„š้“'s avatar
ๆ„š้“ committed
325 326 327 328 329
      // {
      //   name: '่งฆๅ‘ๅผ‚ๅธธ',
      //   path: 'triggerException',
      //   hideInMenu: true,
      // },
jim's avatar
jim committed
330 331 332 333 334
    ],
  },
  {
    name: '่ดฆๆˆท',
    icon: 'user',
xiaohu's avatar
xiaohu committed
335
    path: 'User',
jim's avatar
jim committed
336 337 338 339
    authority: 'guest',
    children: [
      {
        name: '็™ปๅฝ•',
ๆ„š้“'s avatar
ๆ„š้“ committed
340
        path: 'login',
jim's avatar
jim committed
341 342 343
      },
      {
        name: 'ๆณจๅ†Œ',
ๆ„š้“'s avatar
ๆ„š้“ committed
344
        path: 'register',
jim's avatar
jim committed
345 346 347
      },
      {
        name: 'ๆณจๅ†Œ็ป“ๆžœ',
ๆ„š้“'s avatar
ๆ„š้“ committed
348
        path: 'register-result',
jim's avatar
jim committed
349 350 351
      },
    ],
  },
xiaohu's avatar
xiaohu committed
352 353 354
  {
    name: 'ไธชไบบ้กต',
    icon: 'user',
ๆ„š้“'s avatar
ๆ„š้“ committed
355
    path: 'acount',
xiaohu's avatar
xiaohu committed
356 357 358
    children: [
      {
        name: 'ไธชไบบไธญๅฟƒ',
ๆ„š้“'s avatar
ๆ„š้“ committed
359
        path: 'center',
xiaohu's avatar
xiaohu committed
360 361 362
      },
      {
        name: 'ไธชไบบ่ฎพ็ฝฎ',
ๆ„š้“'s avatar
ๆ„š้“ committed
363
        path: 'settings',
xiaohu's avatar
xiaohu committed
364 365 366
      },
    ],
  },
jim's avatar
jim committed
367
];
ddcat1115's avatar
ddcat1115 committed
368

369
function formatter(data, parentPath = '/', parentAuthority) {
jim's avatar
jim committed
370
  return data.map(item => {
371 372 373 374
    let { path } = item;
    if (!isUrl(path)) {
      path = parentPath + item.path;
    }
afc163's avatar
afc163 committed
375 376
    const result = {
      ...item,
377
      path,
ddcat1115's avatar
ddcat1115 committed
378
      authority: item.authority || parentAuthority,
afc163's avatar
afc163 committed
379
    };
ddcat1115's avatar
ddcat1115 committed
380
    if (item.children) {
ddcat1115's avatar
ddcat1115 committed
381
      result.children = formatter(item.children, `${parentPath}${item.path}/`, item.authority);
ddcat1115's avatar
ddcat1115 committed
382
    }
afc163's avatar
afc163 committed
383
    return result;
ddcat1115's avatar
ddcat1115 committed
384 385 386 387
  });
}

export const getMenuData = () => formatter(menuData);