2 lines
7.1 KiB
JavaScript
2 lines
7.1 KiB
JavaScript
import { d as e, o as a, c as l, u as t, r as n, g as s, a as c, b as o, n as r, s as i, e as u, f as d, $ as _, h as v, i as m, w as p, j as h, k as f, l as y, m as g, p as b, U as x, q as w, t as k, v as T, S as C, x as j, F as K, y as S, z, A, B as I, C as D, D as L, E as R, _ as U } from "./index-D6lS2uZ9.js"; import { _ as B } from "./logo.DIuJXRKy.js"; import { g as E, a as F } from "./news.pig5l0m2.js"; import { r as $ } from "./share.CPj3dbHI.js"; import { A as q } from "./ai-assistant-entry.BsT6MDaC.js"; import { T as G } from "./translated-article-card.B0arwmCc.js"; import { G as H } from "./global-popup.B14ONG8j.js"; const M = e({ __name: "feed-translate-card", props: { item: { default: () => ({}) } }, setup: e => (e, t) => (a(), l(G, { item: e.item, variant: "feed" }, null, 8, ["item"])) }), O = U(e({ __name: "index", setup(e) { const U = t(), G = n(0), O = n(500); let P = 667; s({ success: e => { G.value = 0, P = e.windowHeight || 667; const a = G.value + 44, l = c(100); O.value = P - a - l } }); const V = () => { const e = R(); e.select(".top-bar").boundingClientRect(), e.exec(e => { var a; const l = (null == (a = e[0]) ? void 0 : a.height) || G.value + 44, t = c(100); O.value = P - l - t }) }, W = n("搜索世博头条"), X = { id: "__recommend__", name: "推荐", specialType: "recommend", channelKey: "__recommend__" }, Y = { id: "__mychannel__", name: "我的频道", specialType: "mychannel", channelKey: "__mychannel__" }, Z = n([]), J = n([]), N = n(0), Q = n(0), ee = n([]), ae = n(!1), le = n(!1), te = n(1), ne = (e = Z.value) => { var a; const l = (null == (a = J.value[N.value]) ? void 0 : a.channelKey) || X.channelKey; J.value = ((e = []) => { const a = [{ ...X }]; U.isLogin && a.push({ ...Y }); const l = (e || []).map(e => ({ ...e, specialType: "category", channelKey: `cate_${e.id}` })); return [...a, ...l] })(e); const t = J.value.findIndex(e => e.channelKey === l); N.value = t >= 0 ? t : 0 }, se = async () => { try { const e = await E(); Z.value = e || [], ne() } catch (e) { console.log("获取分类失败=>", e), Z.value = [], ne() } }, ce = e => { N.value !== e && (N.value = e, oe()) }, oe = () => { te.value = 1, le.value = !1, ee.value = [], re() }, re = async () => { if (!ae.value && !le.value) { ae.value = !0; try { const e = { page_no: te.value, page_size: 10 }, a = J.value[N.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), n = l || []; 1 === te.value ? ee.value = n : ee.value = [...ee.value, ...n], (ee.value.length >= t || n.length < 10) && (le.value = !0), te.value++ } catch (e) { console.log("feed加载失败=>", e), h({ title: "加载失败,请稍后重试", icon: "none" }) } finally { ae.value = !1 } } }, ie = () => { re() }, ue = e => !!String((null == e ? void 0 : e.translated_content) || (null == e ? void 0 : e.worldcup_translated_content) || "").trim(), de = () => { u({ url: "/pages/search/search" }) }, _e = () => { u({ url: "/pages/channel/channel-manage" }) }; o(async e => { ve(e), await se(), re(), r(() => { setTimeout(V, 100) }) }); const ve = 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 = me(), t = await $({ code: l, fingerprint: e, referer: (null == document ? void 0 : document.referrer) || "" }); (null == (a = t.params) ? void 0 : a.invite_code) && i("invite_code", t.params.invite_code), t.path && "invite" !== t.page_type && setTimeout(() => { u({ url: t.path }) }, 300) } catch (t) { console.error("短链接解析失败", t) } }, me = () => { 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 n = 0; n < l.length; n++)t = (t << 5) - t + l.charCodeAt(n), t |= 0; return Math.abs(t).toString(16) } catch { return "" } }; let pe = !1; d(async () => { var e; ne(), pe || 0 !== Z.value.length || (await se(), re()), pe && "mychannel" === (null == (e = J.value[N.value]) ? void 0 : e.specialType) && oe(), pe = !0 }); const he = e => { if (e.channels && (Z.value = e.channels, ne()), e.selectIndex >= 0) { const l = Z.value[e.selectIndex], t = (a = null == l ? void 0 : l.id, J.value.findIndex(e => "category" === e.specialType && String(e.id) === String(a))); ce(t >= 0 ? t : 0) } else oe(); var a }; return _("channelChanged", he), v(() => { m("channelChanged", he) }), (e, t) => { const n = b, s = f, c = w, o = C; return a(), l(s, { class: "index" }, { default: p(() => [y(s, { class: "top-bar", style: g({ paddingTop: G.value + "px" }) }, { default: p(() => [y(s, { class: "top-bar__content" }, { default: p(() => [y(s, { class: "top-bar__logo" }, { default: p(() => [y(n, { src: B, mode: "aspectFit", class: "top-bar__logo-img" })]), _: 1 }), y(s, { class: "top-bar__search", onClick: de }, { default: p(() => [y(x, { name: "search", size: "28", color: "#999" }), y(c, { class: "top-bar__search-text" }, { default: p(() => [k(T(W.value), 1)]), _: 1 })]), _: 1 }), y(s, { class: "top-bar__actions" }, { default: p(() => [y(q)]), _: 1 })]), _: 1 })]), _: 1 }, 8, ["style"]), y(o, { "scroll-y": "", class: "feed-wrapper", style: g({ height: O.value + "px" }), onScrolltolower: ie, "lower-threshold": 100 }, { default: p(() => [y(s, { class: "channel-bar" }, { default: p(() => [y(o, { "scroll-x": "", class: "channel-bar__scroll", "scroll-left": Q.value, "scroll-with-animation": "" }, { default: p(() => [y(s, { class: "channel-bar__list" }, { default: p(() => [(a(!0), j(K, null, S(J.value, (e, t) => (a(), l(s, { key: e.channelKey, class: z(["channel-bar__item", { "channel-bar__item--active": N.value === t }]), onClick: e => ce(t) }, { default: p(() => [y(c, null, { default: p(() => [k(T(e.name), 1)]), _: 2 }, 1024)]), _: 2 }, 1032, ["class", "onClick"]))), 128))]), _: 1 })]), _: 1 }, 8, ["scroll-left"]), y(s, { class: "channel-bar__more", onClick: _e }, { default: p(() => [y(x, { name: "list", size: "38", color: "#666" })]), _: 1 })]), _: 1 }), (a(!0), j(K, null, S(ee.value, e => (a(), j(K, { key: e.id }, [ue(e) ? (a(), l(M, { key: 0, item: e }, null, 8, ["item"])) : e.is_video ? (a(), l(A, { key: 1, item: e }, null, 8, ["item"])) : (a(), l(I, { key: 2, item: e }, null, 8, ["item"]))], 64))), 128)), ae.value ? (a(), l(s, { key: 0, class: "feed-loading" }, { default: p(() => [y(D, { mode: "circle" }), y(c, { class: "feed-loading__text" }, { default: p(() => [k("加载中...")]), _: 1 })]), _: 1 })) : L("", !0), le.value && ee.value.length ? (a(), l(s, { key: 1, class: "feed-bottom" }, { default: p(() => [y(c, null, { default: p(() => [k("没有更多了")]), _: 1 })]), _: 1 })) : L("", !0), ae.value || ee.value.length ? L("", !0) : (a(), l(s, { key: 2, class: "feed-empty" }, { default: p(() => [y(c, null, { default: p(() => [k("暂无内容")]), _: 1 })]), _: 1 }))]), _: 1 }, 8, ["style"]), y(H)]), _: 1 }) } } }), [["__scopeId", "data-v-2a693eb7"]]); export { O as default };
|