From 3ebaff521866faf50e8aa60b3d3d26e054e69328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B3=E5=85=83=E7=9A=93?= Date: Mon, 2 Jun 2025 14:43:13 +0800 Subject: [PATCH] it works rn ig? --- components/app/windows/news.vue | 2 ++ components/app/windows/settings.vue | 26 +++++++++++++++++++------- pages/desktop.vue | 1 - server/api/publishers/lt/[slug].ts | 23 ++++++++++++++++++----- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/components/app/windows/news.vue b/components/app/windows/news.vue index e046e03..0d15af5 100644 --- a/components/app/windows/news.vue +++ b/components/app/windows/news.vue @@ -34,6 +34,7 @@ const switchTabs = ref(false); const tabs = ref([]); const primary = ref("top"); // Hard code value fn const canNotLoadTabUI = ref(false); +const isDataCached = ref(false); const pullTabsData = async () => { try { const req = await fetch("/api/tabs"); @@ -60,6 +61,7 @@ const updateContent = async (url: string, tabAction: boolean) => { if (data) { contentArray.value = [...data.uuidData, ...(data.nuuiddata?.items || [])]; switchTabs.value = false; + isDataCached.value = data.cached || false; } } catch (e) { console.log(e); diff --git a/components/app/windows/settings.vue b/components/app/windows/settings.vue index 1c8e51b..d2d3d63 100644 --- a/components/app/windows/settings.vue +++ b/components/app/windows/settings.vue @@ -5,12 +5,12 @@ const { t, locale } = useI18n(); const user = ref(); onMounted(async () => { const req = await fetch("/api/user/validateUserToken"); - const res = req.json(); + const res = await req.json(); user.value = res; }); const logoutAction = () => {}; -const groqApiKeyRegex = /^gsk_[a-zA-Z0-9]{52}$/; +const groqApiKeyRegex = /^gsk_[a-zA-Z0-9]{52}$/; const customApiKey = ref(); const isCorrect = ref(false); const submitCustomApiKey = async () => { @@ -27,13 +27,16 @@ const submitCustomApiKey = async () => { headers: { "Content-Type": "application/json", }, - body: JSON.stringify({}), + body: JSON.stringify({ + apiKey: apiKey, + }), }); const data = await sendApi.json(); if (data.error) { } } catch (e) {} }; + const checkValidApiKey = () => { const apiKey = customApiKey.value; if (!apiKey) { @@ -47,7 +50,7 @@ const checkValidApiKey = () => {
Greetings, {{ user }}
- Your Groq API:  + Your Groq API:  { v-on:mouseleave="checkValidApiKey" /> - - -
diff --git a/pages/desktop.vue b/pages/desktop.vue index dcd44c7..72e0a1c 100644 --- a/pages/desktop.vue +++ b/pages/desktop.vue @@ -269,7 +269,6 @@ const navBarDisplayText = (text: string) => { } const trimSpaces = text.trim(); const regex = /.{0,7}/; - console.log("asdasda"); if (trimSpaces.length <= 7) { return text; } diff --git a/server/api/publishers/lt/[slug].ts b/server/api/publishers/lt/[slug].ts index 81028f2..148724a 100644 --- a/server/api/publishers/lt/[slug].ts +++ b/server/api/publishers/lt/[slug].ts @@ -28,12 +28,25 @@ export default defineEventHandler(async (event) => { html("div.editor div figure img").attr("srcset") || html("div.editor div figure img").attr("src") || ""; + const bgImage = html("figure.keyVisual img").attr("srcset") || ""; const articles = []; - const otherArticles = html("section.moduleContainer div").html(); - /*for (const item in otherArticles) { - console.log(item); - console.log("-"); - }*/ + const regexArticleLinks = /[a-zA-Z0-9]{7}/g + const otherArticles = []; + html("a.ltcp-link") + .each((i, element) => { + const articleLink = html(element).attr("href"); + const articleTitle = html(element).find("h3.header").text(); + const date = html(element).find("div._articleCard div.css-wqleh6 span").text(); + if (articleLink && articleTitle) { + const articleSlug = articleLink.matchAll(regexArticleLinks); + otherArticles.push({ + index: i, + title: articleTitle, + link: articleSlug, + date: date, + }); + } + }); return { name: newsOrgName, description: description,