index.js 103 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322
  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. list: dataSource,
  3777. pagination: {
  3778. total: dataSource.length,
  3779. pageSize,
  3780. current: parseInt(params.currentPage, 10) || 1,
  3781. },
  3782. };
  3783. return res.json(result);
  3784. }
  3785. function postRule(req, res, u, b) {
  3786. let url = u;
  3787. if (!url || Object.prototype.toString.call(url) !== '[object String]') {
  3788. url = req.url; // eslint-disable-line
  3789. }
  3790. const body = (b && b.body) || req.body;
  3791. const { method, name, desc, key } = body;
  3792. switch (method) {
  3793. /* eslint no-case-declarations:0 */
  3794. case 'delete':
  3795. tableListDataSource = tableListDataSource.filter(item => key.indexOf(item.key) === -1);
  3796. break;
  3797. case 'post':
  3798. const i = Math.ceil(Math.random() * 10000);
  3799. tableListDataSource.unshift({
  3800. key: i,
  3801. href: 'https://ant.design',
  3802. avatar: [
  3803. 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
  3804. 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
  3805. ][i % 2],
  3806. name: `TradeCode ${i}`,
  3807. title: `一个任务名称 ${i}`,
  3808. owner: '曲丽丽',
  3809. desc,
  3810. callNo: Math.floor(Math.random() * 1000),
  3811. status: Math.floor(Math.random() * 10) % 2,
  3812. updatedAt: new Date(),
  3813. createdAt: new Date(),
  3814. progress: Math.ceil(Math.random() * 100),
  3815. });
  3816. break;
  3817. case 'update':
  3818. tableListDataSource = tableListDataSource.map(item => {
  3819. if (item.key === key) {
  3820. Object.assign(item, {
  3821. desc,
  3822. name,
  3823. });
  3824. return item;
  3825. }
  3826. return item;
  3827. });
  3828. break;
  3829. default:
  3830. break;
  3831. }
  3832. return getRule(req, res, u);
  3833. }
  3834. var rule = {
  3835. 'GET /api/rule': getRule,
  3836. 'POST /api/rule': postRule,
  3837. };
  3838. // 代码中会兼容本地 service mock 以及部署站点的静态数据
  3839. var user$1 = {
  3840. // 支持值为 Object 和 Array
  3841. 'GET /api/currentUser': {
  3842. name: 'Serati Ma',
  3843. avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
  3844. userid: '00000001',
  3845. email: 'antdesign@alipay.com',
  3846. signature: '海纳百川,有容乃大',
  3847. title: '交互专家',
  3848. group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
  3849. tags: [
  3850. {
  3851. key: '0',
  3852. label: '很有想法的',
  3853. },
  3854. {
  3855. key: '1',
  3856. label: '专注设计',
  3857. },
  3858. {
  3859. key: '2',
  3860. label: '辣~',
  3861. },
  3862. {
  3863. key: '3',
  3864. label: '大长腿',
  3865. },
  3866. {
  3867. key: '4',
  3868. label: '川妹子',
  3869. },
  3870. {
  3871. key: '5',
  3872. label: '海纳百川',
  3873. },
  3874. ],
  3875. notice: [
  3876. {
  3877. id: 'xxx1',
  3878. title: titles[0],
  3879. logo: avatars[0],
  3880. description: '那是一种内在的东西,他们到达不了,也无法触及的',
  3881. updatedAt: new Date(),
  3882. member: '科学搬砖组',
  3883. href: '',
  3884. memberLink: '',
  3885. },
  3886. {
  3887. id: 'xxx2',
  3888. title: titles[1],
  3889. logo: avatars[1],
  3890. description: '希望是一个好东西,也许是最好的,好东西是不会消亡的',
  3891. updatedAt: new Date('2017-07-24'),
  3892. member: '全组都是吴彦祖',
  3893. href: '',
  3894. memberLink: '',
  3895. },
  3896. {
  3897. id: 'xxx3',
  3898. title: titles[2],
  3899. logo: avatars[2],
  3900. description: '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
  3901. updatedAt: new Date(),
  3902. member: '中二少女团',
  3903. href: '',
  3904. memberLink: '',
  3905. },
  3906. {
  3907. id: 'xxx4',
  3908. title: titles[3],
  3909. logo: avatars[3],
  3910. description: '那时候我只会想自己想要什么,从不想自己拥有什么',
  3911. updatedAt: new Date('2017-07-23'),
  3912. member: '程序员日常',
  3913. href: '',
  3914. memberLink: '',
  3915. },
  3916. {
  3917. id: 'xxx5',
  3918. title: titles[4],
  3919. logo: avatars[4],
  3920. description: '凛冬将至',
  3921. updatedAt: new Date('2017-07-23'),
  3922. member: '高逼格设计天团',
  3923. href: '',
  3924. memberLink: '',
  3925. },
  3926. {
  3927. id: 'xxx6',
  3928. title: titles[5],
  3929. logo: avatars[5],
  3930. description: '生命就像一盒巧克力,结果往往出人意料',
  3931. updatedAt: new Date('2017-07-23'),
  3932. member: '骗你来学计算机',
  3933. href: '',
  3934. memberLink: '',
  3935. },
  3936. ],
  3937. notifyCount: 12,
  3938. unreadCount: 11,
  3939. country: 'China',
  3940. geographic: {
  3941. province: {
  3942. label: '浙江省',
  3943. key: '330000',
  3944. },
  3945. city: {
  3946. label: '杭州市',
  3947. key: '330100',
  3948. },
  3949. },
  3950. address: '西湖区工专路 77 号',
  3951. phone: '0752-268888888',
  3952. },
  3953. // GET POST 可省略
  3954. 'GET /api/users': [
  3955. {
  3956. key: '1',
  3957. name: 'John Brown',
  3958. age: 32,
  3959. address: 'New York No. 1 Lake Park',
  3960. },
  3961. {
  3962. key: '2',
  3963. name: 'Jim Green',
  3964. age: 42,
  3965. address: 'London No. 1 Lake Park',
  3966. },
  3967. {
  3968. key: '3',
  3969. name: 'Joe Black',
  3970. age: 32,
  3971. address: 'Sidney No. 1 Lake Park',
  3972. },
  3973. ],
  3974. 'POST /api/login/account': (req, res) => {
  3975. const { password, userName, type } = req.body;
  3976. if (password === 'ant.design' && userName === 'admin') {
  3977. res.send({
  3978. status: 'ok',
  3979. type,
  3980. currentAuthority: 'admin',
  3981. });
  3982. return;
  3983. }
  3984. if (password === 'ant.design' && userName === 'user') {
  3985. res.send({
  3986. status: 'ok',
  3987. type,
  3988. currentAuthority: 'user',
  3989. });
  3990. return;
  3991. }
  3992. res.send({
  3993. status: 'error',
  3994. type,
  3995. currentAuthority: 'guest',
  3996. });
  3997. },
  3998. 'POST /api/register': (req, res) => {
  3999. res.send({
  4000. status: 'ok',
  4001. currentAuthority: 'user',
  4002. });
  4003. },
  4004. 'GET /api/500': (req, res) => {
  4005. res.status(500).send({
  4006. timestamp: 1513932555104,
  4007. status: 500,
  4008. error: 'error',
  4009. message: 'error',
  4010. path: '/base/category/list',
  4011. });
  4012. },
  4013. 'GET /api/404': (req, res) => {
  4014. res.status(404).send({
  4015. timestamp: 1513932643431,
  4016. status: 404,
  4017. error: 'Not Found',
  4018. message: 'No message available',
  4019. path: '/base/category/list/2121212',
  4020. });
  4021. },
  4022. 'GET /api/403': (req, res) => {
  4023. res.status(403).send({
  4024. timestamp: 1513932555104,
  4025. status: 403,
  4026. error: 'Unauthorized',
  4027. message: 'Unauthorized',
  4028. path: '/base/category/list',
  4029. });
  4030. },
  4031. 'GET /api/401': (req, res) => {
  4032. res.status(401).send({
  4033. timestamp: 1513932555104,
  4034. status: 401,
  4035. error: 'Unauthorized',
  4036. message: 'Unauthorized',
  4037. path: '/base/category/list',
  4038. });
  4039. },
  4040. };
  4041. const data = _objectSpread({}, api, chart, geographic, notices, profile, rule, user$1);
  4042. return data;
  4043. });