diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index e489cff..3373c88 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -4,6 +4,25 @@ import { APP_NAME } from '../config/app'; import '../styles/global.css' import '../styles/theme.css' const {description, title, keywords} = Astro.props; +import { getHost } from '../../utils/host'; +import { websiteConfig } from '../../utils/rpc'; + +// const host = await getHost(Astro.request); +// console.log(host) +// return Astro.redirect("/login"); +// if (!host) { +// return Astro.redirect('/404'); +// } + +// const {code, data} = await websiteConfig(host); + +// console.log(data) +// if (!data || code !== 0) { +// return Astro.redirect('/news'); +// } + +// console.log(data) + --- diff --git a/src/layouts/Layout_1.astro b/src/layouts/Layout_1.astro new file mode 100644 index 0000000..a23bd46 --- /dev/null +++ b/src/layouts/Layout_1.astro @@ -0,0 +1,576 @@ +--- +import Footer from '../components/Footer.astro' +import { APP_NAME } from '../config/app'; +import '../styles/global.css' +import '../styles/theme.css' +const {description, title, keywords} = Astro.props; +const {template_config} = Astro.locals; +--- + + + + + + + {title} + + + + + + +
+
+ +
+ + + +
+
+ +
+ + + + +
+ + + + + \ No newline at end of file diff --git a/src/middleware/index.ts b/src/middleware/index.ts new file mode 100644 index 0000000..d4bc306 --- /dev/null +++ b/src/middleware/index.ts @@ -0,0 +1,39 @@ +import { getHost } from "../../utils/host"; +import { websiteConfig } from "../../utils/rpc"; + +export async function onRequest (context: any, next: any) { + + // 拦截一个请求里的数据 + // 可选地修改 `locals` 中的属性 + const host = await getHost(context.request); + + if (host == 'www.zhishihuisheng.com' || host == 'zhishihuisheng.com') { + return next(); + } + + + // 防止无线跳转 + if (context.locals.is_write) { + return next(); + } + + if (!host) { + context.locals.is_write = 1; + return context.rewrite('/404'); + } + + const {code, data} = await websiteConfig(host); + if (!data || code !== 0) { + context.locals.is_write = 1; + return context.rewrite('/404'); + } + + if (!context.locals.is_write) { + context.locals.is_write = 1; + context.locals.template_number = 1; + context.locals.template_config = data; + return context.rewrite('/template/' + context.locals.template_number + context.url.pathname); + } + + return next(); +}; \ No newline at end of file diff --git a/src/pages/template/1/index.astro b/src/pages/template/1/index.astro new file mode 100644 index 0000000..7348074 --- /dev/null +++ b/src/pages/template/1/index.astro @@ -0,0 +1,744 @@ +--- +import bg from '../../../../public/bg.png'; + +import Layout from '../../../layouts/Layout_1.astro'; +import { Image } from 'astro:assets'; +import { APP_NAME, BASE_URL } from '../../../config/app'; +import { formatDateTime } from '../../../../utils/date'; + +const title = `${APP_NAME} - 开启有声阅读新方式`; +const description = '知识回声是一款超实用学习应用,涵盖海量读物,热门有声书籍,让知识触手可及'; +const keywords = '知识回声,知识回声官网,知识回声下载,知识回声官方,知识回声软件,知识回声下载,知识回声app'; + +const {template_config} = Astro.locals; +console.log(template_config) +const LDJSON = { + context: "https://ziyuan.baidu.com/contexts/cambrian.jsonld", + id: BASE_URL, + appid: "", + title: title, + image: BASE_URL + "/app-showcase.png", + pubDate: "2025-06-09T11:20:04", + updateDate: formatDateTime(), + description: description, +}; +--- + +
+
+ 背景 +
+
+

视听阅读,尽在这端

+

一款超实用学习应用,涵盖海量读物,热门有声书籍,让知识触手可及。

+ +
+
+
+ +