diff --git a/packages/web-examples/next-example/src/app/BackgroundRemoval.tsx b/packages/web-examples/next-example/src/app/BackgroundRemoval.tsx index c0832d0..4e4cad9 100644 --- a/packages/web-examples/next-example/src/app/BackgroundRemoval.tsx +++ b/packages/web-examples/next-example/src/app/BackgroundRemoval.tsx @@ -21,14 +21,14 @@ const BackgroundRemoval = () => { const [isRunning, setIsRunning] = useState(false); const [seconds, setSeconds] = useState('0'); const [startDate, setStartDate] = useState(Date.now()); - const [caption, setCaption] = useState('Click me to remove background'); + const [caption, setCaption] = useState('กดปุ่มเพื่อลบพื้นหลังภาพ'); const intervalRef = useRef | null>(null); const config: Config = { debug: false, progress: (key, current, total) => { const [type, subtype] = key.split(':'); - setCaption(`${type} ${subtype} ${((current / total) * 100).toFixed(0)}%`); + setCaption(`กำลังโหลด ${subtype || type} ${((current / total) * 100).toFixed(0)}%`); }, rescale: true, device: 'gpu', @@ -49,8 +49,9 @@ const BackgroundRemoval = () => { const imageParam = params.get('image'); const auto = params.get('auto') || false; - const randomImage = - imageParam || images[Math.floor(Math.random() * images.length)]; + const randomImage = imageParam + ? new URL(imageParam, window.location.href).href + : images[Math.floor(Math.random() * images.length)]; setImageUrl(randomImage); const preloadAssets = async () => { @@ -101,8 +102,9 @@ const BackgroundRemoval = () => { const load = async (type: string) => { const params = new URLSearchParams(window.location.search); const imageParam = params.get('image'); - const randomImage = - imageParam || images[Math.floor(Math.random() * images.length)]; + const randomImage = imageParam + ? new URL(imageParam, window.location.href).href + : images[Math.floor(Math.random() * images.length)]; setIsRunning(true); resetTimer(); @@ -121,7 +123,7 @@ const BackgroundRemoval = () => { setImageUrl(url); } catch (error) { console.error('Processing failed:', error); - setCaption('Processing failed'); + setCaption('ประมวลผลไม่สำเร็จ'); } finally { setIsRunning(false); stopTimer(); @@ -132,14 +134,14 @@ const BackgroundRemoval = () => {
{/* // eslint-disable-next-line @next/next/no-img-element */} - {imageUrl && logo} + {imageUrl && ภาพตัวอย่าง}

{caption}

-

Processing: {seconds} s

+

เวลาประมวลผล: {seconds} วินาที

diff --git a/packages/web-examples/next-example/src/app/layout.tsx b/packages/web-examples/next-example/src/app/layout.tsx index 0139388..0d3920e 100644 --- a/packages/web-examples/next-example/src/app/layout.tsx +++ b/packages/web-examples/next-example/src/app/layout.tsx @@ -2,8 +2,8 @@ import type { Metadata } from 'next'; import './globals.css'; export const metadata: Metadata = { - title: 'Create Next App', - description: 'Generated by create next app' + title: 'ลบพื้นหลังภาพ', + description: 'แยกวัตถุและลบพื้นหลังภาพในเบราว์เซอร์' }; export default function RootLayout({ @@ -12,7 +12,7 @@ export default function RootLayout({ children: React.ReactNode; }>) { return ( - + {children} ); diff --git a/packages/web-examples/vite-project/index.html b/packages/web-examples/vite-project/index.html index dde16aa..cc9c9d6 100644 --- a/packages/web-examples/vite-project/index.html +++ b/packages/web-examples/vite-project/index.html @@ -1,10 +1,10 @@ - + - Vite + Vue + TS + ลบพื้นหลังภาพ
diff --git a/packages/web-examples/vite-project/src/App.vue b/packages/web-examples/vite-project/src/App.vue index 4ffbeb3..dba2181 100644 --- a/packages/web-examples/vite-project/src/App.vue +++ b/packages/web-examples/vite-project/src/App.vue @@ -1,8 +1,7 @@