123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432 |
- <template>
- <div>
- <el-container style="height: 100vh;">
- <!-- #333744 -->
- <el-aside width="180px" style="user-select: none; border-right: 1px solid #fafafa; background-color: #333744; overflow-x: hidden;">
- <p class="soft-name" style="-webkit-app-region: drag; color: #fff;">
- <img src="../assets/image/icon.png" class="soft-icon" />
- <span style="letter-spacing: 1px;">{{productName}}</span>
- </p>
-
- <el-menu :default-openeds="['a']" :default-active="menuIndex" @select="setMenuIndex" active-text-color="#409EFF" background-color="#333744" text-color="#fff" style="margin-top: 10px;">
- <el-submenu index="a">
- <template slot="title"><img src="../assets/image/m-download.png" class="m-image"/>图片下载</template>
- <el-menu-item index="3">
- <img src="../assets/image/m-tmall.png" class="m-image"/><span slot="title">天猫</span>
- </el-menu-item>
- <el-menu-item index="2">
- <img src="../assets/image/m-jd.png" class="m-image"/><span slot="title">京东</span>
- </el-menu-item>
- <el-menu-item index="4">
- <img src="../assets/image/m-taobao.png" class="m-image"/><span slot="title">淘宝</span>
- </el-menu-item>
- <el-menu-item index="1">
- <img src="../assets/image/m-alibaba.png" class="m-image"/><span slot="title">阿里巴巴</span>
- </el-menu-item>
- <el-menu-item index="6">
- <img src="../assets/image/m-aliguoji.png" class="m-image"/><span slot="title">阿里国际</span>
- </el-menu-item>
- <el-menu-item index="7">
- <img src="../assets/image/m-baidu.png" class="m-image"/><span slot="title">百度爱采购</span>
- </el-menu-item>
- <!-- <el-menu-item index="8">
- <img src="../assets/image/m-amazon.png" class="m-image"/><span slot="title">亚马逊</span>
- </el-menu-item> -->
- <el-menu-item index="5">
- <img src="../assets/image/m-hong.png" class="m-image"/><span slot="title">小红书</span>
- </el-menu-item>
- <el-menu-item index="10">
- <img src="../assets/image/m-chrome.png" class="m-image"/><span slot="title">其他(Beta)</span>
- </el-menu-item>
- </el-submenu>
-
- <el-submenu index="b">
- <template slot="title"><img src="../assets/image/m-edit.png" class="m-image"/>图片处理</template>
- <el-menu-item index="2-1">
- <img src="../assets/image/m-geshi.png" class="m-image"/><span slot="title">格式转换</span>
- </el-menu-item>
- <el-menu-item index="2-2">
- <img src="../assets/image/m-yasuo.png" class="m-image"/><span slot="title">图片压缩</span>
- </el-menu-item>
- <el-menu-item index="2-3">
- <img src="../assets/image/m-chicun.png" class="m-image"/><span slot="title">修改尺寸</span>
- </el-menu-item>
- <el-menu-item index="2-5">
- <img src="../assets/image/m-shuiyin.png" class="m-image"/><span slot="title">添加水印</span>
- </el-menu-item>
- </el-submenu>
- </el-menu>
- </el-aside>
-
- <el-container>
- <el-header height="45px" style="background-color: #fafafa; padding: 0 10px;">
- <soft-header ref="headerRef" @update-soft="updateSoft()" @export-file="exportFile" @login-url="loginUrl" @clear-cache="clearCache"></soft-header>
- </el-header>
-
- <soft-img ref="imgRef" v-show="['2-1', '2-2', '2-3', '2-5'].indexOf(menuIndex) > -1" @open-vip="openVip" @check-authority="checkAuthority"></soft-img>
-
- <el-main v-show="['1', '2', '3', '4', '5', '6', '7', '8', '10'].indexOf(menuIndex) > -1" ref="el-main" style="background-color: #fafafa;">
- <template>
- <div class="content-top">
- <div>
- <el-button-group>
- <el-button type="primary" size="mini" icon="el-icon-circle-plus-outline"
- @click="addVisible = true; add();">添加链接</el-button>
- <el-button type="primary" size="mini" icon="el-icon-upload"
- @click="pickLink()">导入链接</el-button>
- <el-button type="primary" size="mini" icon="el-icon-delete"
- @click="clearList()">清空链接</el-button>
- <el-button type="danger" size="mini" icon="el-icon-video-pause" :disabled="pauseFlag"
- @click="pause()">任务中止</el-button>
- <!-- <el-button type="danger" size="mini" icon="el-icon-video-pause"
- @click="del()">批量删除</el-button> -->
- </el-button-group>
-
- <el-link type="info" style="margin-left: 10px; vertical-align:baseline; font-size: 12px;" @click="downloadExample()">导入模板<i class="el-icon-download"></i></el-link>
- </div>
-
- <el-row type="flex" style="align-items: center;">
- <div class="set-item">
- <span class="set-title">保存目录:</span>
- <el-input :title="downloadDir" ref="upload-input" size="mini" @focus="pickPath" placeholder="请选择输出目录" v-model="downloadDir" readonly style="width:200px;" prefix-icon="el-icon-folder"></el-input>
- <el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="打开保存目录">
- <i class="el-icon-folder-opened" slot="reference" style="padding-left: 5px; cursor: pointer; font-size: 22px; vertical-align: middle;" @click="openFolder()"></i>
- </el-popover>
- </div>
-
- <el-button type="danger" @click="exportFile()" :loading="loading">开始下载</el-button>
- </el-row>
- </div>
-
- <div style="padding: 20px 20px 0 20px; height: calc(100% - 62px);">
- <el-row type="flex" justify="space-between">
- <div>
- <h3 style="display: inline-block;">
- <span v-if="menuIndex == '1'">阿里巴巴 - </span>
- <span v-if="menuIndex == '2'">京东 - </span>
- <span v-if="menuIndex == '3'">天猫 - </span>
- <span v-if="menuIndex == '4'">淘宝 - </span>
- <span v-if="menuIndex == '5'">小红书 - </span>
- <span v-if="menuIndex == '6'">阿里国际 - </span>
- <span v-if="menuIndex == '7'">百度爱采购 - </span>
- <span v-if="menuIndex == '8'">亚马逊 - </span>
- <span v-if="menuIndex == '10'">网页 - </span>
- 图片下载
- </h3>
- <el-link v-if="menuIndex == '5'" :underline="false" type="danger" style="text-align: center; font-size: 12px;">
- 仅支持win10及以上系统,浏览器请选择最新版本
- </el-link>
- <el-link v-if="menuIndex == '10'" :underline="false" type="danger" style="text-align: center; font-size: 12px;">
- 非会员功能,仅提供测试试用
- </el-link>
- </div>
- </el-row>
-
- <div style="padding: 15px 0 20px;">
- <el-row type="flex" justify="space-between">
- <div v-if="menuIndex == '5'" style="padding-top: 10px;">
- <label>下载类型:</label>
- <el-checkbox-group :min="1" v-model="settingArr" style="display: inline-block;" @input="settingGroup">
- <el-checkbox label="mainImg">文章图</el-checkbox>
- <el-checkbox label="video">视频</el-checkbox>
- </el-checkbox-group>
- <!-- <el-checkbox :value="true" style="opacity: 0.6; cursor: not-allowed;">文章图/视频</el-checkbox> -->
- <el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="实况(Live)图下载的格式是mp4视频">
- <i class="el-icon-info" slot="reference" style="margin-left: 10px; color: #F56C6C;"></i>
- </el-popover>
- </div>
-
- <div v-if="menuIndex == '10'" style="padding-top: 10px;">
- <label>下载类型:</label>
- <el-checkbox :value="true" style="opacity: 0.6; cursor: not-allowed;">图片</el-checkbox>
- </div>
-
- <div v-if="['1', '2', '3', '4', '6', '7', '8'].indexOf(menuIndex) > -1" style="padding-top: 10px;">
- <label>下载类型:</label>
- <el-checkbox-group :min="1" v-model="settingArr" style="display: inline-block;" @input="settingGroup">
- <el-checkbox label="mainImg">主图</el-checkbox>
- <el-checkbox label="detailImg">详情图</el-checkbox>
- <el-checkbox label="skuImg" v-if="menuIndex != '7'">SKU图</el-checkbox>
- <el-checkbox label="commentImg" v-if="menuIndex == '3' || menuIndex == '4'">评论图</el-checkbox>
- <el-checkbox label="video">视频</el-checkbox>
- </el-checkbox-group>
- <el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="下载类型至少选一个,评论图默认只下载商品首页展示的评论内容">
- <i class="el-icon-info" slot="reference" style="margin-left: 10px; color: #F56C6C;"></i>
- </el-popover>
- </div>
-
- <!-- 阿里巴巴账号 -->
- <template v-if="menuIndex == '1'">
- <div>
- <el-tag type="info" size="mini" v-if="alibabaStatus == 1">未检测</el-tag>
- <el-tag type="success" size="mini" v-if="alibabaStatus == 2">阿里巴巴账号已登录</el-tag>
- <el-link type="danger" style="text-decoration: underline;" v-if="alibabaStatus == 3" :underline="false" @click="loginUrl('https://www.1688.com')">未登录,点击登录阿里巴巴账号</el-link>
- <el-button size="mini" type="warning" :loading="checkLoading" style="margin-left: 10px;" :disabled='alibabaStatus == 2' @click="checkAlibabaLogin">检测登录状态</el-button>
- </div>
- </template>
-
- <!-- 天猫/淘宝 -->
- <template v-if="menuIndex == '3' || menuIndex == '4'">
- <div>
- <el-tag type="info" size="mini" v-if="tbStatus == 1">未检测</el-tag>
- <el-tag type="success" size="mini" v-if="tbStatus == 2">{{menuIndex == '3' ? '天猫' : '淘宝'}}账号已登录</el-tag>
- <el-link type="danger" style="text-decoration: underline;" v-if="tbStatus == 3" :underline="false" @click="loginUrl('https://login.taobao.com')">未登录,点击登录<span>{{menuIndex == '3' ? '天猫' : '淘宝'}}</span>账号</el-link>
- <el-button size="mini" type="warning" :loading="checkLoading" style="margin-left: 10px;" :disabled='tbStatus == 2' @click="checkLogin">检测登录状态</el-button>
- </div>
- </template>
-
- <!-- 京东账号 -->
- <template v-if="menuIndex == '2'">
- <div>
- <el-tag type="info" size="mini" v-if="jdStatus == 1">未检测</el-tag>
- <el-tag type="success" size="mini" v-if="jdStatus == 2">京东账号已登录</el-tag>
- <el-link type="danger" style="text-decoration: underline;" v-if="jdStatus == 3" :underline="false" @click="loginUrl('https://passport.jd.com/new/login.aspx')">未登录,点击登录京东账号</el-link>
- <el-button size="mini" type="warning" :loading="checkLoading" style="margin-left: 10px;" :disabled='jdStatus == 2' @click="checkJdLogin">检测登录状态</el-button>
- </div>
- </template>
-
- <!-- 小红书 -->
- <template v-if="menuIndex == '5'">
- <div>
- <el-tag type="info" size="mini" v-if="redStatus == 1">未检测</el-tag>
- <el-tag type="success" size="mini" v-if="redStatus == 2">小红书账号已登录</el-tag>
- <el-link type="danger" style="text-decoration: underline;" v-if="redStatus == 3" :underline="false" @click="loginUrl('https://www.xiaohongshu.com')">未登录,点击登录小红书账号</el-link>
- <el-button size="mini" type="warning" :loading="checkLoading" style="margin-left: 10px;" :disabled='redStatus == 2' @click="checkRedLogin">检测登录状态</el-button>
- </div>
- </template>
- </el-row>
- </div>
-
- <div class="table-scroll">
- <!-- 1、 -->
- <vxe-table ref="xTable" show-overflow class="img-table" max-height="100%" empty-text="没有更多数据了!" :loading="tabLoading" :row-config="{isHover: true}"
- :loading-config="{icon: 'vxe-icon-indicator roll', text: '列表加载中...'}" :data="this[listStr+'List']" :scroll-y="{enabled: true}">
- <!-- <vxe-column type="checkbox" width="40"></vxe-column> -->
- <vxe-column type="seq" width="60"></vxe-column>
- <vxe-column field="title" title="目录名称" width="180">
- <template #default="{ row, rowIndex }">
- <span v-if="row.title">{{row.title}}</span>
- <el-tag size="mini" v-else>默认使用网页标题</el-tag>
- </template>
- </vxe-column>
- <vxe-column field="url" title="网页链接"></vxe-column>
- <vxe-column field="status" title="下载状态" width="200">
- <template #default="{ row }">
- <template v-if="row.status == '1'">
- <i class="el-icon-info" style="font-size: 16px; color: #999;"></i>
- <span>待操作</span>
- </template>
- <template v-if="row.status == '2'">
- <i class="el-icon-loading" style="font-size: 16px; color: #999;"></i>
- <span>任务处理中...</span>
- </template>
- <template v-if="row.status == '3'">
- <i class="el-icon-loading" style="font-size: 16px; color: #999;"></i>
- <span>图片下载中..<span v-if="row.num > 0">第{{row.num}}张</span></span>
- </template>
- <template v-if="row.status == '4'">
- <i class="el-icon-success" style="font-size: 16px; color: #19be6b;"></i>
- <span>下载完成</span>
- </template>
- <template v-if="row.status == '5'">
- <i class="el-icon-error" style="font-size: 16px; color: #ed4014;"></i>
- <span>网络异常,请重试!</span>
- </template>
- <template v-if="row.status == '6'">
- <i class="el-icon-error" style="font-size: 16px; color: #ed4014;"></i>
- <span>验证码拦截,请手动验证!</span>
- </template>
- </template>
- </vxe-column>
- <vxe-column title="操作" width="80">
- <template #default="{ row, rowIndex }">
- <i class="el-icon-delete cur-pointer" style="font-size: 20px;" @click="delFile(rowIndex)"></i>
- </template>
- </vxe-column>
- </vxe-table>
- </div>
- </div>
-
- </template>
-
- <el-dialog title="添加链接" :visible.sync="addVisible" width="500px" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false">
- <div>
- <el-form label-position="right" label-width="80px" :rules="rules" :model="formData" ref="formData">
- <el-form-item label="目录名称" prop="title">
- <el-input id="aaa" v-model="formData.title" placeholder="为空则默认使用网页标题前50个字符"></el-input>
- </el-form-item>
- <el-form-item label="网页链接" prop="url">
- <el-input id="bbb" type="textarea" :rows="10" :placeholder="'请输入网址链接(例:' + exampleUrl[menuIndex-1] + ')'" v-model="formData.url"></el-input>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="addVisible = false; $refs['formData'].resetFields();">取 消</el-button>
- <el-button type="primary" @click="onSubmit">确 定</el-button>
- </span>
- </el-dialog>
-
- <el-dialog title="提示" :visible.sync="loginVisible" width="400px" :close-on-click-modal="false" :close-on-press-escape="false">
- <div style="text-align: center; color: #999; font-size: 14px;">
- <template v-if="menuIndex == '1'">
- <p>阿里巴巴渠道建议登录后下载</p>
- <p class="visible-tips-style">目前检测还未登录阿里巴巴账号,未登录可能会导致图片下载不全</p>
- </template>
- <template v-else-if="menuIndex == '2'">
- <p>京东渠道需要登录后才能下载</p>
- <p class="visible-tips-style">目前检测还未登录京东账号,需立即登录</p>
- </template>
- <template v-else-if="menuIndex == '5'">
- <p>小红书渠道需要登录后才能下载</p>
- <p class="visible-tips-style">目前检测还未登录小红书账号,需立即登录</p>
- </template>
- <template v-else>
- <p>天猫/淘宝渠道需要登录后才能下载</p>
- <p class="visible-tips-style">目前检测还未登录天猫/淘宝账号,需立即登录</p>
- </template>
-
- </div>
- <div slot="footer" class="dialog-footer-center">
- <el-button v-if="menuIndex == '2'" @click="loginVisible = false; loginUrl('https://passport.jd.com/new/login.aspx')">点击登录京东账号</el-button>
- <template v-else-if="menuIndex == '1'">
- <el-button @click="loginVisible = false; loginUrl('https://www.1688.com')">点击登录阿里巴巴账号</el-button>
- <el-button type="primary" @click="loginVisible = false; skipLogin = true; exportFile();">继续下载</el-button>
- </template>
- <el-button v-else-if="menuIndex == '5'" @click="loginVisible = false; loginUrl('https://www.xiaohongshu.com')">点击登录小红书账号</el-button>
- <el-button v-else @click="loginVisible = false; loginUrl('https://login.taobao.com')">点击登录天猫/淘宝账号</el-button>
- </div>
- </el-dialog>
-
- <!-- 非会员转换提示框 -->
- <el-dialog title="非会员提示" :visible.sync="tipsModal" width="400px">
- <div class="member-model">
- <div class="tips-flex">
- <i class="el-icon-s-opportunity"></i>
- <p class="m-title">{{tipsDesc}}</p>
- </div>
- <div class="member-btn">
- <el-button size="small" round type="primary" @click="openVip()">开通会员</el-button>
- </div>
- </div>
- </el-dialog>
-
- </el-main>
-
- <el-footer height="48px">
- <!-- 更新 -->
- <soft-update ref="updateRef" :showDowload="dowloadModel" :dowloadFinish="finishModel"></soft-update>
- </el-footer>
- </el-container>
- </el-container>
- </div>
- </template>
- <script>
- import os from 'os'
- import fs from 'fs'
- import request from 'request'
- import path from 'path';
- import xlsx from 'node-xlsx';
- import softUpdate from './update.vue';
- import softHeader from './header.vue';
- import softImg from './img.vue';
- import electronApi from '@/utils/electronApi';
- import pjson from '/package.json'
- // import puppeteer from 'puppeteer'
- import puppeteer from 'puppeteer-extra'
- const StealthPlugin = require('puppeteer-extra-plugin-stealth');
- const listNameArr = ['alibaba','jd','tmall','tb','red','aliguoji','acaigou','amazon', '' ,'common'];
- // const headless = true;
- // const waitUntil = 'networkidle2';
- const { ipcRenderer } = require('electron');
- //const chromePath = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe";
-
- let separator = '';
- if (os.platform == 'linux') {
- separator = '/'
- } else {
- separator = '\\'
- }
-
- // let chromePath = process.cwd() + '\\resources\\app\\node_modules\\puppeteer\\.local-chromium\\win64-1045629\\chrome-win\\chrome.exe';
- // if (process.env.NODE_ENV == 'development') {
- // chromePath = process.cwd() + '\\node_modules\\puppeteer\\.local-chromium\\win64-1045629\\chrome-win\\chrome.exe';
- // }
- export default {
- name: 'landing-page',
- components: {
- softUpdate,
- softHeader,
- softImg
- },
- data() {
- return {
- tipsModal: false,
- tipsDesc: "非VIP用户不能下载视频,如需完整功能请开通VIP会员。",
- settingArr: ['mainImg'],
- loginVisible: false,
- addVisible: false,
- formData: {
- title: '',
- url: ''
- },
- rules:{ //
- title: [
- { min: 0, max: 50, message: '不能超过 50 个字符', trigger: 'blur' },
- { pattern: /^[^\\/:*?"<>|]*$/, message: '标题中不能包含 \\ / : * ? " < > |', trigger: 'blur' }
- ],
- url: [
- { required: true, message: '请输入网页链接', trigger: 'blur' },
- { pattern: /^(http|https):\/\/.+$/, message: '请输入正确的网址链接(http://或https://开头),结尾不能有换行符', trigger: 'blur' }
- ],
- },
- tabLoading: false,
- alibabaList: [],
- aliguojiList: [],
- amazonList: [],
- acaigouList: [],
- jdList: [],
- tbList: [],
- tmallList: [],
- redList: [],
- commonList: [],
- productName: pjson.softInfo.softName,
- imgUrl: this.$api.imgUrl,
- imgSrc: '',
- menuIndex: '3',
- settingData: {
- detailImg: true,
- skuImg: true,
- commentImg: false,
- video: false,
- },
- exampleUrl: ['https://www.1688.com', 'https://www.jd.com', 'https://www.tmall.com', 'https://www.taobao.com', 'https://www.xiaohongshu.com',
- 'https://www.alibaba.com', 'https://b2b.baidu.com', 'https://www.amazon.com/', '', 'https://www.example.com'],
- fileList: [],
-
- downloadDir: os.userInfo().homedir + separator + "Downloads",
- dowloadModel: false,
- finishModel: false,
- loading: false,
- checkLoading: false, //点击检测登录状态
- tbStatus: 1, // 1、未检测 2、已经登录 3、未登录
- jdStatus: 1, // 1、未检测 2、已经登录 3、未登录
- redStatus: 1, //同上
- alibabaStatus: 1, //同上上
- aliguojiStatus: 1, //同上上上
- execLimit: 1,
- execNum: 3, // 限制5张
-
- /** 浏览器名称 **/
- alibabaBrowser: null,
- aliguojiBrowser: null,
- amazonBrowser: null,
- acaigouBrowser: null,
- tbBrowser: null,
- jdBrowser: null,
- commonBrowser: null,
- redBrowser: null,
- loginBrowser: null, // 登录用的浏览器实例
- skipLogin: false,
- pauseFlag: true, //暂停中止标志
-
- rightClick: false, // 右击事件绑定
- };
- },
- computed: {
- listStr: function(){
- let index = Number(this.menuIndex) - 1;
- return listNameArr[index];
- }
- },
- async mounted() {
- this.$refs.updateRef.updateSoft(true);
- let homedir = os.userInfo().homedir;
- if (fs.existsSync(homedir + separator + "Desktop")) {
- this.downloadDir = homedir + separator + "Desktop"
- } else {
- this.downloadDir = homedir + separator + "Downloads"
- }
-
- if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture')) {
- fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture');
- }
-
- if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture-jd')) {
- fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture-jd');
- }
-
- if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture-local')) {
- fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture-local');
- }
-
- let path = os.tmpdir() + separator + 'chrome-data-capture';
- let path2 = os.tmpdir() + separator + 'chrome-data-capture-jd';
- //this.deleteAll(path, false);
- //this.deleteAll(path2, false);
- // 打开浏览器
- const {
- shell
- } = require('electron');
- const links = document.querySelectorAll('a[href]');
- links.forEach(link => {
- link.addEventListener('click', e => {
- const url = link.getAttribute('href');
- e.preventDefault();
- shell.openExternal(url);
- });
- });
-
- // 判断系统版本 低于10使用兼容模式
- if(os.release() && os.release().indexOf('.') > -1){
- let systemVersion = Number(os.release().split('.')[0]);
- if(systemVersion < 10){ // 低于win10,软件打开时候浏览器设置为兼容版
- this.$utils.setStorage('versionType', 1);
- }else{
- this.$utils.setStorage('versionType', 2);
- }
- }
-
- // 初始化开发者设置
- this.$utils.setStorage('headless', 1);
- this.$utils.setStorage('waitUntil', 'networkidle2');
- },
- methods: {
- add(){
- if(!this.rightClick){
- setTimeout(() => {
- document.getElementById('aaa').addEventListener('contextmenu', e => {
- e.preventDefault();
- // 发送事件到主进程,附带元素类型信息
- ipcRenderer.send('show-context-menu', 'input');
- });
-
- document.getElementById('bbb').addEventListener('contextmenu', e => {
- e.preventDefault();
- // 发送事件到主进程,附带元素类型信息
- ipcRenderer.send('show-context-menu', 'input');
- });
- }, 800)
-
- this.rightClick = true;
- }
- },
- // 实时获取浏览器路径
- initPath(){
- let chromeType = this.$utils.getStorage('chromeType');
- let chromePath = puppeteer.executablePath().replace('win32-1', 'win64-1');
- if(chromeType == 1){ // 电脑自带浏览器
- chromePath = this.$utils.getStorage('chromePath');
- }else{
- chromePath = puppeteer.executablePath().replace('win32-1', 'win64-1');
- let versionType = this.$utils.getStorage('versionType');
- if(versionType && versionType == 1){
- chromePath = chromePath.replace('chrome-win', 'chrome7');
- }
- }
- return chromePath;
- },
- // 实时获取浏览器数据缓存
- initDataDir(tag){
- let chromeType = this.$utils.getStorage('chromeType');
- let userDataDir = os.tmpdir() + separator + 'chrome-data-capture';
- if(chromeType == 1){ // 电脑自带浏览器
- userDataDir = os.tmpdir() + separator + 'chrome-data-capture-local';
- }else{
- userDataDir = os.tmpdir() + separator + 'chrome-data-capture';
- if(tag == 'jd'){
- userDataDir = os.tmpdir() + separator + 'chrome-data-capture-jd';
- }
- }
- return userDataDir;
- },
- // 实时获取页面滚动加载时间
- initMs(){
- let pageMs = this.$utils.getStorage('pageMs');
- if(pageMs){
- return Number(pageMs);
- }else{
- return 500;
- }
- },
- // 实时获取淘宝的开发者设置
- initDevelop(){
- let develop = {
- headless: true,
- waitUntil: 'networkidle2'
- };
- let n1 = this.$utils.getStorage('headless');
- let n2 = this.$utils.getStorage('waitUntil');
- if(n1){
- if(n1 == 1){
- develop.headless = true;
- }else if(n1 == 2){
- develop.headless = false;
- }
- }
- if(n2){
- develop.waitUntil = n2;
- }
-
- return develop;
- },
- // 删除文件夹内容
- deleteAll(folderPath, flag) {
- if (fs.existsSync(folderPath)) {
- fs.readdirSync(folderPath).forEach((file, index) => {
- var curPath = path.join(folderPath, file);
- if (fs.lstatSync(curPath).isDirectory()) {
- this.deleteAll(curPath, true);
- } else {
- fs.unlinkSync(curPath);
- }
- });
- if(flag){
- fs.rmdirSync(folderPath);
- }
- }
- },
- checkAuthority(){
- let authority = this.$refs.headerRef.authority;
- this.$refs.imgRef.authority = authority;
- },
- setMenuIndex(index){
- this.menuIndex = index;
- if(index.indexOf('2-') > -1){
- let num = Number(index.split('-')[1]);
- this.$refs.imgRef.setMenuIndex(num);
- }
- },
- // 选择目录
- pickPath() {
- this.$refs['upload-input'].blur();
- electronApi.call('pickDir', []).then((path) => {
- if (path) {
- this.downloadDir = path;
- }
- });
- },
- // 打开自定义下载目录
- openFolder() {
- let path = this.downloadDir;
- if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)) {
- path = this.downloadDir + separator + pjson.softInfo.softName;
- } else {
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName);
- path = this.downloadDir + separator + pjson.softInfo.softName;
- }
- electronApi.call('showItemInfolder', [path + '\\tty.tty'])
- },
- openVip() {
- this.$refs.headerRef.openVip();
- },
- updateSoft() {
- this.$refs.updateRef.updateSoft();
- },
- // 删除文件
- delFile(rowIndex){
- let index = Number(this.menuIndex) - 1;
- let type = listNameArr[index];
-
- this.$confirm('确认删除此行数据吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this[type+'List'].splice(rowIndex, 1);
- if(this[type+'List'].length == 0) {
- this.clearList();
- }
- }).catch(() => {
-
- });
- },
- // 清除列表
- clearList() {
- let index = Number(this.menuIndex) - 1;
- this[listNameArr[index]+'List'] = [];
- },
- // 提交表单
- onSubmit(){
- this.$refs['formData'].validate((valid) => {
- if (valid) {
- let info = {
- url: this.formData.url,
- title: this.formData.title,
- status: '1',
- num: 0,
- newPath: ''
- }
- let index = Number(this.menuIndex) - 1;
- this[listNameArr[index]+'List'].push(info);
- this.$refs['formData'].resetFields();
- this.addVisible = false;
- } else {
- return false;
- }
- });
- },
- async pickLink() { // 导入链接
- const spinLoad = this.$loading();
- await electronApi.call('pickFile', ['xlsx,xls', true]).then(async (path) => {
- spinLoad.close();
- if(path.length > 0){
- this.$notify({
- title: '提示',
- message: '导入成功',
- type: 'success'
- });
- let workSheetsFromBuffer = xlsx.parse(fs.readFileSync(path[0]));
- if(workSheetsFromBuffer && workSheetsFromBuffer.length > 0){
- let errMsg = "";
- workSheetsFromBuffer[0].data.map((item, index) => {
- if(item.length > 0){
- let ititle = '';
- if(item[0]){
- ititle = item[0].toString().trim();
- }
-
- if(item[0] == '目录名称' && item[1] == '网页链接'){
- return false;
- }
- if(this.containsAnyChar(ititle.toString(), ['\\', '/', ':', '*', '?', '"', '<', '>', '|'])){ //判断是否含有特殊字符
- errMsg += "第" + (index+1) + '行-名称不能包以下字符 \\ / : * ? " < > |';
- ititle = ititle.replace(/[\\|/|:|*|?|"|<|>||]/g, "");
- }
- if(item[1] == undefined){
- errMsg += "第" + (index+1) + "行格式有误</br>";
- item[1] = '';
- }else if(!/^(http|https):\/\/.+$/.exec(item[1])){
- errMsg += "第" + (index+1) + "行网址格式有误</br>";
- }else{
- let info = {
- url: item[1],
- title: ititle,
- status: '1',
- num: 0,
- newPath: ''
- }
- let key = Number(this.menuIndex) - 1;
- this[listNameArr[key]+'List'].push(info);
- }
- }
- });
- if(errMsg){
- this.$notify({
- title: '请检查文件以下问题',
- dangerouslyUseHTMLString: true,
- message: errMsg,
- type: 'warning'
- });
- }
- }else{
- this.$notify({
- title: '提示',
- message: '格式有误,请重新导入',
- type: 'warning'
- });
- }
- }
- });
- },
- settingGroup(name){
- let authority = this.$refs.headerRef.authority.isAuthority;
- let index = name.indexOf('video');
- if(index > -1 && !authority){ // 非会员选中下载视频选项-提示
- this.tipsModal = true;
- name.splice(index, 1);
- }
- },
- // 清除缓存的后续操作
- async clearCache(){
- this.jdStatus = 3;
- this.tbStatus = 3;
- this.redStatus = 3;
- this.alibabaStatus = 3;
- this.aliguojiStatus = 3;
-
- if(this.loginBrowser){
- await this.loginBrowser.close();
- this.loginBrowser = null;
- }
-
- for(let i = 0; i < listNameArr.length; i++){
- if(listNameArr[i]){
- if(this[listNameArr[i]+'Browser']){
- await this[listNameArr[i]+'Browser'].close();
- this[listNameArr[i]+'Browser'] = null;
- }
- }
- }
- },
-
- // 去登录
- loginUrl(url){
- (async () => {
- try{
- if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture')) {
- fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture');
- }
- if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture-jd')) {
- fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture-jd');
- }
- if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture-local')) {
- fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture-local');
- }
-
- let userDataDir = this.initDataDir();
- if(url.indexOf('.jd.com/') > -1){
- userDataDir = this.initDataDir('jd');
- }
-
- puppeteer.use(StealthPlugin());
- this.loginBrowser = await puppeteer.launch({
- headless: false,
- executablePath: this.initPath(),
- args: ['--window-size=1280,800'],
- userDataDir: userDataDir,
- });
- const page = await this.loginBrowser.newPage();
- await page.setViewport({ width: 1280, height: 800 });
-
- await page.evaluateOnNewDocument(() => {
- const newProto = navigator.__proto__;
- delete newProto.webdriver;
- navigator.__proto__ = newProto;
-
- window.navigator.chrome = {
- runtime: {}
- };
- });
- await page.goto(url, {waitUntil : 'networkidle2'});
- }catch(e){
- this.showError(e);
- }
- })();
- },
-
- del(){
- let info = this.$refs.xTable.getCheckboxRecords();
- console.log(info);
- },
-
- //任务暂停
- async pause(){
- this.$confirm('是否中止下载任务?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(async() => {
- if(this.loginBrowser){
- await this.loginBrowser.close();
- this.loginBrowser = null;
- }
- this.pauseFlag = true;
- for(let i = 0; i < listNameArr.length; i++){
- if(listNameArr[i]){
- if(this[listNameArr[i]+'Browser']){
- await this[listNameArr[i]+'Browser'].close();
- this[listNameArr[i]+'Browser'] = null;
- }
- }
- }
-
- let index = Number(this.menuIndex) - 1;
- this[listNameArr[index]+'List'].map(item => {
- if(item.status != '4'){
- item.status = '1';
- }
- });
- }).catch(() => {
-
- });
-
- },
-
- // 开始下载
- async exportFile(flag) {
- this.pauseFlag = false;
- if(this.loginBrowser){
- await this.loginBrowser.close();
- this.loginBrowser = null;
- }
- let authority = this.$refs.headerRef.authority.isAuthority;
- if (!fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)) {
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName);
- }
-
- let index = Number(this.menuIndex) - 1;
- let fileList = this[listNameArr[index]+'List'];
-
- if(fileList.length > 0){
- if (!authority && !flag) { // 非会员点击转换弹出提示框
- this.$refs.headerRef.memberModel = true;
- this.$refs.headerRef.isClick = true;
- return false;
- } else {
- this.$refs.headerRef.memberModel = false;
- this.loading = true;
- setTimeout(() => {
- this.loading = false;
- }, 60000);
- }
-
- if(this.menuIndex == '1' && !this.skipLogin){ // 阿里巴巴
- if(this.alibabaStatus == 1 || this.alibabaStatus == 3){ // 未检测登录状态/或提示未登录状态,开始检测
- await this.checkAlibabaLogin().then((data) => {
- if(data != 2){ // 未登录
- this.alibabaStatus = 3;
- this.loginVisible = true;
- }
- }).catch(err => {
- this.alibabaStatus = 3;
- });
- if(this.alibabaStatus == 3){
- this.loading = false;
- return false;
- }
- }
- }
-
- if(this.menuIndex == '2'){ // 京东
- if(this.jdStatus == 1 || this.jdStatus == 3){ // 未检测登录状态/或提示未登录状态,开始检测
- await this.checkJdLogin().then((data) => {
- if(data != 2){ // 未登录
- this.jdStatus = 3;
- this.loginVisible = true;
- }
- }).catch(err => {
- this.jdStatus = 3;
- });
- if(this.jdStatus == 3){
- this.loading = false;
- return false;
- }
- }
- }
-
- if(this.menuIndex == '3' || this.menuIndex == '4'){ // 天猫/淘宝
- if(this.tbStatus == 1 || this.tbStatus == 3){ // 未检测登录状态/或提示未登录状态,开始检测
- await this.checkLogin().then((data) => {
- if(data != 2){ // 未登录
- this.tbStatus = 3;
- this.loginVisible = true;
- }
- }).catch(err => {
- this.tbStatus = 3;
- });
- }
- if(this.tbStatus == 3){
- this.loading = false;
- return false;
- }
- }
-
- if(this.menuIndex == '5'){ // 小红书
- if(this.redStatus == 1 || this.redStatus == 3){ // 未检测登录状态/或提示未登录状态,开始检测
- await this.checkRedLogin().then((data) => {
- if(data != 2){ // 未登录
- this.redStatus = 3;
- this.loginVisible = true;
- }
- }).catch(err => {
- this.redStatus = 3;
- });
- if(this.redStatus == 3){
- this.loading = false;
- return false;
- }
- }
- }
-
- let taskArr = [];
- let task = "";
- let userDataDir = this.initDataDir();
- if(this.menuIndex == '2'){
- userDataDir = this.initDataDir('jd');
- }
- // 运行不同平台的浏览器
- puppeteer.use(StealthPlugin());
- let browserName = listNameArr[index] + 'Browser';
- if(index == '2'){ // 天猫和淘宝共用一个
- browserName = 'tbBrowser';
- }
-
- let headless = true;
- headless = this.initDevelop().headless;
- this[browserName] = await puppeteer.launch({
- headless: headless,
- executablePath: this.initPath(),
- userDataDir: userDataDir,
- args: [
- '--start-maximized',
- '--no-sandbox',
- '--disable-setuid-sandbox',
- '--disable-blink-features=AutomationControlled'
- ]
- });
-
- for(let i = 0; i < fileList.length; i++){
- let item = fileList[i];
-
- switch(this.menuIndex){
- case '1': // 阿里巴巴
- task = this.alibabaDownload(item, this.alibabaBrowser);
- break;
- case '2': // 京东
- task = this.jdScanImg(item, this.jdBrowser);
- break;
- case '3': // 天猫
- case '4': // 淘宝
- task = this.tbScanImg(item, this.tbBrowser);
- break;
- case '5': // 小红书
- task = this.redDownload(item, this.redBrowser);
- break;
- case '6': // 阿里国际
- task = this.alibabaDownload(item, this.aliguojiBrowser);
- break;
- case '7': // 百度爱采购
- task = this.alibabaDownload(item, this.acaigouBrowser);
- break;
- case '8': // 亚马逊
- task = this.alibabaDownload(item, this.amazonBrowser);
- break;
- case '10': // 普通网址
- task = this.normalDownload(item, this.commonBrowser);
- break;
- }
-
- if(this.pauseFlag){ //暂停跳出循环
- break;
- }
-
- if(task){
- taskArr.push(task);
- }
-
- if((i+1) % this.execLimit == 0){
- await Promise.all(taskArr).then(result => {
- taskArr = [];
- }).catch(err => {
- console.log('err'+i, err)
- })
- }
- }
-
- if(taskArr.length > 0){
- await Promise.all(taskArr).then(result => {
- taskArr = [];
- }).catch(err => {
- // 错误文件添加到服务中
- console.log('err',err)
- })
- }
-
- if(this[browserName]){
- this[browserName].close();
- this[browserName] = null;
- }
-
- this.loading = false;
- // 打开文件夹
- if(fileList.length > 0){
- this.$message({message: '恭喜你,任务已完成!', type: 'success'});
- electronApi.call('showItemInfolder',[this.downloadDir + separator + pjson.softInfo.softName +'\\tty.tty'])
- }
- }
- },
-
- // 10-普通网址下载
- async normalDownload(urlInfo, commonBrowser){
- let task = await new Promise((resolve,reject) =>{
- (async () => {
- try{
- let authority = this.$refs.headerRef.authority.isAuthority;
- let number = 0;
- urlInfo.status = '2';
- urlInfo.num = 0;
- const page = await commonBrowser.newPage();
-
- let titleFlag = true;
- page.on('response', async(response) => {
- if(titleFlag){ // 第一次生成页面标题
- if(urlInfo.title){
- if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title)) {
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
- } else {
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title);
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
- }
- }else{
- await this.getTitle(page, urlInfo); // 生成页面标题对应的文件夹
- }
- titleFlag = false;
- }
-
- // 检查响应的 MIME 类型是否以 'image/' 开头
- let flag = false;
- if(response.headers()['content-encoding'] && response.headers()['content-encoding'].indexOf('gzip') > -1){
- flag = true;
- }
- if (response.headers()['content-type'] && response.headers()['content-type'].startsWith('image/') && (flag || response.headers()['content-length'])) {
- let imgArr = ['gif', 'jpeg', 'png', 'webp', 'svg', 'tiff', 'bmp', 'ico', 'avif'];
- let imgType = 'jpg';
- let isBase = false;
- imgArr.map((item, index) => {
- if(response.headers()['content-type'].indexOf(item) > -1){
- imgType = item;
- if(item == 'jpeg'){
- imgType = 'jpg';
- }else if(item == 'avif'){
- imgType = 'png';
- }
- }
- });
-
- let url = response.url();
- let regex = /^data:image\/[\w|+|-]+;base64,/;
- if(regex.exec(url)){
- url = response.url().replace(/^data:image\/[\w|+|-]+;base64,/, '');
- isBase = true;
- }
-
- let imgInfo = {
- url: url,
- contentType: response.headers()['content-type'],
- status: response.status(),
- imgType: imgType,
- isBase: isBase
- }
-
- let outputPath = urlInfo.newPath + '\\' + this.randomString(35) + '.' + imgInfo.imgType;
-
- urlInfo.status = '3';
- number++;
- if(!authority && number <= this.execNum){
- if(imgInfo.isBase){ //base64位图片下载
- this.downloadBaseImage(imgInfo.url, outputPath, urlInfo)
- }else{
- this.downloadImage(imgInfo.url, outputPath, urlInfo);
- }
- }
-
- if(authority){
- if(imgInfo.isBase){ //base64位图片下载
- this.downloadBaseImage(imgInfo.url, outputPath, urlInfo)
- }else{
- this.downloadImage(imgInfo.url, outputPath, urlInfo);
- }
- }
-
- }
- });
- await page.goto(urlInfo.url, {waitUntil : 'networkidle2'});
-
- let pageInfo = await page.evaluate(() => {
- let cHeight = document.documentElement.clientHeight;
- let scrollHeight = document.body.scrollHeight;
- return {'scrollHeight': scrollHeight, 'cHeight': cHeight}
- });
-
- let scrollHeight = pageInfo.scrollHeight;
- let cHeight = pageInfo.cHeight;
-
- let num = Math.ceil(scrollHeight / cHeight);
- let start = -1;
- let scrollTime = this.initMs();
- let scrollInt = setInterval(async() => {
- start ++;
- await page.evaluate((start) => {
- let cHeight = document.documentElement.clientHeight;
- window.scrollTo({
- top: cHeight * start,
- behavior: "smooth"
- });
- }, start);
- if(start > num || start > 200){ // 防止页面过长,滚动200次自动停止
- clearInterval(scrollInt);
- await page.close();
- urlInfo.status = '4';
- resolve(true);
- this.loading = false;
- }
- }, scrollTime);
-
- }catch(e){
- urlInfo.status = '5';
- reject(e);
- this.showError(e);
- }
- })();
- });
-
- },
-
- // 检查阿里巴巴登录状态
- checkAlibabaLogin(){
- this.checkLoading = true;
- this.alibabaStatus = 1;
- return new Promise((resolve, reject) => {
- (async () => {
- try{
- if(this.loginBrowser){
- await this.loginBrowser.close();
- this.loginBrowser = null;
- }
- this.loginBrowser = await puppeteer.launch({
- executablePath: this.initPath(),
- args: ['--window-size=1280,800'],
- userDataDir: this.initDataDir()
- });
- const page = await this.loginBrowser.newPage();
- await page.setViewport({ width: 1280, height: 800 });
- let testUrl = 'https://www.1688.com';
- await page.goto(testUrl, {waitUntil : 'networkidle2'});
- const cookies = await page.cookies();
- let loginDiv = await page.$('div[class^=userNotLogin-]');
- const loginEle = await page.$('div[class^=loginAvatar-]');
- let loginText = '';
- if (loginEle) {
- loginText = await page.evaluate(el => el.innerText, loginEle);
- }
- const loginCookie = cookies.find(cookie =>
- cookie.name === '__cn_logon__'
- );
- let logonValue = '';
- if(loginCookie){
- logonValue = loginCookie.value;
- }
- if(loginDiv || loginText == '登录' || logonValue == 'false' || logonValue == false){
- this.alibabaStatus = 3; //未登录
- }else{
- this.alibabaStatus = 2;
- }
-
- resolve(this.alibabaStatus);
- this.checkLoading = false;
- await this.loginBrowser.close();
- this.loginBrowser = null;
- }catch(e){
- this.checkLoading = false;
- reject(3);
- this.showError(e);
- }
- })();
- });
-
- },
-
- // 1 - 阿里巴巴下载
- async alibabaDownload(urlInfo, browser){
- let task = await new Promise((resolve,reject) =>{
- (async () => {
- try{
- let authority = this.$refs.headerRef.authority.isAuthority;
- urlInfo.status = '2';
- urlInfo.num = 0;
- const page = await browser.newPage();
-
- let waitUntil = 'networkidle2';
- waitUntil = this.initDevelop().waitUntil;
-
- let goUrl = urlInfo.url;
- if(this.menuIndex == '1' && goUrl.indexOf('version=0') == -1){ // 阿里巴巴
- if(goUrl.indexOf('?') > -1){
- goUrl += "&version=0";
- }else{
- goUrl += "?verison=0";
- }
- }
- await page.goto(goUrl, {waitUntil : waitUntil});
-
- if(urlInfo.title){
- if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title)) {
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
- } else {
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title);
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
- }
- }else{
- await this.getTitle(page, urlInfo); // 生成页面标题对应的文件夹
- }
-
- let pageInfo = await page.evaluate(() => {
- let cHeight = document.documentElement.clientHeight;
- let scrollHeight = document.body.scrollHeight;
- return {'scrollHeight': scrollHeight, 'cHeight': cHeight}
- });
-
- let scrollHeight = pageInfo.scrollHeight;
- let cHeight = pageInfo.cHeight;
-
- let num = Math.ceil(scrollHeight / cHeight);
- let start = -1;
- let scrollTime = this.initMs();
- if(scrollTime < 800 && this.menuIndex == '6'){
- scrollTime = 800;
- }
- let scrollInt = setInterval(async() => {
- start ++;
- if(this.settingArr.indexOf('detailImg') > -1){
- let scrollHeight2 = await page.evaluate((start) => {
- let scrollHeight = document.body.scrollHeight;
- let cHeight = document.documentElement.clientHeight;
- // let num = Math.ceil(scrollHeight / cHeight);
- window.scrollTo({
- top: cHeight * start,
- behavior: "smooth"
- });
- return scrollHeight;
- }, start);
- num = Math.ceil(scrollHeight2 / cHeight);
- }
-
- if(start > num || start > 200){ // 防止页面过长,滚动200次自动停止
- urlInfo.status = '3';
- clearInterval(scrollInt);
- if(this.menuIndex == '1'){ // 阿里巴巴
- await this.alibabaScanImg(browser, page, urlInfo, authority);
- }else if(this.menuIndex == '6'){ //阿里国际
- await this.aliguojiScanImg(browser, page, urlInfo, authority);
- }else if(this.menuIndex == '7'){ // 爱采购
- await this.acaigouScanImg(browser, page, urlInfo, authority);
- }else if(this.menuIndex == '8'){ // 亚马逊
- await this.amazonScanImg(browser, page, urlInfo, authority);
- }
- this.loading = false;
- urlInfo.status = '4';
- resolve(true);
- }
- }, scrollTime);
-
- }catch(e){
- urlInfo.status = '5';
- reject(e);
- this.showError(e);
- }
- })();
- });
- },
-
- // 检查京东登录状态
- checkJdLogin(){
- this.checkLoading = true;
- this.jdStatus = 1;
- return new Promise((resolve, reject) => {
- (async () => {
- try{
- if(this.loginBrowser){
- await this.loginBrowser.close();
- this.loginBrowser = null;
- }
- this.loginBrowser = await puppeteer.launch({
- executablePath: this.initPath(),
- args: ['--window-size=1280,800'],
- userDataDir: this.initDataDir('jd'),
- args: [
- '--start-maximized',
- '--no-sandbox',
- '--disable-setuid-sandbox',
- '--disable-blink-features=AutomationControlled'
- ]
- });
- const page = await this.loginBrowser.newPage();
- await page.setViewport({ width: 1280, height: 800 });
- let testUrl = 'https://www.jd.com';
- await page.goto(testUrl, {waitUntil : 'networkidle2'});
-
- let loginInfo = await page.evaluate(() => {
- let navTags = document.querySelector('.link-login');
- let userTags = document.querySelector('.nickname');
- let userTags2 = document.querySelector('.nick'); //企业账号
-
- let userInfo2 = document.querySelector('.login_info'); //页面右侧的登录信息
- let userTags3 = false;
- if(userInfo2 && userInfo2.innerText.indexOf('退出') > -1){
- userTags3 = true;
- }
-
- if(navTags && navTags.innerHTML.indexOf('请登录') > -1 && !userTags3){
- return false;
- }else if(userTags || userTags2 || userTags3){
- return true;
- }else{
- return false;
- }
- });
-
- if(loginInfo){
- this.jdStatus = 2;
- }else{
- this.jdStatus = 3;
- }
-
- resolve(this.jdStatus);
- this.checkLoading = false;
- await this.loginBrowser.close();
- this.loginBrowser = null;
- }catch(e){
- this.checkLoading = false;
- reject(3);
- this.showError(e);
- }
- })();
- });
- },
-
- // 京东下载
- async jdScanImg(urlInfo, jdBrowser){
- let task = await new Promise((resolve,reject) =>{
- (async () => {
- try{
- let authority = this.$refs.headerRef.authority.isAuthority;
- urlInfo.status = '2';
- urlInfo.num = 0;
- const page = await jdBrowser.newPage();
- await page.evaluateOnNewDocument(() => {
- const newProto = navigator.__proto__;
- delete newProto.webdriver;
- navigator.__proto__ = newProto;
-
- window.navigator.chrome = {
- runtime: {}
- };
- });
-
- let jdImgInfo = {
- mainImg: [],
- skuImg: [],
- commentImg: [],
- detailImg: [],
- video: []
- };
-
- let titleFlag = true;
- let skuNum = 0, mainNum = 0, videoNum = 0;
-
- page.on('response', async(response) => {
- if(titleFlag){ // 第一次生成页面标题
- if(urlInfo.title){
- if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title)) {
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
- } else {
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title);
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
- }
- }else{
- await this.getTitle(page, urlInfo); // 生成页面标题对应的文件夹
- }
- titleFlag = false;
- }
-
- // 检查响应的 MIME 类型是否以 'image/' 开头
- if (response.headers()['content-type']) {
-
- let detailUrl = '';
- let videoUrl = '';
- if(response.url().indexOf('/description/') > -1){ // 商品详情接口
- detailUrl = response.url();
- }
-
- if(response.url().indexOf('/tencent/video_v3') > -1){ // 商品视频接口
- videoUrl = response.url();
- }
-
- urlInfo.status = '3';
-
- if(detailUrl && this.settingArr.indexOf('detailImg') > -1){ // jd商品详情
- try {
- let data = await response.text();
- if(data.indexOf('showdesc(') > -1){
- data = data.slice(0, -1).replace('showdesc(', '');
- }
- let detailInfo = JSON.parse(data);
- let regex = /\/\/img[0-9]+.360buyimg.com\S+.(jpg|jpeg|png|gif|avif|tif|tiff)/g;
- let detailImgArr = [];
- if(detailInfo && detailInfo.content){
- detailImgArr = detailInfo.content.match(regex);
- }
-
- jdImgInfo.detailImg = detailImgArr;
-
- for(let i = 0; i < detailImgArr.length; i++){
- let imgUrl = 'https:' + detailImgArr[i];
- imgUrl = imgUrl.replace('.avif', '');
- let fileName = imgUrl.split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(i) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\详情图')) {
- fs.mkdirSync(urlInfo.newPath + '\\详情图');
- }
-
- let outputPath = urlInfo.newPath + '\\详情图\\详情图' + num + suffix;
- if(!authority && i < this.execNum){
- await this.downloadImage(imgUrl, outputPath, urlInfo);
- }
- if(authority){
- await this.downloadImage(imgUrl, outputPath, urlInfo);
- }
- }
- }
-
- } catch (error) {
- console.error('详情图片解析失败:', error);
- }
- }
-
- if(videoUrl && this.settingArr.indexOf('video') > -1){ // jd商品视频
- try {
- let data = await response.text();
- data = data.slice(0, -1).replace(/^jQuery[0-9]+\(/, '');
- let videoInfo = JSON.parse(data);
- let videoUrl = videoInfo.playUrl;
- jdImgInfo.video.push(videoUrl);
-
- let fileName = videoUrl.split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\视频')) {
- fs.mkdirSync(urlInfo.newPath + '\\视频');
- }
-
- let outputPath = urlInfo.newPath + '\\视频\\' + fileName;
- await this.downloadImage(videoUrl, outputPath, urlInfo);
- }
-
- } catch (error) {
- console.error('视频解析失败:', error);
- }
- }
- }
-
- });
- await page.goto(urlInfo.url, {waitUntil : 'networkidle2'});
-
- let pageInfo = await page.evaluate(() => {
- let cHeight = document.documentElement.clientHeight;
- let scrollHeight = document.body.scrollHeight;
- return {'scrollHeight': scrollHeight, 'cHeight': cHeight}
- });
-
- let scrollHeight = pageInfo.scrollHeight;
- let cHeight = pageInfo.cHeight;
- let num = Math.ceil(scrollHeight / cHeight);
- let start = -1;
- let scrollTime = this.initMs();
- let scrollInt = setInterval(async() => {
- start ++;
- if(this.settingArr.indexOf('detailImg') > -1){ // 选择详情图
- let scrollHeight2 = await page.evaluate((start) => {
- let scrollHeight = document.body.scrollHeight;
- let cHeight = document.documentElement.clientHeight;
- let obj = document.querySelector('.detail-content') || document.querySelector('.detail-content-item');
- if(obj && obj.getBoundingClientRect().top < 0){
- return -1;
- }
- window.scrollTo({
- top: cHeight * start,
- behavior: "smooth"
- });
- return scrollHeight;
- }, start);
-
- if(scrollHeight2 > 0){
- num = Math.ceil(scrollHeight2 / cHeight);
- }else{
- num = 0;
- }
- }else{
- num = 0;
- }
- if(start > num || start > 20){ // 防止页面过长,滚动20次自动停止
- clearInterval(scrollInt);
- //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
- const imgInfo = await page.evaluate((authority, execNum) => {
- let outObj = {
- mainImg: [],
- skuImg: [],
- detailImg: []
- };
- //主图
- let arr1 = document.querySelectorAll('#spec-list img');
- for(let i=0; i< arr1.length; i++){
- let mainImgUrl = arr1[i].src;
- let reg = /\/n[0-9]+\/jfs\//;
- let reg2 = /\/n[0-9]+\/s([0-9]+)x([0-9]+)_jfs\//;
- let reg3 = /![a-z]+_[0-9]+x[0-9]+(.avif)?/;
- let replaceStr = '/n5/s800x800_jfs/';
- if(mainImgUrl.match(/\/n[0-9]+\/s50x66_jfs\//)){
- replaceStr = '/n5/s750x1000_jfs/';
- }
- mainImgUrl = mainImgUrl.replace(reg, replaceStr).replace(reg2, replaceStr).replace(reg3, '').replace('.avif', '');
-
- if(!authority && i < execNum){
- outObj.mainImg.push(mainImgUrl);
- }
- if(authority){
- outObj.mainImg.push(mainImgUrl);
- }
- }
- //sku图片
- let arr2 = document.querySelectorAll('#choose-attr-1 img');
- for(let i=0; i< arr2.length; i++){
- let skuImgUrl = arr2[i].src;
- let skuReg = /\/n[0-9]+\/s([0-9]+)x([0-9]+)_jfs\//;
- let replaceStr = '/n5/s800x800_jfs/';
- if(skuImgUrl.match(/\/n[0-9]+\/s60x80_jfs\//)){
- replaceStr = '/n5/s750x1000_jfs/';
- }
- skuImgUrl = skuImgUrl.replace(skuReg, replaceStr).replace('.avif', '');
- if(!authority && i < execNum){
- outObj.skuImg.push(skuImgUrl);
- }
- if(authority){
- outObj.skuImg.push(skuImgUrl);
- }
- }
-
- //详情图 - 图片类目需要网页直接抓取
- let arr3 = document.querySelectorAll('.book-detail-content img');
- for(let i=0; i< arr3.length; i++){
- let detailImgUrl = arr3[i].src;
- detailImgUrl = detailImgUrl.replace('.avif', '');
- if(!authority && i < execNum){
- outObj.detailImg.push(detailImgUrl);
- }
- if(authority){
- outObj.detailImg.push(detailImgUrl);
- }
- }
-
- return outObj;
- }, authority, this.execNum);
-
- if(this.settingArr.indexOf('mainImg') > -1){
- // 主图下载
- for(let j = 0; j < imgInfo.mainImg.length; j++){
- let fileName = imgInfo.mainImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\主图')) {
- fs.mkdirSync(urlInfo.newPath + '\\主图');
- }
-
- let outputPath = urlInfo.newPath + '\\主图\\主图' + num + suffix;
- await this.downloadImage(imgInfo.mainImg[j], outputPath, urlInfo);
- }
- }
- }
-
- // sku图片下载
- if(this.settingArr.indexOf('skuImg') > -1){
- for(let j = 0; j < imgInfo.skuImg.length; j++){
- let fileName = imgInfo.skuImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\sku图')) {
- fs.mkdirSync(urlInfo.newPath + '\\sku图');
- }
-
- let outputPath = urlInfo.newPath + '\\sku图\\sku图' + num + suffix;
- await this.downloadImage(imgInfo.skuImg[j], outputPath, urlInfo);
- }
- }
- }
-
- // 详情图下载 --图书类目
- if(this.settingArr.indexOf('detailImg') > -1 && jdImgInfo.detailImg.length == 0){
- for(let j = 0; j < imgInfo.detailImg.length; j++){
- let fileName = imgInfo.detailImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\详情图')) {
- fs.mkdirSync(urlInfo.newPath + '\\详情图');
- }
-
- let outputPath = urlInfo.newPath + '\\详情图\\详情图' + num + suffix;
- await this.downloadImage(imgInfo.detailImg[j], outputPath, urlInfo);
- }
- }
- }
-
- /**end**/
- await page.close();
- urlInfo.status = '4';
- resolve(true);
- this.loading = false;
- }
- }, scrollTime);
- }catch(e){
- reject(e);
- this.showError(e);
- }
- })();
- });
- },
-
- // 检查天猫淘宝登录状态
- checkLogin(){
- this.checkLoading = true;
- this.tbStatus = 1;
- return new Promise((resolve, reject) => {
- (async () => {
- try{
- if(this.loginBrowser){
- await this.loginBrowser.close();
- this.loginBrowser = null;
- }
- this.loginBrowser = await puppeteer.launch({
- executablePath: this.initPath(),
- args: ['--window-size=1280,800'],
- userDataDir: this.initDataDir()
- });
- const page = await this.loginBrowser.newPage();
- await page.setViewport({ width: 1280, height: 800 });
- let testUrl = 'https://www.taobao.com';
- await page.goto(testUrl, {waitUntil : 'networkidle2'});
-
- let loginInfo = await page.evaluate(() => {
- let navTags = document.querySelector('.site-nav-sign a');
- let userTags = document.querySelector('.site-nav-user a');
-
- if(navTags && navTags.innerHTML.indexOf('登录') > -1){
- return false;
- }else if(userTags){
- return true;
- }else{
- return false;
- }
- });
-
- if(loginInfo){
- this.tbStatus = 2;
- }else{
- this.tbStatus = 3;
- }
-
- resolve(this.tbStatus);
- this.checkLoading = false;
- await this.loginBrowser.close();
- this.loginBrowser = null;
- }catch(e){
- this.checkLoading = false;
- reject(3);
- this.showError(e);
- }
- })();
- });
-
- },
-
- // 淘宝天猫扫描下载图片
- async tbScanImg(urlInfo, tbBrowser){
- let task = await new Promise((resolve,reject) =>{
- (async () => {
- try{
- let authority = this.$refs.headerRef.authority.isAuthority;
- urlInfo.status = '2';
- urlInfo.num = 0;
- let page = await tbBrowser.newPage();
-
- let responseVideo = [];
- page.on('response', async(response) => {
- // 检查响应的 MIME 类型是否以 'video/' 开头
- if (response.headers()['content-type'] && response.headers()['content-type'].startsWith('video/')) {
- if(responseVideo.indexOf(response.url()) < 0 && !response.url().startsWith('blob:https://')){
- responseVideo.push(response.url());
- }
- }
- });
- let waitUntil = 'networkidle2';
- waitUntil = this.initDevelop().waitUntil;
- await page.goto(urlInfo.url, {waitUntil : waitUntil});
-
- if(this.settingArr.indexOf('video') > -1){ // 用户选择下载视频的时候才会触发
- //鼠标放在主图第一张,生成视频
- const elementHandle = await page.$('li[class*=thumbnail--]');
- if(elementHandle){
- const classListProperty = await elementHandle.getProperty('classList');
- const classList = await classListProperty.jsonValue();
- const classesArray = Object.values(classList);
- const allClasses = classesArray.join('.');
- if(allClasses && allClasses.indexOf('active-') < 0){
- await page.hover('li.'+allClasses);
- }
- }
- }
-
- let iframeElementHandle = await page.$('iframe');
- if(iframeElementHandle){
- let m1 = await page.$('img[class^=PicGallery--thumbnailPic--]');
- let m2 = await page.$('img[class*=thumbnailPic--]');
- if(!m1 && !m2){ // 出现弹窗而且没有主图,判断为拦截模式
- await page.close();
- urlInfo.status = '6';
- resolve(true);
- this.loading = false;
- return false;
- }
- }
-
- let pageInfo = await page.evaluate(() => {
- let cHeight = document.documentElement.clientHeight;
- let scrollHeight = document.body.scrollHeight;
- return {'scrollHeight': scrollHeight, 'cHeight': cHeight}
- });
-
- let scrollHeight = pageInfo.scrollHeight;
- let cHeight = pageInfo.cHeight;
- let num = Math.ceil(scrollHeight / cHeight);
- let start = -1;
- let scrollTime = this.initMs();
- let scrollInt = setInterval(async() => {
- start ++;
- if(this.settingArr.indexOf('commentImg') > -1 && this.settingArr.indexOf('detailImg') < 0){ // 选择了评论图没选择详情图
- let scrollHeight2 = await page.evaluate((start) => {
- let scrollHeight = document.body.scrollHeight;
- let cHeight = document.documentElement.clientHeight;
- let obj = document.getElementById('container') || document.getElementById('content');
- if(obj && obj.getBoundingClientRect().top < -500){
- return -1;
- }
- window.scrollTo({
- top: cHeight * start,
- behavior: "smooth"
- });
- return scrollHeight;
- }, start);
-
- if(scrollHeight2 > 0){
- num = Math.ceil(scrollHeight2 / cHeight);
- }else{
- num = 0;
- }
- }
- if(this.settingArr.indexOf('detailImg') > -1){ // 选择详情图
- let scrollHeight2 = await page.evaluate((start) => {
- let scrollHeight = document.body.scrollHeight;
- let cHeight = document.documentElement.clientHeight;
- let obj = document.getElementById('container') || document.getElementById('content');
- if(obj && obj.getBoundingClientRect().bottom < 100){
- return -1;
- }
- window.scrollTo({
- top: cHeight * start,
- behavior: "smooth"
- });
- return scrollHeight;
- }, start);
-
- if(scrollHeight2 > 0){
- num = Math.ceil(scrollHeight2 / cHeight);
- }else{
- num = 0;
- }
- }
- if(this.settingArr.indexOf('skuImg') > -1 && this.settingArr.indexOf('commentImg') < 0 && this.settingArr.indexOf('detailImg') < 0){ // 选择了sku图片没选择评论和详情
- let scrollHeight2 = await page.evaluate((start) => {
- let scrollHeight = document.body.scrollHeight;
- let cHeight = document.documentElement.clientHeight;
- let obj = document.querySelector('div[class^=SkuContent--]');
- if(obj && obj.getBoundingClientRect().bottom < 500){
- return -1;
- }
- window.scrollTo({
- top: cHeight * start,
- behavior: "smooth"
- });
- return scrollHeight;
- }, start);
-
- if(scrollHeight2 > 0){
- num = Math.ceil(scrollHeight2 / cHeight);
- }else{
- num = 0;
- }
- }
- if(this.settingArr.indexOf('skuImg') < 0 && this.settingArr.indexOf('detailImg') < 0 && this.settingArr.indexOf('commentImg') < 0){ // 没有选择评论图和详情图
- num = 0;
- }
- if(start > num || start > 200){ // 防止页面过长,滚动200次自动停止
- urlInfo.status = '3';
- clearInterval(scrollInt);
-
- if(urlInfo.title){
- if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title)) {
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
- } else {
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title);
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
- }
- }else{
- await this.getTitle(page, urlInfo); // 生成页面标题对应的文件夹
- }
-
- //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
- const imgInfo = await page.evaluate((authority, execNum) => {
- let outObj = {
- mainImg: [],
- detailImg: [],
- skuImg: [],
- commentImg: [],
- video: []
- };
-
- // 正则表达式匹配字符 重写图片路径
- let regex = /\.(.{3,4})_[0-9a-zA-z]+\.(.{3,4})_\.(.{3,4})/;
-
- //主图
- let arr1 = document.querySelectorAll('img[class^=PicGallery--thumbnailPic--]');
- if(arr1.length === 0){
- arr1 = document.querySelectorAll('img[class*=thumbnailPic--]');
- }
- for(let i=0; i< arr1.length; i++){
- let mainImgUrl = arr1[i].src;
- let result = regex.exec(mainImgUrl);
- if(result){
- mainImgUrl = mainImgUrl.replace(result[0], '.'+result[1]);
- }
- if(!authority && i < execNum){
- outObj.mainImg.push(mainImgUrl);
- }
- if(authority){
- outObj.mainImg.push(mainImgUrl);
- }
- }
- //sku图片
- let arr2 = document.querySelectorAll('img[class^=SkuContent--valueItemImg--]');
- if(arr2.length === 0){
- arr2 = document.querySelectorAll('img[class*=valueItemImg--]');
- }
- for(let i=0; i< arr2.length; i++){
- let skuImgUrl = arr2[i].src;
- let result = regex.exec(skuImgUrl);
- if(result){
- skuImgUrl = skuImgUrl.replace(result[0], '.'+result[1]);
- }
- if(!authority && i < execNum){
- outObj.skuImg.push(skuImgUrl);
- }
- if(authority){
- outObj.skuImg.push(skuImgUrl);
- }
- }
- //详情图片
- let arr3 = document.querySelectorAll('#content img');
- for(let i=0; i< arr3.length; i++){
- let detailImgUrl = arr3[i].src;
- let lazyUrl = arr3[i].getAttribute('data-src');
- if(arr3[i].src.indexOf('/s.gif') > -1 && lazyUrl){
- detailImgUrl = lazyUrl;
- if(!/^http/.exec(lazyUrl)){
- detailImgUrl = 'https:' + lazyUrl;
- }
- }
- let result = regex.exec(detailImgUrl);
- if(result){
- detailImgUrl = detailImgUrl.replace(result[0], '.'+result[1]);
- }
- if(!authority && i < execNum){
- outObj.detailImg.push(detailImgUrl);
- }
- if(authority){
- outObj.detailImg.push(detailImgUrl);
- }
- }
- //评论图片
- let arr4 = document.querySelectorAll('div[class*=Comments--] img');
- if(arr4.length === 0){
- arr4 = document.querySelectorAll('div[class*=comments--] img');
- }
- for(let i=0; i< arr4.length; i++){
- if(arr4[i].src.indexOf('/avatar/sns/user/flag/sns_logo') == -1 && arr4[i].className.indexOf('creditImg') == -1){ //过滤淘宝用户头像
- if(!authority && i < execNum){
- outObj.commentImg.push(arr4[i].src);
- }
- if(authority){
- outObj.commentImg.push(arr4[i].src);
- }
- }
- }
- // 视频
- let arr5 = document.querySelectorAll('video');
- for(let i=0; i< arr5.length; i++){
- if(outObj.video.indexOf(arr5[i].src) == -1){
- if(!authority && i < execNum){
- outObj.video.push(arr5[i].src);
- }
- if(authority){
- outObj.video.push(arr5[i].src);
- }
- }
- }
- return outObj;
- }, authority, this.execNum);
-
- if(responseVideo.length > 0){
- for(let l=0; l<responseVideo.length; l++){
- if(imgInfo.video.indexOf(responseVideo[l]) == -1){
- imgInfo.video.push(responseVideo[l]);
- }
- }
- }
-
- if(this.settingArr.indexOf('mainImg') > -1){
- // 主图下载
- for(let j = 0; j < imgInfo.mainImg.length; j++){
- let fileName = imgInfo.mainImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\主图')) {
- fs.mkdirSync(urlInfo.newPath + '\\主图');
- }
-
- let outputPath = urlInfo.newPath + '\\主图\\主图' + num + suffix;
- await this.downloadImage(imgInfo.mainImg[j], outputPath, urlInfo);
- }
- }
- }
-
- // sku图片下载
- if(this.settingArr.indexOf('skuImg') > -1){
- for(let j = 0; j < imgInfo.skuImg.length; j++){
- let fileName = imgInfo.skuImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\sku图')) {
- fs.mkdirSync(urlInfo.newPath + '\\sku图');
- }
-
- let outputPath = urlInfo.newPath + '\\sku图\\sku图' + num + suffix;
- await this.downloadImage(imgInfo.skuImg[j], outputPath, urlInfo);
- }
- }
- }
-
- //详情图下载
- if(this.settingArr.indexOf('detailImg') > -1){
- for(let j = 0; j < imgInfo.detailImg.length; j++){
- let fileName = imgInfo.detailImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\详情图')) {
- fs.mkdirSync(urlInfo.newPath + '\\详情图');
- }
-
- let outputPath = urlInfo.newPath + '\\详情图\\详情图' + num + suffix;
- await this.downloadImage(imgInfo.detailImg[j], outputPath, urlInfo);
- }
- }
- }
-
- //评论图下载
- if(this.settingArr.indexOf('commentImg') > -1){
- for(let j = 0; j < imgInfo.commentImg.length; j++){
- let fileName = imgInfo.commentImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\评论图')) {
- fs.mkdirSync(urlInfo.newPath + '\\评论图');
- }
-
- let outputPath = urlInfo.newPath + '\\评论图\\评论图' + num + suffix;
- await this.downloadImage(imgInfo.commentImg[j], outputPath, urlInfo);
- }
- }
- }
-
- //视频下载
- if(this.settingArr.indexOf('video') > -1){
- for(let j = 0; j < imgInfo.video.length; j++){
- let fileName = imgInfo.video[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\视频')) {
- fs.mkdirSync(urlInfo.newPath + '\\视频');
- }
-
- let outputPath = urlInfo.newPath + '\\视频\\' + fileName;
- await this.downloadImage(imgInfo.video[j], outputPath, urlInfo);
- }
- }
- }
-
- await page.close();
- urlInfo.status = '4';
- resolve(true);
- this.loading = false;
- }
- }, scrollTime);
- }catch(e){
- reject(e);
- this.showError(e);
- }
- })();
- });
- },
-
- // 阿里巴巴 - 扫描并下载图片
- async alibabaScanImg(browser, page, urlInfo, authority){
- //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
- const imgInfo = await page.evaluate((authority, execNum) => {
- let outObj = {
- mainImg: [],
- detailImg: [],
- skuImg: [],
- commentImg: [],
- video: []
- };
-
- //主图
- let arr1 = document.querySelectorAll('img[class*="-gallery-img"]');
- for(let i=0; i< arr1.length; i++){
- let srcUrl = arr1[i].src;
- if(srcUrl.endsWith('_b.jpg')){
- srcUrl = srcUrl.replace(/_b\.jpg$/, '');
- }
- if(!authority && i < execNum){
- outObj.mainImg.push(srcUrl);
- }
- if(authority){
- outObj.mainImg.push(srcUrl);
- }
- }
- //sku图片
- let type = 'bg';
- let arr2 = document.querySelectorAll('.prop-img');
- if(arr2.length == 0){
- arr2 = document.querySelectorAll('.sku-item-image');
- }
- if(arr2.length == 0){
- arr2 = document.querySelectorAll('.ant-image-img');
- type = 'img';
- }
- for(let i=0; i< arr2.length; i++){
- let src;
- if(type == 'bg'){
- src = window.getComputedStyle(arr2[i]).backgroundImage.replace(/url\(["']?(.+?)["']?\)/i, '$1');
- }
- if(type == 'img'){
- src = arr2[i].src;
- }
- if(src.endsWith('_sum.jpg')){
- src = src.replace(/_sum\.jpg$/, '');
- }
- if(!authority && i < execNum){
- outObj.skuImg.push(src);
- }
- if(authority){
- outObj.skuImg.push(src);
- }
- }
- //详情图片
- let arr3 = document.querySelectorAll('img.desc-img-loaded');
- if(arr3.length == 0){
- if(document.getElementById('description') && document.getElementById('description').querySelector('.html-description')){
- arr3 = document.getElementById('description').querySelector('.html-description').shadowRoot.querySelectorAll('img');
- }
- }
- for(let i=0; i< arr3.length; i++){
- if(!authority && i < execNum){
- outObj.detailImg.push(arr3[i].src);
- }
- if(authority){
- outObj.detailImg.push(arr3[i].src);
- }
- }
- // 视频
- let arr5 = document.querySelectorAll('video');
- for(let i=0; i< arr5.length; i++){
- if(outObj.video.indexOf(arr5[i].src) == -1){
- if(!authority && i < execNum){
- outObj.video.push(arr5[i].src);
- }
- if(authority){
- outObj.video.push(arr5[i].src);
- }
- }
- }
- return outObj;
- }, authority, this.execNum);
-
- // 主图下载
- if(this.settingArr.indexOf('mainImg') > -1){
- for(let j = 0; j < imgInfo.mainImg.length; j++){
- let fileName = imgInfo.mainImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\主图')) {
- fs.mkdirSync(urlInfo.newPath + '\\主图');
- }
-
- let outputPath = urlInfo.newPath + '\\主图\\主图' + num + suffix;
- await this.downloadImage(imgInfo.mainImg[j], outputPath, urlInfo);
- }
- }
- }
-
- // sku图片下载
- if(this.settingArr.indexOf('skuImg') > -1){
- for(let j = 0; j < imgInfo.skuImg.length; j++){
- let fileName = imgInfo.skuImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\sku图')) {
- fs.mkdirSync(urlInfo.newPath + '\\sku图');
- }
-
- let outputPath = urlInfo.newPath + '\\sku图\\sku图' + num + suffix;
- await this.downloadImage(imgInfo.skuImg[j], outputPath, urlInfo);
- }
- }
- }
-
- //详情图下载
- if(this.settingArr.indexOf('detailImg') > -1){
- for(let j = 0; j < imgInfo.detailImg.length; j++){
- let fileName = imgInfo.detailImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\详情图')) {
- fs.mkdirSync(urlInfo.newPath + '\\详情图');
- }
-
- let outputPath = urlInfo.newPath + '\\详情图\\' + '详情图' + num + suffix;
- await this.downloadImage(imgInfo.detailImg[j], outputPath, urlInfo);
- }
- }
- }
- //视频下载
- if(this.settingArr.indexOf('video') > -1){
- for(let j = 0; j < imgInfo.video.length; j++){
- let fileName = imgInfo.video[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\视频')) {
- fs.mkdirSync(urlInfo.newPath + '\\视频');
- }
-
- let outputPath = urlInfo.newPath + '\\视频\\' + fileName;
- await this.downloadImage(imgInfo.video[j], outputPath, urlInfo);
- }
- }
- }
-
- await page.close(); // 关闭页面但不关闭浏览器
- },
-
- // 检查小红书登录状态
- checkRedLogin(){
- this.checkLoading = true;
- this.redStatus = 1;
- return new Promise((resolve, reject) => {
- (async () => {
- try{
- if(this.loginBrowser){
- await this.loginBrowser.close();
- this.loginBrowser = null;
- }
- puppeteer.use(StealthPlugin());
- this.loginBrowser = await puppeteer.launch({
- executablePath: this.initPath(),
- userDataDir: this.initDataDir(),
- args: [
- '--start-maximized',
- '--no-sandbox',
- '--disable-setuid-sandbox',
- '--disable-blink-features=AutomationControlled',
- '--window-size=1280,800'
- ],
- });
- const page = await this.loginBrowser.newPage();
- await page.setViewport({ width: 1280, height: 800 });
- let testUrl = "https://www.xiaohongshu.com";
- await page.goto(testUrl, {waitUntil : 'networkidle2'});
-
- let loginBtn = await page.$$('#login-btn');
- let loginContainer = await page.$$('.login-container');
- if(loginContainer.length > 0 || loginBtn.length > 0){
- this.redStatus = 3; //未登录
- }else{
- this.redStatus = 2;
- }
-
- resolve(this.redStatus);
- this.checkLoading = false;
- await this.loginBrowser.close();
- this.loginBrowser = null;
- }catch(e){
- this.checkLoading = false;
- reject(3);
- this.showError(e);
- }
- })();
- });
- },
- // 5-小红书下载
- async redDownload(urlInfo, redBrowser){
- let task = await new Promise((resolve,reject) =>{
- (async () => {
- try{
- let authority = this.$refs.headerRef.authority.isAuthority;
- let number = 0;
- urlInfo.status = '2';
- urlInfo.num = 0;
- const page = await redBrowser.newPage();
- let responseVideo = [];
- page.on('response', async(response) => {
- // 检查响应的 MIME 类型是否以 'video/' 开头
- if (response.headers()['content-type'] && response.headers()['content-type'].startsWith('video/')) {
- if(responseVideo.indexOf(response.url()) < 0 && !response.url().startsWith('blob:https://')){
- responseVideo.push(response.url());
- }
- }
- });
- await page.goto(urlInfo.url, {waitUntil : 'networkidle2'});
-
- if(urlInfo.title){
- if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title)) {
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
- } else {
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title);
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + urlInfo.title;
- }
- }else{
- await this.getTitle(page, urlInfo); // 生成页面标题对应的文件夹
- }
- urlInfo.status = '3';
-
- // 定位元素
- const handle = await page.$$('.pagination-media-container .pagination-item');
- if(handle.length > 0){ // 模拟鼠标拖动 将鼠标移动到元素的中心,然后开始拖动
- let handleLength = handle.length;
- const box = await handle[0].boundingBox();
- const boxEnd = await handle[handleLength - 1].boundingBox();
- const center = {
- x: box.x + box.width / 2,
- y: box.y + box.height / 2
- };
- const centerEnd = {
- x: boxEnd.x + boxEnd.width / 2,
- y: boxEnd.y + boxEnd.height / 2
- };
- await page.mouse.move(center.x, center.y);
- await page.mouse.down();
- await page.mouse.move(centerEnd.x, centerEnd.y, { steps: 50 }); // 新的位置,可以根据需要调整步骤数
- }
-
- //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
- const imgInfo = await page.evaluate((authority, execNum) => {
- let outObj = {
- mainImg: [],
- detailImg: [],
- skuImg: [],
- commentImg: [],
- video: []
- };
-
- // 正则表达式匹配字符 重写图片路径
- let regex = /\.(.{3,4})_[0-9a-zA-z]+\.(.{3,4})_\.(.{3,4})/;
-
- //主图
- let arr1 = document.querySelectorAll('img[class^=note-slider-img]');
- for(let i=0; i< arr1.length; i++){
- let mainImgUrl = arr1[i].src;
- let result = regex.exec(mainImgUrl);
- if(result){
- mainImgUrl = mainImgUrl.replace(result[0], '.'+result[1]);
- }
- if(!authority && i < execNum){
- outObj.mainImg.push(mainImgUrl);
- }
- if(authority){
- outObj.mainImg.push(mainImgUrl);
- }
- }
- // 视频
- let arr5 = document.querySelectorAll('video.lib-video');
- for(let i=0; i< arr5.length; i++){
- if(outObj.video.indexOf(arr5[i].src) == -1){
- if(!authority && i < execNum){
- outObj.video.push(arr5[i].src);
- }
- if(authority){
- outObj.video.push(arr5[i].src);
- }
- }
- }
- return outObj;
- }, authority, this.execNum);
-
- if(imgInfo.mainImg.length >= 3 && authority){
- imgInfo.mainImg = imgInfo.mainImg.slice(1, imgInfo.mainImg.length-1); //小红书轮播图第一个/最后一个和内容重复去掉
- }
- imgInfo.video = responseVideo;
-
- if(this.settingArr.indexOf('mainImg') > -1){
- // 主图下载
- for(let j = 0; j < imgInfo.mainImg.length; j++){
- let fileName = imgInfo.mainImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '.jpg';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- let outputPath = urlInfo.newPath + '\\文章图' + num + suffix;
- await this.downloadImage(imgInfo.mainImg[j], outputPath, urlInfo);
- }
- }
- }
-
- if(this.settingArr.indexOf('video') > -1){
- //视频下载
- for(let j = 0; j < imgInfo.video.length; j++){
- let fileName = imgInfo.video[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '.mp4';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
- let outputPath = urlInfo.newPath + '\\视频' + num + suffix;
- await this.downloadImage(imgInfo.video[j], outputPath, urlInfo);
- }
- }
- }
-
- await page.close();
- urlInfo.status = '4';
- resolve(true);
- this.loading = false;
- }catch(e){
- urlInfo.status = '5';
- reject(e);
- this.showError(e);
- }
- })();
- });
- },
-
- /**************************阿里国际商品图片下载*******************************************************************************************/
- // 6 - 阿里国际 - 扫描并下载图片
- async aliguojiScanImg(browser, page, urlInfo, authority){
- //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
- const imgInfo = await page.evaluate((authority, execNum) => {
- let outObj = {
- mainImg: [],
- detailImg: [],
- skuImg: [],
- commentImg: [],
- video: []
- };
-
- //主图
- let arr1 = document.querySelectorAll('.module_productImage img[class*="-object-contain"]');
- for(let i=0; i< arr1.length; i++){
- if(!authority && i < execNum){
- outObj.mainImg.push(arr1[i].src);
- }
- if(authority){
- outObj.mainImg.push(arr1[i].src);
- }
- }
- //sku图片
- let arr2 = document.querySelectorAll('.module_sku img[class*="-object-contain"]');
- for(let i=0; i< arr2.length; i++){
- if(!authority && i < execNum){
- outObj.skuImg.push(arr2[i].src);
- }
- if(authority){
- outObj.skuImg.push(arr2[i].src);
- }
- }
- //详情图片
- let arr3 = document.querySelectorAll('#description-layout img');
- // if(arr3.length == 0){
- // if(document.getElementById('description') && document.getElementById('description').querySelector('.html-description')){
- // arr3 = document.getElementById('description').querySelector('.html-description').shadowRoot.querySelectorAll('img');
- // }
- // }
- if(arr3.length == 0){
- if(document.querySelector('#description-layout').querySelector('iframe')){
- arr3 = document.querySelector('#description-layout').querySelector('iframe').contentDocument.querySelectorAll('img')
- }
- }
-
- for(let i=0; i< arr3.length; i++){
- if(!authority && i < execNum){
- outObj.detailImg.push(arr3[i].src);
- }
- if(authority){
- outObj.detailImg.push(arr3[i].src);
- }
- }
- // 视频
- let arr5 = document.querySelectorAll('video');
- for(let i=0; i< arr5.length; i++){
- if(arr5[i].src && outObj.video.indexOf(arr5[i].src) == -1){
- if(!authority && i < execNum){
- outObj.video.push(arr5[i].src);
- }
- if(authority){
- outObj.video.push(arr5[i].src);
- }
- }
- }
- return outObj;
- }, authority, this.execNum);
-
- // 主图下载
- if(this.settingArr.indexOf('mainImg') > -1){
- for(let j = 0; j < imgInfo.mainImg.length; j++){
- let fileName = imgInfo.mainImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\主图')) {
- fs.mkdirSync(urlInfo.newPath + '\\主图');
- }
-
- let outputPath = urlInfo.newPath + '\\主图\\主图' + num + suffix;
- await this.downloadImage(imgInfo.mainImg[j], outputPath, urlInfo);
- }
- }
- }
-
- // sku图片下载
- if(this.settingArr.indexOf('skuImg') > -1){
- for(let j = 0; j < imgInfo.skuImg.length; j++){
- let fileName = imgInfo.skuImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\sku图')) {
- fs.mkdirSync(urlInfo.newPath + '\\sku图');
- }
-
- let outputPath = urlInfo.newPath + '\\sku图\\sku图' + num + suffix;
- await this.downloadImage(imgInfo.skuImg[j], outputPath, urlInfo);
- }
- }
- }
-
- //详情图下载
- if(this.settingArr.indexOf('detailImg') > -1){
- for(let j = 0; j < imgInfo.detailImg.length; j++){
- let fileName = imgInfo.detailImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\详情图')) {
- fs.mkdirSync(urlInfo.newPath + '\\详情图');
- }
-
- let outputPath = urlInfo.newPath + '\\详情图\\' + '详情图' + num + suffix;
- await this.downloadImage(imgInfo.detailImg[j], outputPath, urlInfo);
- }
- }
- }
- //视频下载
- if(this.settingArr.indexOf('video') > -1){
- for(let j = 0; j < imgInfo.video.length; j++){
- let fileName = imgInfo.video[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\视频')) {
- fs.mkdirSync(urlInfo.newPath + '\\视频');
- }
-
- let outputPath = urlInfo.newPath + '\\视频\\' + fileName;
- await this.downloadImage(imgInfo.video[j], outputPath, urlInfo);
- }
- }
- }
-
- await page.close(); // 关闭页面但不关闭浏览器
- },
- /*********************************************************************************************************************/
-
- /**************************百度爱采购商品图片下载*******************************************************************************************/
- // 7 - 百度爱采购 - 扫描并下载图片
- async acaigouScanImg(browser, page, urlInfo, authority){
- //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
- const imgInfo = await page.evaluate((authority, execNum) => {
- let outObj = {
- mainImg: [],
- detailImg: [],
- skuImg: [],
- commentImg: [],
- video: []
- };
-
- //主图
- let arr1 = document.querySelectorAll('.album .img-container .img');
- for(let i=0; i< arr1.length; i++){
- let src = window.getComputedStyle(arr1[i]).backgroundImage.replace(/url\(["']?(.+?)["']?\)/i, '$1');
- if(src && outObj.mainImg.indexOf(src) == -1){
- if(!authority && i < execNum){
- outObj.mainImg.push(src);
- }
- if(authority){
- outObj.mainImg.push(src);
- }
- }
-
- }
- //sku图片
- // let arr2 = document.querySelectorAll('.module_sku img[class*="-object-contain"]');
- // for(let i=0; i< arr2.length; i++){
- // if(!authority && i < execNum){
- // outObj.skuImg.push(arr2[i].src);
- // }
- // if(authority){
- // outObj.skuImg.push(arr2[i].src);
- // }
- // }
- //详情图片
- let arr3 = document.querySelectorAll('.details .questionable-detail img');
- for(let i=0; i< arr3.length; i++){
- if(!authority && i < execNum){
- outObj.detailImg.push(arr3[i].src);
- }
- if(authority){
- outObj.detailImg.push(arr3[i].src);
- }
- }
- // 视频
- let arr5 = document.querySelectorAll('.album video');
- for(let i=0; i< arr5.length; i++){
- if(arr5[i].src && outObj.video.indexOf(arr5[i].src) == -1){
- if(!authority && i < execNum){
- outObj.video.push(arr5[i].src);
- }
- if(authority){
- outObj.video.push(arr5[i].src);
- }
- }
- }
- return outObj;
- }, authority, this.execNum);
-
- // 主图下载
- if(this.settingArr.indexOf('mainImg') > -1){
- for(let j = 0; j < imgInfo.mainImg.length; j++){
- let fileName = imgInfo.mainImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '.webp';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\主图')) {
- fs.mkdirSync(urlInfo.newPath + '\\主图');
- }
-
- let outputPath = urlInfo.newPath + '\\主图\\主图' + num + suffix;
- await this.downloadImage(imgInfo.mainImg[j], outputPath, urlInfo);
- }
- }
- }
-
- // sku图片下载
- if(this.settingArr.indexOf('skuImg') > -1){
- for(let j = 0; j < imgInfo.skuImg.length; j++){
- let fileName = imgInfo.skuImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\sku图')) {
- fs.mkdirSync(urlInfo.newPath + '\\sku图');
- }
-
- let outputPath = urlInfo.newPath + '\\sku图\\sku图' + num + suffix;
- await this.downloadImage(imgInfo.skuImg[j], outputPath, urlInfo);
- }
- }
- }
-
- //详情图下载
- if(this.settingArr.indexOf('detailImg') > -1){
- for(let j = 0; j < imgInfo.detailImg.length; j++){
- let fileName = imgInfo.detailImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '.webp';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\详情图')) {
- fs.mkdirSync(urlInfo.newPath + '\\详情图');
- }
-
- let outputPath = urlInfo.newPath + '\\详情图\\' + '详情图' + num + suffix;
- await this.downloadImage(imgInfo.detailImg[j], outputPath, urlInfo);
- }
- }
- }
- //视频下载
- if(this.settingArr.indexOf('video') > -1){
- for(let j = 0; j < imgInfo.video.length; j++){
- let fileName = imgInfo.video[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\视频')) {
- fs.mkdirSync(urlInfo.newPath + '\\视频');
- }
-
- let outputPath = urlInfo.newPath + '\\视频\\' + fileName;
- await this.downloadImage(imgInfo.video[j], outputPath, urlInfo);
- }
- }
- }
-
- await page.close(); // 关闭页面但不关闭浏览器
- },
- /*********************************************************************************************************************/
-
- /**************************亚马逊商品图片下载*******************************************************************************************/
- // 8 - 亚马逊 - 扫描并下载图片
- async amazonScanImg(browser, page, urlInfo, authority){
- //detailImg:详情图;skuImg:sku图片;commentImg: 评论图;video: 视频
- const imgInfo = await page.evaluate((authority, execNum) => {
- let outObj = {
- mainImg: [],
- detailImg: [],
- skuImg: [],
- commentImg: [],
- video: []
- };
-
- //主图
- let arr1 = document.querySelectorAll('#leftCol img.a-dynamic-image');
- for(let i=0; i< arr1.length; i++){
- if(!authority && i < execNum){
- outObj.mainImg.push(arr1[i].src);
- }
- if(authority){
- outObj.mainImg.push(arr1[i].src);
- }
- }
- //sku图片
- let arr2 = document.querySelectorAll('.module_sku img[class*="-object-contain"]');
- for(let i=0; i< arr2.length; i++){
- if(!authority && i < execNum){
- outObj.skuImg.push(arr2[i].src);
- }
- if(authority){
- outObj.skuImg.push(arr2[i].src);
- }
- }
- //详情图片
- let arr3 = document.querySelectorAll('#description-layout img');
- // if(arr3.length == 0){
- // if(document.getElementById('description') && document.getElementById('description').querySelector('.html-description')){
- // arr3 = document.getElementById('description').querySelector('.html-description').shadowRoot.querySelectorAll('img');
- // }
- // }
- for(let i=0; i< arr3.length; i++){
- if(!authority && i < execNum){
- outObj.detailImg.push(arr3[i].src);
- }
- if(authority){
- outObj.detailImg.push(arr3[i].src);
- }
- }
- // 视频
- let arr5 = document.querySelectorAll('#description-layout video');
- for(let i=0; i< arr5.length; i++){
- if(arr5[i].src && outObj.video.indexOf(arr5[i].src) == -1){
- if(!authority && i < execNum){
- outObj.video.push(arr5[i].src);
- }
- if(authority){
- outObj.video.push(arr5[i].src);
- }
- }
- }
- return outObj;
- }, authority, this.execNum);
-
- // 主图下载
- if(this.settingArr.indexOf('mainImg') > -1){
- for(let j = 0; j < imgInfo.mainImg.length; j++){
- let fileName = imgInfo.mainImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\主图')) {
- fs.mkdirSync(urlInfo.newPath + '\\主图');
- }
-
- let outputPath = urlInfo.newPath + '\\主图\\主图' + num + suffix;
- await this.downloadImage(imgInfo.mainImg[j], outputPath, urlInfo);
- }
- }
- }
-
- // sku图片下载
- if(this.settingArr.indexOf('skuImg') > -1){
- for(let j = 0; j < imgInfo.skuImg.length; j++){
- let fileName = imgInfo.skuImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\sku图')) {
- fs.mkdirSync(urlInfo.newPath + '\\sku图');
- }
-
- let outputPath = urlInfo.newPath + '\\sku图\\sku图' + num + suffix;
- await this.downloadImage(imgInfo.skuImg[j], outputPath, urlInfo);
- }
- }
- }
-
- //详情图下载
- if(this.settingArr.indexOf('detailImg') > -1){
- for(let j = 0; j < imgInfo.detailImg.length; j++){
- let fileName = imgInfo.detailImg[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- let num = Number(j) + 1;
- let suffix = '';
- if(fileName.lastIndexOf('.') > -1){
- suffix = fileName.substr(fileName.lastIndexOf('.'));
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\详情图')) {
- fs.mkdirSync(urlInfo.newPath + '\\详情图');
- }
-
- let outputPath = urlInfo.newPath + '\\详情图\\' + '详情图' + num + suffix;
- await this.downloadImage(imgInfo.detailImg[j], outputPath, urlInfo);
- }
- }
- }
- //视频下载
- if(this.settingArr.indexOf('video') > -1){
- for(let j = 0; j < imgInfo.video.length; j++){
- let fileName = imgInfo.video[j].split('/').pop();
- if(fileName){
- let queryIndex = fileName.indexOf('?');
- if (queryIndex !== -1) {
- fileName = fileName.substr(0, queryIndex);
- }
-
- if (!fs.existsSync(urlInfo.newPath + '\\视频')) {
- fs.mkdirSync(urlInfo.newPath + '\\视频');
- }
-
- let outputPath = urlInfo.newPath + '\\视频\\' + fileName;
- await this.downloadImage(imgInfo.video[j], outputPath, urlInfo);
- }
- }
- }
-
- await page.close(); // 关闭页面但不关闭浏览器
- },
- /*********************************************************************************************************************/
-
-
- //
- downloadExample(){
- let url = 'https://www.xingyousoft.com/soft/XYCapture/example.xlsx';
- if (!fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)) {
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName);
- }
- let path = this.downloadDir + separator + pjson.softInfo.softName + '\\链接模板下载.xlsx';
- this.downloadImage(url, path, 'example');
- },
-
- // 下载网址链接的图片
- async downloadImage(imageUrl, outputPath, urlInfo) {
- let _this = this;
- let received_bytes = 0;
- let total_bytes = 0;
- try {
- let req = request({
- method: 'GET', uri: imageUrl, strictSSL: false
- });
- let out = fs.createWriteStream(outputPath);
- req.pipe(out);
-
- return new Promise((resolve, reject) => {
- req.on('response', (data) => {
- total_bytes = parseInt(data.headers['content-length']);
- const status = data.statusCode;
- if (status < 200 || status >= 300) {
- //reject(false);
- this.$notify.error({
- title: '网络图片访问异常!- 1',
- message: imageUrl.slice(0,50)
- });
- }else if(isNaN(total_bytes)){
- //reject(false);
- this.$notify.error({
- title: '网络图片访问异常!- 2',
- message: imageUrl.slice(0,50)
- });
- }else{
- // console.log('下载中...')
- }
- });
-
- req.on('data', (chunk) => {
- received_bytes += chunk.length;
- });
-
- req.on('end', ()=> {
- if(urlInfo != 'example'){
- urlInfo.num += 1;
- }else{
- this.$msgbox({
- title: '消息',
- message: '模板下载成功,保存位置:' + this.downloadDir + separator + pjson.softInfo.softName,
- showCancelButton: true,
- confirmButtonText: '去查看',
- cancelButtonText: '取消',
- }).then(action => {
- this.openFolder();
- }).catch(action => {
-
- });
- }
- //console.log('下载完成', outputPath)
- resolve(true);
- });
- });
- } catch (error) {
- console.error(imageUrl, `Failed to download image: ${error.message}`);
- throw error;
- }
- },
-
- // 获取页面标题 - 生成对应的文件夹
- async getTitle(page, urlInfo){
- // 已页面标题作为新建文件夹,保留前50个字
- let title = await page.title();
- if(!title){
- title = '无标题-'+new Date().getTime();
- }
- if(title){
- title = title.substring(0, 50).trim();
- if(this.containsAnyChar(title, ['\\', '/', ':', '*', '?', '"', '<', '>', '|'])){ //判断是否含有特殊字符
- title = title.replace(/[\\|/|:|*|?|"|<|>||]/g, "");
- }
- if (fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName + separator + title)) {
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + title;
- } else {
- fs.mkdirSync(this.downloadDir + separator + pjson.softInfo.softName + separator + title);
- urlInfo.newPath = this.downloadDir + separator + pjson.softInfo.softName + separator + title;
- }
- }
- },
-
- // 下载base64位的图片
- async downloadBaseImage(base64String, outputPath, urlInfo) {
- const buffer = Buffer.from(base64String, 'base64');
- const writeStream = fs.createWriteStream(outputPath);
- writeStream.write(buffer);
- writeStream.end();
- writeStream.on('finish', () => {
- urlInfo.num += 1;
- });
- // 监听错误事件
- writeStream.on('error', (err) => {
- console.error('base64位写入文件时出错:', err);
- });
- },
-
- // 错误提示
- showError(e){
- let str = '';
- if(e.toString().indexOf('ERR_NAME_NOT_RESOLVE') > -1){
- str = '无法解析该网址,请查看网址是否正确!-1';
- }else if(e.toString().indexOf('Cannot navigate to invalid URL') > -1){
- str = '无效的网址,请查看网址格式是否正确!-2';
- }else if(e.toString().indexOf('ERR_CONNECTION_TIMED_OUT') > -1){
- str = '链接请求超时,请查看网络状态!-3';
- }else if(e.toString().indexOf('TimeoutError') > -1){
- str = '链接请求超时,请查看网络状态!-4';
- }else if(e.toString().indexOf('operation not permitted') > -1){
- str = '权限受限,请以管理员权限运行软件!-5';
- }else if(e.toString().indexOf('browser has disconnected') > -1){
- str = '内置浏览器已关闭!-6';
- }else if(e.toString().indexOf('Failed to launch the browser') > -1){
- str = '请先关闭内置浏览器!-7';
- }else{
- str = e.toString();
- //console.log(e);
- }
- this.loading = false;
- this.$notify.error({
- title: '提示',
- message: str
- });
- },
-
- // 是否包含特殊字符
- containsAnyChar(str, charsArray) {
- for (let i = 0; i < charsArray.length; i++) {
- if (str.includes(charsArray[i])) {
- return true;
- }
- }
- return false;
- },
-
- // 随机生成字符
- randomString(length) {
- let result = '';
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
- const charactersLength = characters.length;
- for (let i = 0; i < length; i++ ) {
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
- }
- return result;
- }
-
- }
- };
- </script>
- <style lang="scss">
- @import "../assets/css/fontx/iconfont.css";
- @import "../assets/css/home.scss";
- .ivu-input-number-controls-outside-btn i {
- font-weight: 800;
- }
- .update-point {
- display: inline-block;
- width: 8px;
- height: 8px;
- border-radius: 8px;
- background: #ff0000;
- top: 14px;
- position: absolute;
- left: -13px;
- }
- .menu-item {
- padding: 8px 0;
- font-size: 14px;
- .iconfont {
- font-size: 32px;
- }
- &:hover,
- &.active {
- color: #ed4014;
- }
- }
- .ivu-progress-show-info .ivu-progress-outer {
- padding-right: 40px !important;
- margin-right: -40px !important;
- }
- .tips {
- text-align: center;
- padding: 10px 0;
- color: #ed4014;
- font-size: 12px;
- }
- .handle-desc {
- display: inline-block;
- width: calc(100% - 100px);
- overflow: hidden;
- }
- .ivu-menu-submenu-title {
- font-weight: 600;
- }
- .ivu-menu .ivu-menu-item {
- line-height: 1;
- }
- // new-el
- .el-menu {
- border-right: none !important;
- }
- .cmenu-item {
- padding: 0 20px 20px;
- margin-bottom: 15px;
- .cmenu-title {
- font-size: 18px;
- font-weight: 600;
- padding-bottom: 20px;
- }
- .citem-nav {
- text-align: center;
- border-radius: 10px;
- min-height: 110px;
- padding: 15px 0;
- background-color: #fff;
- font-size: 15px;
- cursor: pointer;
- &.bg-linear1 {
- color: #fff;
- font-size: 20px;
- background: linear-gradient(to right bottom, #2A56CA, #5795F4);
- }
- &.bg-linear2 {
- color: #fff;
- font-size: 20px;
- background: linear-gradient(to right top, #147FBB, #5EB3E3);
- }
- &.bg-linear3 {
- color: #fff;
- font-size: 20px;
- background: linear-gradient(to right bottom, #2F9E8A, #56CDB1);
- }
- &:hover {
- margin-top: -5px;
- box-shadow: 3px 3px 6px #ccc, -3px -3px 6px #ccc;
- }
- .citem-img {
- width: 50px;
- margin-bottom: 10px;
- }
- }
- }
-
- .popper-open{
- text-align: center !important;
- padding: 10px !important;
- background: #303133 !important;
- color: #fff !important;
- min-width: 120px !important;
- opacity: 0.8;
- }
-
- .popper-open[x-placement^=bottom] .popper__arrow::after{
- border-bottom-color: #303133 !important;
- }
-
- textarea.el-textarea__inner{
- height: 100% !important;
- font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
- }
-
- .set-item{
- margin-right: 15px;
-
- .set-title{
- font-size: 13px;
- }
- }
-
- .outarea{
- height: 100%;
- border: 1px solid #DCDFE6;
- background-color: #4851a415;
- padding: 15px;
- font-size: 20px;
- overflow: hidden auto;
- }
-
- .outtext{
- height: 100%;
- font-size: 20px;
- overflow: hidden auto;
-
- textarea{
- background-color: #4851a415;
- }
- }
-
- .pin-tips{
- font-size: 14px;
- position: absolute;
- bottom: 10px;
- color: #ff0000;
- left: 0;
- right: 0;
- margin: auto;
- text-align: center;
- }
-
- .outarea.red-border{
- border: 1px solid #F56C6C;
- }
-
- .outtext.red-border textarea{
- border: 1px solid #F56C6C;
- }
-
- h3{
- margin: 0;
- }
-
- .m-image{
- width: 20px;
- margin-right: 5px;
- }
-
- .dialog-footer-center{
- text-align: center;
- }
-
- .visible-tips-style{
- font-size: 18px;
- color: #f73131;
- font-weight: 600;
- padding: 30px 40px 0;
- }
-
- .no-select{
- user-select: none;
- }
-
- .tips-flex{
- display: flex;
- flex-wrap: nowrap;
- justify-content: space-around;
- align-items: center;
-
- .el-icon-s-opportunity{
- font-size: 50px;
- color: #f73131;
- margin-right: 10px;
- }
-
- .m-title{
- flex: 1;
- color: #f73131;
- }
- }
-
- </style>
|