{children}
-
+
diff --git a/mdx-components.tsx b/mdx-components.tsx deleted file mode 100644 index d052e70..0000000 --- a/mdx-components.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import type { MDXComponents } from 'mdx/types' - -export function useMDXComponents(components: MDXComponents): MDXComponents { - return { - h1: (props) =>
, - h2: (props) => , - h3: (props) => , - ...components, - } -} \ No newline at end of file diff --git a/next.config.mjs b/next.config.mjs index 3182546..bf50f14 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,10 +1,14 @@ /** @type {import('next').NextConfig} */ const nextConfig = { output: 'export', + reactStrictMode: true, pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx'], + images: { unoptimized: true } } import remarkGfm from 'remark-gfm' import remarkMath from 'remark-math' +import remarkFrontmatter from 'remark-frontmatter'; +import remarkMdxFrontmatter from 'remark-mdx-frontmatter'; import rehypeKatex from 'rehype-katex' import rehypeHighlight from 'rehype-highlight' import rehypePrettyCode from 'rehype-pretty-code'; @@ -17,8 +21,19 @@ import createMDX from '@next/mdx' const withMDX = createMDX({ // Add markdown plugins here, as desired options: { - remarkPlugins: [remarkGfm, remarkMath, [remarkEmbedder, { transformers: [oembedTransformer] }]], - rehypePlugins: [rehypeAutolinkHeadings, rehypePrettyCode, rehypeKatex, rehypeHighlight,], + remarkPlugins: [ + remarkGfm, + remarkMath, + [remarkEmbedder, { transformers: [oembedTransformer] }], + remarkFrontmatter, + [remarkMdxFrontmatter, { name: 'frontmatter' }] + ], + rehypePlugins: [ + rehypeAutolinkHeadings, + rehypePrettyCode, + rehypeKatex, + rehypeHighlight, + ], }, }) // Merge MDX config with Next.js config diff --git a/package.json b/package.json index 43fbd38..6deba64 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,10 @@ "rehype-highlight": "^7.0.0", "rehype-katex": "^7.0.0", "rehype-pretty-code": "^0.10.2", + "remark-frontmatter": "^5.0.0", "remark-gfm": "^4.0.0", "remark-math": "^6.0.0", + "remark-mdx-frontmatter": "^4.0.0", "shiki": "^0.14.5" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b08b49d..273bfd7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -80,12 +80,18 @@ dependencies: rehype-pretty-code: specifier: ^0.10.2 version: 0.10.2(shiki@0.14.5) + remark-frontmatter: + specifier: ^5.0.0 + version: 5.0.0 remark-gfm: specifier: ^4.0.0 version: 4.0.0 remark-math: specifier: ^6.0.0 version: 6.0.0 + remark-mdx-frontmatter: + specifier: ^4.0.0 + version: 4.0.0 shiki: specifier: ^0.14.5 version: 0.14.5 @@ -5376,6 +5382,14 @@ packages: resolution: {integrity: sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==} dev: false + /estree-util-value-to-estree@3.0.1: + resolution: {integrity: sha512-b2tdzTurEIbwRh+mKrEcaWfu1wgb8J1hVsgREg7FFiecWwK/PhO8X0kyc+0bIcKNtD4sqxIdNoRy6/p/TvECEA==} + engines: {node: '>=16.0.0'} + dependencies: + '@types/estree': 1.0.4 + is-plain-obj: 4.1.0 + dev: false + /estree-util-visit@2.0.0: resolution: {integrity: sha512-m5KgiH85xAhhW8Wta0vShLcUvOsh3LLPI2YVwcbio1l7E09NTLL1EyMZFM1OyWowoH0skScNbhOPl4kcBgzTww==} dependencies: @@ -5498,6 +5512,12 @@ packages: dependencies: reusify: 1.0.4 + /fault@2.0.1: + resolution: {integrity: sha512-WtySTkS4OKev5JtpHXnib4Gxiurzh5NCGvWrFaZ34m6JehfTUhKZvn9njTfw48t6JumVQOmrKqpmGcdwxnhqBQ==} + dependencies: + format: 0.2.2 + dev: false + /file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -5662,6 +5682,11 @@ packages: mime-types: 2.1.35 dev: false + /format@0.2.2: + resolution: {integrity: sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==} + engines: {node: '>=0.4.x'} + dev: false + /fraction.js@4.3.7: resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==} dev: true @@ -7224,6 +7249,19 @@ packages: - supports-color dev: false + /mdast-util-frontmatter@2.0.1: + resolution: {integrity: sha512-LRqI9+wdgC25P0URIJY9vwocIzCcksduHQ9OF2joxQoyTNVduwLAFUzjoopuRJbJAReaKrNQKAZKL3uCMugWJA==} + dependencies: + '@types/mdast': 4.0.2 + devlop: 1.1.0 + escape-string-regexp: 5.0.0 + mdast-util-from-markdown: 2.0.0 + mdast-util-to-markdown: 2.1.0 + micromark-extension-frontmatter: 2.0.0 + transitivePeerDependencies: + - supports-color + dev: false + /mdast-util-gfm-autolink-literal@2.0.0: resolution: {integrity: sha512-FyzMsduZZHSc3i0Px3PQcBT4WJY/X/RCtEJKuybiC6sjPqLv7h1yqAkmILZtuxMSsUyaLUWNp71+vQH2zqp5cg==} dependencies: @@ -7438,6 +7476,15 @@ packages: micromark-util-types: 2.0.0 dev: false + /micromark-extension-frontmatter@2.0.0: + resolution: {integrity: sha512-C4AkuM3dA58cgZha7zVnuVxBhDsbttIMiytjgsM2XbHAB2faRVaHRle40558FBN+DJcrLNCoqG5mlrpdU4cRtg==} + dependencies: + fault: 2.0.1 + micromark-util-character: 2.0.1 + micromark-util-symbol: 2.0.0 + micromark-util-types: 2.0.0 + dev: false + /micromark-extension-gfm-autolink-literal@2.0.0: resolution: {integrity: sha512-rTHfnpt/Q7dEAK1Y5ii0W8bhfJlVJFnJMHIPisfPK3gpVNuOP0VnRl96+YJ3RYWV/P4gFeQoGKNlT3RhuvpqAg==} dependencies: @@ -8834,6 +8881,17 @@ packages: resolution: {integrity: sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==} engines: {node: '>= 0.10'} + /remark-frontmatter@5.0.0: + resolution: {integrity: sha512-XTFYvNASMe5iPN0719nPrdItC9aU0ssC4v14mH1BCi1u0n1gAocqcujWUrByftZTbLhRtiKRyjYTSIOcr69UVQ==} + dependencies: + '@types/mdast': 4.0.2 + mdast-util-frontmatter: 2.0.1 + micromark-extension-frontmatter: 2.0.0 + unified: 11.0.4 + transitivePeerDependencies: + - supports-color + dev: false + /remark-gfm@4.0.0: resolution: {integrity: sha512-U92vJgBPkbw4Zfu/IiW2oTZLSL3Zpv+uI7My2eq8JxKgqraFdU8YUGicEJCEgSbeaG+QDFqIcwwfMTOEelPxuA==} dependencies: @@ -8858,6 +8916,17 @@ packages: - supports-color dev: false + /remark-mdx-frontmatter@4.0.0: + resolution: {integrity: sha512-PZzAiDGOEfv1Ua7exQ8S5kKxkD8CDaSb4nM+1Mprs6u8dyvQifakh+kCj6NovfGXW+bTvrhjaR3srzjS2qJHKg==} + dependencies: + '@types/mdast': 4.0.2 + estree-util-is-identifier-name: 3.0.0 + estree-util-value-to-estree: 3.0.1 + toml: 3.0.0 + unified: 11.0.4 + yaml: 2.3.3 + dev: false + /remark-mdx@3.0.0: resolution: {integrity: sha512-O7yfjuC6ra3NHPbRVxfflafAj3LTwx3b73aBvkEFU5z4PsD6FD4vrqJAkE5iNGLz71GdjXfgRqm3SQ0h0VuE7g==} dependencies: @@ -9757,6 +9826,10 @@ packages: through2: 2.0.5 dev: true + /toml@3.0.0: + resolution: {integrity: sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==} + dev: false + /trim-lines@3.0.1: resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==} dev: false diff --git a/public/Background.png b/public/Background.png new file mode 100644 index 0000000..cc2fbd1 Binary files /dev/null and b/public/Background.png differ diff --git a/src/app/Docs/config/sidebar.tsx b/src/app/Docs/config/sidebar.tsx new file mode 100644 index 0000000..7192689 --- /dev/null +++ b/src/app/Docs/config/sidebar.tsx @@ -0,0 +1,9 @@ +import { Sidebar } from "./typeSidebar"; + +const sidebarConfig: Sidebar = [ + { "title": "前言", "path": "Preface.mdx" }, + { "title": "内核介绍", "path": "Kernels/Introduction.mdx" }, + { "title": "KernelSU", "path": "Kernels/KernelSU.mdx" } +] + +export default sidebarConfig; diff --git a/src/app/Docs/config/typeSidebar.tsx b/src/app/Docs/config/typeSidebar.tsx new file mode 100644 index 0000000..d8129c1 --- /dev/null +++ b/src/app/Docs/config/typeSidebar.tsx @@ -0,0 +1,7 @@ + +export type Sidebar = SidebarItem[] + +export type SidebarItem = { + title: string + path: string +} \ No newline at end of file diff --git a/src/app/Docs/content/Kernels/Introduction.mdx b/src/app/Docs/content/Kernels/Introduction.mdx new file mode 100644 index 0000000..1660263 --- /dev/null +++ b/src/app/Docs/content/Kernels/Introduction.mdx @@ -0,0 +1,13 @@ +# 安卓内核介绍 + +> 对于内核的基础知识,可以阅读[让 Android 手机更省电流畅,你可以试试「刷内核」](https://sspai.com/post/56296)一文。 + +## 内核的重要性 + +Android 设备的启动分为三个阶段: + +- Boot Loader: Android 设备打开电源后,首先会从处理器片上 ROM 的启动引导代码开始执行,寻找 Bootloader 代码,并加载到内存。(这一步由“芯片厂商”负责设计和实现) +- Linux Kernel: Bootloader 开始执行,首先负责完成硬件的初始化,然后找到 Linux 内核代码,并加载到内存。(这一步由“设备厂商”负责设计和实现) +- Android 系统服务: Linux 内核开始启动,初始化各种软硬件环境,加载驱动程序,挂载根文件系统,并执行 init 程序,由此开启 Android 的世界。(这一步则是 Android 内核开发过程中需要涉及的地方) + +Android 系统实际上是运行在 Linux Kernel 之上的一系列系统服务进程。 diff --git a/src/app/Docs/content/Kernels/KernelSU.mdx b/src/app/Docs/content/Kernels/KernelSU.mdx new file mode 100644 index 0000000..926b5a1 --- /dev/null +++ b/src/app/Docs/content/Kernels/KernelSU.mdx @@ -0,0 +1,79 @@ +--- +title: Privacy policy +description: The privacy of your data... +--- + +# KernelSU + +顾名思义,`KernelSU` 就是基于内核的 `SU` 。它通过自定义内核,直接在内核中赋予目标进程 `Root` 权限。 + +## 前身 + +大约 2018 年的时候,XDA 上的 `zx2c4` 就给出了一个 [KernelSU 的简单实现](https://git.zx2c4.com/kernel-assisted-superuser/);虽然整个实现非常简单,但它的确给我们展示了另外一种可能。 + +后来,LSPosed 团队在实现 WSA 的 Magisk 方案的时候,也曾通过 `KernelSU` 来 root [WSA](https://github.com/LSPosed/WSA-Kernel-SU)。 + +在 [GKI 2.0](https://source.android.com/docs/core/architecture/kernel/generic-kernel-image?hl=zh-cn) 出现之前,各厂商的内核都是各自为战,因此内核碎片化严重,因此当时 `KernelSU` 并不能成为一个通用的 Root 方案。而随着 [GKI 2.0](https://source.android.com/docs/core/architecture/kernel/generic-kernel-image?hl=zh-cn) 的出现,内核逐渐在各个手机之间通用,使得 `KernelSU` 的推广也成为了可能。 + +## 特性 + +- 基于内核的 su 和权限管理。 +- 基于 overlayfs 的模块系统。 + +## KernelSU 安装 + +### 1. 检查您的设备是否被支持 + +从 [GitHub Releases](https://github.com/tiann/KernelSU/releases) 或 [酷安](https://www.coolapk.com/apk/me.weishu.kernelsu) 下载 `KernelSU` 管理器应用,然后将应用程序安装到设备并打开: + +- 如果应用程序显示 “不支持”,则表示您的设备不支持 `KernelSU`,你需要自己编译设备的内核才能使用,`KernelSU` 官方不会也永远不会为你提供一个可以刷写的 `boot` 镜像。 +- 如果应用程序显示 “未安装”,那么 `KernelSU` 支持您的设备;可以进行下一步操作。 + +> 任何刷机操作都是有风险的,请务必做好备份。 + +### 2. KMI 查看 + +`KMI` 全称 `Kernel Module Interface`,相同 `KMI` 的内核版本是**兼容的** 这也是 `GKI` 中“通用”的含义所在;反之,如果 `KMI` 不同,那么这些内核之间无法互相兼容,刷入与你设备 `KMI` 不同的内核镜像可能会导致死机。 + +具体来说,对 `GKI` 的设备,其内核版本格式应该如下: + +```bash +KernelRelease := +Version.PatchLevel.SubLevel-AndroidRelease-KmiGeneration-suffix +w .x .y -zzz -k -something +``` + +其中,`w.x-zzz-k` 为 `KMI` 版本。例如,一个设备内核版本为`5.10.101-android12-9-g30979850fc20`,那么它的 KMI 为 `5.10-android12-9`;理论上刷入其他这个 `KMI` 的内核也能正常开机。 + +> 请注意,内核版本中的 `SubLevel` 不属于 `KMI` 的范畴!也就是说 `5.10.101-android12-9-g30979850fc20` 与 `5.10.137-android12-9-g30979850fc20` 的 `KMI` 相同!(只看前两个版本号) +> +> 同时,内核版本与 Android 版本也并不一定相同。如果您发现您的内核版本是 `android12-5.10.101`,然而你 Android 系统的版本为 Android 13 或者其他这并不会影响什么。如果你需要刷机,请以内核版本为准。 + +### 3. 安装 + +KernelSU 的安装方法有如下几种,各自适用于不同的场景,请按需选择: + +1. 使用自定义 Recovery(如 TWRP)安装 +2. 使用内核刷写 App,如 (Franco Kernel Manager)安装 +3. 使用 KernelSU 提供的 boot.img 使用 fastboot 安装 +4. 手动修补 boot.img 然后安装 + +具体操作过程可以查看[官方文档](https://kernelsu.org/zh_CN/guide/installation.html#%E5%AE%89%E8%A3%85%E4%BB%8B%E7%BB%8D)。 + +## 如何为非 GKI 内核集成 KernelSU + +请查阅[官方文档](https://kernelsu.org/zh_CN/guide/how-to-integrate-for-non-gki.html)以及本博客中的[内核编译教程](/Topic/Android/ROM/Kernel/Compile.md)。 + +一些现成的第三方 KernelSU 提供请查看[非官方支持设备](https://kernelsu.org/zh_CN/guide/unofficially-support-devices.html#%E9%9D%9E%E5%AE%98%E6%96%B9%E6%94%AF%E6%8C%81%E8%AE%BE%E5%A4%87)。 + +## 必备模块 + +- [ZygiskOnKernelSU](https://github.com/Dr-TSNG/ZygiskOnKernelSU): 使用 `KernelSU` 运行 `Zygisk` + +> 刷入上面的模块后,其他常用模块直接刷入,部分模块可能存在问题。 + +## 参考 + +- [KernelSU 官网](https://kernelsu.org/zh_CN/guide/installation.html) +- [何为 Root?](https://mp.weixin.qq.com/s?__biz=MjM5Njg5ODU2NA==&mid=2257499009&idx=1&sn=3cfce1ea7deb6e0e4f2ac170cffd7cc1&scene=21#wechat_redirect) +- [KernelSU: 内核 ROOT 方案,来了!](https://mp.weixin.qq.com/s?__biz=MjM5Njg5ODU2NA==&mid=2257500703&idx=1&sn=31e8d32ee4ac1122764db58d320493c4&chksm=a598287492efa1625dfc4ad932dee0f05d03acd834d7bd5b44daa657a1188aa5fc243fdf6329&scene=21#wechat_redirect) diff --git a/src/app/Docs/content/Preface.mdx b/src/app/Docs/content/Preface.mdx new file mode 100644 index 0000000..4113c2a --- /dev/null +++ b/src/app/Docs/content/Preface.mdx @@ -0,0 +1,3 @@ +# 前言 + +这个Github操作可以帮助您构建内核。它从配置文件中读取多个内核源,并使用不同的工具链构建它们。此外,它还支持使用KernelSU修补内核,并上传构建的内核映像。 \ No newline at end of file diff --git a/src/app/Docs/page.tsx b/src/app/Docs/page.tsx new file mode 100644 index 0000000..7dfe96a --- /dev/null +++ b/src/app/Docs/page.tsx @@ -0,0 +1,56 @@ +"use client"; + +import { useState } from 'react'; + +import dynamic from 'next/dynamic' +import Loading from '@/components/Loading' + +import Divider from '@mui/material/Divider'; +import Stack from '@mui/material/Stack'; +import Button from '@mui/material/Button'; +import { Card, CardHeader, CardBody, CardFooter } from "@nextui-org/card"; + +import sidebarConfig from './config/sidebar'; +import type { SidebarItem } from "@/app/Docs/config/typeSidebar"; + +const Docs = () => { + const [curPage, setCurPage] = useState("Preface.mdx") + const prefixPath = "./content/" + const getContentPath = (subPath: string) => { + const DynamicComponent = dynamic(() => import(`${prefixPath}${subPath}`), { + loading: () =>DogDay
diff --git a/src/mdx-components.tsx b/src/mdx-components.tsx new file mode 100644 index 0000000..fe21864 --- /dev/null +++ b/src/mdx-components.tsx @@ -0,0 +1,28 @@ +import type { MDXComponents } from 'mdx/types' + +import Link from '@mui/material/Link'; +import Image from 'next/image' + +// This file allows you to provide custom React components +// to be used in MDX files. You can import and use any +// React component you want, including inline styles, +// components from other libraries, and more. + +export function useMDXComponents(components: MDXComponents): MDXComponents { + return { + // Allows customizing built-in components, e.g. to add styling. + h1: ({ children }) =>{children}
, + Link: props => , + // img: (props) => ( + //