From 1b45f0ec74274c848ece439007a0e5ef6c3c7a70 Mon Sep 17 00:00:00 2001 From: wibus-wee <1596355173@qq.com> Date: Sun, 29 Oct 2023 11:35:16 +0800 Subject: [PATCH 1/6] =?UTF-8?q?docs:=20add=20the=20"=E5=B8=B8=E8=A7=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98"=20chapter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Icons/UnlockAlt.tsx | 7 ++ pages/docs/_meta.json | 9 ++- pages/docs/index.mdx | 6 +- pages/docs/problems.mdx | 125 +++++++++++++++++++++++++++++++++ 4 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 components/Icons/UnlockAlt.tsx create mode 100644 pages/docs/problems.mdx diff --git a/components/Icons/UnlockAlt.tsx b/components/Icons/UnlockAlt.tsx new file mode 100644 index 00000000..5f74cd1c --- /dev/null +++ b/components/Icons/UnlockAlt.tsx @@ -0,0 +1,7 @@ +import { SVGProps } from "react"; + +export function UimUnlockAlt(props: SVGProps) { + return ( + + ) +} \ No newline at end of file diff --git a/pages/docs/_meta.json b/pages/docs/_meta.json index cc7af99f..865e176d 100644 --- a/pages/docs/_meta.json +++ b/pages/docs/_meta.json @@ -8,6 +8,11 @@ "docker": "Docker 部署", "scripts": "预设脚本部署", "advanced": "进阶部署", - "extra": "拓展内容", - "community": "社区分享" + "community": "社区分享", + "-- more": { + "type": "separator", + "title": "更多" + }, + "problems": "常见问题", + "extra": "拓展内容" } \ No newline at end of file diff --git a/pages/docs/index.mdx b/pages/docs/index.mdx index 204da555..0d002f1e 100644 --- a/pages/docs/index.mdx +++ b/pages/docs/index.mdx @@ -6,7 +6,7 @@ title: 引言 **Mix Space** 是一个一款简洁而不简单的个人博客系统,它够快,够现代。你可以利用它构建一个属于自己的个人空间,记录生活,分享知识。 -在本章节,我们将完成的是 **后端** 的安装,而 **前端** 的安装则需要你阅读 [前端主题文档](/themes)。 +在本章节,我们将完成的是 **后端** 的安装,在此章节中所有的「部署」都将默认指向「后端部署」。**前端** 的安装需要你阅读 [对应的前端主题文档](/themes)。 为什么分开部署?请查看本页 [一些你需要知道的事情](#一些你需要知道的事情) 小节。 @@ -24,12 +24,14 @@ import { UilPaintTool } from '@components/Icons/PaintTool'; import { UimStar } from '@components/Icons/Star'; import { FluentPeopleCommunity } from '@components/Icons/PeopleCommunity'; import { UilExternalLinkAlt } from '@components/Icons/ExternalLinkAlt'; +import { UimUnlockAlt } from '@components/Icons/UnlockAlt'; - + } /> } /> } /> } /> + } /> } /> diff --git a/pages/docs/problems.mdx b/pages/docs/problems.mdx new file mode 100644 index 00000000..581e7120 --- /dev/null +++ b/pages/docs/problems.mdx @@ -0,0 +1,125 @@ +# 常见问题 + +如果可以,建议你先补充一下你的基本信息,这样或许可以更快的帮助你解决问题。 + +import { useState, useEffect } from "react"; +import clsx from "clsx"; + +export function BasicInfo() { + // FIX: by @wibus-wee + // dbq. 这个组件写了很严重的shit code,但是我懒得改了,主要是能在这里检查的东西并不多,甚至 CORS 都没法检查,所以就这样吧 + // shit 指: + // 1. 这个 info 居然是 Array! 但是明明只有两个,即前端和后端 + // 2. 为了解决这个问题,我居然选择了 index === 0 ? "后端服务" : "前端主题" 的方式来判断! + // 3. wibus-wee 就是个fw, 所以写啥都变成 shit code + + const [backend, setBackend] = useState("https://api.example.com"); + const [frontend, setFrontend] = useState("https://example.com"); + const [info, setInfo] = useState([ + { + https: true, + access: true, + }, + { + https: true, + access: true, + } + ]); + +return ( + + <> +
+ + + setBackend(e.target.value)} + /> +
+ +
+ + setFrontend(e.target.value)} + /> +
+ +

基本检查

+ +
+ { + info.map((i, index) => { + return ( +
+

+ { + index === 0 ? "后端服务" : "前端主题" + } +

+
+
+

+ HTTPS 前缀 + + {info.https ? "正常" : "异常"} + +

+
+
+
+

+ 连通性 + + {info.access ? "正常" : "异常"} + +

+
+
+ ) + }) + } +
+ + + ) +} + + + +## 后端服务类问题 + +### 后端 SSL 出现问题 + +### 后端 Cross-Origin 设置错误 + +### 网关、API 填错 / 填反 + +按照常理思路,即本文档所介绍的部署方式,你的网关地址应该是 + +### 内核出现问题 + +## 前端主题类问题 + +### ClientSide 报错 + +### ServerSide 报错 From a09bc34fdb793bb5ee3536172a001c762887d3dc Mon Sep 17 00:00:00 2001 From: wibus-wee <1596355173@qq.com> Date: Sun, 29 Oct 2023 11:43:47 +0800 Subject: [PATCH 2/6] chore(renovate): use the configuration from Innei [skip ci] --- .github/renovate.json | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index a325063e..07e59d7b 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,23 +1,4 @@ { - "labels": ["dependencies"], - "extends": [ - "config:base", - ":automergePatch", - ":automergeTypes", - ":automergeTesters", - ":automergeLinters", - ":rebaseStalePrs" - ], - "packageRules": [ - { - "updateTypes": [ - "major" - ], - "labels": [ - "UPDATE-MAJOR", - "dependencies" - ] - } - ], - "enabled": true + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["local>Innei/renovate-config"] } From 597e3a58898dce119719b26767648bdd5d88051d Mon Sep 17 00:00:00 2001 From: wibus-wee <1596355173@qq.com> Date: Sun, 5 Nov 2023 09:11:40 +0800 Subject: [PATCH 3/6] revert: remove BasicInfo component to improve readability and maintainability. --- pages/docs/problems.mdx | 145 +++++++++++----------------------------- 1 file changed, 38 insertions(+), 107 deletions(-) diff --git a/pages/docs/problems.mdx b/pages/docs/problems.mdx index 581e7120..eb55231e 100644 --- a/pages/docs/problems.mdx +++ b/pages/docs/problems.mdx @@ -1,125 +1,56 @@ # 常见问题 -如果可以,建议你先补充一下你的基本信息,这样或许可以更快的帮助你解决问题。 - -import { useState, useEffect } from "react"; -import clsx from "clsx"; - -export function BasicInfo() { - // FIX: by @wibus-wee - // dbq. 这个组件写了很严重的shit code,但是我懒得改了,主要是能在这里检查的东西并不多,甚至 CORS 都没法检查,所以就这样吧 - // shit 指: - // 1. 这个 info 居然是 Array! 但是明明只有两个,即前端和后端 - // 2. 为了解决这个问题,我居然选择了 index === 0 ? "后端服务" : "前端主题" 的方式来判断! - // 3. wibus-wee 就是个fw, 所以写啥都变成 shit code - - const [backend, setBackend] = useState("https://api.example.com"); - const [frontend, setFrontend] = useState("https://example.com"); - const [info, setInfo] = useState([ - { - https: true, - access: true, - }, - { - https: true, - access: true, - } - ]); - -return ( - - <> -
- - - setBackend(e.target.value)} - /> -
- -
- - setFrontend(e.target.value)} - /> -
- -

基本检查

- -
- { - info.map((i, index) => { - return ( -
-

- { - index === 0 ? "后端服务" : "前端主题" - } -

-
-
-

- HTTPS 前缀 - - {info.https ? "正常" : "异常"} - -

-
-
-
-

- 连通性 - - {info.access ? "正常" : "异常"} - -

-
-
- ) - }) - } -
- - - ) -} - - - ## 后端服务类问题 ### 后端 SSL 出现问题 +TBD. + +很多时候出现前后端联通出现问题的情况都是因为后端的 SSL 配置出现了问题,mx-space 要求前后端都需要同时配置 SSL,否则无法正常工作。 + +请检查你的后端 SSL 配置是否正确,我们推荐你使用 Caddy,使用 Caddy 可以很方便的配置 SSL + ### 后端 Cross-Origin 设置错误 +TBD. + ### 网关、API 填错 / 填反 -按照常理思路,即本文档所介绍的部署方式,你的网关地址应该是 +按照常理思路,即本文档所介绍的部署方式,你的网关地址应该是 `https://api.example.com`,而你的 API 地址应该是 `https://api.example.com/api/v2` + +二者填反,会导致前端无法正常访问 API,从而导致前端无法正常工作。 ### 内核出现问题 +TBD. + ## 前端主题类问题 ### ClientSide 报错 +> 此处是讲述如何 Debug,而非如何解决问题,这里发生的问题数不胜数,无法一一列举,建议通过 AI + Google + GitHub Issues 来解决问题 + +这是最常见的问题,也是最容易解决的问题,你只需要打开浏览器的开发者工具,查看控制台输出即可,如果你不知道如何打开浏览器的开发者工具,那么你可以通过 Google 来解决「如何打开」这个问题。 + +在截取控制台输出的时候,你可以通过截图的方式,也可以通过复制的方式,请不要只截取一部分,而是截取全部,我们发现有一些只截取报错的前几行,而不截取完整的报错信息,这样我们是无法帮助你解决问题的。 + ### ServerSide 报错 + +> 此处是讲述如何 Debug,而非如何解决问题,这里发生的问题数不胜数,无法一一列举,建议通过 AI + Google + GitHub Issues 来解决问题 + +ServerSide 报错,通常是指后端报错,这种报错通常是由于后端配置错误导致的,你可以通过查看后端的日志来解决问题。 + +如果你是使用 Vercel 部署的,查看错误日志的方式如下: + +1. 打开 Vercel 的控制台 +2. 点击你的项目 +3. 点击「Logs」 +4. 查看错误日志 + +同样的,你也可以通过截图或者复制的方式来获取完整的错误日志,但不是只截取一部分。 + +如果你是使用 Docker 部署的,查看错误日志的方式如下: + +1. 打开你的服务器 +2. 进入你的 Docker 容器 +3. 查看错误日志 \ No newline at end of file From 679f8f89246f29bdfc7bf5735a786f00c5d69150 Mon Sep 17 00:00:00 2001 From: wibus-wee <1596355173@qq.com> Date: Sun, 7 Jan 2024 17:28:36 +0800 Subject: [PATCH 4/6] =?UTF-8?q?docs:=20Docker=20MongoDB=20Container=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/docs/problems.mdx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pages/docs/problems.mdx b/pages/docs/problems.mdx index eb55231e..29c78742 100644 --- a/pages/docs/problems.mdx +++ b/pages/docs/problems.mdx @@ -24,6 +24,21 @@ TBD. TBD. +### Docker MongoDB Container 无法正常启动 + +如果您是使用 Docker 部署的 Core,更新后,你却发现 MongoDB Container 无法正常启动(一直在 `Restarting` 状态)这大概率是因为 MongoDB 大版本更新出现 BREAKING CHANGE 导致的,这种情况下,你需要锁定 MongoDB 的版本。 + +请前往 `docker-compose.yml`,锁定 MongoDB 的版本,例如: + +```diff +mongo: + container_name: mongo +- image: mongo ++ image: mongo:6.0.8 +``` + +接着重新执行 `docker-compose up -d` 即可。 + ## 前端主题类问题 ### ClientSide 报错 From a09012482aa6e572fbfba5d4d6eb7a1be2547908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AE=E5=BF=83=E7=89=A9=E8=AF=AD?= <108316419+wuhang2003@users.noreply.github.com> Date: Fri, 19 Jan 2024 16:02:08 +0800 Subject: [PATCH 5/6] add: ip error in mx-admin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 浮心物语 <108316419+wuhang2003@users.noreply.github.com> --- pages/docs/problems.mdx | 78 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/pages/docs/problems.mdx b/pages/docs/problems.mdx index 29c78742..66c3e48e 100644 --- a/pages/docs/problems.mdx +++ b/pages/docs/problems.mdx @@ -20,6 +20,80 @@ TBD. 二者填反,会导致前端无法正常访问 API,从而导致前端无法正常工作。 +### 后台无法获取 IP 归属地 + +附加功能->配置与云函数,找到位于 built-in 里边的 ip 函数,编辑替换如下内容并保存。 + +```ts +import { isIPv4, isIPv6 } from 'net' +import { URLSearchParams } from 'url' + +const TIMEOUT = 5000 + +export default async function handler(ctx: Context, timeout = TIMEOUT) { + const { ip } = ctx.req.query + + if (!ip) { ctx.res.throws(422, 'ip is empty') } + const cache = ctx.storage.cache + const hasCatch = await cache.get(ip) + if (hasCatch) return JSON.parse(hasCatch) + + const result = await getIp(ctx, ip); + await cache.set(ip, result) + return result +} + +async function getIp(ctx: Context, ip: string, timeout = TIMEOUT) { + const isV4 = isIPv4(ip) + const isV6 = isIPv6(ip) + const { axios } = await (ctx.getService('http')) + if (!isV4 && !isV6) { + ctx.throws(422, 'Invalid IP') + } + try { + const data = await axios.get('http://ip-api.com/json/' + ip).then(data => data.data) as Ip + const res: FinalIpRecord = { + cityName: data.city, + countryName: data.country, + ip: data.query, + ispDomain: data.isp, + ownerDomain: data.org, + regionName: data.regionName + + } + + return res + } catch (e) { + ctx.throws(500, `IP API 调用失败,${e.message}`) + } +}; + + +interface FinalIpRecord { + cityName: string + countryName: string + ip: string + ispDomain: string + ownerDomain: string + regionName: string +} +interface Ip { + country: string; + countryCode: string; + region: string; + regionName: string; + city: string; + zip: string; + lat: number; + lon: number; + timezone: string; + isp: string; + org: string; + as: string; + query: string; +} +``` + ### 内核出现问题 TBD. @@ -37,7 +111,7 @@ mongo: + image: mongo:6.0.8 ``` -接着重新执行 `docker-compose up -d` 即可。 +接着重新执行 `docker compose up -d` 即可。 ## 前端主题类问题 @@ -68,4 +142,4 @@ ServerSide 报错,通常是指后端报错,这种报错通常是由于后端 1. 打开你的服务器 2. 进入你的 Docker 容器 -3. 查看错误日志 \ No newline at end of file +3. 查看错误日志 From 9b696dff88c88f6dfadcab1fd8f6fd25afb5247c Mon Sep 17 00:00:00 2001 From: BLxcwg666 Date: Sat, 20 Jan 2024 22:17:01 +0800 Subject: [PATCH 6/6] fix: ip function error "[object Object]" (#50) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: ip function error "[object Object]" 由于云函数 "ip" 中 hasCatch 是 await cache.get(ip); 属于一个对象,而下面直接对这个对象用了 JSON.parse,然后会报错 "message": "Function 执行报错: \"[object Object]\" is not valid JSON" 所以需要加一个判断,确保他是一个字符串 Signed-off-by: BLxcwg666 * fix: mistakes & feat: get zh-CN data from ip-api.com Signed-off-by: BLxcwg666 --------- Signed-off-by: BLxcwg666 --- pages/docs/problems.mdx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pages/docs/problems.mdx b/pages/docs/problems.mdx index 66c3e48e..344a5db7 100644 --- a/pages/docs/problems.mdx +++ b/pages/docs/problems.mdx @@ -22,7 +22,7 @@ TBD. ### 后台无法获取 IP 归属地 -附加功能->配置与云函数,找到位于 built-in 里边的 ip 函数,编辑替换如下内容并保存。 +附加功能 → 配置与云函数,找到位于 built-in 里边的 ip 函数,编辑替换如下内容并保存。 ```ts import { isIPv4, isIPv6 } from 'net' @@ -36,7 +36,11 @@ export default async function handler(ctx: Context, timeout = TIMEOUT) { if (!ip) { ctx.res.throws(422, 'ip is empty') } const cache = ctx.storage.cache const hasCatch = await cache.get(ip) - if (hasCatch) return JSON.parse(hasCatch) + + if (hasCatch) { + const cachedData = typeof hasCatch === 'string' ? JSON.parse(hasCatch) : hasCatch; + return cachedData; + } const result = await getIp(ctx, ip); await cache.set(ip, result) @@ -51,7 +55,7 @@ async function getIp(ctx: Context, ip: string, timeout = TIMEOUT) { ctx.throws(422, 'Invalid IP') } try { - const data = await axios.get('http://ip-api.com/json/' + ip).then(data => data.data) as Ip + const data = await axios.get(`http://ip-api.com/json/${ip}?lang=zh-CN`).then(data => data.data) as Ip const res: FinalIpRecord = { cityName: data.city, countryName: data.country, @@ -68,7 +72,6 @@ async function getIp(ctx: Context, ip: string, timeout = TIMEOUT) { } }; - interface FinalIpRecord { cityName: string countryName: string @@ -77,6 +80,7 @@ interface FinalIpRecord { ownerDomain: string regionName: string } + interface Ip { country: string; countryCode: string;