前端转vue
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mockUtils.js 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. const responseBody = {
  2. message: '',
  3. timestamp: 0,
  4. result: null,
  5. code: 0,
  6. _status: 0,
  7. _headers: {}
  8. }
  9. module.exports = {
  10. builder: (data, message, code = 0, headers = {}) => {
  11. responseBody.result = data
  12. if (message !== undefined && message !== null) {
  13. responseBody.message = message
  14. }
  15. if (code !== undefined && code !== 0) {
  16. responseBody.code = code
  17. responseBody._status = code
  18. }
  19. if (headers !== null && typeof headers === 'object' && Object.keys(headers).length > 0) {
  20. responseBody._headers = headers
  21. }
  22. responseBody.timestamp = new Date().getTime()
  23. return responseBody
  24. },
  25. userNav: [
  26. // dashboard
  27. {
  28. 'name': 'dashboard',
  29. 'parentId': 0,
  30. 'id': 1,
  31. 'meta': {
  32. 'icon': 'bx-analyse',
  33. 'title': '仪表盘',
  34. 'show': true,
  35. },
  36. 'component': 'RouteView',
  37. 'redirect': '/dashboard/workplace'
  38. },
  39. {
  40. 'name': 'workplace',
  41. 'parentId': 1,
  42. 'id': 7,
  43. 'meta': {
  44. 'title': '工作台',
  45. 'show': true
  46. },
  47. 'component': 'Workplace'
  48. },
  49. {
  50. 'name': 'monitor',
  51. 'path': 'monitor',
  52. 'parentId': 1,
  53. 'id': 3,
  54. 'meta': {
  55. 'title': '监控页(外部)',
  56. 'show': true,
  57. 'target': 'http://www.baidu.com',
  58. 'blank': true
  59. }
  60. },
  61. {
  62. 'name': 'Analysis',
  63. 'parentId': 1,
  64. 'id': 2,
  65. 'meta': {
  66. 'title': '分析页',
  67. 'show': true
  68. },
  69. 'component': 'Home',
  70. 'path': '/dashboard/analysis'
  71. },
  72. {
  73. 'name': 'tests',
  74. 'parentId': 1,
  75. 'id': 8,
  76. 'meta': {
  77. 'title': '测试功能',
  78. 'show': true
  79. },
  80. 'component': 'TestWork'
  81. },
  82. // form
  83. {
  84. 'name': 'form',
  85. 'parentId': 0,
  86. 'id': 10,
  87. 'meta': {
  88. 'icon': 'form',
  89. 'title': '表单页'
  90. },
  91. 'redirect': '/form/base-form',
  92. 'component': 'PageView'
  93. },
  94. {
  95. 'name': 'basic-form',
  96. 'parentId': 10,
  97. 'id': 6,
  98. 'meta': {
  99. 'title': '基础表单'
  100. },
  101. 'component': 'BasicForm'
  102. },
  103. {
  104. 'name': 'step-form',
  105. 'parentId': 10,
  106. 'id': 5,
  107. 'meta': {
  108. 'title': '分步表单'
  109. },
  110. 'component': 'StepForm'
  111. },
  112. {
  113. 'name': 'advanced-form',
  114. 'parentId': 10,
  115. 'id': 4,
  116. 'meta': {
  117. 'title': '高级表单'
  118. },
  119. 'component': 'AdvanceForm'
  120. },
  121. // list
  122. {
  123. 'name': 'list',
  124. 'parentId': 0,
  125. 'id': 10010,
  126. 'meta': {
  127. 'icon': 'table',
  128. 'title': '列表页',
  129. 'show': true
  130. },
  131. 'redirect': '/list/table-list',
  132. 'component': 'PageView'
  133. },
  134. {
  135. 'name': 'table-list',
  136. 'parentId': 10010,
  137. 'id': 10011,
  138. 'path': '/list/table-list/:pageNo([1-9]\\d*)?',
  139. 'meta': {
  140. 'title': '查询表格',
  141. 'show': true
  142. },
  143. 'component': 'TableList'
  144. },
  145. {
  146. 'name': 'basic-list',
  147. 'parentId': 10010,
  148. 'id': 10012,
  149. 'meta': {
  150. 'title': '标准列表',
  151. 'show': true
  152. },
  153. 'component': 'StandardList'
  154. },
  155. {
  156. 'name': 'card',
  157. 'parentId': 10010,
  158. 'id': 10013,
  159. 'meta': {
  160. 'title': '卡片列表',
  161. 'show': true
  162. },
  163. 'component': 'CardList'
  164. },
  165. {
  166. 'name': 'search',
  167. 'parentId': 10010,
  168. 'id': 10014,
  169. 'meta': {
  170. 'title': '搜索列表',
  171. 'show': true
  172. },
  173. 'redirect': '/list/search/article',
  174. 'component': 'SearchLayout'
  175. },
  176. {
  177. 'name': 'article',
  178. 'parentId': 10014,
  179. 'id': 10015,
  180. 'meta': {
  181. 'title': '搜索列表(文章)',
  182. 'show': true
  183. },
  184. 'component': 'SearchArticles'
  185. },
  186. {
  187. 'name': 'project',
  188. 'parentId': 10014,
  189. 'id': 10016,
  190. 'meta': {
  191. 'title': '搜索列表(项目)',
  192. 'show': true
  193. },
  194. 'component': 'SearchProjects'
  195. },
  196. {
  197. 'name': 'application',
  198. 'parentId': 10014,
  199. 'id': 10017,
  200. 'meta': {
  201. 'title': '搜索列表(应用)',
  202. 'show': true
  203. },
  204. 'component': 'SearchApplications'
  205. },
  206. // profile
  207. {
  208. 'name': 'profile',
  209. 'parentId': 0,
  210. 'id': 10018,
  211. 'meta': {
  212. 'title': '详情页',
  213. 'icon': 'profile',
  214. 'show': true
  215. },
  216. 'redirect': '/profile/basic',
  217. 'component': 'RouteView'
  218. },
  219. {
  220. 'name': 'basic',
  221. 'parentId': 10018,
  222. 'id': 10019,
  223. 'meta': {
  224. 'title': '基础详情页',
  225. 'show': true
  226. },
  227. 'component': 'ProfileBasic'
  228. },
  229. {
  230. 'name': 'advanced',
  231. 'parentId': 10018,
  232. 'id': 10020,
  233. 'meta': {
  234. 'title': '高级详情页',
  235. 'show': true
  236. },
  237. 'component': 'ProfileAdvanced'
  238. },
  239. // result
  240. {
  241. 'name': 'result',
  242. 'parentId': 0,
  243. 'id': 10021,
  244. 'meta': {
  245. 'title': '结果页',
  246. 'icon': 'check-circle-o',
  247. 'show': true
  248. },
  249. 'redirect': '/result/success',
  250. 'component': 'PageView'
  251. },
  252. {
  253. 'name': 'success',
  254. 'parentId': 10021,
  255. 'id': 10022,
  256. 'meta': {
  257. 'title': '成功',
  258. 'hiddenHeaderContent': true,
  259. 'show': true
  260. },
  261. 'component': 'ResultSuccess'
  262. },
  263. {
  264. 'name': 'fail',
  265. 'parentId': 10021,
  266. 'id': 10023,
  267. 'meta': {
  268. 'title': '失败',
  269. 'hiddenHeaderContent': true,
  270. 'show': true
  271. },
  272. 'component': 'ResultFail'
  273. },
  274. // Exception
  275. {
  276. 'name': 'exception',
  277. 'parentId': 0,
  278. 'id': 10024,
  279. 'meta': {
  280. 'title': '异常页',
  281. 'icon': 'warning',
  282. 'show': true
  283. },
  284. 'redirect': '/exception/403',
  285. 'component': 'RouteView'
  286. },
  287. {
  288. 'name': '403',
  289. 'parentId': 10024,
  290. 'id': 10025,
  291. 'meta': {
  292. 'title': '403',
  293. 'show': true
  294. },
  295. 'component': 'Exception403'
  296. },
  297. {
  298. 'name': '404',
  299. 'parentId': 10024,
  300. 'id': 10026,
  301. 'meta': {
  302. 'title': '404',
  303. 'show': true
  304. },
  305. 'component': 'Exception404'
  306. },
  307. {
  308. 'name': '500',
  309. 'parentId': 10024,
  310. 'id': 10027,
  311. 'meta': {
  312. 'title': '500',
  313. 'show': true
  314. },
  315. 'component': 'Exception500'
  316. },
  317. // account
  318. {
  319. 'name': 'account',
  320. 'parentId': 0,
  321. 'id': 10028,
  322. 'meta': {
  323. 'title': '个人页',
  324. 'icon': 'user',
  325. 'show': true
  326. },
  327. 'redirect': '/account/center',
  328. 'component': 'RouteView'
  329. },
  330. {
  331. 'name': 'center',
  332. 'parentId': 10028,
  333. 'id': 10029,
  334. 'meta': {
  335. 'title': '个人中心',
  336. 'show': true
  337. },
  338. 'component': 'AccountCenter'
  339. },
  340. // 特殊三级菜单
  341. {
  342. 'name': 'settings',
  343. 'parentId': 10028,
  344. 'id': 10030,
  345. 'meta': {
  346. 'title': '个人设置',
  347. 'hideHeader': true,
  348. 'hideChildren': true,
  349. 'show': true
  350. },
  351. 'redirect': '/account/settings/base',
  352. 'component': 'AccountSettings'
  353. },
  354. {
  355. 'name': 'BaseSettings',
  356. 'path': '/account/settings/base',
  357. 'parentId': 10030,
  358. 'id': 10031,
  359. 'meta': {
  360. 'title': '基本设置',
  361. 'show': false
  362. },
  363. 'component': 'BaseSettings'
  364. },
  365. {
  366. 'name': 'SecuritySettings',
  367. 'path': '/account/settings/security',
  368. 'parentId': 10030,
  369. 'id': 10032,
  370. 'meta': {
  371. 'title': '安全设置',
  372. 'show': false
  373. },
  374. 'component': 'SecuritySettings'
  375. },
  376. {
  377. 'name': 'CustomSettings',
  378. 'path': '/account/settings/custom',
  379. 'parentId': 10030,
  380. 'id': 10033,
  381. 'meta': {
  382. 'title': '个性化设置',
  383. 'show': false
  384. },
  385. 'component': 'CustomSettings'
  386. },
  387. {
  388. 'name': 'BindingSettings',
  389. 'path': '/account/settings/binding',
  390. 'parentId': 10030,
  391. 'id': 10034,
  392. 'meta': {
  393. 'title': '账户绑定',
  394. 'show': false
  395. },
  396. 'component': 'BindingSettings'
  397. },
  398. {
  399. 'name': 'NotificationSettings',
  400. 'path': '/account/settings/notification',
  401. 'parentId': 10030,
  402. 'id': 10034,
  403. 'meta': {
  404. 'title': '新消息通知',
  405. 'show': false
  406. },
  407. 'component': 'NotificationSettings'
  408. }
  409. ]
  410. }