2 lines
6.2 KiB
JavaScript
2 lines
6.2 KiB
JavaScript
import{d as e,o as a,c as l,u as t,r as s,g as n,a as c,b as o,n as i,s as r,e as u,f as d,$ as _,h as v,i as m,w as h,j as f,k as p,l as y,m as g,p as w,U as x,q as b,t as k,v as T,S as C,x as I,F as K,y as S,z as j,A as z,B as A,C as D,D as L,E as R,_ as U}from"./index-D8LSe3rK.js";import{_ as B}from"./logo.DIuJXRKy.js";import{g as E,a as F}from"./news.CGrr83Hz.js";import{r as $}from"./share.CmeSVjvc.js";import{T as q}from"./translated-article-card.BbvtbdMe.js";const H=e({__name:"feed-translate-card",props:{item:{default:()=>({})}},setup:e=>(e,t)=>(a(),l(q,{item:e.item,variant:"feed"},null,8,["item"]))}),M=U(e({__name:"index",setup(e){const U=t(),q=s(0),M=s(500);let O=667;n({success:e=>{q.value=0,O=e.windowHeight||667;const a=q.value+44,l=c(100);M.value=O-a-l}});const P=()=>{const e=R();e.select(".top-bar").boundingClientRect(),e.exec(e=>{var a;const l=(null==(a=e[0])?void 0:a.height)||q.value+44,t=c(100);M.value=O-l-t})},V=s("搜索乐博头条"),W={id:"__recommend__",name:"推荐",specialType:"recommend",channelKey:"__recommend__"},X={id:"__mychannel__",name:"我的频道",specialType:"mychannel",channelKey:"__mychannel__"},Y=s([]),G=s([]),J=s(0),N=s(0),Q=s([]),Z=s(!1),ee=s(!1),ae=s(1),le=(e=Y.value)=>{var a;const l=(null==(a=G.value[J.value])?void 0:a.channelKey)||W.channelKey;G.value=((e=[])=>{const a=[{...W}];U.isLogin&&a.push({...X});const l=(e||[]).map(e=>({...e,specialType:"category",channelKey:`cate_${e.id}`}));return[...a,...l]})(e);const t=G.value.findIndex(e=>e.channelKey===l);J.value=t>=0?t:0},te=async()=>{try{const e=await E();Y.value=e||[],le()}catch(e){console.log("获取分类失败=>",e),Y.value=[],le()}},se=e=>{J.value!==e&&(J.value=e,ne())},ne=()=>{ae.value=1,ee.value=!1,Q.value=[],ce()},ce=async()=>{if(!Z.value&&!ee.value){Z.value=!0;try{const e={page_no:ae.value,page_size:10},a=G.value[J.value];a&&"recommend"!==a.specialType?"mychannel"===a.specialType?e.is_mychannel=1:a.id&&(e.cid=a.id):e.is_recommend=1;const{lists:l,count:t}=await F(e),s=l||[];1===ae.value?Q.value=s:Q.value=[...Q.value,...s],(Q.value.length>=t||s.length<10)&&(ee.value=!0),ae.value++}catch(e){console.log("feed加载失败=>",e),f({title:"加载失败,请稍后重试",icon:"none"})}finally{Z.value=!1}}},oe=()=>{ce()},ie=e=>!!String((null==e?void 0:e.translated_content)||(null==e?void 0:e.worldcup_translated_content)||"").trim(),re=()=>{u({url:"/pages/search/search"})},ue=()=>{u({url:"/pages/channel/channel-manage"})},de=()=>{u({url:"/pages/ai_assistant/ai_assistant"})};o(async e=>{_e(e),await te(),ce(),i(()=>{setTimeout(P,100)})});const _e=async e=>{var a;let l=(null==e?void 0:e.slc)||"";if(!l){l=new URLSearchParams(window.location.search).get("slc")||""}if(l)try{const e=ve(),t=await $({code:l,fingerprint:e,referer:(null==document?void 0:document.referrer)||""});(null==(a=t.params)?void 0:a.invite_code)&&r("invite_code",t.params.invite_code),t.path&&"invite"!==t.page_type&&setTimeout(()=>{u({url:t.path})},300)}catch(t){console.error("短链接解析失败",t)}},ve=()=>{try{const e=document.createElement("canvas"),a=e.getContext("2d");a&&(a.textBaseline="top",a.font="14px Arial",a.fillText("fp",2,2));const l=navigator.userAgent+navigator.language+(screen.width+"x")+screen.height+screen.colorDepth+(new Date).getTimezoneOffset()+e.toDataURL();let t=0;for(let s=0;s<l.length;s++)t=(t<<5)-t+l.charCodeAt(s),t|=0;return Math.abs(t).toString(16)}catch{return""}};let me=!1;d(async()=>{var e;le(),me||0!==Y.value.length||(await te(),ce()),me&&"mychannel"===(null==(e=G.value[J.value])?void 0:e.specialType)&&ne(),me=!0});const he=e=>{if(e.channels&&(Y.value=e.channels,le()),e.selectIndex>=0){const l=Y.value[e.selectIndex],t=(a=null==l?void 0:l.id,G.value.findIndex(e=>"category"===e.specialType&&String(e.id)===String(a)));se(t>=0?t:0)}else ne();var a};return _("channelChanged",he),v(()=>{m("channelChanged",he)}),(e,t)=>{const s=w,n=p,c=b,o=C;return a(),l(n,{class:"index"},{default:h(()=>[y(n,{class:"top-bar",style:g({paddingTop:q.value+"px"})},{default:h(()=>[y(n,{class:"top-bar__content"},{default:h(()=>[y(n,{class:"top-bar__logo"},{default:h(()=>[y(s,{src:B,mode:"aspectFit",class:"top-bar__logo-img"})]),_:1}),y(n,{class:"top-bar__search",onClick:re},{default:h(()=>[y(x,{name:"search",size:"28",color:"#999"}),y(c,{class:"top-bar__search-text"},{default:h(()=>[k(T(V.value),1)]),_:1})]),_:1}),y(n,{class:"top-bar__actions"})]),_:1})]),_:1},8,["style"]),y(o,{"scroll-y":"",class:"feed-wrapper",style:g({height:M.value+"px"}),onScrolltolower:oe,"lower-threshold":100},{default:h(()=>[y(n,{class:"assistant-entry",onClick:de},{default:h(()=>[y(n,{class:"assistant-entry__icon"},{default:h(()=>[k("AI")]),_:1}),y(n,{class:"assistant-entry__body"},{default:h(()=>[y(c,{class:"assistant-entry__title"},{default:h(()=>[k("世博头条 AI 助手")]),_:1}),y(c,{class:"assistant-entry__desc"},{default:h(()=>[k("问资讯、赛事、社区、彩票和行情")]),_:1})]),_:1}),y(x,{name:"arrow-right",size:"28",color:"#185dff"})]),_:1}),y(n,{class:"channel-bar"},{default:h(()=>[y(o,{"scroll-x":"",class:"channel-bar__scroll","scroll-left":N.value,"scroll-with-animation":""},{default:h(()=>[y(n,{class:"channel-bar__list"},{default:h(()=>[(a(!0),I(K,null,S(G.value,(e,t)=>(a(),l(n,{key:e.channelKey,class:j(["channel-bar__item",{"channel-bar__item--active":J.value===t}]),onClick:e=>se(t)},{default:h(()=>[y(c,null,{default:h(()=>[k(T(e.name),1)]),_:2},1024)]),_:2},1032,["class","onClick"]))),128))]),_:1})]),_:1},8,["scroll-left"]),y(n,{class:"channel-bar__more",onClick:ue},{default:h(()=>[y(x,{name:"list",size:"38",color:"#666"})]),_:1})]),_:1}),(a(!0),I(K,null,S(Q.value,e=>(a(),I(K,{key:e.id},[ie(e)?(a(),l(H,{key:0,item:e},null,8,["item"])):e.is_video?(a(),l(z,{key:1,item:e},null,8,["item"])):(a(),l(A,{key:2,item:e},null,8,["item"]))],64))),128)),Z.value?(a(),l(n,{key:0,class:"feed-loading"},{default:h(()=>[y(D,{mode:"circle"}),y(c,{class:"feed-loading__text"},{default:h(()=>[k("加载中...")]),_:1})]),_:1})):L("",!0),ee.value&&Q.value.length?(a(),l(n,{key:1,class:"feed-bottom"},{default:h(()=>[y(c,null,{default:h(()=>[k("没有更多了")]),_:1})]),_:1})):L("",!0),Z.value||Q.value.length?L("",!0):(a(),l(n,{key:2,class:"feed-empty"},{default:h(()=>[y(c,null,{default:h(()=>[k("暂无内容")]),_:1})]),_:1}))]),_:1},8,["style"])]),_:1})}}}),[["__scopeId","data-v-fa028560"]]);export{M as default};
|