diff --git a/src/app/[locale]/do-not-write-on-this-page/page.tsx b/src/app/[locale]/do-not-write-on-this-page/page.tsx
index 9e717eb..450f4ab 100644
--- a/src/app/[locale]/do-not-write-on-this-page/page.tsx
+++ b/src/app/[locale]/do-not-write-on-this-page/page.tsx
@@ -36,7 +36,7 @@ export default function Page() {
{t("toolTitle")}
-
+
{/* Features Section */}
diff --git a/src/app/[locale]/editor/[data]/page.tsx b/src/app/[locale]/editor/[data]/page.tsx
index cd02ba4..488077f 100644
--- a/src/app/[locale]/editor/[data]/page.tsx
+++ b/src/app/[locale]/editor/[data]/page.tsx
@@ -1,5 +1,5 @@
import { OnlyPage } from "@/components/editor/OnlyPage";
-import { decodeText } from "@/lib/utils";
+import { decode } from "@/lib/utils";
import { Metadata } from "next";
import { getTranslations } from "next-intl/server";
@@ -7,20 +7,21 @@ export default async function Page({ params }: { params: Promise<{ data: string
const { data } = await params
- let backgroundProp, textProp
+ let backgroundProp, textProp, effectProp
if (data) {
try {
- const { bg, text } = JSON.parse(decodeText(data));
+ const { bg, text, effect } = decode(data);
backgroundProp = bg;
textProp = text;
+ effectProp = effect;
} catch (error) {
console.error("parse data from url error", error)
}
}
- return ()
+ return ()
}
@@ -39,8 +40,7 @@ export async function generateMetadata({
if (data) {
try {
- const { bg, text } = JSON.parse(decodeText(data));
-
+ const { bg, text } = decode(data);
backgroundProp = bg;
textProp = text;
} catch (error) {
diff --git a/src/app/[locale]/editor/page.tsx b/src/app/[locale]/editor/page.tsx
index 5dcb936..6f85e3f 100644
--- a/src/app/[locale]/editor/page.tsx
+++ b/src/app/[locale]/editor/page.tsx
@@ -7,7 +7,7 @@ import { Metadata } from "next";
import { getTranslations } from "next-intl/server";
const host = process.env.NEXT_PUBLIC_HOST;
export default function Page() {
- return ()
+ return ()
}
const locales = Locales;
diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx
index a34490e..d45fda1 100644
--- a/src/app/[locale]/layout.tsx
+++ b/src/app/[locale]/layout.tsx
@@ -4,7 +4,7 @@ import { routing } from "@/i18n/routing";
import { getTranslations, setRequestLocale } from "next-intl/server";
import { jsonLdScriptProps } from "react-schemaorg";
import { WebSite } from "schema-dts";
-import { Geist, Geist_Mono } from "next/font/google";
+// import { Geist, Geist_Mono } from "next/font/google";
import { Analytics } from "@vercel/analytics/react";
import { SpeedInsights } from "@vercel/speed-insights/next";
import "../globals.css";
@@ -12,15 +12,15 @@ import { ThemeProvider } from "next-themes";
import { Theme } from "@radix-ui/themes";
const host = process.env.NEXT_PUBLIC_HOST;
-const geistSans = Geist({
- variable: "--font-geist-sans",
- subsets: ["latin"],
-});
+// const geistSans = Geist({
+// variable: "--font-geist-sans",
+// subsets: ["latin"],
+// });
-const geistMono = Geist_Mono({
- variable: "--font-geist-mono",
- subsets: ["latin"],
-});
+// const geistMono = Geist_Mono({
+// variable: "--font-geist-mono",
+// subsets: ["latin"],
+// });
export default async function RootLayout({
children,
@@ -66,7 +66,7 @@ export default async function RootLayout({
/>
diff --git a/src/app/[locale]/page.tsx b/src/app/[locale]/page.tsx
index 662b734..1cb70ce 100644
--- a/src/app/[locale]/page.tsx
+++ b/src/app/[locale]/page.tsx
@@ -41,7 +41,7 @@ export default function HomePage() {
{t("toolTitle")}
-
+
diff --git a/src/components/common/PreviewToolbar.tsx b/src/components/common/PreviewToolbar.tsx
index c96afd2..9d51bb6 100644
--- a/src/components/common/PreviewToolbar.tsx
+++ b/src/components/common/PreviewToolbar.tsx
@@ -6,7 +6,7 @@ import { BackgroundProp } from "./BackgroundSelector";
import { Text, Flex, Button, Select, AlertDialog, Code, AspectRatio } from "@radix-ui/themes";
import { getPicture, resize, init as threeInit, updateBackground, updateEffectProp, updateTextProp } from "./ThreeTools";
import { TextProp } from "./TextSetting";
-import { encodeText, getShareLink } from "@/lib/utils";
+import { getShareLink } from "@/lib/utils";
import { EffectProp } from "./Effects";
const Sizes = [
@@ -198,11 +198,8 @@ export default function PreviewToolbar({
}
const bg = { ...background, image: null };
- let txt = JSON.stringify({ bg, text });
- txt = encodeText(txt);
-
- const link = getShareLink(txt, locale);
+ const link = getShareLink({ bg, text }, locale);
setShareLink(link);
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index b9eccc1..f9690d0 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -2,18 +2,21 @@ import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
import CryptoJS from "crypto-js";
import LZString from "lz-string";
+import { BackgroundProp } from "@/components/common/BackgroundSelector";
+import { EffectProp } from "@/components/common/Effects";
+import { TextProp } from "@/components/common/TextSetting";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
const SECRET_KEY = "fast3dtext-ymk";
-export function encodeText(text: string) {
+function encodeText(text: string) {
const compressed = LZString.compressToEncodedURIComponent(text);
const encrypted = CryptoJS.AES.encrypt(compressed, SECRET_KEY).toString();
return encodeURIComponent(encrypted);
}
-export function decodeText(encodedText: string) {
+function decodeText(encodedText: string) {
const decoded = decodeURIComponent(encodedText);
const decrypted = CryptoJS.AES.decrypt(decoded, SECRET_KEY).toString(
CryptoJS.enc.Utf8
@@ -22,6 +25,16 @@ export function decodeText(encodedText: string) {
return decompressed;
}
-export function getShareLink(data: string, locale: string) {
- return `${window.location.origin}/${locale}/editor/${data}`;
+export interface ShareObj {
+ bg: BackgroundProp;
+ text: TextProp;
+ effect?: EffectProp;
+}
+export function getShareLink(data: ShareObj, locale: string) {
+ const dataStr = JSON.stringify(data);
+ return `${window.location.origin}/${locale}/editor/${encodeText(dataStr)}`;
+}
+export function decode(data: string) {
+ const decoded = decodeText(data);
+ return JSON.parse(decoded) as ShareObj;
}