{"version":3,"file":"util-CG4WFU_b.js","sources":["../../../src/components/public/d-item-loading/d-item-loading.vue","../../../../global-common/apis/img-clippng/img/download.ts","../../../src/helpers/downLoad.ts","../../../src/assets/images/grid-item-down.svg","../../../src/helpers/util.ts"],"sourcesContent":["\n\n\n\n\n","import {$axios, GcResponse} from \"../../helper\";\nimport {ServerClippngImg} from \"../../../lib/constants/server\";\n/** 获取下载链接\n * @see http://doc.bigbigwork.com/docs/hw/7951\n */\nexport const IImgDownLoad = (\n params: { img_id: number, token: any }\n) => {\n console.log(params,'参数')\n return $axios({\n url: `${ServerClippngImg}/img/download`,\n method: `GET`,\n params: params\n })\n}\n","import axios from \"axios\";\nimport CreateMessage from \"./CreateMessage.ts\"\nimport {IImgDownLoad} from \"global-common/apis/img-clippng/img/download.ts\";\nimport {useStoreDownload} from \"@stores/useStoreDownload.ts\"\nimport {buyVip} from \"@helpers/utils\";\nimport {useStoreUserInfo} from \"@stores/useStoreUserInfo.ts\";\nimport {storeToRefs} from \"pinia\";\nimport {showContactModel} from \"@helpers/ui.ts\";\nimport { useStoreRoute } from \"@stores/useStoreRoute\";\n\nexport const download = async (ops: {\n token: string,\n img_id: number,\n name?: string,\n start?: Function,\n cb?: Function,\n beforeDownload?: Function,\n fromPage?: string\n}) => {\n try {\n const { route } = useStoreRoute();\n const fromPageDefault = route?.meta?.from_page || ``;\n const {img_id, cb, token, name = `clippng-${new Date().getTime()}`, fromPage = fromPageDefault} = ops\n const downStore = useStoreDownload();\n const { isVip } = storeToRefs(useStoreUserInfo());\n console.log(token, '获取token')\n console.log(downStore, 'downStore')\n const isDownload = downStore.isDownloading;\n console.log('isDownload', isDownload)\n if (isDownload) {\n //正在下载中,请勿重复操作\n new CreateMessage({\n content: 'Downloading in progress...',\n type: 'loading',\n duration: 3000\n })\n return\n }\n setTimeout(() => {\n ops.start && ops.start()\n }, 500)\n const [err, res] = await IImgDownLoad({img_id, token})\n console.log(res, '下载接口')\n if (res.code === 200) {\n ops.beforeDownload && ops.beforeDownload()\n /*添加下载记录*/\n // new CreateMessage({\n // content: '下载中···',\n // type: 'loading',\n // component: 'dMessageAnimation',\n // duration: 3000\n // })\n // $store.commit('addDownloadCount', {uuid})\n downStore.addDownloadCount({img_id})\n // await downloadBlob(res.data, uuid, cb, 'texture')\n await downloadBlob({url: res.data, img_id, name: name, cb, type: '下载大图'})\n } else if (res.code === 403) {\n } else if ([500].includes(res.code)) {\n new CreateMessage({content: 'Download successful'})\n } else if( res.code === 1401) {\n console.log ( `下载达限` )\n if ( isVip.value ){\n showContactModel({})\n } else {\n const str = fromPage.replace ( `cp-`, `` );\n buyVip({fromText: `${str ? str+`-` : ``}下载达限`})\n }\n } else {\n throw Error(res.data.message)\n }\n } catch (e) {\n new CreateMessage({type: `warn`, content: e.message, duration: 3000 })\n }\n}\n/**\n * @description 根据url下载blob数据\n * @param ops\n */\n// export const downloadBlob = async (url: string,id:string, cb?: Function) => {\nexport const downloadBlob = async (ops: { url: string, img_id: number, name: string, cb?: Function, type: string }) => {\n console.log(new Date().getTime(), `开始`)\n try {\n // @ts-ignore\n const res = await axios ( {\n url: ops.url,\n responseType: `blob`,\n headers: {\n \"Content-type\": `application/x-www-form-urlencoded`\n },\n config: {removeToken: true},\n onDownloadProgress: function ( res ) {\n console.log(Math.round(res.loaded / res.total * 100) + '%');\n }\n } ) ;\n console.log(res, `下载blob`)\n if (res.status === 200) {\n // bdStat(ops.type, '下载', '成功', `${ops.type}下载成功`)\n const link = document.createElement(`a`);\n const blob = new Blob([res.data], {type: res.data.type});\n const csvUrl = URL.createObjectURL(blob);\n link.href = csvUrl;\n const fileUrl = ops.url.split('?')[0]\n link.download = ops.name ? ops.name + fileUrl.slice(fileUrl.lastIndexOf('.')) : fileUrl.slice(fileUrl.lastIndexOf('/') + 1);\n link.click();\n ops.cb && ops.cb({code: 200, img_id: ops.img_id})\n new CreateMessage({content: 'Download successful'})\n window.setTimeout ( () => {\n // 需要释放,防止内存泄漏\n URL.revokeObjectURL ( csvUrl ) ;\n }, 1000 ) ;\n console.log(new Date().getTime(), `结束`)\n } else {\n /*下载失败*/\n // bdStat(ops.type, '下载', '失败', `${ops.type}下载失败`)\n // postStatDownloadComplete({type: ops.type,download_uuid: ops.id, error_code: res.status, info: JSON.stringify(res), time: (new Date().getTime())-startTime})\n // new CreateMessage({content: '下载失败'})\n ops.cb && ops.cb({code: 500, img_id: ops.img_id})\n }\n } catch (e) {\n console.log('download-error', e.message, e)\n // new CreateMessage({content: '下载失败'})\n ops.cb && ops.cb({code: 500, img_id: ops.img_id})\n // postStatDownloadComplete({type: ops.type,download_uuid: ops.id, error_code: 500, info: e.message, time: (new Date().getTime())-startTime})\n // bdStat(ops.type, '下载', '失败', `${ops.type}下载失败`)\n throw e\n }\n}\n","export default \"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='16px'%20height='16px'%20viewBox='0%200%2016%2016'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3c!--%20Generator:%20Sketch%2055.2%20(78181)%20-%20https://sketchapp.com%20--%3e%3ctitle%3e编组%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cg%20id='页面1'%20stroke='none'%20stroke-width='1'%20fill-rule='evenodd'%3e%3cg%20id='模型-SU模型-列表页2'%20transform='translate(-719.000000,%20-723.000000)'%20fill-rule='nonzero'%3e%3cg%20id='瀑布流'%20transform='translate(62.000000,%20439.000000)'%3e%3cg%20id='1备份-3'%20transform='translate(0.000000,%2011.000000)'%3e%3cg%20id='1-1备份'%20transform='translate(364.000000,%200.000000)'%3e%3cg%20id='下载'%20transform='translate(278.000000,%20258.000000)'%3e%3cg%20id='编组'%20transform='translate(15.038462,%2015.038462)'%3e%3cpath%20d='M15.2596154,14.5961538%20L0.663461538,14.5961538%20C0.297041849,14.5961538%200,14.8931957%200,15.2596154%20C0,15.6260351%200.297041849,15.9230769%200.663461538,15.9230769%20L15.2596154,15.9230769%20C15.6260351,15.9230769%2015.9230769,15.6260351%2015.9230769,15.2596154%20C15.9230769,14.8931957%2015.6260351,14.5961538%2015.2596154,14.5961538%20Z%20M13.9592308,5.65269231%20L10.6153846,5.65269231%20L10.6153846,0.703269231%20C10.6153846,0.31486436%2010.3005203,0%209.91211538,0%20L5.93134615,0%20C5.57432313,0.040671697%205.30538314,0.343944453%205.30769231,0.703269231%20L5.30769231,5.65269231%20L1.96384615,5.65269231%20C1.70518197,5.6440039%201.46803093,5.79597702%201.36786135,6.0346163%20C1.26769178,6.27325559%201.32532213,6.54896411%201.51269231,6.7275%20L7.51038462,12.7384615%20C7.76485738,12.9744662%208.15821954,12.9744662%208.41269231,12.7384615%20L14.4103846,6.7275%20C14.5977548,6.54896411%2014.6553851,6.27325559%2014.5552156,6.0346163%20C14.455046,5.79597702%2014.217895,5.6440039%2013.9592308,5.65269231%20L13.9592308,5.65269231%20Z'%20id='形状'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e\"","import type {IHotWord} from \"global-common/apis/img-clippng/hot/word/list.ts\";\nimport Router, { RouteLocationRaw, useRouter } from \"vue-router\";\nimport {useStoreUserInfo} from \"@stores/useStoreUserInfo.ts\";\nexport type WaterFallItemType = {\n real_width: number,\n real_height: number,\n width: number,\n height: number,\n dw: number,\n dh: number\n}\nexport type WaterFallItemOverflow = `long` | `normal` | `short` ;\n/** 计算瀑布流元素大小\n * @see http://doc.bigbigwork.com/docs/ai_hua/4649\n * @param item\n * @param width\n * @param maxHeight\n * @param minHeight\n * @param bottom\n */\nexport const resizeWaterFallItem = (\n item:WaterFallItemType,\n width:number = 326,\n maxHeight:number = width * 3,\n minHeight:number = width * 0.4,\n bottom:number = 0\n): {dw:number, dh: number, overflow: WaterFallItemOverflow } => {\n const dw = width ;\n const height = (dw / item.real_width * item.real_height);\n const dh = Math.max ( minHeight, Math.min ( height, maxHeight ) ) + bottom;\n return {\n dw, dh, overflow: height > dh ? `long` : height === dh ? `normal` : `short`\n } ;\n} ;\n\n/**\n * 搜索关键词\n * @param kw\n * @param router\n * @param options\n */\nexport const searchKeyword = async (\n kw:string,\n router: Router,\n options?: {\n replace?: boolean,\n newTab?: boolean\n }\n) => {\n const route = getSearchRoute( kw );\n const { replace = false, newTab = false } = options || {};\n if ( newTab ) {\n const url = router.resolve(route).fullPath;\n window.open ( url, `_blank` );\n } else {\n if ( replace ) {\n await router.replace(route)\n } else {\n await router.push(route)\n }\n }\n}\n/**\n * 根据搜索词,获取搜索路由\n * @param kw\n */\nexport const getSearchRoute = ( kw:string ) => {\n const word = kw.trim().replace(/\\s+/g, '-');\n if ( word ) {\n const route:RouteLocationRaw = {\n name: `search`,\n params: {\n word\n }\n }\n return route;\n } else {\n const route:RouteLocationRaw = {\n name: `searchIndex`,\n }\n return route;\n }\n\n}\n/**\n * 跳转到路由\n */\nexport const jumpToUrl = ( url:string ) => {\n\n}"],"names":["_sfc_main","defineComponent","_sfc_render","_ctx","_cache","$props","$setup","$options","_normalizeClass","IImgDownLoad","params","$axios","ServerClippngImg","download","ops","route","useStoreRoute","fromPageDefault","_a","img_id","cb","token","name","fromPage","downStore","useStoreDownload","isVip","storeToRefs","useStoreUserInfo","isDownload","CreateMessage","err","res","downloadBlob","showContactModel","str","buyVip","e","axios","link","blob","csvUrl","fileUrl","gridItemDown","resizeWaterFallItem","item","width","maxHeight","minHeight","bottom","dw","height","dh","searchKeyword","kw","router","options","getSearchRoute","replace","newTab","url","word"],"mappings":"yLASA,MAAAA,EAAeC,EAAgB,CAC7B,KAAM,eACN,MAAO,CAIL,KAAM,CACJ,KAAM,OACN,QAAS,SACT,SAAU,EACZ,EAEA,MAAM,CACJ,KAAM,OACN,QAAS,OACT,SAAU,EAAA,CAEd,EACA,OAAQ,CAEN,MAAO,CAEP,CAAA,CAEJ,CAAC,6VAhCYC,EAAGC,EAAAC,EAAAC,EAAOC,IAAiBC,EAAM,qBAC1C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