index.js 103 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320
  1. (function(global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined'
  3. ? (module.exports = factory(require('mockjs'), require('moment')))
  4. : typeof define === 'function' && define.amd
  5. ? define(['mockjs', 'moment'], factory)
  6. : ((global = global || self), (global.mock = factory(global.mockjs, global.moment)));
  7. })(this, function(mockjs, moment) {
  8. 'use strict';
  9. mockjs = mockjs && mockjs.hasOwnProperty('default') ? mockjs['default'] : mockjs;
  10. moment = moment && moment.hasOwnProperty('default') ? moment['default'] : moment;
  11. function _defineProperty(obj, key, value) {
  12. if (key in obj) {
  13. Object.defineProperty(obj, key, {
  14. value: value,
  15. enumerable: true,
  16. configurable: true,
  17. writable: true,
  18. });
  19. } else {
  20. obj[key] = value;
  21. }
  22. return obj;
  23. }
  24. function _objectSpread(target) {
  25. for (var i = 1; i < arguments.length; i++) {
  26. var source = arguments[i] != null ? arguments[i] : {};
  27. var ownKeys = Object.keys(source);
  28. if (typeof Object.getOwnPropertySymbols === 'function') {
  29. ownKeys = ownKeys.concat(
  30. Object.getOwnPropertySymbols(source).filter(function(sym) {
  31. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  32. }),
  33. );
  34. }
  35. ownKeys.forEach(function(key) {
  36. _defineProperty(target, key, source[key]);
  37. });
  38. }
  39. return target;
  40. }
  41. const titles = [
  42. 'Alipay',
  43. 'Angular',
  44. 'Ant Design',
  45. 'Ant Design Pro',
  46. 'Bootstrap',
  47. 'React',
  48. 'Vue',
  49. 'Webpack',
  50. ];
  51. const avatars = [
  52. 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', // Alipay
  53. 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', // Angular
  54. 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png', // Ant Design
  55. 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png', // Ant Design Pro
  56. 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png', // Bootstrap
  57. 'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png', // React
  58. 'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png', // Vue
  59. 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png',
  60. ];
  61. const avatars2 = [
  62. 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
  63. 'https://gw.alipayobjects.com/zos/rmsportal/cnrhVkzwxjPwAaCfPbdc.png',
  64. 'https://gw.alipayobjects.com/zos/rmsportal/gaOngJwsRYRaVAuXXcmB.png',
  65. 'https://gw.alipayobjects.com/zos/rmsportal/ubnKSIfAJTxIgXOKlciN.png',
  66. 'https://gw.alipayobjects.com/zos/rmsportal/WhxKECPNujWoWEFNdnJE.png',
  67. 'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png',
  68. 'https://gw.alipayobjects.com/zos/rmsportal/psOgztMplJMGpVEqfcgF.png',
  69. 'https://gw.alipayobjects.com/zos/rmsportal/ZpBqSxLxVEXfcUNoPKrz.png',
  70. 'https://gw.alipayobjects.com/zos/rmsportal/laiEnJdGHVOhJrUShBaJ.png',
  71. 'https://gw.alipayobjects.com/zos/rmsportal/UrQsqscbKEpNuJcvBZBu.png',
  72. ];
  73. const covers = [
  74. 'https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png',
  75. 'https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png',
  76. 'https://gw.alipayobjects.com/zos/rmsportal/iXjVmWVHbCJAyqvDxdtx.png',
  77. 'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png',
  78. ];
  79. const desc = [
  80. '那是一种内在的东西, 他们到达不了,也无法触及的',
  81. '希望是一个好东西,也许是最好的,好东西是不会消亡的',
  82. '生命就像一盒巧克力,结果往往出人意料',
  83. '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
  84. '那时候我只会想自己想要什么,从不想自己拥有什么',
  85. ];
  86. const user = [
  87. '付小小',
  88. '曲丽丽',
  89. '林东东',
  90. '周星星',
  91. '吴加好',
  92. '朱偏右',
  93. '鱼酱',
  94. '乐哥',
  95. '谭小仪',
  96. '仲尼',
  97. ];
  98. function fakeList(count) {
  99. const list = [];
  100. for (let i = 0; i < count; i += 1) {
  101. list.push({
  102. id: `fake-list-${i}`,
  103. owner: user[i % 10],
  104. title: titles[i % 8],
  105. avatar: avatars[i % 8],
  106. cover: parseInt(i / 4, 10) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)],
  107. status: ['active', 'exception', 'normal'][i % 3],
  108. percent: Math.ceil(Math.random() * 50) + 50,
  109. logo: avatars[i % 8],
  110. href: 'https://ant.design',
  111. updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i),
  112. createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i),
  113. subDescription: desc[i % 5],
  114. description:
  115. '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。',
  116. activeUser: Math.ceil(Math.random() * 100000) + 100000,
  117. newUser: Math.ceil(Math.random() * 1000) + 1000,
  118. star: Math.ceil(Math.random() * 100) + 100,
  119. like: Math.ceil(Math.random() * 100) + 100,
  120. message: Math.ceil(Math.random() * 10) + 10,
  121. content:
  122. '段落示意:蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。',
  123. members: [
  124. {
  125. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png',
  126. name: '曲丽丽',
  127. id: 'member1',
  128. },
  129. {
  130. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png',
  131. name: '王昭君',
  132. id: 'member2',
  133. },
  134. {
  135. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png',
  136. name: '董娜娜',
  137. id: 'member3',
  138. },
  139. ],
  140. });
  141. }
  142. return list;
  143. }
  144. let sourceData;
  145. function getFakeList(req, res) {
  146. const params = req.query;
  147. const count = params.count * 1 || 20;
  148. const result = fakeList(count);
  149. sourceData = result;
  150. return res.json(result);
  151. }
  152. function postFakeList(req, res) {
  153. const {
  154. /* url = '', */
  155. body,
  156. } = req; // const params = getUrlParams(url);
  157. const { method, id } = body; // const count = (params.count * 1) || 20;
  158. let result = sourceData;
  159. switch (method) {
  160. case 'delete':
  161. result = result.filter(item => item.id !== id);
  162. break;
  163. case 'update':
  164. result.forEach((item, i) => {
  165. if (item.id === id) {
  166. result[i] = Object.assign(item, body);
  167. }
  168. });
  169. break;
  170. case 'post':
  171. result.unshift({
  172. body,
  173. id: `fake-list-${result.length}`,
  174. createdAt: new Date().getTime(),
  175. });
  176. break;
  177. default:
  178. break;
  179. }
  180. return res.json(result);
  181. }
  182. const getNotice = [
  183. {
  184. id: 'xxx1',
  185. title: titles[0],
  186. logo: avatars[0],
  187. description: '那是一种内在的东西,他们到达不了,也无法触及的',
  188. updatedAt: new Date(),
  189. member: '科学搬砖组',
  190. href: '',
  191. memberLink: '',
  192. },
  193. {
  194. id: 'xxx2',
  195. title: titles[1],
  196. logo: avatars[1],
  197. description: '希望是一个好东西,也许是最好的,好东西是不会消亡的',
  198. updatedAt: new Date('2017-07-24'),
  199. member: '全组都是吴彦祖',
  200. href: '',
  201. memberLink: '',
  202. },
  203. {
  204. id: 'xxx3',
  205. title: titles[2],
  206. logo: avatars[2],
  207. description: '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
  208. updatedAt: new Date(),
  209. member: '中二少女团',
  210. href: '',
  211. memberLink: '',
  212. },
  213. {
  214. id: 'xxx4',
  215. title: titles[3],
  216. logo: avatars[3],
  217. description: '那时候我只会想自己想要什么,从不想自己拥有什么',
  218. updatedAt: new Date('2017-07-23'),
  219. member: '程序员日常',
  220. href: '',
  221. memberLink: '',
  222. },
  223. {
  224. id: 'xxx5',
  225. title: titles[4],
  226. logo: avatars[4],
  227. description: '凛冬将至',
  228. updatedAt: new Date('2017-07-23'),
  229. member: '高逼格设计天团',
  230. href: '',
  231. memberLink: '',
  232. },
  233. {
  234. id: 'xxx6',
  235. title: titles[5],
  236. logo: avatars[5],
  237. description: '生命就像一盒巧克力,结果往往出人意料',
  238. updatedAt: new Date('2017-07-23'),
  239. member: '骗你来学计算机',
  240. href: '',
  241. memberLink: '',
  242. },
  243. ];
  244. const getActivities = [
  245. {
  246. id: 'trend-1',
  247. updatedAt: new Date(),
  248. user: {
  249. name: '曲丽丽',
  250. avatar: avatars2[0],
  251. },
  252. group: {
  253. name: '高逼格设计天团',
  254. link: 'http://github.com/',
  255. },
  256. project: {
  257. name: '六月迭代',
  258. link: 'http://github.com/',
  259. },
  260. template: '在 @{group} 新建项目 @{project}',
  261. },
  262. {
  263. id: 'trend-2',
  264. updatedAt: new Date(),
  265. user: {
  266. name: '付小小',
  267. avatar: avatars2[1],
  268. },
  269. group: {
  270. name: '高逼格设计天团',
  271. link: 'http://github.com/',
  272. },
  273. project: {
  274. name: '六月迭代',
  275. link: 'http://github.com/',
  276. },
  277. template: '在 @{group} 新建项目 @{project}',
  278. },
  279. {
  280. id: 'trend-3',
  281. updatedAt: new Date(),
  282. user: {
  283. name: '林东东',
  284. avatar: avatars2[2],
  285. },
  286. group: {
  287. name: '中二少女团',
  288. link: 'http://github.com/',
  289. },
  290. project: {
  291. name: '六月迭代',
  292. link: 'http://github.com/',
  293. },
  294. template: '在 @{group} 新建项目 @{project}',
  295. },
  296. {
  297. id: 'trend-4',
  298. updatedAt: new Date(),
  299. user: {
  300. name: '周星星',
  301. avatar: avatars2[4],
  302. },
  303. project: {
  304. name: '5 月日常迭代',
  305. link: 'http://github.com/',
  306. },
  307. template: '将 @{project} 更新至已发布状态',
  308. },
  309. {
  310. id: 'trend-5',
  311. updatedAt: new Date(),
  312. user: {
  313. name: '朱偏右',
  314. avatar: avatars2[3],
  315. },
  316. project: {
  317. name: '工程效能',
  318. link: 'http://github.com/',
  319. },
  320. comment: {
  321. name: '留言',
  322. link: 'http://github.com/',
  323. },
  324. template: '在 @{project} 发布了 @{comment}',
  325. },
  326. {
  327. id: 'trend-6',
  328. updatedAt: new Date(),
  329. user: {
  330. name: '乐哥',
  331. avatar: avatars2[5],
  332. },
  333. group: {
  334. name: '程序员日常',
  335. link: 'http://github.com/',
  336. },
  337. project: {
  338. name: '品牌迭代',
  339. link: 'http://github.com/',
  340. },
  341. template: '在 @{group} 新建项目 @{project}',
  342. },
  343. ];
  344. function getFakeCaptcha(req, res) {
  345. return res.json('captcha-xxx');
  346. }
  347. var api = {
  348. 'GET /api/project/notice': getNotice,
  349. 'GET /api/activities': getActivities,
  350. 'POST /api/forms': (req, res) => {
  351. res.send({
  352. message: 'Ok',
  353. });
  354. },
  355. 'GET /api/tags': mockjs.mock({
  356. 'list|100': [
  357. {
  358. name: '@city',
  359. 'value|1-100': 150,
  360. 'type|0-2': 1,
  361. },
  362. ],
  363. }),
  364. 'GET /api/fake_list': getFakeList,
  365. 'POST /api/fake_list': postFakeList,
  366. 'GET /api/captcha': getFakeCaptcha,
  367. };
  368. const visitData = [];
  369. const beginDay = new Date().getTime();
  370. const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5];
  371. for (let i = 0; i < fakeY.length; i += 1) {
  372. visitData.push({
  373. x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
  374. y: fakeY[i],
  375. });
  376. }
  377. const visitData2 = [];
  378. const fakeY2 = [1, 6, 4, 8, 3, 7, 2];
  379. for (let i = 0; i < fakeY2.length; i += 1) {
  380. visitData2.push({
  381. x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
  382. y: fakeY2[i],
  383. });
  384. }
  385. const salesData = [];
  386. for (let i = 0; i < 12; i += 1) {
  387. salesData.push({
  388. x: `${i + 1}月`,
  389. y: Math.floor(Math.random() * 1000) + 200,
  390. });
  391. }
  392. const searchData = [];
  393. for (let i = 0; i < 50; i += 1) {
  394. searchData.push({
  395. index: i + 1,
  396. keyword: `搜索关键词-${i}`,
  397. count: Math.floor(Math.random() * 1000),
  398. range: Math.floor(Math.random() * 100),
  399. status: Math.floor((Math.random() * 10) % 2),
  400. });
  401. }
  402. const salesTypeData = [
  403. {
  404. x: '家用电器',
  405. y: 4544,
  406. },
  407. {
  408. x: '食用酒水',
  409. y: 3321,
  410. },
  411. {
  412. x: '个护健康',
  413. y: 3113,
  414. },
  415. {
  416. x: '服饰箱包',
  417. y: 2341,
  418. },
  419. {
  420. x: '母婴产品',
  421. y: 1231,
  422. },
  423. {
  424. x: '其他',
  425. y: 1231,
  426. },
  427. ];
  428. const salesTypeDataOnline = [
  429. {
  430. x: '家用电器',
  431. y: 244,
  432. },
  433. {
  434. x: '食用酒水',
  435. y: 321,
  436. },
  437. {
  438. x: '个护健康',
  439. y: 311,
  440. },
  441. {
  442. x: '服饰箱包',
  443. y: 41,
  444. },
  445. {
  446. x: '母婴产品',
  447. y: 121,
  448. },
  449. {
  450. x: '其他',
  451. y: 111,
  452. },
  453. ];
  454. const salesTypeDataOffline = [
  455. {
  456. x: '家用电器',
  457. y: 99,
  458. },
  459. {
  460. x: '食用酒水',
  461. y: 188,
  462. },
  463. {
  464. x: '个护健康',
  465. y: 344,
  466. },
  467. {
  468. x: '服饰箱包',
  469. y: 255,
  470. },
  471. {
  472. x: '其他',
  473. y: 65,
  474. },
  475. ];
  476. const offlineData = [];
  477. for (let i = 0; i < 10; i += 1) {
  478. offlineData.push({
  479. name: `Stores ${i}`,
  480. cvr: Math.ceil(Math.random() * 9) / 10,
  481. });
  482. }
  483. const offlineChartData = [];
  484. for (let i = 0; i < 20; i += 1) {
  485. offlineChartData.push({
  486. x: new Date().getTime() + 1000 * 60 * 30 * i,
  487. y1: Math.floor(Math.random() * 100) + 10,
  488. y2: Math.floor(Math.random() * 100) + 10,
  489. });
  490. }
  491. const radarOriginData = [
  492. {
  493. name: '个人',
  494. ref: 10,
  495. koubei: 8,
  496. output: 4,
  497. contribute: 5,
  498. hot: 7,
  499. },
  500. {
  501. name: '团队',
  502. ref: 3,
  503. koubei: 9,
  504. output: 6,
  505. contribute: 3,
  506. hot: 1,
  507. },
  508. {
  509. name: '部门',
  510. ref: 4,
  511. koubei: 1,
  512. output: 6,
  513. contribute: 5,
  514. hot: 7,
  515. },
  516. ];
  517. const radarData = [];
  518. const radarTitleMap = {
  519. ref: '引用',
  520. koubei: '口碑',
  521. output: '产量',
  522. contribute: '贡献',
  523. hot: '热度',
  524. };
  525. radarOriginData.forEach(item => {
  526. Object.keys(item).forEach(key => {
  527. if (key !== 'name') {
  528. radarData.push({
  529. name: item.name,
  530. label: radarTitleMap[key],
  531. value: item[key],
  532. });
  533. }
  534. });
  535. });
  536. const getFakeChartData = {
  537. visitData,
  538. visitData2,
  539. salesData,
  540. searchData,
  541. offlineData,
  542. offlineChartData,
  543. salesTypeData,
  544. salesTypeDataOnline,
  545. salesTypeDataOffline,
  546. radarData,
  547. };
  548. var chart = {
  549. 'GET /api/fake_chart_data': getFakeChartData,
  550. };
  551. var city = {
  552. '110000': [
  553. {
  554. province: '北京市',
  555. name: '市辖区',
  556. id: '110100',
  557. },
  558. ],
  559. '120000': [
  560. {
  561. province: '天津市',
  562. name: '市辖区',
  563. id: '120100',
  564. },
  565. ],
  566. '130000': [
  567. {
  568. province: '河北省',
  569. name: '石家庄市',
  570. id: '130100',
  571. },
  572. {
  573. province: '河北省',
  574. name: '唐山市',
  575. id: '130200',
  576. },
  577. {
  578. province: '河北省',
  579. name: '秦皇岛市',
  580. id: '130300',
  581. },
  582. {
  583. province: '河北省',
  584. name: '邯郸市',
  585. id: '130400',
  586. },
  587. {
  588. province: '河北省',
  589. name: '邢台市',
  590. id: '130500',
  591. },
  592. {
  593. province: '河北省',
  594. name: '保定市',
  595. id: '130600',
  596. },
  597. {
  598. province: '河北省',
  599. name: '张家口市',
  600. id: '130700',
  601. },
  602. {
  603. province: '河北省',
  604. name: '承德市',
  605. id: '130800',
  606. },
  607. {
  608. province: '河北省',
  609. name: '沧州市',
  610. id: '130900',
  611. },
  612. {
  613. province: '河北省',
  614. name: '廊坊市',
  615. id: '131000',
  616. },
  617. {
  618. province: '河北省',
  619. name: '衡水市',
  620. id: '131100',
  621. },
  622. {
  623. province: '河北省',
  624. name: '省直辖县级行政区划',
  625. id: '139000',
  626. },
  627. ],
  628. '140000': [
  629. {
  630. province: '山西省',
  631. name: '太原市',
  632. id: '140100',
  633. },
  634. {
  635. province: '山西省',
  636. name: '大同市',
  637. id: '140200',
  638. },
  639. {
  640. province: '山西省',
  641. name: '阳泉市',
  642. id: '140300',
  643. },
  644. {
  645. province: '山西省',
  646. name: '长治市',
  647. id: '140400',
  648. },
  649. {
  650. province: '山西省',
  651. name: '晋城市',
  652. id: '140500',
  653. },
  654. {
  655. province: '山西省',
  656. name: '朔州市',
  657. id: '140600',
  658. },
  659. {
  660. province: '山西省',
  661. name: '晋中市',
  662. id: '140700',
  663. },
  664. {
  665. province: '山西省',
  666. name: '运城市',
  667. id: '140800',
  668. },
  669. {
  670. province: '山西省',
  671. name: '忻州市',
  672. id: '140900',
  673. },
  674. {
  675. province: '山西省',
  676. name: '临汾市',
  677. id: '141000',
  678. },
  679. {
  680. province: '山西省',
  681. name: '吕梁市',
  682. id: '141100',
  683. },
  684. ],
  685. '150000': [
  686. {
  687. province: '内蒙古自治区',
  688. name: '呼和浩特市',
  689. id: '150100',
  690. },
  691. {
  692. province: '内蒙古自治区',
  693. name: '包头市',
  694. id: '150200',
  695. },
  696. {
  697. province: '内蒙古自治区',
  698. name: '乌海市',
  699. id: '150300',
  700. },
  701. {
  702. province: '内蒙古自治区',
  703. name: '赤峰市',
  704. id: '150400',
  705. },
  706. {
  707. province: '内蒙古自治区',
  708. name: '通辽市',
  709. id: '150500',
  710. },
  711. {
  712. province: '内蒙古自治区',
  713. name: '鄂尔多斯市',
  714. id: '150600',
  715. },
  716. {
  717. province: '内蒙古自治区',
  718. name: '呼伦贝尔市',
  719. id: '150700',
  720. },
  721. {
  722. province: '内蒙古自治区',
  723. name: '巴彦淖尔市',
  724. id: '150800',
  725. },
  726. {
  727. province: '内蒙古自治区',
  728. name: '乌兰察布市',
  729. id: '150900',
  730. },
  731. {
  732. province: '内蒙古自治区',
  733. name: '兴安盟',
  734. id: '152200',
  735. },
  736. {
  737. province: '内蒙古自治区',
  738. name: '锡林郭勒盟',
  739. id: '152500',
  740. },
  741. {
  742. province: '内蒙古自治区',
  743. name: '阿拉善盟',
  744. id: '152900',
  745. },
  746. ],
  747. '210000': [
  748. {
  749. province: '辽宁省',
  750. name: '沈阳市',
  751. id: '210100',
  752. },
  753. {
  754. province: '辽宁省',
  755. name: '大连市',
  756. id: '210200',
  757. },
  758. {
  759. province: '辽宁省',
  760. name: '鞍山市',
  761. id: '210300',
  762. },
  763. {
  764. province: '辽宁省',
  765. name: '抚顺市',
  766. id: '210400',
  767. },
  768. {
  769. province: '辽宁省',
  770. name: '本溪市',
  771. id: '210500',
  772. },
  773. {
  774. province: '辽宁省',
  775. name: '丹东市',
  776. id: '210600',
  777. },
  778. {
  779. province: '辽宁省',
  780. name: '锦州市',
  781. id: '210700',
  782. },
  783. {
  784. province: '辽宁省',
  785. name: '营口市',
  786. id: '210800',
  787. },
  788. {
  789. province: '辽宁省',
  790. name: '阜新市',
  791. id: '210900',
  792. },
  793. {
  794. province: '辽宁省',
  795. name: '辽阳市',
  796. id: '211000',
  797. },
  798. {
  799. province: '辽宁省',
  800. name: '盘锦市',
  801. id: '211100',
  802. },
  803. {
  804. province: '辽宁省',
  805. name: '铁岭市',
  806. id: '211200',
  807. },
  808. {
  809. province: '辽宁省',
  810. name: '朝阳市',
  811. id: '211300',
  812. },
  813. {
  814. province: '辽宁省',
  815. name: '葫芦岛市',
  816. id: '211400',
  817. },
  818. ],
  819. '220000': [
  820. {
  821. province: '吉林省',
  822. name: '长春市',
  823. id: '220100',
  824. },
  825. {
  826. province: '吉林省',
  827. name: '吉林市',
  828. id: '220200',
  829. },
  830. {
  831. province: '吉林省',
  832. name: '四平市',
  833. id: '220300',
  834. },
  835. {
  836. province: '吉林省',
  837. name: '辽源市',
  838. id: '220400',
  839. },
  840. {
  841. province: '吉林省',
  842. name: '通化市',
  843. id: '220500',
  844. },
  845. {
  846. province: '吉林省',
  847. name: '白山市',
  848. id: '220600',
  849. },
  850. {
  851. province: '吉林省',
  852. name: '松原市',
  853. id: '220700',
  854. },
  855. {
  856. province: '吉林省',
  857. name: '白城市',
  858. id: '220800',
  859. },
  860. {
  861. province: '吉林省',
  862. name: '延边朝鲜族自治州',
  863. id: '222400',
  864. },
  865. ],
  866. '230000': [
  867. {
  868. province: '黑龙江省',
  869. name: '哈尔滨市',
  870. id: '230100',
  871. },
  872. {
  873. province: '黑龙江省',
  874. name: '齐齐哈尔市',
  875. id: '230200',
  876. },
  877. {
  878. province: '黑龙江省',
  879. name: '鸡西市',
  880. id: '230300',
  881. },
  882. {
  883. province: '黑龙江省',
  884. name: '鹤岗市',
  885. id: '230400',
  886. },
  887. {
  888. province: '黑龙江省',
  889. name: '双鸭山市',
  890. id: '230500',
  891. },
  892. {
  893. province: '黑龙江省',
  894. name: '大庆市',
  895. id: '230600',
  896. },
  897. {
  898. province: '黑龙江省',
  899. name: '伊春市',
  900. id: '230700',
  901. },
  902. {
  903. province: '黑龙江省',
  904. name: '佳木斯市',
  905. id: '230800',
  906. },
  907. {
  908. province: '黑龙江省',
  909. name: '七台河市',
  910. id: '230900',
  911. },
  912. {
  913. province: '黑龙江省',
  914. name: '牡丹江市',
  915. id: '231000',
  916. },
  917. {
  918. province: '黑龙江省',
  919. name: '黑河市',
  920. id: '231100',
  921. },
  922. {
  923. province: '黑龙江省',
  924. name: '绥化市',
  925. id: '231200',
  926. },
  927. {
  928. province: '黑龙江省',
  929. name: '大兴安岭地区',
  930. id: '232700',
  931. },
  932. ],
  933. '310000': [
  934. {
  935. province: '上海市',
  936. name: '市辖区',
  937. id: '310100',
  938. },
  939. ],
  940. '320000': [
  941. {
  942. province: '江苏省',
  943. name: '南京市',
  944. id: '320100',
  945. },
  946. {
  947. province: '江苏省',
  948. name: '无锡市',
  949. id: '320200',
  950. },
  951. {
  952. province: '江苏省',
  953. name: '徐州市',
  954. id: '320300',
  955. },
  956. {
  957. province: '江苏省',
  958. name: '常州市',
  959. id: '320400',
  960. },
  961. {
  962. province: '江苏省',
  963. name: '苏州市',
  964. id: '320500',
  965. },
  966. {
  967. province: '江苏省',
  968. name: '南通市',
  969. id: '320600',
  970. },
  971. {
  972. province: '江苏省',
  973. name: '连云港市',
  974. id: '320700',
  975. },
  976. {
  977. province: '江苏省',
  978. name: '淮安市',
  979. id: '320800',
  980. },
  981. {
  982. province: '江苏省',
  983. name: '盐城市',
  984. id: '320900',
  985. },
  986. {
  987. province: '江苏省',
  988. name: '扬州市',
  989. id: '321000',
  990. },
  991. {
  992. province: '江苏省',
  993. name: '镇江市',
  994. id: '321100',
  995. },
  996. {
  997. province: '江苏省',
  998. name: '泰州市',
  999. id: '321200',
  1000. },
  1001. {
  1002. province: '江苏省',
  1003. name: '宿迁市',
  1004. id: '321300',
  1005. },
  1006. ],
  1007. '330000': [
  1008. {
  1009. province: '浙江省',
  1010. name: '杭州市',
  1011. id: '330100',
  1012. },
  1013. {
  1014. province: '浙江省',
  1015. name: '宁波市',
  1016. id: '330200',
  1017. },
  1018. {
  1019. province: '浙江省',
  1020. name: '温州市',
  1021. id: '330300',
  1022. },
  1023. {
  1024. province: '浙江省',
  1025. name: '嘉兴市',
  1026. id: '330400',
  1027. },
  1028. {
  1029. province: '浙江省',
  1030. name: '湖州市',
  1031. id: '330500',
  1032. },
  1033. {
  1034. province: '浙江省',
  1035. name: '绍兴市',
  1036. id: '330600',
  1037. },
  1038. {
  1039. province: '浙江省',
  1040. name: '金华市',
  1041. id: '330700',
  1042. },
  1043. {
  1044. province: '浙江省',
  1045. name: '衢州市',
  1046. id: '330800',
  1047. },
  1048. {
  1049. province: '浙江省',
  1050. name: '舟山市',
  1051. id: '330900',
  1052. },
  1053. {
  1054. province: '浙江省',
  1055. name: '台州市',
  1056. id: '331000',
  1057. },
  1058. {
  1059. province: '浙江省',
  1060. name: '丽水市',
  1061. id: '331100',
  1062. },
  1063. ],
  1064. '340000': [
  1065. {
  1066. province: '安徽省',
  1067. name: '合肥市',
  1068. id: '340100',
  1069. },
  1070. {
  1071. province: '安徽省',
  1072. name: '芜湖市',
  1073. id: '340200',
  1074. },
  1075. {
  1076. province: '安徽省',
  1077. name: '蚌埠市',
  1078. id: '340300',
  1079. },
  1080. {
  1081. province: '安徽省',
  1082. name: '淮南市',
  1083. id: '340400',
  1084. },
  1085. {
  1086. province: '安徽省',
  1087. name: '马鞍山市',
  1088. id: '340500',
  1089. },
  1090. {
  1091. province: '安徽省',
  1092. name: '淮北市',
  1093. id: '340600',
  1094. },
  1095. {
  1096. province: '安徽省',
  1097. name: '铜陵市',
  1098. id: '340700',
  1099. },
  1100. {
  1101. province: '安徽省',
  1102. name: '安庆市',
  1103. id: '340800',
  1104. },
  1105. {
  1106. province: '安徽省',
  1107. name: '黄山市',
  1108. id: '341000',
  1109. },
  1110. {
  1111. province: '安徽省',
  1112. name: '滁州市',
  1113. id: '341100',
  1114. },
  1115. {
  1116. province: '安徽省',
  1117. name: '阜阳市',
  1118. id: '341200',
  1119. },
  1120. {
  1121. province: '安徽省',
  1122. name: '宿州市',
  1123. id: '341300',
  1124. },
  1125. {
  1126. province: '安徽省',
  1127. name: '六安市',
  1128. id: '341500',
  1129. },
  1130. {
  1131. province: '安徽省',
  1132. name: '亳州市',
  1133. id: '341600',
  1134. },
  1135. {
  1136. province: '安徽省',
  1137. name: '池州市',
  1138. id: '341700',
  1139. },
  1140. {
  1141. province: '安徽省',
  1142. name: '宣城市',
  1143. id: '341800',
  1144. },
  1145. ],
  1146. '350000': [
  1147. {
  1148. province: '福建省',
  1149. name: '福州市',
  1150. id: '350100',
  1151. },
  1152. {
  1153. province: '福建省',
  1154. name: '厦门市',
  1155. id: '350200',
  1156. },
  1157. {
  1158. province: '福建省',
  1159. name: '莆田市',
  1160. id: '350300',
  1161. },
  1162. {
  1163. province: '福建省',
  1164. name: '三明市',
  1165. id: '350400',
  1166. },
  1167. {
  1168. province: '福建省',
  1169. name: '泉州市',
  1170. id: '350500',
  1171. },
  1172. {
  1173. province: '福建省',
  1174. name: '漳州市',
  1175. id: '350600',
  1176. },
  1177. {
  1178. province: '福建省',
  1179. name: '南平市',
  1180. id: '350700',
  1181. },
  1182. {
  1183. province: '福建省',
  1184. name: '龙岩市',
  1185. id: '350800',
  1186. },
  1187. {
  1188. province: '福建省',
  1189. name: '宁德市',
  1190. id: '350900',
  1191. },
  1192. ],
  1193. '360000': [
  1194. {
  1195. province: '江西省',
  1196. name: '南昌市',
  1197. id: '360100',
  1198. },
  1199. {
  1200. province: '江西省',
  1201. name: '景德镇市',
  1202. id: '360200',
  1203. },
  1204. {
  1205. province: '江西省',
  1206. name: '萍乡市',
  1207. id: '360300',
  1208. },
  1209. {
  1210. province: '江西省',
  1211. name: '九江市',
  1212. id: '360400',
  1213. },
  1214. {
  1215. province: '江西省',
  1216. name: '新余市',
  1217. id: '360500',
  1218. },
  1219. {
  1220. province: '江西省',
  1221. name: '鹰潭市',
  1222. id: '360600',
  1223. },
  1224. {
  1225. province: '江西省',
  1226. name: '赣州市',
  1227. id: '360700',
  1228. },
  1229. {
  1230. province: '江西省',
  1231. name: '吉安市',
  1232. id: '360800',
  1233. },
  1234. {
  1235. province: '江西省',
  1236. name: '宜春市',
  1237. id: '360900',
  1238. },
  1239. {
  1240. province: '江西省',
  1241. name: '抚州市',
  1242. id: '361000',
  1243. },
  1244. {
  1245. province: '江西省',
  1246. name: '上饶市',
  1247. id: '361100',
  1248. },
  1249. ],
  1250. '370000': [
  1251. {
  1252. province: '山东省',
  1253. name: '济南市',
  1254. id: '370100',
  1255. },
  1256. {
  1257. province: '山东省',
  1258. name: '青岛市',
  1259. id: '370200',
  1260. },
  1261. {
  1262. province: '山东省',
  1263. name: '淄博市',
  1264. id: '370300',
  1265. },
  1266. {
  1267. province: '山东省',
  1268. name: '枣庄市',
  1269. id: '370400',
  1270. },
  1271. {
  1272. province: '山东省',
  1273. name: '东营市',
  1274. id: '370500',
  1275. },
  1276. {
  1277. province: '山东省',
  1278. name: '烟台市',
  1279. id: '370600',
  1280. },
  1281. {
  1282. province: '山东省',
  1283. name: '潍坊市',
  1284. id: '370700',
  1285. },
  1286. {
  1287. province: '山东省',
  1288. name: '济宁市',
  1289. id: '370800',
  1290. },
  1291. {
  1292. province: '山东省',
  1293. name: '泰安市',
  1294. id: '370900',
  1295. },
  1296. {
  1297. province: '山东省',
  1298. name: '威海市',
  1299. id: '371000',
  1300. },
  1301. {
  1302. province: '山东省',
  1303. name: '日照市',
  1304. id: '371100',
  1305. },
  1306. {
  1307. province: '山东省',
  1308. name: '莱芜市',
  1309. id: '371200',
  1310. },
  1311. {
  1312. province: '山东省',
  1313. name: '临沂市',
  1314. id: '371300',
  1315. },
  1316. {
  1317. province: '山东省',
  1318. name: '德州市',
  1319. id: '371400',
  1320. },
  1321. {
  1322. province: '山东省',
  1323. name: '聊城市',
  1324. id: '371500',
  1325. },
  1326. {
  1327. province: '山东省',
  1328. name: '滨州市',
  1329. id: '371600',
  1330. },
  1331. {
  1332. province: '山东省',
  1333. name: '菏泽市',
  1334. id: '371700',
  1335. },
  1336. ],
  1337. '410000': [
  1338. {
  1339. province: '河南省',
  1340. name: '郑州市',
  1341. id: '410100',
  1342. },
  1343. {
  1344. province: '河南省',
  1345. name: '开封市',
  1346. id: '410200',
  1347. },
  1348. {
  1349. province: '河南省',
  1350. name: '洛阳市',
  1351. id: '410300',
  1352. },
  1353. {
  1354. province: '河南省',
  1355. name: '平顶山市',
  1356. id: '410400',
  1357. },
  1358. {
  1359. province: '河南省',
  1360. name: '安阳市',
  1361. id: '410500',
  1362. },
  1363. {
  1364. province: '河南省',
  1365. name: '鹤壁市',
  1366. id: '410600',
  1367. },
  1368. {
  1369. province: '河南省',
  1370. name: '新乡市',
  1371. id: '410700',
  1372. },
  1373. {
  1374. province: '河南省',
  1375. name: '焦作市',
  1376. id: '410800',
  1377. },
  1378. {
  1379. province: '河南省',
  1380. name: '濮阳市',
  1381. id: '410900',
  1382. },
  1383. {
  1384. province: '河南省',
  1385. name: '许昌市',
  1386. id: '411000',
  1387. },
  1388. {
  1389. province: '河南省',
  1390. name: '漯河市',
  1391. id: '411100',
  1392. },
  1393. {
  1394. province: '河南省',
  1395. name: '三门峡市',
  1396. id: '411200',
  1397. },
  1398. {
  1399. province: '河南省',
  1400. name: '南阳市',
  1401. id: '411300',
  1402. },
  1403. {
  1404. province: '河南省',
  1405. name: '商丘市',
  1406. id: '411400',
  1407. },
  1408. {
  1409. province: '河南省',
  1410. name: '信阳市',
  1411. id: '411500',
  1412. },
  1413. {
  1414. province: '河南省',
  1415. name: '周口市',
  1416. id: '411600',
  1417. },
  1418. {
  1419. province: '河南省',
  1420. name: '驻马店市',
  1421. id: '411700',
  1422. },
  1423. {
  1424. province: '河南省',
  1425. name: '省直辖县级行政区划',
  1426. id: '419000',
  1427. },
  1428. ],
  1429. '420000': [
  1430. {
  1431. province: '湖北省',
  1432. name: '武汉市',
  1433. id: '420100',
  1434. },
  1435. {
  1436. province: '湖北省',
  1437. name: '黄石市',
  1438. id: '420200',
  1439. },
  1440. {
  1441. province: '湖北省',
  1442. name: '十堰市',
  1443. id: '420300',
  1444. },
  1445. {
  1446. province: '湖北省',
  1447. name: '宜昌市',
  1448. id: '420500',
  1449. },
  1450. {
  1451. province: '湖北省',
  1452. name: '襄阳市',
  1453. id: '420600',
  1454. },
  1455. {
  1456. province: '湖北省',
  1457. name: '鄂州市',
  1458. id: '420700',
  1459. },
  1460. {
  1461. province: '湖北省',
  1462. name: '荆门市',
  1463. id: '420800',
  1464. },
  1465. {
  1466. province: '湖北省',
  1467. name: '孝感市',
  1468. id: '420900',
  1469. },
  1470. {
  1471. province: '湖北省',
  1472. name: '荆州市',
  1473. id: '421000',
  1474. },
  1475. {
  1476. province: '湖北省',
  1477. name: '黄冈市',
  1478. id: '421100',
  1479. },
  1480. {
  1481. province: '湖北省',
  1482. name: '咸宁市',
  1483. id: '421200',
  1484. },
  1485. {
  1486. province: '湖北省',
  1487. name: '随州市',
  1488. id: '421300',
  1489. },
  1490. {
  1491. province: '湖北省',
  1492. name: '恩施土家族苗族自治州',
  1493. id: '422800',
  1494. },
  1495. {
  1496. province: '湖北省',
  1497. name: '省直辖县级行政区划',
  1498. id: '429000',
  1499. },
  1500. ],
  1501. '430000': [
  1502. {
  1503. province: '湖南省',
  1504. name: '长沙市',
  1505. id: '430100',
  1506. },
  1507. {
  1508. province: '湖南省',
  1509. name: '株洲市',
  1510. id: '430200',
  1511. },
  1512. {
  1513. province: '湖南省',
  1514. name: '湘潭市',
  1515. id: '430300',
  1516. },
  1517. {
  1518. province: '湖南省',
  1519. name: '衡阳市',
  1520. id: '430400',
  1521. },
  1522. {
  1523. province: '湖南省',
  1524. name: '邵阳市',
  1525. id: '430500',
  1526. },
  1527. {
  1528. province: '湖南省',
  1529. name: '岳阳市',
  1530. id: '430600',
  1531. },
  1532. {
  1533. province: '湖南省',
  1534. name: '常德市',
  1535. id: '430700',
  1536. },
  1537. {
  1538. province: '湖南省',
  1539. name: '张家界市',
  1540. id: '430800',
  1541. },
  1542. {
  1543. province: '湖南省',
  1544. name: '益阳市',
  1545. id: '430900',
  1546. },
  1547. {
  1548. province: '湖南省',
  1549. name: '郴州市',
  1550. id: '431000',
  1551. },
  1552. {
  1553. province: '湖南省',
  1554. name: '永州市',
  1555. id: '431100',
  1556. },
  1557. {
  1558. province: '湖南省',
  1559. name: '怀化市',
  1560. id: '431200',
  1561. },
  1562. {
  1563. province: '湖南省',
  1564. name: '娄底市',
  1565. id: '431300',
  1566. },
  1567. {
  1568. province: '湖南省',
  1569. name: '湘西土家族苗族自治州',
  1570. id: '433100',
  1571. },
  1572. ],
  1573. '440000': [
  1574. {
  1575. province: '广东省',
  1576. name: '广州市',
  1577. id: '440100',
  1578. },
  1579. {
  1580. province: '广东省',
  1581. name: '韶关市',
  1582. id: '440200',
  1583. },
  1584. {
  1585. province: '广东省',
  1586. name: '深圳市',
  1587. id: '440300',
  1588. },
  1589. {
  1590. province: '广东省',
  1591. name: '珠海市',
  1592. id: '440400',
  1593. },
  1594. {
  1595. province: '广东省',
  1596. name: '汕头市',
  1597. id: '440500',
  1598. },
  1599. {
  1600. province: '广东省',
  1601. name: '佛山市',
  1602. id: '440600',
  1603. },
  1604. {
  1605. province: '广东省',
  1606. name: '江门市',
  1607. id: '440700',
  1608. },
  1609. {
  1610. province: '广东省',
  1611. name: '湛江市',
  1612. id: '440800',
  1613. },
  1614. {
  1615. province: '广东省',
  1616. name: '茂名市',
  1617. id: '440900',
  1618. },
  1619. {
  1620. province: '广东省',
  1621. name: '肇庆市',
  1622. id: '441200',
  1623. },
  1624. {
  1625. province: '广东省',
  1626. name: '惠州市',
  1627. id: '441300',
  1628. },
  1629. {
  1630. province: '广东省',
  1631. name: '梅州市',
  1632. id: '441400',
  1633. },
  1634. {
  1635. province: '广东省',
  1636. name: '汕尾市',
  1637. id: '441500',
  1638. },
  1639. {
  1640. province: '广东省',
  1641. name: '河源市',
  1642. id: '441600',
  1643. },
  1644. {
  1645. province: '广东省',
  1646. name: '阳江市',
  1647. id: '441700',
  1648. },
  1649. {
  1650. province: '广东省',
  1651. name: '清远市',
  1652. id: '441800',
  1653. },
  1654. {
  1655. province: '广东省',
  1656. name: '东莞市',
  1657. id: '441900',
  1658. },
  1659. {
  1660. province: '广东省',
  1661. name: '中山市',
  1662. id: '442000',
  1663. },
  1664. {
  1665. province: '广东省',
  1666. name: '潮州市',
  1667. id: '445100',
  1668. },
  1669. {
  1670. province: '广东省',
  1671. name: '揭阳市',
  1672. id: '445200',
  1673. },
  1674. {
  1675. province: '广东省',
  1676. name: '云浮市',
  1677. id: '445300',
  1678. },
  1679. ],
  1680. '450000': [
  1681. {
  1682. province: '广西壮族自治区',
  1683. name: '南宁市',
  1684. id: '450100',
  1685. },
  1686. {
  1687. province: '广西壮族自治区',
  1688. name: '柳州市',
  1689. id: '450200',
  1690. },
  1691. {
  1692. province: '广西壮族自治区',
  1693. name: '桂林市',
  1694. id: '450300',
  1695. },
  1696. {
  1697. province: '广西壮族自治区',
  1698. name: '梧州市',
  1699. id: '450400',
  1700. },
  1701. {
  1702. province: '广西壮族自治区',
  1703. name: '北海市',
  1704. id: '450500',
  1705. },
  1706. {
  1707. province: '广西壮族自治区',
  1708. name: '防城港市',
  1709. id: '450600',
  1710. },
  1711. {
  1712. province: '广西壮族自治区',
  1713. name: '钦州市',
  1714. id: '450700',
  1715. },
  1716. {
  1717. province: '广西壮族自治区',
  1718. name: '贵港市',
  1719. id: '450800',
  1720. },
  1721. {
  1722. province: '广西壮族自治区',
  1723. name: '玉林市',
  1724. id: '450900',
  1725. },
  1726. {
  1727. province: '广西壮族自治区',
  1728. name: '百色市',
  1729. id: '451000',
  1730. },
  1731. {
  1732. province: '广西壮族自治区',
  1733. name: '贺州市',
  1734. id: '451100',
  1735. },
  1736. {
  1737. province: '广西壮族自治区',
  1738. name: '河池市',
  1739. id: '451200',
  1740. },
  1741. {
  1742. province: '广西壮族自治区',
  1743. name: '来宾市',
  1744. id: '451300',
  1745. },
  1746. {
  1747. province: '广西壮族自治区',
  1748. name: '崇左市',
  1749. id: '451400',
  1750. },
  1751. ],
  1752. '460000': [
  1753. {
  1754. province: '海南省',
  1755. name: '海口市',
  1756. id: '460100',
  1757. },
  1758. {
  1759. province: '海南省',
  1760. name: '三亚市',
  1761. id: '460200',
  1762. },
  1763. {
  1764. province: '海南省',
  1765. name: '三沙市',
  1766. id: '460300',
  1767. },
  1768. {
  1769. province: '海南省',
  1770. name: '儋州市',
  1771. id: '460400',
  1772. },
  1773. {
  1774. province: '海南省',
  1775. name: '省直辖县级行政区划',
  1776. id: '469000',
  1777. },
  1778. ],
  1779. '500000': [
  1780. {
  1781. province: '重庆市',
  1782. name: '市辖区',
  1783. id: '500100',
  1784. },
  1785. {
  1786. province: '重庆市',
  1787. name: '县',
  1788. id: '500200',
  1789. },
  1790. ],
  1791. '510000': [
  1792. {
  1793. province: '四川省',
  1794. name: '成都市',
  1795. id: '510100',
  1796. },
  1797. {
  1798. province: '四川省',
  1799. name: '自贡市',
  1800. id: '510300',
  1801. },
  1802. {
  1803. province: '四川省',
  1804. name: '攀枝花市',
  1805. id: '510400',
  1806. },
  1807. {
  1808. province: '四川省',
  1809. name: '泸州市',
  1810. id: '510500',
  1811. },
  1812. {
  1813. province: '四川省',
  1814. name: '德阳市',
  1815. id: '510600',
  1816. },
  1817. {
  1818. province: '四川省',
  1819. name: '绵阳市',
  1820. id: '510700',
  1821. },
  1822. {
  1823. province: '四川省',
  1824. name: '广元市',
  1825. id: '510800',
  1826. },
  1827. {
  1828. province: '四川省',
  1829. name: '遂宁市',
  1830. id: '510900',
  1831. },
  1832. {
  1833. province: '四川省',
  1834. name: '内江市',
  1835. id: '511000',
  1836. },
  1837. {
  1838. province: '四川省',
  1839. name: '乐山市',
  1840. id: '511100',
  1841. },
  1842. {
  1843. province: '四川省',
  1844. name: '南充市',
  1845. id: '511300',
  1846. },
  1847. {
  1848. province: '四川省',
  1849. name: '眉山市',
  1850. id: '511400',
  1851. },
  1852. {
  1853. province: '四川省',
  1854. name: '宜宾市',
  1855. id: '511500',
  1856. },
  1857. {
  1858. province: '四川省',
  1859. name: '广安市',
  1860. id: '511600',
  1861. },
  1862. {
  1863. province: '四川省',
  1864. name: '达州市',
  1865. id: '511700',
  1866. },
  1867. {
  1868. province: '四川省',
  1869. name: '雅安市',
  1870. id: '511800',
  1871. },
  1872. {
  1873. province: '四川省',
  1874. name: '巴中市',
  1875. id: '511900',
  1876. },
  1877. {
  1878. province: '四川省',
  1879. name: '资阳市',
  1880. id: '512000',
  1881. },
  1882. {
  1883. province: '四川省',
  1884. name: '阿坝藏族羌族自治州',
  1885. id: '513200',
  1886. },
  1887. {
  1888. province: '四川省',
  1889. name: '甘孜藏族自治州',
  1890. id: '513300',
  1891. },
  1892. {
  1893. province: '四川省',
  1894. name: '凉山彝族自治州',
  1895. id: '513400',
  1896. },
  1897. ],
  1898. '520000': [
  1899. {
  1900. province: '贵州省',
  1901. name: '贵阳市',
  1902. id: '520100',
  1903. },
  1904. {
  1905. province: '贵州省',
  1906. name: '六盘水市',
  1907. id: '520200',
  1908. },
  1909. {
  1910. province: '贵州省',
  1911. name: '遵义市',
  1912. id: '520300',
  1913. },
  1914. {
  1915. province: '贵州省',
  1916. name: '安顺市',
  1917. id: '520400',
  1918. },
  1919. {
  1920. province: '贵州省',
  1921. name: '毕节市',
  1922. id: '520500',
  1923. },
  1924. {
  1925. province: '贵州省',
  1926. name: '铜仁市',
  1927. id: '520600',
  1928. },
  1929. {
  1930. province: '贵州省',
  1931. name: '黔西南布依族苗族自治州',
  1932. id: '522300',
  1933. },
  1934. {
  1935. province: '贵州省',
  1936. name: '黔东南苗族侗族自治州',
  1937. id: '522600',
  1938. },
  1939. {
  1940. province: '贵州省',
  1941. name: '黔南布依族苗族自治州',
  1942. id: '522700',
  1943. },
  1944. ],
  1945. '530000': [
  1946. {
  1947. province: '云南省',
  1948. name: '昆明市',
  1949. id: '530100',
  1950. },
  1951. {
  1952. province: '云南省',
  1953. name: '曲靖市',
  1954. id: '530300',
  1955. },
  1956. {
  1957. province: '云南省',
  1958. name: '玉溪市',
  1959. id: '530400',
  1960. },
  1961. {
  1962. province: '云南省',
  1963. name: '保山市',
  1964. id: '530500',
  1965. },
  1966. {
  1967. province: '云南省',
  1968. name: '昭通市',
  1969. id: '530600',
  1970. },
  1971. {
  1972. province: '云南省',
  1973. name: '丽江市',
  1974. id: '530700',
  1975. },
  1976. {
  1977. province: '云南省',
  1978. name: '普洱市',
  1979. id: '530800',
  1980. },
  1981. {
  1982. province: '云南省',
  1983. name: '临沧市',
  1984. id: '530900',
  1985. },
  1986. {
  1987. province: '云南省',
  1988. name: '楚雄彝族自治州',
  1989. id: '532300',
  1990. },
  1991. {
  1992. province: '云南省',
  1993. name: '红河哈尼族彝族自治州',
  1994. id: '532500',
  1995. },
  1996. {
  1997. province: '云南省',
  1998. name: '文山壮族苗族自治州',
  1999. id: '532600',
  2000. },
  2001. {
  2002. province: '云南省',
  2003. name: '西双版纳傣族自治州',
  2004. id: '532800',
  2005. },
  2006. {
  2007. province: '云南省',
  2008. name: '大理白族自治州',
  2009. id: '532900',
  2010. },
  2011. {
  2012. province: '云南省',
  2013. name: '德宏傣族景颇族自治州',
  2014. id: '533100',
  2015. },
  2016. {
  2017. province: '云南省',
  2018. name: '怒江傈僳族自治州',
  2019. id: '533300',
  2020. },
  2021. {
  2022. province: '云南省',
  2023. name: '迪庆藏族自治州',
  2024. id: '533400',
  2025. },
  2026. ],
  2027. '540000': [
  2028. {
  2029. province: '西藏自治区',
  2030. name: '拉萨市',
  2031. id: '540100',
  2032. },
  2033. {
  2034. province: '西藏自治区',
  2035. name: '日喀则市',
  2036. id: '540200',
  2037. },
  2038. {
  2039. province: '西藏自治区',
  2040. name: '昌都市',
  2041. id: '540300',
  2042. },
  2043. {
  2044. province: '西藏自治区',
  2045. name: '林芝市',
  2046. id: '540400',
  2047. },
  2048. {
  2049. province: '西藏自治区',
  2050. name: '山南市',
  2051. id: '540500',
  2052. },
  2053. {
  2054. province: '西藏自治区',
  2055. name: '那曲地区',
  2056. id: '542400',
  2057. },
  2058. {
  2059. province: '西藏自治区',
  2060. name: '阿里地区',
  2061. id: '542500',
  2062. },
  2063. ],
  2064. '610000': [
  2065. {
  2066. province: '陕西省',
  2067. name: '西安市',
  2068. id: '610100',
  2069. },
  2070. {
  2071. province: '陕西省',
  2072. name: '铜川市',
  2073. id: '610200',
  2074. },
  2075. {
  2076. province: '陕西省',
  2077. name: '宝鸡市',
  2078. id: '610300',
  2079. },
  2080. {
  2081. province: '陕西省',
  2082. name: '咸阳市',
  2083. id: '610400',
  2084. },
  2085. {
  2086. province: '陕西省',
  2087. name: '渭南市',
  2088. id: '610500',
  2089. },
  2090. {
  2091. province: '陕西省',
  2092. name: '延安市',
  2093. id: '610600',
  2094. },
  2095. {
  2096. province: '陕西省',
  2097. name: '汉中市',
  2098. id: '610700',
  2099. },
  2100. {
  2101. province: '陕西省',
  2102. name: '榆林市',
  2103. id: '610800',
  2104. },
  2105. {
  2106. province: '陕西省',
  2107. name: '安康市',
  2108. id: '610900',
  2109. },
  2110. {
  2111. province: '陕西省',
  2112. name: '商洛市',
  2113. id: '611000',
  2114. },
  2115. ],
  2116. '620000': [
  2117. {
  2118. province: '甘肃省',
  2119. name: '兰州市',
  2120. id: '620100',
  2121. },
  2122. {
  2123. province: '甘肃省',
  2124. name: '嘉峪关市',
  2125. id: '620200',
  2126. },
  2127. {
  2128. province: '甘肃省',
  2129. name: '金昌市',
  2130. id: '620300',
  2131. },
  2132. {
  2133. province: '甘肃省',
  2134. name: '白银市',
  2135. id: '620400',
  2136. },
  2137. {
  2138. province: '甘肃省',
  2139. name: '天水市',
  2140. id: '620500',
  2141. },
  2142. {
  2143. province: '甘肃省',
  2144. name: '武威市',
  2145. id: '620600',
  2146. },
  2147. {
  2148. province: '甘肃省',
  2149. name: '张掖市',
  2150. id: '620700',
  2151. },
  2152. {
  2153. province: '甘肃省',
  2154. name: '平凉市',
  2155. id: '620800',
  2156. },
  2157. {
  2158. province: '甘肃省',
  2159. name: '酒泉市',
  2160. id: '620900',
  2161. },
  2162. {
  2163. province: '甘肃省',
  2164. name: '庆阳市',
  2165. id: '621000',
  2166. },
  2167. {
  2168. province: '甘肃省',
  2169. name: '定西市',
  2170. id: '621100',
  2171. },
  2172. {
  2173. province: '甘肃省',
  2174. name: '陇南市',
  2175. id: '621200',
  2176. },
  2177. {
  2178. province: '甘肃省',
  2179. name: '临夏回族自治州',
  2180. id: '622900',
  2181. },
  2182. {
  2183. province: '甘肃省',
  2184. name: '甘南藏族自治州',
  2185. id: '623000',
  2186. },
  2187. ],
  2188. '630000': [
  2189. {
  2190. province: '青海省',
  2191. name: '西宁市',
  2192. id: '630100',
  2193. },
  2194. {
  2195. province: '青海省',
  2196. name: '海东市',
  2197. id: '630200',
  2198. },
  2199. {
  2200. province: '青海省',
  2201. name: '海北藏族自治州',
  2202. id: '632200',
  2203. },
  2204. {
  2205. province: '青海省',
  2206. name: '黄南藏族自治州',
  2207. id: '632300',
  2208. },
  2209. {
  2210. province: '青海省',
  2211. name: '海南藏族自治州',
  2212. id: '632500',
  2213. },
  2214. {
  2215. province: '青海省',
  2216. name: '果洛藏族自治州',
  2217. id: '632600',
  2218. },
  2219. {
  2220. province: '青海省',
  2221. name: '玉树藏族自治州',
  2222. id: '632700',
  2223. },
  2224. {
  2225. province: '青海省',
  2226. name: '海西蒙古族藏族自治州',
  2227. id: '632800',
  2228. },
  2229. ],
  2230. '640000': [
  2231. {
  2232. province: '宁夏回族自治区',
  2233. name: '银川市',
  2234. id: '640100',
  2235. },
  2236. {
  2237. province: '宁夏回族自治区',
  2238. name: '石嘴山市',
  2239. id: '640200',
  2240. },
  2241. {
  2242. province: '宁夏回族自治区',
  2243. name: '吴忠市',
  2244. id: '640300',
  2245. },
  2246. {
  2247. province: '宁夏回族自治区',
  2248. name: '固原市',
  2249. id: '640400',
  2250. },
  2251. {
  2252. province: '宁夏回族自治区',
  2253. name: '中卫市',
  2254. id: '640500',
  2255. },
  2256. ],
  2257. '650000': [
  2258. {
  2259. province: '新疆维吾尔自治区',
  2260. name: '乌鲁木齐市',
  2261. id: '650100',
  2262. },
  2263. {
  2264. province: '新疆维吾尔自治区',
  2265. name: '克拉玛依市',
  2266. id: '650200',
  2267. },
  2268. {
  2269. province: '新疆维吾尔自治区',
  2270. name: '吐鲁番市',
  2271. id: '650400',
  2272. },
  2273. {
  2274. province: '新疆维吾尔自治区',
  2275. name: '哈密市',
  2276. id: '650500',
  2277. },
  2278. {
  2279. province: '新疆维吾尔自治区',
  2280. name: '昌吉回族自治州',
  2281. id: '652300',
  2282. },
  2283. {
  2284. province: '新疆维吾尔自治区',
  2285. name: '博尔塔拉蒙古自治州',
  2286. id: '652700',
  2287. },
  2288. {
  2289. province: '新疆维吾尔自治区',
  2290. name: '巴音郭楞蒙古自治州',
  2291. id: '652800',
  2292. },
  2293. {
  2294. province: '新疆维吾尔自治区',
  2295. name: '阿克苏地区',
  2296. id: '652900',
  2297. },
  2298. {
  2299. province: '新疆维吾尔自治区',
  2300. name: '克孜勒苏柯尔克孜自治州',
  2301. id: '653000',
  2302. },
  2303. {
  2304. province: '新疆维吾尔自治区',
  2305. name: '喀什地区',
  2306. id: '653100',
  2307. },
  2308. {
  2309. province: '新疆维吾尔自治区',
  2310. name: '和田地区',
  2311. id: '653200',
  2312. },
  2313. {
  2314. province: '新疆维吾尔自治区',
  2315. name: '伊犁哈萨克自治州',
  2316. id: '654000',
  2317. },
  2318. {
  2319. province: '新疆维吾尔自治区',
  2320. name: '塔城地区',
  2321. id: '654200',
  2322. },
  2323. {
  2324. province: '新疆维吾尔自治区',
  2325. name: '阿勒泰地区',
  2326. id: '654300',
  2327. },
  2328. {
  2329. province: '新疆维吾尔自治区',
  2330. name: '自治区直辖县级行政区划',
  2331. id: '659000',
  2332. },
  2333. ],
  2334. };
  2335. var province = [
  2336. {
  2337. name: '北京市',
  2338. id: '110000',
  2339. },
  2340. {
  2341. name: '天津市',
  2342. id: '120000',
  2343. },
  2344. {
  2345. name: '河北省',
  2346. id: '130000',
  2347. },
  2348. {
  2349. name: '山西省',
  2350. id: '140000',
  2351. },
  2352. {
  2353. name: '内蒙古自治区',
  2354. id: '150000',
  2355. },
  2356. {
  2357. name: '辽宁省',
  2358. id: '210000',
  2359. },
  2360. {
  2361. name: '吉林省',
  2362. id: '220000',
  2363. },
  2364. {
  2365. name: '黑龙江省',
  2366. id: '230000',
  2367. },
  2368. {
  2369. name: '上海市',
  2370. id: '310000',
  2371. },
  2372. {
  2373. name: '江苏省',
  2374. id: '320000',
  2375. },
  2376. {
  2377. name: '浙江省',
  2378. id: '330000',
  2379. },
  2380. {
  2381. name: '安徽省',
  2382. id: '340000',
  2383. },
  2384. {
  2385. name: '福建省',
  2386. id: '350000',
  2387. },
  2388. {
  2389. name: '江西省',
  2390. id: '360000',
  2391. },
  2392. {
  2393. name: '山东省',
  2394. id: '370000',
  2395. },
  2396. {
  2397. name: '河南省',
  2398. id: '410000',
  2399. },
  2400. {
  2401. name: '湖北省',
  2402. id: '420000',
  2403. },
  2404. {
  2405. name: '湖南省',
  2406. id: '430000',
  2407. },
  2408. {
  2409. name: '广东省',
  2410. id: '440000',
  2411. },
  2412. {
  2413. name: '广西壮族自治区',
  2414. id: '450000',
  2415. },
  2416. {
  2417. name: '海南省',
  2418. id: '460000',
  2419. },
  2420. {
  2421. name: '重庆市',
  2422. id: '500000',
  2423. },
  2424. {
  2425. name: '四川省',
  2426. id: '510000',
  2427. },
  2428. {
  2429. name: '贵州省',
  2430. id: '520000',
  2431. },
  2432. {
  2433. name: '云南省',
  2434. id: '530000',
  2435. },
  2436. {
  2437. name: '西藏自治区',
  2438. id: '540000',
  2439. },
  2440. {
  2441. name: '陕西省',
  2442. id: '610000',
  2443. },
  2444. {
  2445. name: '甘肃省',
  2446. id: '620000',
  2447. },
  2448. {
  2449. name: '青海省',
  2450. id: '630000',
  2451. },
  2452. {
  2453. name: '宁夏回族自治区',
  2454. id: '640000',
  2455. },
  2456. {
  2457. name: '新疆维吾尔自治区',
  2458. id: '650000',
  2459. },
  2460. {
  2461. name: '台湾省',
  2462. id: '710000',
  2463. },
  2464. {
  2465. name: '香港特别行政区',
  2466. id: '810000',
  2467. },
  2468. {
  2469. name: '澳门特别行政区',
  2470. id: '820000',
  2471. },
  2472. ];
  2473. function getProvince(req, res) {
  2474. return res.json(province);
  2475. }
  2476. function getCity(req, res) {
  2477. return res.json(city[req.params.province]);
  2478. }
  2479. var geographic = {
  2480. 'GET /api/geographic/province': getProvince,
  2481. 'GET /api/geographic/city/:province': getCity,
  2482. };
  2483. const getNotices = (req, res) =>
  2484. res.json([
  2485. {
  2486. id: '000000001',
  2487. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
  2488. title: '你收到了 14 份新周报',
  2489. datetime: '2017-08-09',
  2490. type: 'notification',
  2491. },
  2492. {
  2493. id: '000000002',
  2494. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
  2495. title: '你推荐的 曲妮妮 已通过第三轮面试',
  2496. datetime: '2017-08-08',
  2497. type: 'notification',
  2498. },
  2499. {
  2500. id: '000000003',
  2501. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png',
  2502. title: '这种模板可以区分多种通知类型',
  2503. datetime: '2017-08-07',
  2504. read: true,
  2505. type: 'notification',
  2506. },
  2507. {
  2508. id: '000000004',
  2509. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png',
  2510. title: '左侧图标用于区分不同的类型',
  2511. datetime: '2017-08-07',
  2512. type: 'notification',
  2513. },
  2514. {
  2515. id: '000000005',
  2516. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
  2517. title: '内容不要超过两行字,超出时自动截断',
  2518. datetime: '2017-08-07',
  2519. type: 'notification',
  2520. },
  2521. {
  2522. id: '000000006',
  2523. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
  2524. title: '曲丽丽 评论了你',
  2525. description: '描述信息描述信息描述信息',
  2526. datetime: '2017-08-07',
  2527. type: 'message',
  2528. clickClose: true,
  2529. },
  2530. {
  2531. id: '000000007',
  2532. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
  2533. title: '朱偏右 回复了你',
  2534. description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
  2535. datetime: '2017-08-07',
  2536. type: 'message',
  2537. clickClose: true,
  2538. },
  2539. {
  2540. id: '000000008',
  2541. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
  2542. title: '标题',
  2543. description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
  2544. datetime: '2017-08-07',
  2545. type: 'message',
  2546. clickClose: true,
  2547. },
  2548. {
  2549. id: '000000009',
  2550. title: '任务名称',
  2551. description: '任务需要在 2017-01-12 20:00 前启动',
  2552. extra: '未开始',
  2553. status: 'todo',
  2554. type: 'event',
  2555. },
  2556. {
  2557. id: '000000010',
  2558. title: '第三方紧急代码变更',
  2559. description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
  2560. extra: '马上到期',
  2561. status: 'urgent',
  2562. type: 'event',
  2563. },
  2564. {
  2565. id: '000000011',
  2566. title: '信息安全考试',
  2567. description: '指派竹尔于 2017-01-09 前完成更新并发布',
  2568. extra: '已耗时 8 天',
  2569. status: 'doing',
  2570. type: 'event',
  2571. },
  2572. {
  2573. id: '000000012',
  2574. title: 'ABCD 版本发布',
  2575. description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
  2576. extra: '进行中',
  2577. status: 'processing',
  2578. type: 'event',
  2579. },
  2580. ]);
  2581. var notices = {
  2582. 'GET /api/notices': getNotices,
  2583. };
  2584. const basicGoods = [
  2585. {
  2586. id: '1234561',
  2587. name: '矿泉水 550ml',
  2588. barcode: '12421432143214321',
  2589. price: '2.00',
  2590. num: '1',
  2591. amount: '2.00',
  2592. },
  2593. {
  2594. id: '1234562',
  2595. name: '凉茶 300ml',
  2596. barcode: '12421432143214322',
  2597. price: '3.00',
  2598. num: '2',
  2599. amount: '6.00',
  2600. },
  2601. {
  2602. id: '1234563',
  2603. name: '好吃的薯片',
  2604. barcode: '12421432143214323',
  2605. price: '7.00',
  2606. num: '4',
  2607. amount: '28.00',
  2608. },
  2609. {
  2610. id: '1234564',
  2611. name: '特别好吃的蛋卷',
  2612. barcode: '12421432143214324',
  2613. price: '8.50',
  2614. num: '3',
  2615. amount: '25.50',
  2616. },
  2617. ];
  2618. const basicProgress = [
  2619. {
  2620. key: '1',
  2621. time: '2017-10-01 14:10',
  2622. rate: '联系客户',
  2623. status: 'processing',
  2624. operator: '取货员 ID1234',
  2625. cost: '5mins',
  2626. },
  2627. {
  2628. key: '2',
  2629. time: '2017-10-01 14:05',
  2630. rate: '取货员出发',
  2631. status: 'success',
  2632. operator: '取货员 ID1234',
  2633. cost: '1h',
  2634. },
  2635. {
  2636. key: '3',
  2637. time: '2017-10-01 13:05',
  2638. rate: '取货员接单',
  2639. status: 'success',
  2640. operator: '取货员 ID1234',
  2641. cost: '5mins',
  2642. },
  2643. {
  2644. key: '4',
  2645. time: '2017-10-01 13:00',
  2646. rate: '申请审批通过',
  2647. status: 'success',
  2648. operator: '系统',
  2649. cost: '1h',
  2650. },
  2651. {
  2652. key: '5',
  2653. time: '2017-10-01 12:00',
  2654. rate: '发起退货申请',
  2655. status: 'success',
  2656. operator: '用户',
  2657. cost: '5mins',
  2658. },
  2659. ];
  2660. const advancedOperation1 = [
  2661. {
  2662. key: 'op1',
  2663. type: '订购关系生效',
  2664. name: '曲丽丽',
  2665. status: 'agree',
  2666. updatedAt: '2017-10-03 19:23:12',
  2667. memo: '-',
  2668. },
  2669. {
  2670. key: 'op2',
  2671. type: '财务复审',
  2672. name: '付小小',
  2673. status: 'reject',
  2674. updatedAt: '2017-10-03 19:23:12',
  2675. memo: '不通过原因',
  2676. },
  2677. {
  2678. key: 'op3',
  2679. type: '部门初审',
  2680. name: '周毛毛',
  2681. status: 'agree',
  2682. updatedAt: '2017-10-03 19:23:12',
  2683. memo: '-',
  2684. },
  2685. {
  2686. key: 'op4',
  2687. type: '提交订单',
  2688. name: '林东东',
  2689. status: 'agree',
  2690. updatedAt: '2017-10-03 19:23:12',
  2691. memo: '很棒',
  2692. },
  2693. {
  2694. key: 'op5',
  2695. type: '创建订单',
  2696. name: '汗牙牙',
  2697. status: 'agree',
  2698. updatedAt: '2017-10-03 19:23:12',
  2699. memo: '-',
  2700. },
  2701. ];
  2702. const advancedOperation2 = [
  2703. {
  2704. key: 'op1',
  2705. type: '订购关系生效',
  2706. name: '曲丽丽',
  2707. status: 'agree',
  2708. updatedAt: '2017-10-03 19:23:12',
  2709. memo: '-',
  2710. },
  2711. ];
  2712. const advancedOperation3 = [
  2713. {
  2714. key: 'op1',
  2715. type: '创建订单',
  2716. name: '汗牙牙',
  2717. status: 'agree',
  2718. updatedAt: '2017-10-03 19:23:12',
  2719. memo: '-',
  2720. },
  2721. ];
  2722. const getProfileAdvancedData = {
  2723. advancedOperation1,
  2724. advancedOperation2,
  2725. advancedOperation3,
  2726. };
  2727. const { Random } = mockjs;
  2728. var profile = {
  2729. 'GET /api/profile/advanced': getProfileAdvancedData,
  2730. 'GET /api/profile/basic': (req, res) => {
  2731. const { id } = req.query;
  2732. const application = {
  2733. id,
  2734. status: '已取货',
  2735. orderNo: Random.id(),
  2736. childOrderNo: Random.id(),
  2737. };
  2738. const userInfo = {
  2739. name: Random.cname(),
  2740. tel: '18100000000',
  2741. delivery: '菜鸟物流',
  2742. addr: '浙江省杭州市西湖区万塘路18号',
  2743. remark: '备注',
  2744. };
  2745. res.json({
  2746. userInfo,
  2747. application,
  2748. basicGoods,
  2749. basicProgress,
  2750. });
  2751. },
  2752. };
  2753. /*! https://mths.be/punycode v1.4.1 by @mathias */
  2754. /** Highest positive signed 32-bit float value */
  2755. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  2756. /** Bootstring parameters */
  2757. var base = 36;
  2758. var tMin = 1;
  2759. var tMax = 26;
  2760. var skew = 38;
  2761. var damp = 700;
  2762. var initialBias = 72;
  2763. var initialN = 128; // 0x80
  2764. var delimiter = '-'; // '\x2D'
  2765. var regexNonASCII = /[^\x20-\x7E]/; // unprintable ASCII chars + non-ASCII chars
  2766. var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  2767. /** Error messages */
  2768. var errors = {
  2769. overflow: 'Overflow: input needs wider integers to process',
  2770. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  2771. 'invalid-input': 'Invalid input',
  2772. };
  2773. /** Convenience shortcuts */
  2774. var baseMinusTMin = base - tMin;
  2775. var floor = Math.floor;
  2776. var stringFromCharCode = String.fromCharCode;
  2777. /*--------------------------------------------------------------------------*/
  2778. /**
  2779. * A generic error utility function.
  2780. * @private
  2781. * @param {String} type The error type.
  2782. * @returns {Error} Throws a `RangeError` with the applicable error message.
  2783. */
  2784. function error(type) {
  2785. throw new RangeError(errors[type]);
  2786. }
  2787. /**
  2788. * A generic `Array#map` utility function.
  2789. * @private
  2790. * @param {Array} array The array to iterate over.
  2791. * @param {Function} callback The function that gets called for every array
  2792. * item.
  2793. * @returns {Array} A new array of values returned by the callback function.
  2794. */
  2795. function map(array, fn) {
  2796. var length = array.length;
  2797. var result = [];
  2798. while (length--) {
  2799. result[length] = fn(array[length]);
  2800. }
  2801. return result;
  2802. }
  2803. /**
  2804. * A simple `Array#map`-like wrapper to work with domain name strings or email
  2805. * addresses.
  2806. * @private
  2807. * @param {String} domain The domain name or email address.
  2808. * @param {Function} callback The function that gets called for every
  2809. * character.
  2810. * @returns {Array} A new string of characters returned by the callback
  2811. * function.
  2812. */
  2813. function mapDomain(string, fn) {
  2814. var parts = string.split('@');
  2815. var result = '';
  2816. if (parts.length > 1) {
  2817. // In email addresses, only the domain name should be punycoded. Leave
  2818. // the local part (i.e. everything up to `@`) intact.
  2819. result = parts[0] + '@';
  2820. string = parts[1];
  2821. } // Avoid `split(regex)` for IE8 compatibility. See #17.
  2822. string = string.replace(regexSeparators, '\x2E');
  2823. var labels = string.split('.');
  2824. var encoded = map(labels, fn).join('.');
  2825. return result + encoded;
  2826. }
  2827. /**
  2828. * Creates an array containing the numeric code points of each Unicode
  2829. * character in the string. While JavaScript uses UCS-2 internally,
  2830. * this function will convert a pair of surrogate halves (each of which
  2831. * UCS-2 exposes as separate characters) into a single code point,
  2832. * matching UTF-16.
  2833. * @see `punycode.ucs2.encode`
  2834. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  2835. * @memberOf punycode.ucs2
  2836. * @name decode
  2837. * @param {String} string The Unicode input string (UCS-2).
  2838. * @returns {Array} The new array of code points.
  2839. */
  2840. function ucs2decode(string) {
  2841. var output = [],
  2842. counter = 0,
  2843. length = string.length,
  2844. value,
  2845. extra;
  2846. while (counter < length) {
  2847. value = string.charCodeAt(counter++);
  2848. if (value >= 0xd800 && value <= 0xdbff && counter < length) {
  2849. // high surrogate, and there is a next character
  2850. extra = string.charCodeAt(counter++);
  2851. if ((extra & 0xfc00) == 0xdc00) {
  2852. // low surrogate
  2853. output.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);
  2854. } else {
  2855. // unmatched surrogate; only append this code unit, in case the next
  2856. // code unit is the high surrogate of a surrogate pair
  2857. output.push(value);
  2858. counter--;
  2859. }
  2860. } else {
  2861. output.push(value);
  2862. }
  2863. }
  2864. return output;
  2865. }
  2866. /**
  2867. * Converts a digit/integer into a basic code point.
  2868. * @see `basicToDigit()`
  2869. * @private
  2870. * @param {Number} digit The numeric value of a basic code point.
  2871. * @returns {Number} The basic code point whose value (when used for
  2872. * representing integers) is `digit`, which needs to be in the range
  2873. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  2874. * used; else, the lowercase form is used. The behavior is undefined
  2875. * if `flag` is non-zero and `digit` has no uppercase form.
  2876. */
  2877. function digitToBasic(digit, flag) {
  2878. // 0..25 map to ASCII a..z or A..Z
  2879. // 26..35 map to ASCII 0..9
  2880. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  2881. }
  2882. /**
  2883. * Bias adaptation function as per section 3.4 of RFC 3492.
  2884. * https://tools.ietf.org/html/rfc3492#section-3.4
  2885. * @private
  2886. */
  2887. function adapt(delta, numPoints, firstTime) {
  2888. var k = 0;
  2889. delta = firstTime ? floor(delta / damp) : delta >> 1;
  2890. delta += floor(delta / numPoints);
  2891. for (
  2892. ;
  2893. /* no initialization */
  2894. delta > (baseMinusTMin * tMax) >> 1;
  2895. k += base
  2896. ) {
  2897. delta = floor(delta / baseMinusTMin);
  2898. }
  2899. return floor(k + ((baseMinusTMin + 1) * delta) / (delta + skew));
  2900. }
  2901. /**
  2902. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  2903. * Punycode string of ASCII-only symbols.
  2904. * @memberOf punycode
  2905. * @param {String} input The string of Unicode symbols.
  2906. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  2907. */
  2908. function encode(input) {
  2909. var n,
  2910. delta,
  2911. handledCPCount,
  2912. basicLength,
  2913. bias,
  2914. j,
  2915. m,
  2916. q,
  2917. k,
  2918. t,
  2919. currentValue,
  2920. output = [],
  2921. /** `inputLength` will hold the number of code points in `input`. */
  2922. inputLength,
  2923. /** Cached calculation results */
  2924. handledCPCountPlusOne,
  2925. baseMinusT,
  2926. qMinusT; // Convert the input in UCS-2 to Unicode
  2927. input = ucs2decode(input); // Cache the length
  2928. inputLength = input.length; // Initialize the state
  2929. n = initialN;
  2930. delta = 0;
  2931. bias = initialBias; // Handle the basic code points
  2932. for (j = 0; j < inputLength; ++j) {
  2933. currentValue = input[j];
  2934. if (currentValue < 0x80) {
  2935. output.push(stringFromCharCode(currentValue));
  2936. }
  2937. }
  2938. handledCPCount = basicLength = output.length; // `handledCPCount` is the number of code points that have been handled;
  2939. // `basicLength` is the number of basic code points.
  2940. // Finish the basic string - if it is not empty - with a delimiter
  2941. if (basicLength) {
  2942. output.push(delimiter);
  2943. } // Main encoding loop:
  2944. while (handledCPCount < inputLength) {
  2945. // All non-basic code points < n have been handled already. Find the next
  2946. // larger one:
  2947. for (m = maxInt, j = 0; j < inputLength; ++j) {
  2948. currentValue = input[j];
  2949. if (currentValue >= n && currentValue < m) {
  2950. m = currentValue;
  2951. }
  2952. } // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  2953. // but guard against overflow
  2954. handledCPCountPlusOne = handledCPCount + 1;
  2955. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  2956. error('overflow');
  2957. }
  2958. delta += (m - n) * handledCPCountPlusOne;
  2959. n = m;
  2960. for (j = 0; j < inputLength; ++j) {
  2961. currentValue = input[j];
  2962. if (currentValue < n && ++delta > maxInt) {
  2963. error('overflow');
  2964. }
  2965. if (currentValue == n) {
  2966. // Represent delta as a generalized variable-length integer
  2967. for (
  2968. q = delta, k = base;
  2969. ;
  2970. /* no condition */
  2971. k += base
  2972. ) {
  2973. t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  2974. if (q < t) {
  2975. break;
  2976. }
  2977. qMinusT = q - t;
  2978. baseMinusT = base - t;
  2979. output.push(stringFromCharCode(digitToBasic(t + (qMinusT % baseMinusT), 0)));
  2980. q = floor(qMinusT / baseMinusT);
  2981. }
  2982. output.push(stringFromCharCode(digitToBasic(q, 0)));
  2983. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  2984. delta = 0;
  2985. ++handledCPCount;
  2986. }
  2987. }
  2988. ++delta;
  2989. ++n;
  2990. }
  2991. return output.join('');
  2992. }
  2993. /**
  2994. * Converts a Unicode string representing a domain name or an email address to
  2995. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  2996. * i.e. it doesn't matter if you call it with a domain that's already in
  2997. * ASCII.
  2998. * @memberOf punycode
  2999. * @param {String} input The domain name or email address to convert, as a
  3000. * Unicode string.
  3001. * @returns {String} The Punycode representation of the given domain name or
  3002. * email address.
  3003. */
  3004. function toASCII(input) {
  3005. return mapDomain(input, function(string) {
  3006. return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
  3007. });
  3008. }
  3009. // shim for using process in browser
  3010. if (typeof global.setTimeout === 'function');
  3011. if (typeof global.clearTimeout === 'function');
  3012. var performance = global.performance || {};
  3013. var performanceNow =
  3014. performance.now ||
  3015. performance.mozNow ||
  3016. performance.msNow ||
  3017. performance.oNow ||
  3018. performance.webkitNow ||
  3019. function() {
  3020. return new Date().getTime();
  3021. }; // generate timestamp or delta
  3022. // Copyright Joyent, Inc. and other Node contributors.
  3023. function isNull(arg) {
  3024. return arg === null;
  3025. }
  3026. function isNullOrUndefined(arg) {
  3027. return arg == null;
  3028. }
  3029. function isString(arg) {
  3030. return typeof arg === 'string';
  3031. }
  3032. function isObject(arg) {
  3033. return typeof arg === 'object' && arg !== null;
  3034. }
  3035. // Copyright Joyent, Inc. and other Node contributors.
  3036. //
  3037. // Permission is hereby granted, free of charge, to any person obtaining a
  3038. // copy of this software and associated documentation files (the
  3039. // "Software"), to deal in the Software without restriction, including
  3040. // without limitation the rights to use, copy, modify, merge, publish,
  3041. // distribute, sublicense, and/or sell copies of the Software, and to permit
  3042. // persons to whom the Software is furnished to do so, subject to the
  3043. // following conditions:
  3044. //
  3045. // The above copyright notice and this permission notice shall be included
  3046. // in all copies or substantial portions of the Software.
  3047. //
  3048. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  3049. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  3050. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  3051. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  3052. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  3053. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  3054. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  3055. // If obj.hasOwnProperty has been overridden, then calling
  3056. // obj.hasOwnProperty(prop) will break.
  3057. // See: https://github.com/joyent/node/issues/1707
  3058. function hasOwnProperty(obj, prop) {
  3059. return Object.prototype.hasOwnProperty.call(obj, prop);
  3060. }
  3061. var isArray =
  3062. Array.isArray ||
  3063. function(xs) {
  3064. return Object.prototype.toString.call(xs) === '[object Array]';
  3065. };
  3066. function stringifyPrimitive(v) {
  3067. switch (typeof v) {
  3068. case 'string':
  3069. return v;
  3070. case 'boolean':
  3071. return v ? 'true' : 'false';
  3072. case 'number':
  3073. return isFinite(v) ? v : '';
  3074. default:
  3075. return '';
  3076. }
  3077. }
  3078. function stringify(obj, sep, eq, name) {
  3079. sep = sep || '&';
  3080. eq = eq || '=';
  3081. if (obj === null) {
  3082. obj = undefined;
  3083. }
  3084. if (typeof obj === 'object') {
  3085. return map$1(objectKeys(obj), function(k) {
  3086. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  3087. if (isArray(obj[k])) {
  3088. return map$1(obj[k], function(v) {
  3089. return ks + encodeURIComponent(stringifyPrimitive(v));
  3090. }).join(sep);
  3091. } else {
  3092. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  3093. }
  3094. }).join(sep);
  3095. }
  3096. if (!name) return '';
  3097. return (
  3098. encodeURIComponent(stringifyPrimitive(name)) +
  3099. eq +
  3100. encodeURIComponent(stringifyPrimitive(obj))
  3101. );
  3102. }
  3103. function map$1(xs, f) {
  3104. if (xs.map) return xs.map(f);
  3105. var res = [];
  3106. for (var i = 0; i < xs.length; i++) {
  3107. res.push(f(xs[i], i));
  3108. }
  3109. return res;
  3110. }
  3111. var objectKeys =
  3112. Object.keys ||
  3113. function(obj) {
  3114. var res = [];
  3115. for (var key in obj) {
  3116. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  3117. }
  3118. return res;
  3119. };
  3120. function parse(qs, sep, eq, options) {
  3121. sep = sep || '&';
  3122. eq = eq || '=';
  3123. var obj = {};
  3124. if (typeof qs !== 'string' || qs.length === 0) {
  3125. return obj;
  3126. }
  3127. var regexp = /\+/g;
  3128. qs = qs.split(sep);
  3129. var maxKeys = 1000;
  3130. if (options && typeof options.maxKeys === 'number') {
  3131. maxKeys = options.maxKeys;
  3132. }
  3133. var len = qs.length; // maxKeys <= 0 means that we should not limit keys count
  3134. if (maxKeys > 0 && len > maxKeys) {
  3135. len = maxKeys;
  3136. }
  3137. for (var i = 0; i < len; ++i) {
  3138. var x = qs[i].replace(regexp, '%20'),
  3139. idx = x.indexOf(eq),
  3140. kstr,
  3141. vstr,
  3142. k,
  3143. v;
  3144. if (idx >= 0) {
  3145. kstr = x.substr(0, idx);
  3146. vstr = x.substr(idx + 1);
  3147. } else {
  3148. kstr = x;
  3149. vstr = '';
  3150. }
  3151. k = decodeURIComponent(kstr);
  3152. v = decodeURIComponent(vstr);
  3153. if (!hasOwnProperty(obj, k)) {
  3154. obj[k] = v;
  3155. } else if (isArray(obj[k])) {
  3156. obj[k].push(v);
  3157. } else {
  3158. obj[k] = [obj[k], v];
  3159. }
  3160. }
  3161. return obj;
  3162. }
  3163. // Copyright Joyent, Inc. and other Node contributors.
  3164. function Url() {
  3165. this.protocol = null;
  3166. this.slashes = null;
  3167. this.auth = null;
  3168. this.host = null;
  3169. this.port = null;
  3170. this.hostname = null;
  3171. this.hash = null;
  3172. this.search = null;
  3173. this.query = null;
  3174. this.pathname = null;
  3175. this.path = null;
  3176. this.href = null;
  3177. } // Reference: RFC 3986, RFC 1808, RFC 2396
  3178. // define these here so at least they only have to be
  3179. // compiled once on the first module load.
  3180. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  3181. portPattern = /:[0-9]*$/,
  3182. // Special case for a simple path URL
  3183. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  3184. // RFC 2396: characters reserved for delimiting URLs.
  3185. // We actually just auto-escape these.
  3186. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  3187. // RFC 2396: characters not allowed for various reasons.
  3188. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  3189. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  3190. autoEscape = ["'"].concat(unwise),
  3191. // Characters that are never ever allowed in a hostname.
  3192. // Note that any invalid chars are also handled, but these
  3193. // are the ones that are *expected* to be seen, so we fast-path
  3194. // them.
  3195. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  3196. hostEndingChars = ['/', '?', '#'],
  3197. hostnameMaxLen = 255,
  3198. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  3199. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  3200. // protocols that can allow "unsafe" and "unwise" chars.
  3201. unsafeProtocol = {
  3202. javascript: true,
  3203. 'javascript:': true,
  3204. },
  3205. // protocols that never have a hostname.
  3206. hostlessProtocol = {
  3207. javascript: true,
  3208. 'javascript:': true,
  3209. },
  3210. // protocols that always contain a // bit.
  3211. slashedProtocol = {
  3212. http: true,
  3213. https: true,
  3214. ftp: true,
  3215. gopher: true,
  3216. file: true,
  3217. 'http:': true,
  3218. 'https:': true,
  3219. 'ftp:': true,
  3220. 'gopher:': true,
  3221. 'file:': true,
  3222. };
  3223. function urlParse(url, parseQueryString, slashesDenoteHost) {
  3224. if (url && isObject(url) && url instanceof Url) return url;
  3225. var u = new Url();
  3226. u.parse(url, parseQueryString, slashesDenoteHost);
  3227. return u;
  3228. }
  3229. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  3230. return parse$1(this, url, parseQueryString, slashesDenoteHost);
  3231. };
  3232. function parse$1(self, url, parseQueryString, slashesDenoteHost) {
  3233. if (!isString(url)) {
  3234. throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
  3235. } // Copy chrome, IE, opera backslash-handling behavior.
  3236. // Back slashes before the query string get converted to forward slashes
  3237. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  3238. var queryIndex = url.indexOf('?'),
  3239. splitter = queryIndex !== -1 && queryIndex < url.indexOf('#') ? '?' : '#',
  3240. uSplit = url.split(splitter),
  3241. slashRegex = /\\/g;
  3242. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  3243. url = uSplit.join(splitter);
  3244. var rest = url; // trim before proceeding.
  3245. // This is to support parse stuff like " http://foo.com \n"
  3246. rest = rest.trim();
  3247. if (!slashesDenoteHost && url.split('#').length === 1) {
  3248. // Try fast path regexp
  3249. var simplePath = simplePathPattern.exec(rest);
  3250. if (simplePath) {
  3251. self.path = rest;
  3252. self.href = rest;
  3253. self.pathname = simplePath[1];
  3254. if (simplePath[2]) {
  3255. self.search = simplePath[2];
  3256. if (parseQueryString) {
  3257. self.query = parse(self.search.substr(1));
  3258. } else {
  3259. self.query = self.search.substr(1);
  3260. }
  3261. } else if (parseQueryString) {
  3262. self.search = '';
  3263. self.query = {};
  3264. }
  3265. return self;
  3266. }
  3267. }
  3268. var proto = protocolPattern.exec(rest);
  3269. if (proto) {
  3270. proto = proto[0];
  3271. var lowerProto = proto.toLowerCase();
  3272. self.protocol = lowerProto;
  3273. rest = rest.substr(proto.length);
  3274. } // figure out if it's got a host
  3275. // user@server is *always* interpreted as a hostname, and url
  3276. // resolution will treat //foo/bar as host=foo,path=bar because that's
  3277. // how the browser resolves relative URLs.
  3278. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  3279. var slashes = rest.substr(0, 2) === '//';
  3280. if (slashes && !(proto && hostlessProtocol[proto])) {
  3281. rest = rest.substr(2);
  3282. self.slashes = true;
  3283. }
  3284. }
  3285. var i, hec, l, p;
  3286. if (!hostlessProtocol[proto] && (slashes || (proto && !slashedProtocol[proto]))) {
  3287. // there's a hostname.
  3288. // the first instance of /, ?, ;, or # ends the host.
  3289. //
  3290. // If there is an @ in the hostname, then non-host chars *are* allowed
  3291. // to the left of the last @ sign, unless some host-ending character
  3292. // comes *before* the @-sign.
  3293. // URLs are obnoxious.
  3294. //
  3295. // ex:
  3296. // http://a@b@c/ => user:a@b host:c
  3297. // http://a@b?@c => user:a host:c path:/?@c
  3298. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  3299. // Review our test case against browsers more comprehensively.
  3300. // find the first instance of any hostEndingChars
  3301. var hostEnd = -1;
  3302. for (i = 0; i < hostEndingChars.length; i++) {
  3303. hec = rest.indexOf(hostEndingChars[i]);
  3304. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) hostEnd = hec;
  3305. } // at this point, either we have an explicit point where the
  3306. // auth portion cannot go past, or the last @ char is the decider.
  3307. var auth, atSign;
  3308. if (hostEnd === -1) {
  3309. // atSign can be anywhere.
  3310. atSign = rest.lastIndexOf('@');
  3311. } else {
  3312. // atSign must be in auth portion.
  3313. // http://a@b/c@d => host:b auth:a path:/c@d
  3314. atSign = rest.lastIndexOf('@', hostEnd);
  3315. } // Now we have a portion which is definitely the auth.
  3316. // Pull that off.
  3317. if (atSign !== -1) {
  3318. auth = rest.slice(0, atSign);
  3319. rest = rest.slice(atSign + 1);
  3320. self.auth = decodeURIComponent(auth);
  3321. } // the host is the remaining to the left of the first non-host char
  3322. hostEnd = -1;
  3323. for (i = 0; i < nonHostChars.length; i++) {
  3324. hec = rest.indexOf(nonHostChars[i]);
  3325. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) hostEnd = hec;
  3326. } // if we still have not hit it, then the entire thing is a host.
  3327. if (hostEnd === -1) hostEnd = rest.length;
  3328. self.host = rest.slice(0, hostEnd);
  3329. rest = rest.slice(hostEnd); // pull out port.
  3330. parseHost(self); // we've indicated that there is a hostname,
  3331. // so even if it's empty, it has to be present.
  3332. self.hostname = self.hostname || ''; // if hostname begins with [ and ends with ]
  3333. // assume that it's an IPv6 address.
  3334. var ipv6Hostname =
  3335. self.hostname[0] === '[' && self.hostname[self.hostname.length - 1] === ']'; // validate a little.
  3336. if (!ipv6Hostname) {
  3337. var hostparts = self.hostname.split(/\./);
  3338. for (i = 0, l = hostparts.length; i < l; i++) {
  3339. var part = hostparts[i];
  3340. if (!part) continue;
  3341. if (!part.match(hostnamePartPattern)) {
  3342. var newpart = '';
  3343. for (var j = 0, k = part.length; j < k; j++) {
  3344. if (part.charCodeAt(j) > 127) {
  3345. // we replace non-ASCII char with a temporary placeholder
  3346. // we need this to make sure size of hostname is not
  3347. // broken by replacing non-ASCII by nothing
  3348. newpart += 'x';
  3349. } else {
  3350. newpart += part[j];
  3351. }
  3352. } // we test again with ASCII char only
  3353. if (!newpart.match(hostnamePartPattern)) {
  3354. var validParts = hostparts.slice(0, i);
  3355. var notHost = hostparts.slice(i + 1);
  3356. var bit = part.match(hostnamePartStart);
  3357. if (bit) {
  3358. validParts.push(bit[1]);
  3359. notHost.unshift(bit[2]);
  3360. }
  3361. if (notHost.length) {
  3362. rest = '/' + notHost.join('.') + rest;
  3363. }
  3364. self.hostname = validParts.join('.');
  3365. break;
  3366. }
  3367. }
  3368. }
  3369. }
  3370. if (self.hostname.length > hostnameMaxLen) {
  3371. self.hostname = '';
  3372. } else {
  3373. // hostnames are always lower case.
  3374. self.hostname = self.hostname.toLowerCase();
  3375. }
  3376. if (!ipv6Hostname) {
  3377. // IDNA Support: Returns a punycoded representation of "domain".
  3378. // It only converts parts of the domain name that
  3379. // have non-ASCII characters, i.e. it doesn't matter if
  3380. // you call it with a domain that already is ASCII-only.
  3381. self.hostname = toASCII(self.hostname);
  3382. }
  3383. p = self.port ? ':' + self.port : '';
  3384. var h = self.hostname || '';
  3385. self.host = h + p;
  3386. self.href += self.host; // strip [ and ] from the hostname
  3387. // the host field still retains them, though
  3388. if (ipv6Hostname) {
  3389. self.hostname = self.hostname.substr(1, self.hostname.length - 2);
  3390. if (rest[0] !== '/') {
  3391. rest = '/' + rest;
  3392. }
  3393. }
  3394. } // now rest is set to the post-host stuff.
  3395. // chop off any delim chars.
  3396. if (!unsafeProtocol[lowerProto]) {
  3397. // First, make 100% sure that any "autoEscape" chars get
  3398. // escaped, even if encodeURIComponent doesn't think they
  3399. // need to be.
  3400. for (i = 0, l = autoEscape.length; i < l; i++) {
  3401. var ae = autoEscape[i];
  3402. if (rest.indexOf(ae) === -1) continue;
  3403. var esc = encodeURIComponent(ae);
  3404. if (esc === ae) {
  3405. esc = escape(ae);
  3406. }
  3407. rest = rest.split(ae).join(esc);
  3408. }
  3409. } // chop off from the tail first.
  3410. var hash = rest.indexOf('#');
  3411. if (hash !== -1) {
  3412. // got a fragment string.
  3413. self.hash = rest.substr(hash);
  3414. rest = rest.slice(0, hash);
  3415. }
  3416. var qm = rest.indexOf('?');
  3417. if (qm !== -1) {
  3418. self.search = rest.substr(qm);
  3419. self.query = rest.substr(qm + 1);
  3420. if (parseQueryString) {
  3421. self.query = parse(self.query);
  3422. }
  3423. rest = rest.slice(0, qm);
  3424. } else if (parseQueryString) {
  3425. // no query string, but parseQueryString still requested
  3426. self.search = '';
  3427. self.query = {};
  3428. }
  3429. if (rest) self.pathname = rest;
  3430. if (slashedProtocol[lowerProto] && self.hostname && !self.pathname) {
  3431. self.pathname = '/';
  3432. } //to support http.request
  3433. if (self.pathname || self.search) {
  3434. p = self.pathname || '';
  3435. var s = self.search || '';
  3436. self.path = p + s;
  3437. } // finally, reconstruct the href based on what has been validated.
  3438. self.href = format(self);
  3439. return self;
  3440. } // format a parsed object into a url string
  3441. function format(self) {
  3442. var auth = self.auth || '';
  3443. if (auth) {
  3444. auth = encodeURIComponent(auth);
  3445. auth = auth.replace(/%3A/i, ':');
  3446. auth += '@';
  3447. }
  3448. var protocol = self.protocol || '',
  3449. pathname = self.pathname || '',
  3450. hash = self.hash || '',
  3451. host = false,
  3452. query = '';
  3453. if (self.host) {
  3454. host = auth + self.host;
  3455. } else if (self.hostname) {
  3456. host = auth + (self.hostname.indexOf(':') === -1 ? self.hostname : '[' + this.hostname + ']');
  3457. if (self.port) {
  3458. host += ':' + self.port;
  3459. }
  3460. }
  3461. if (self.query && isObject(self.query) && Object.keys(self.query).length) {
  3462. query = stringify(self.query);
  3463. }
  3464. var search = self.search || (query && '?' + query) || '';
  3465. if (protocol && protocol.substr(-1) !== ':') protocol += ':'; // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  3466. // unless they had them to begin with.
  3467. if (self.slashes || ((!protocol || slashedProtocol[protocol]) && host !== false)) {
  3468. host = '//' + (host || '');
  3469. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  3470. } else if (!host) {
  3471. host = '';
  3472. }
  3473. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  3474. if (search && search.charAt(0) !== '?') search = '?' + search;
  3475. pathname = pathname.replace(/[?#]/g, function(match) {
  3476. return encodeURIComponent(match);
  3477. });
  3478. search = search.replace('#', '%23');
  3479. return protocol + host + pathname + search + hash;
  3480. }
  3481. Url.prototype.format = function() {
  3482. return format(this);
  3483. };
  3484. Url.prototype.resolve = function(relative) {
  3485. return this.resolveObject(urlParse(relative, false, true)).format();
  3486. };
  3487. Url.prototype.resolveObject = function(relative) {
  3488. if (isString(relative)) {
  3489. var rel = new Url();
  3490. rel.parse(relative, false, true);
  3491. relative = rel;
  3492. }
  3493. var result = new Url();
  3494. var tkeys = Object.keys(this);
  3495. for (var tk = 0; tk < tkeys.length; tk++) {
  3496. var tkey = tkeys[tk];
  3497. result[tkey] = this[tkey];
  3498. } // hash is always overridden, no matter what.
  3499. // even href="" will remove it.
  3500. result.hash = relative.hash; // if the relative url is empty, then there's nothing left to do here.
  3501. if (relative.href === '') {
  3502. result.href = result.format();
  3503. return result;
  3504. } // hrefs like //foo/bar always cut to the protocol.
  3505. if (relative.slashes && !relative.protocol) {
  3506. // take everything except the protocol from relative
  3507. var rkeys = Object.keys(relative);
  3508. for (var rk = 0; rk < rkeys.length; rk++) {
  3509. var rkey = rkeys[rk];
  3510. if (rkey !== 'protocol') result[rkey] = relative[rkey];
  3511. } //urlParse appends trailing / to urls like http://www.example.com
  3512. if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) {
  3513. result.path = result.pathname = '/';
  3514. }
  3515. result.href = result.format();
  3516. return result;
  3517. }
  3518. var relPath;
  3519. if (relative.protocol && relative.protocol !== result.protocol) {
  3520. // if it's a known url protocol, then changing
  3521. // the protocol does weird things
  3522. // first, if it's not file:, then we MUST have a host,
  3523. // and if there was a path
  3524. // to begin with, then we MUST have a path.
  3525. // if it is file:, then the host is dropped,
  3526. // because that's known to be hostless.
  3527. // anything else is assumed to be absolute.
  3528. if (!slashedProtocol[relative.protocol]) {
  3529. var keys = Object.keys(relative);
  3530. for (var v = 0; v < keys.length; v++) {
  3531. var k = keys[v];
  3532. result[k] = relative[k];
  3533. }
  3534. result.href = result.format();
  3535. return result;
  3536. }
  3537. result.protocol = relative.protocol;
  3538. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  3539. relPath = (relative.pathname || '').split('/');
  3540. while (relPath.length && !(relative.host = relPath.shift()));
  3541. if (!relative.host) relative.host = '';
  3542. if (!relative.hostname) relative.hostname = '';
  3543. if (relPath[0] !== '') relPath.unshift('');
  3544. if (relPath.length < 2) relPath.unshift('');
  3545. result.pathname = relPath.join('/');
  3546. } else {
  3547. result.pathname = relative.pathname;
  3548. }
  3549. result.search = relative.search;
  3550. result.query = relative.query;
  3551. result.host = relative.host || '';
  3552. result.auth = relative.auth;
  3553. result.hostname = relative.hostname || relative.host;
  3554. result.port = relative.port; // to support http.request
  3555. if (result.pathname || result.search) {
  3556. var p = result.pathname || '';
  3557. var s = result.search || '';
  3558. result.path = p + s;
  3559. }
  3560. result.slashes = result.slashes || relative.slashes;
  3561. result.href = result.format();
  3562. return result;
  3563. }
  3564. var isSourceAbs = result.pathname && result.pathname.charAt(0) === '/',
  3565. isRelAbs = relative.host || (relative.pathname && relative.pathname.charAt(0) === '/'),
  3566. mustEndAbs = isRelAbs || isSourceAbs || (result.host && relative.pathname),
  3567. removeAllDots = mustEndAbs,
  3568. srcPath = (result.pathname && result.pathname.split('/')) || [],
  3569. psychotic = result.protocol && !slashedProtocol[result.protocol];
  3570. relPath = (relative.pathname && relative.pathname.split('/')) || []; // if the url is a non-slashed url, then relative
  3571. // links like ../.. should be able
  3572. // to crawl up to the hostname, as well. This is strange.
  3573. // result.protocol has already been set by now.
  3574. // Later on, put the first path part into the host field.
  3575. if (psychotic) {
  3576. result.hostname = '';
  3577. result.port = null;
  3578. if (result.host) {
  3579. if (srcPath[0] === '') srcPath[0] = result.host;
  3580. else srcPath.unshift(result.host);
  3581. }
  3582. result.host = '';
  3583. if (relative.protocol) {
  3584. relative.hostname = null;
  3585. relative.port = null;
  3586. if (relative.host) {
  3587. if (relPath[0] === '') relPath[0] = relative.host;
  3588. else relPath.unshift(relative.host);
  3589. }
  3590. relative.host = null;
  3591. }
  3592. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  3593. }
  3594. var authInHost;
  3595. if (isRelAbs) {
  3596. // it's absolute.
  3597. result.host = relative.host || relative.host === '' ? relative.host : result.host;
  3598. result.hostname =
  3599. relative.hostname || relative.hostname === '' ? relative.hostname : result.hostname;
  3600. result.search = relative.search;
  3601. result.query = relative.query;
  3602. srcPath = relPath; // fall through to the dot-handling below.
  3603. } else if (relPath.length) {
  3604. // it's relative
  3605. // throw away the existing file, and take the new path instead.
  3606. if (!srcPath) srcPath = [];
  3607. srcPath.pop();
  3608. srcPath = srcPath.concat(relPath);
  3609. result.search = relative.search;
  3610. result.query = relative.query;
  3611. } else if (!isNullOrUndefined(relative.search)) {
  3612. // just pull out the search.
  3613. // like href='?foo'.
  3614. // Put this after the other two cases because it simplifies the booleans
  3615. if (psychotic) {
  3616. result.hostname = result.host = srcPath.shift(); //occationaly the auth can get stuck only in host
  3617. //this especially happens in cases like
  3618. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  3619. authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
  3620. if (authInHost) {
  3621. result.auth = authInHost.shift();
  3622. result.host = result.hostname = authInHost.shift();
  3623. }
  3624. }
  3625. result.search = relative.search;
  3626. result.query = relative.query; //to support http.request
  3627. if (!isNull(result.pathname) || !isNull(result.search)) {
  3628. result.path =
  3629. (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
  3630. }
  3631. result.href = result.format();
  3632. return result;
  3633. }
  3634. if (!srcPath.length) {
  3635. // no path at all. easy.
  3636. // we've already handled the other stuff above.
  3637. result.pathname = null; //to support http.request
  3638. if (result.search) {
  3639. result.path = '/' + result.search;
  3640. } else {
  3641. result.path = null;
  3642. }
  3643. result.href = result.format();
  3644. return result;
  3645. } // if a url ENDs in . or .., then it must get a trailing slash.
  3646. // however, if it ends in anything else non-slashy,
  3647. // then it must NOT get a trailing slash.
  3648. var last = srcPath.slice(-1)[0];
  3649. var hasTrailingSlash =
  3650. ((result.host || relative.host || srcPath.length > 1) && (last === '.' || last === '..')) ||
  3651. last === ''; // strip single dots, resolve double dots to parent dir
  3652. // if the path tries to go above the root, `up` ends up > 0
  3653. var up = 0;
  3654. for (var i = srcPath.length; i >= 0; i--) {
  3655. last = srcPath[i];
  3656. if (last === '.') {
  3657. srcPath.splice(i, 1);
  3658. } else if (last === '..') {
  3659. srcPath.splice(i, 1);
  3660. up++;
  3661. } else if (up) {
  3662. srcPath.splice(i, 1);
  3663. up--;
  3664. }
  3665. } // if the path is allowed to go above the root, restore leading ..s
  3666. if (!mustEndAbs && !removeAllDots) {
  3667. for (; up--; up) {
  3668. srcPath.unshift('..');
  3669. }
  3670. }
  3671. if (mustEndAbs && srcPath[0] !== '' && (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  3672. srcPath.unshift('');
  3673. }
  3674. if (hasTrailingSlash && srcPath.join('/').substr(-1) !== '/') {
  3675. srcPath.push('');
  3676. }
  3677. var isAbsolute = srcPath[0] === '' || (srcPath[0] && srcPath[0].charAt(0) === '/'); // put the host back
  3678. if (psychotic) {
  3679. result.hostname = result.host = isAbsolute ? '' : srcPath.length ? srcPath.shift() : ''; //occationaly the auth can get stuck only in host
  3680. //this especially happens in cases like
  3681. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  3682. authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
  3683. if (authInHost) {
  3684. result.auth = authInHost.shift();
  3685. result.host = result.hostname = authInHost.shift();
  3686. }
  3687. }
  3688. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  3689. if (mustEndAbs && !isAbsolute) {
  3690. srcPath.unshift('');
  3691. }
  3692. if (!srcPath.length) {
  3693. result.pathname = null;
  3694. result.path = null;
  3695. } else {
  3696. result.pathname = srcPath.join('/');
  3697. } //to support request.http
  3698. if (!isNull(result.pathname) || !isNull(result.search)) {
  3699. result.path = (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
  3700. }
  3701. result.auth = relative.auth || result.auth;
  3702. result.slashes = result.slashes || relative.slashes;
  3703. result.href = result.format();
  3704. return result;
  3705. };
  3706. Url.prototype.parseHost = function() {
  3707. return parseHost(this);
  3708. };
  3709. function parseHost(self) {
  3710. var host = self.host;
  3711. var port = portPattern.exec(host);
  3712. if (port) {
  3713. port = port[0];
  3714. if (port !== ':') {
  3715. self.port = port.substr(1);
  3716. }
  3717. host = host.substr(0, host.length - port.length);
  3718. }
  3719. if (host) self.hostname = host;
  3720. }
  3721. let tableListDataSource = [];
  3722. for (let i = 0; i < 46; i += 1) {
  3723. tableListDataSource.push({
  3724. key: i,
  3725. disabled: i % 6 === 0,
  3726. href: 'https://ant.design',
  3727. avatar: [
  3728. 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
  3729. 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
  3730. ][i % 2],
  3731. name: `TradeCode ${i}`,
  3732. title: `一个任务名称 ${i}`,
  3733. owner: '曲丽丽',
  3734. desc: '这是一段描述',
  3735. callNo: Math.floor(Math.random() * 1000),
  3736. status: Math.floor(Math.random() * 10) % 4,
  3737. updatedAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`),
  3738. createdAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`),
  3739. progress: Math.ceil(Math.random() * 100),
  3740. });
  3741. }
  3742. function getRule(req, res, u) {
  3743. let url = u;
  3744. if (!url || Object.prototype.toString.call(url) !== '[object String]') {
  3745. url = req.url; // eslint-disable-line
  3746. }
  3747. const params = urlParse(url, true).query;
  3748. let dataSource = tableListDataSource;
  3749. if (params.sorter) {
  3750. const s = params.sorter.split('_');
  3751. dataSource = dataSource.sort((prev, next) => {
  3752. if (s[1] === 'descend') {
  3753. return next[s[0]] - prev[s[0]];
  3754. }
  3755. return prev[s[0]] - next[s[0]];
  3756. });
  3757. }
  3758. if (params.status) {
  3759. const status = params.status.split(',');
  3760. let filterDataSource = [];
  3761. status.forEach(s => {
  3762. filterDataSource = filterDataSource.concat(
  3763. dataSource.filter(data => parseInt(data.status, 10) === parseInt(s[0], 10)),
  3764. );
  3765. });
  3766. dataSource = filterDataSource;
  3767. }
  3768. if (params.name) {
  3769. dataSource = dataSource.filter(data => data.name.indexOf(params.name) > -1);
  3770. }
  3771. let pageSize = 10;
  3772. if (params.pageSize) {
  3773. pageSize = params.pageSize * 1;
  3774. }
  3775. const result = {
  3776. data: dataSource,
  3777. total: dataSource.length,
  3778. pageSize,
  3779. current: parseInt(params.currentPage, 10) || 1,
  3780. };
  3781. return res.json(result);
  3782. }
  3783. function postRule(req, res, u, b) {
  3784. let url = u;
  3785. if (!url || Object.prototype.toString.call(url) !== '[object String]') {
  3786. url = req.url; // eslint-disable-line
  3787. }
  3788. const body = (b && b.body) || req.body;
  3789. const { method, name, desc, key } = body;
  3790. switch (method) {
  3791. /* eslint no-case-declarations:0 */
  3792. case 'delete':
  3793. tableListDataSource = tableListDataSource.filter(item => key.indexOf(item.key) === -1);
  3794. break;
  3795. case 'post':
  3796. const i = Math.ceil(Math.random() * 10000);
  3797. tableListDataSource.unshift({
  3798. key: i,
  3799. href: 'https://ant.design',
  3800. avatar: [
  3801. 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
  3802. 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
  3803. ][i % 2],
  3804. name: `TradeCode ${i}`,
  3805. title: `一个任务名称 ${i}`,
  3806. owner: '曲丽丽',
  3807. desc,
  3808. callNo: Math.floor(Math.random() * 1000),
  3809. status: Math.floor(Math.random() * 10) % 2,
  3810. updatedAt: new Date(),
  3811. createdAt: new Date(),
  3812. progress: Math.ceil(Math.random() * 100),
  3813. });
  3814. break;
  3815. case 'update':
  3816. tableListDataSource = tableListDataSource.map(item => {
  3817. if (item.key === key) {
  3818. Object.assign(item, {
  3819. desc,
  3820. name,
  3821. });
  3822. return item;
  3823. }
  3824. return item;
  3825. });
  3826. break;
  3827. default:
  3828. break;
  3829. }
  3830. return getRule(req, res, u);
  3831. }
  3832. var rule = {
  3833. 'GET /api/rule': getRule,
  3834. 'POST /api/rule': postRule,
  3835. };
  3836. // 代码中会兼容本地 service mock 以及部署站点的静态数据
  3837. var user$1 = {
  3838. // 支持值为 Object 和 Array
  3839. 'GET /api/currentUser': {
  3840. name: 'Serati Ma',
  3841. avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
  3842. userid: '00000001',
  3843. email: 'antdesign@alipay.com',
  3844. signature: '海纳百川,有容乃大',
  3845. title: '交互专家',
  3846. group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
  3847. tags: [
  3848. {
  3849. key: '0',
  3850. label: '很有想法的',
  3851. },
  3852. {
  3853. key: '1',
  3854. label: '专注设计',
  3855. },
  3856. {
  3857. key: '2',
  3858. label: '辣~',
  3859. },
  3860. {
  3861. key: '3',
  3862. label: '大长腿',
  3863. },
  3864. {
  3865. key: '4',
  3866. label: '川妹子',
  3867. },
  3868. {
  3869. key: '5',
  3870. label: '海纳百川',
  3871. },
  3872. ],
  3873. notice: [
  3874. {
  3875. id: 'xxx1',
  3876. title: titles[0],
  3877. logo: avatars[0],
  3878. description: '那是一种内在的东西,他们到达不了,也无法触及的',
  3879. updatedAt: new Date(),
  3880. member: '科学搬砖组',
  3881. href: '',
  3882. memberLink: '',
  3883. },
  3884. {
  3885. id: 'xxx2',
  3886. title: titles[1],
  3887. logo: avatars[1],
  3888. description: '希望是一个好东西,也许是最好的,好东西是不会消亡的',
  3889. updatedAt: new Date('2017-07-24'),
  3890. member: '全组都是吴彦祖',
  3891. href: '',
  3892. memberLink: '',
  3893. },
  3894. {
  3895. id: 'xxx3',
  3896. title: titles[2],
  3897. logo: avatars[2],
  3898. description: '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
  3899. updatedAt: new Date(),
  3900. member: '中二少女团',
  3901. href: '',
  3902. memberLink: '',
  3903. },
  3904. {
  3905. id: 'xxx4',
  3906. title: titles[3],
  3907. logo: avatars[3],
  3908. description: '那时候我只会想自己想要什么,从不想自己拥有什么',
  3909. updatedAt: new Date('2017-07-23'),
  3910. member: '程序员日常',
  3911. href: '',
  3912. memberLink: '',
  3913. },
  3914. {
  3915. id: 'xxx5',
  3916. title: titles[4],
  3917. logo: avatars[4],
  3918. description: '凛冬将至',
  3919. updatedAt: new Date('2017-07-23'),
  3920. member: '高逼格设计天团',
  3921. href: '',
  3922. memberLink: '',
  3923. },
  3924. {
  3925. id: 'xxx6',
  3926. title: titles[5],
  3927. logo: avatars[5],
  3928. description: '生命就像一盒巧克力,结果往往出人意料',
  3929. updatedAt: new Date('2017-07-23'),
  3930. member: '骗你来学计算机',
  3931. href: '',
  3932. memberLink: '',
  3933. },
  3934. ],
  3935. notifyCount: 12,
  3936. unreadCount: 11,
  3937. country: 'China',
  3938. geographic: {
  3939. province: {
  3940. label: '浙江省',
  3941. key: '330000',
  3942. },
  3943. city: {
  3944. label: '杭州市',
  3945. key: '330100',
  3946. },
  3947. },
  3948. address: '西湖区工专路 77 号',
  3949. phone: '0752-268888888',
  3950. },
  3951. // GET POST 可省略
  3952. 'GET /api/users': [
  3953. {
  3954. key: '1',
  3955. name: 'John Brown',
  3956. age: 32,
  3957. address: 'New York No. 1 Lake Park',
  3958. },
  3959. {
  3960. key: '2',
  3961. name: 'Jim Green',
  3962. age: 42,
  3963. address: 'London No. 1 Lake Park',
  3964. },
  3965. {
  3966. key: '3',
  3967. name: 'Joe Black',
  3968. age: 32,
  3969. address: 'Sidney No. 1 Lake Park',
  3970. },
  3971. ],
  3972. 'POST /api/login/account': (req, res) => {
  3973. const { password, userName, type } = req.body;
  3974. if (password === 'ant.design' && userName === 'admin') {
  3975. res.send({
  3976. status: 'ok',
  3977. type,
  3978. currentAuthority: 'admin',
  3979. });
  3980. return;
  3981. }
  3982. if (password === 'ant.design' && userName === 'user') {
  3983. res.send({
  3984. status: 'ok',
  3985. type,
  3986. currentAuthority: 'user',
  3987. });
  3988. return;
  3989. }
  3990. res.send({
  3991. status: 'error',
  3992. type,
  3993. currentAuthority: 'guest',
  3994. });
  3995. },
  3996. 'POST /api/register': (req, res) => {
  3997. res.send({
  3998. status: 'ok',
  3999. currentAuthority: 'user',
  4000. });
  4001. },
  4002. 'GET /api/500': (req, res) => {
  4003. res.status(500).send({
  4004. timestamp: 1513932555104,
  4005. status: 500,
  4006. error: 'error',
  4007. message: 'error',
  4008. path: '/base/category/list',
  4009. });
  4010. },
  4011. 'GET /api/404': (req, res) => {
  4012. res.status(404).send({
  4013. timestamp: 1513932643431,
  4014. status: 404,
  4015. error: 'Not Found',
  4016. message: 'No message available',
  4017. path: '/base/category/list/2121212',
  4018. });
  4019. },
  4020. 'GET /api/403': (req, res) => {
  4021. res.status(403).send({
  4022. timestamp: 1513932555104,
  4023. status: 403,
  4024. error: 'Unauthorized',
  4025. message: 'Unauthorized',
  4026. path: '/base/category/list',
  4027. });
  4028. },
  4029. 'GET /api/401': (req, res) => {
  4030. res.status(401).send({
  4031. timestamp: 1513932555104,
  4032. status: 401,
  4033. error: 'Unauthorized',
  4034. message: 'Unauthorized',
  4035. path: '/base/category/list',
  4036. });
  4037. },
  4038. };
  4039. const data = _objectSpread({}, api, chart, geographic, notices, profile, rule, user$1);
  4040. return data;
  4041. });