Skip to content

Commit

Permalink
perf: 删除国际化模块相关代码
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwumm committed Jan 3, 2025
1 parent 1eeb4f6 commit e810665
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 92 deletions.
11 changes: 11 additions & 0 deletions prisma/migrations/20250103070539_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- You are about to drop the `Internalization` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "Internalization" DROP CONSTRAINT "Internalization_parentId_fkey";

-- DropTable
DROP TABLE "Internalization";
13 changes: 0 additions & 13 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,3 @@ model User {
createdAt DateTime @default(now()) // 创建时间
updatedAt DateTime @updatedAt // 更新时间
}

// 系统管理 - 国际化
model Internalization {
id String @id @default(uuid()) // 主键
name String // 键
parentId String? // 父级
parent Internalization? @relation(name: "InternalizationHierarchy", fields: [parentId], references: [id])
zh String? // 中文
en String? // 英文
createdAt DateTime @default(now()) // 创建时间
updatedAt DateTime @updatedAt // 更新时间
children Internalization[] @relation(name: "InternalizationHierarchy")
}
31 changes: 0 additions & 31 deletions src/app/api/auth/locales/route.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2024-12-06 10:31:59
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2025-01-02 12:05:20
* @LastEditTime: 2025-01-03 15:03:42
* @Description: 404页面
*/

Expand All @@ -13,7 +13,7 @@ export default function NotFound() {
return (
<div className="flex justify-center items-center flex-col w-full gap-6" style={{ height: 'calc(100vh - 8.4rem)' }}>
<h2 className="font-black text-xl">客官,你走丢了哟!😉</h2>
<Link href="/">
<Link href="/dashboard">
<Button color="primary">返回首页</Button>
</Link>
</div>
Expand Down
35 changes: 0 additions & 35 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,41 +60,6 @@ export function convertFlatDataToTree<T extends NodeBase>(items: T[]): TreeNode<
return roots;
}

/**
* @description: 将树形树形转成层级对象
*/
export const convertToLocalization = (data: App.SystemManage.Internalization[]): App.Auth.Locales => {
const result: App.Auth.Locales = {
zh: {},
en: {},
};

function buildNestedObject(
item: App.SystemManage.Internalization & {
children?: App.SystemManage.Internalization[];
},
obj: Record<string, any>,
lang: App.Common.Langs,
) {
if (item.children) {
obj[item.name] = {};
for (const child of item.children) {
buildNestedObject(child, obj[item.name], lang);
}
} else {
obj[item.name] = item[lang];
}
}

for (const lang of Object.values(LOCALES)) {
for (const item of data) {
buildNestedObject(item, result[lang], lang);
}
}

return result;
};

/**
* @description: 判断请求是否成功
*/
Expand Down
12 changes: 1 addition & 11 deletions src/typings/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ declare namespace App {
};
}
namespace SystemManage {
/** @description: 国际化 */
/** @description: 用户管理 */
type User = import('@prisma/client').User;
/** @description: 查询参数 */
type UserSearchParams = Common.PaginatingParams & {
Expand All @@ -44,15 +44,5 @@ declare namespace App {
/** @description: 保存参数 */
type UserSaveParams = Partial<Pick<User, 'id' | 'avatar'>> &
Pick<User, 'userName' | 'password' | 'cnName' | 'email' | 'phone' | 'sex' | 'status' | 'sort'>;
/** @description: 国际化 */
type Internalization = import('@prisma/client').Internalization;
/** @description: 查询参数 */
type InternalizationSearchParams = {
name?: string;
zh?: string;
};
/** @description: 保存参数 */
type InternalizationSaveParams = Partial<Pick<Internalization, 'id' | 'parentId' | 'zh' | 'en'>> &
Pick<Internalization, 'name'>;
}
}

0 comments on commit e810665

Please sign in to comment.