Remove docs and added them back? And also made the return uuid thing

now an endpoint that can be logged & cached.
This commit is contained in:
吳元皓 2025-05-20 16:29:55 +08:00
parent 5c64ae08bf
commit 0dfbdb4c91
21 changed files with 31 additions and 55 deletions

View File

@ -0,0 +1,8 @@
#!/bin/bash
cd ./docs/
npm install -g vitepress
bunx vitepress build
cd ..
cp -R ./docs/.vitepress/dist/ ./public/docs/
echo "Done :)"
exit 1

View File

@ -1 +0,0 @@
import{t as p}from"./chunks/theme.zLgzrmCh.js";import{R as s,a0 as i,a1 as u,a2 as c,a3 as l,a4 as f,a5 as d,a6 as m,a7 as h,a8 as g,a9 as A,d as v,u as y,v as C,s as P,aa as b,ab as w,ac as R,ad as E}from"./chunks/framework.WowTybjF.js";function r(e){if(e.extends){const a=r(e.extends);return{...a,...e,async enhanceApp(t){a.enhanceApp&&await a.enhanceApp(t),e.enhanceApp&&await e.enhanceApp(t)}}}return e}const n=r(p),S=v({name:"VitePressApp",setup(){const{site:e,lang:a,dir:t}=y();return C(()=>{P(()=>{document.documentElement.lang=a.value,document.documentElement.dir=t.value})}),e.value.router.prefetchLinks&&b(),w(),R(),n.setup&&n.setup(),()=>E(n.Layout)}});async function T(){globalThis.__VITEPRESS__=!0;const e=_(),a=D();a.provide(u,e);const t=c(e.route);return a.provide(l,t),a.component("Content",f),a.component("ClientOnly",d),Object.defineProperties(a.config.globalProperties,{$frontmatter:{get(){return t.frontmatter.value}},$params:{get(){return t.page.value.params}}}),n.enhanceApp&&await n.enhanceApp({app:a,router:e,siteData:m}),{app:a,router:e,data:t}}function D(){return A(S)}function _(){let e=s;return h(a=>{let t=g(a),o=null;return t&&(e&&(t=t.replace(/\.js$/,".lean.js")),o=import(t)),s&&(e=!1),o},n.NotFound)}s&&T().then(({app:e,router:a,data:t})=>{a.go().then(()=>{i(a.route,t.site),e.mount("#app")})});export{T as createApp};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,3 @@
import { gunzip } from "zlib";
import { promisify } from "util";
const gunzipAsync = promisify(gunzip);
// Check /about/scraping_line_today_home.md for more info or https://news.yuanhau.com/datainfo/linetodayjsondata.json
async function getLineTodayData(type: string) {
try {
@ -15,20 +10,28 @@ async function getLineTodayData(type: string) {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
},
});
const buffer = await req.arrayBuffer();
const decompressed = await gunzipAsync(Buffer.from(buffer));
const res = JSON.parse(decompressed.toString());
const data = res.getPageData?.[type];
return res;
const res = await req.json();
const req2 = res.pageProps.fallback["getPageData,domestic"].modules;
const req3 = [];
req2.forEach((key) => {
const listings = key.listings;
if (Array.isArray(listings)) {
listings.forEach((listing) => {
if (listing && listing.id) {
req3.push(listing.id);
}
});
} else if (listings && listings.id) {
req3.push(listings.id);
}
});
return req3;
} catch (e) {
console.log(e);
}
}
async function demo() {
console.log(await getLineTodayData("domestic"));
}
demo();
//export default getLineTodayData;
export default defineEventHandler(async (event) => {
const slug = getRouterParam(event, "slug");
return await getLineTodayData(slug);
});

View File

@ -0,0 +1,3 @@
export default defineEventHandler((event) => {
return sendRedirect(event, "/datainfo/linetodayjsondata.json", 302);
});

View File

@ -1,35 +0,0 @@
{
pageProps: {
__lang: "tw",
__namespaces: {
common: [Object ...],
forYou: [Object ...],
video: [Object ...],
quiz: [Object ...],
poll: [Object ...],
},
runtimeConfig: {
countryConfig: [Object ...],
COMMIT_SHA: "fb546888",
DEPLOY_ENV: "release",
SENTRY_DSN: "https://8ca685e4ca2f4b2ba32b4459381f91b8@sentry-uit.line-apps.com/475",
},
_sentryTraceData: "5c81d62ef22d861e5555ee0e170bd82b-a6d22f47579e751a-1",
_sentryBaggage: "sentry-environment=release,sentry-release=release%40fb546888,sentry-public_key=8ca685e4ca2f4b2ba32b4459381f91b8,sentry-trace_id=5c81d62ef22d861e5555ee0e170bd82b,sentry-transaction=getServerSideProps%20%2Fv3%2Ftab%2F%5B%5B...tabs%5D%5D,sentry-sampled=true",
articleDedupeState: {
pool: [Object ...],
serverPool: [Object ...],
},
fallback: {
getTabsData: [Object ...],
"getPageData,domestic": [Object ...],
"5e4ceeda408f3c5ca031940d_{\"offset\":5,\"length\":3}": [
[Object ...], [Object ...], [Object ...]
],
"5e4cee49408f3c5ca031940b_{\"offset\":0,\"length\":5}": [
[Object ...], [Object ...], [Object ...], [Object ...], [Object ...]
],
},
},
__N_SSP: true,
}