init router

This commit is contained in:
2024-10-16 00:47:30 +08:00
commit 733677f3f3
32 changed files with 2185 additions and 0 deletions

13
src/utils/parse.ts Normal file
View File

@@ -0,0 +1,13 @@
export const parseIfJson = (input: string): { [key: string]: any } | string => {
try {
// 尝试解析 JSON
const parsed = JSON.parse(input);
// 检查解析结果是否为对象(数组或普通对象)
if (typeof parsed === 'object' && parsed !== null) {
return parsed;
}
} catch (e) {
// 如果解析失败,直接返回原始字符串
}
return input;
};