Spaces:
Running
Running
feat: Add redirect modal for new version
Browse filesAdded a modal that appears on app load to inform users about the new version
at https://deepsite.hf.co/. Users can choose to redirect or continue with
the current version.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
src/components/App.tsx
CHANGED
@@ -11,6 +11,7 @@ import Tabs from "./tabs/tabs";
|
|
11 |
import AskAI from "./ask-ai/ask-ai";
|
12 |
import { Auth } from "../utils/types";
|
13 |
import Preview from "./preview/preview";
|
|
|
14 |
|
15 |
function App() {
|
16 |
const [htmlStorage, , removeHtmlStorage] = useLocalStorage("html_content");
|
@@ -25,6 +26,7 @@ function App() {
|
|
25 |
const [html, setHtml] = useState((htmlStorage as string) ?? defaultHTML);
|
26 |
const [isAiWorking, setisAiWorking] = useState(false);
|
27 |
const [auth, setAuth] = useState<Auth | undefined>(undefined);
|
|
|
28 |
|
29 |
const fetchMe = async () => {
|
30 |
const res = await fetch("/api/@me");
|
@@ -135,6 +137,9 @@ function App() {
|
|
135 |
|
136 |
return (
|
137 |
<div className="h-screen bg-gray-950 font-sans overflow-hidden">
|
|
|
|
|
|
|
138 |
<Header
|
139 |
onReset={() => {
|
140 |
if (isAiWorking) {
|
|
|
11 |
import AskAI from "./ask-ai/ask-ai";
|
12 |
import { Auth } from "../utils/types";
|
13 |
import Preview from "./preview/preview";
|
14 |
+
import RedirectModal from "./redirect-modal/redirect-modal";
|
15 |
|
16 |
function App() {
|
17 |
const [htmlStorage, , removeHtmlStorage] = useLocalStorage("html_content");
|
|
|
26 |
const [html, setHtml] = useState((htmlStorage as string) ?? defaultHTML);
|
27 |
const [isAiWorking, setisAiWorking] = useState(false);
|
28 |
const [auth, setAuth] = useState<Auth | undefined>(undefined);
|
29 |
+
const [showRedirectModal, setShowRedirectModal] = useState(true);
|
30 |
|
31 |
const fetchMe = async () => {
|
32 |
const res = await fetch("/api/@me");
|
|
|
137 |
|
138 |
return (
|
139 |
<div className="h-screen bg-gray-950 font-sans overflow-hidden">
|
140 |
+
{showRedirectModal && (
|
141 |
+
<RedirectModal onDismiss={() => setShowRedirectModal(false)} />
|
142 |
+
)}
|
143 |
<Header
|
144 |
onReset={() => {
|
145 |
if (isAiWorking) {
|
src/components/redirect-modal/redirect-modal.tsx
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { useState, useEffect } from "react";
|
2 |
+
|
3 |
+
interface RedirectModalProps {
|
4 |
+
onDismiss: () => void;
|
5 |
+
}
|
6 |
+
|
7 |
+
const RedirectModal = ({ onDismiss }: RedirectModalProps) => {
|
8 |
+
const [isVisible, setIsVisible] = useState(false);
|
9 |
+
|
10 |
+
useEffect(() => {
|
11 |
+
setIsVisible(true);
|
12 |
+
}, []);
|
13 |
+
|
14 |
+
const handleRedirect = () => {
|
15 |
+
window.location.href = "https://deepsite.hf.co/";
|
16 |
+
};
|
17 |
+
|
18 |
+
return (
|
19 |
+
<div
|
20 |
+
className={`fixed inset-0 z-50 flex items-center justify-center transition-opacity duration-300 ${
|
21 |
+
isVisible ? "opacity-100" : "opacity-0"
|
22 |
+
}`}
|
23 |
+
>
|
24 |
+
<div
|
25 |
+
className="absolute inset-0 bg-black bg-opacity-75"
|
26 |
+
onClick={onDismiss}
|
27 |
+
/>
|
28 |
+
<div className="relative bg-gray-900 rounded-lg shadow-2xl p-8 max-w-md w-full mx-4 transform transition-transform duration-300">
|
29 |
+
<h2 className="text-2xl font-bold text-white mb-4">
|
30 |
+
New Version Available!
|
31 |
+
</h2>
|
32 |
+
<p className="text-gray-300 mb-6">
|
33 |
+
A new and improved version of DeepSite is now available. We recommend
|
34 |
+
using the latest version for the best experience and newest features.
|
35 |
+
</p>
|
36 |
+
<div className="flex gap-4">
|
37 |
+
<button
|
38 |
+
onClick={handleRedirect}
|
39 |
+
className="flex-1 bg-blue-600 hover:bg-blue-700 text-white font-semibold py-3 px-6 rounded-lg transition-colors duration-200"
|
40 |
+
>
|
41 |
+
Go to Latest Version
|
42 |
+
</button>
|
43 |
+
<button
|
44 |
+
onClick={onDismiss}
|
45 |
+
className="flex-1 bg-gray-700 hover:bg-gray-600 text-white font-semibold py-3 px-6 rounded-lg transition-colors duration-200"
|
46 |
+
>
|
47 |
+
Continue Here
|
48 |
+
</button>
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
</div>
|
52 |
+
);
|
53 |
+
};
|
54 |
+
|
55 |
+
export default RedirectModal;
|