Skip to content

Commit

Permalink
feta: tag 中文化
Browse files Browse the repository at this point in the history
  • Loading branch information
youyou-sudo committed Dec 18, 2024
1 parent e32b01c commit 5c1a901
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/[vnid]/(action)/vndbGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const vndbdatagsdata = async (ref: any) => {
select: {
gid: true,
name: true,
name_zh: true,
applicable: true,
defaultspoil: true,
},
Expand Down
2 changes: 1 addition & 1 deletion app/[vnid]/(components)/ContentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function ContentCard({ data, fullsereenfill }: ContentCardProps) {
href={`/tag/${item.tags.gid}`}
prefetch={true}
>
{item.tags.name}
{item.tags.name_zh || item.tags.name}
</Link>
<span className="ml-1 text-slate-500" style={{ fontSize: "10px" }}>
{item.average_rating}
Expand Down
13 changes: 12 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { Navbar } from "@/components/navbar";
import { Toaster } from "@/components/ui/toaster";
import AuthProvider from "./(auth)/(components)/AuthProvider";
import { PublicEnvScript } from "next-runtime-env";
import Script from "next/script";
import prisma from "@/lib/prisma";

export const metadata: Metadata = {
openGraph: {
Expand Down Expand Up @@ -37,11 +39,16 @@ export const viewport: Viewport = {
],
};

export default function RootLayout({
export default async function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const umami = await prisma.siteConfig.findFirst({
where: {
type: "umami",
},
});
return (
<html suppressHydrationWarning lang="zh-CN">
<head>
Expand All @@ -68,6 +75,10 @@ export default function RootLayout({
</Providers>
</AuthProvider>
</body>
<Script
src={`https://${umami?.value?.umami_id}/script.js`}
strategy="afterInteractive"
/>
</html>
);
}
1 change: 1 addition & 0 deletions app/tag/[gid]/(action)/Tagvndb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export async function tagsvndbInfo({
select: {
gid: true,
name: true,
name_zh: true,
alias: true,
description: true,
vndbdatas: {
Expand Down
2 changes: 1 addition & 1 deletion app/tag/[gid]/(components)/TagsContentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function TagsContentCard({ data }: { data: any }) {
<CardBody>
<div className="text-center">
<h1 className="text-xl select-all font-bold sm:text-2xl md:text-3xl lg:text-4xl">
#{data.giddata.name}
#{data.giddata.name_zh || data.giddata.name}
</h1>
{data.giddata.alias
.split("\\n") // 将字符串按 '\n' 分割
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"ioredis": "^5.4.1",
"lucide-react": "^0.452.0",
"motion": "12.0.0-alpha.2",
"next": "^15.0.2",
"next": "^15.1.1",
"next-auth": "^5.0.0-beta.25",
"next-runtime-env": "^3.2.2",
"next-themes": "^0.2.1",
Expand Down
14 changes: 14 additions & 0 deletions prisma/migrations/20241130043049_umami/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- AlterTable
ALTER TABLE "_duptimesTomeilisearchdatas" ADD CONSTRAINT "_duptimesTomeilisearchdatas_AB_pkey" PRIMARY KEY ("A", "B");

-- DropIndex
DROP INDEX "_duptimesTomeilisearchdatas_AB_unique";

-- CreateTable
CREATE TABLE "siteConfig" (
"id" SERIAL NOT NULL,
"umami" TEXT,
"umami_id" TEXT,

CONSTRAINT "siteConfig_pkey" PRIMARY KEY ("id")
);
13 changes: 13 additions & 0 deletions prisma/migrations/20241130043411_configsite/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Warnings:
- You are about to drop the column `umami` on the `siteConfig` table. All the data in the column will be lost.
- You are about to drop the column `umami_id` on the `siteConfig` table. All the data in the column will be lost.
- Added the required column `type` to the `siteConfig` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "siteConfig" DROP COLUMN "umami",
DROP COLUMN "umami_id",
ADD COLUMN "type" TEXT NOT NULL,
ADD COLUMN "value" JSONB;
2 changes: 2 additions & 0 deletions prisma/migrations/20241218150752_tag_name_zh/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "tags" ADD COLUMN "name_zh" TEXT;
7 changes: 7 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ model tags {
searchable String
applicable String
name String
name_zh String?
alias String
description String
vndbdatas tags_vndatas[]
Expand Down Expand Up @@ -109,3 +110,9 @@ model users {
twoFactor String?
identity String
}

model siteConfig {
id Int @id @default(autoincrement())
type String
value Json?
}

0 comments on commit 5c1a901

Please sign in to comment.