]> acesimba.cloud Git - words.git/commitdiff
V1 根站点: 默认显示'已切换到分组模式'提示页并引导至 /split/; 开发者模式(?dev=1 或 localStorage.v1_dev=1)可打开原...
authorroot <root@localhost.localdomain>
Thu, 10 Sep 2026 15:36:45 +0000 (23:36 +0800)
committerroot <root@localhost.localdomain>
Thu, 10 Sep 2026 15:36:45 +0000 (23:36 +0800)
frontend/src/V1Notice.js [new file with mode: 0644]
frontend/src/index.js

diff --git a/frontend/src/V1Notice.js b/frontend/src/V1Notice.js
new file mode 100644 (file)
index 0000000..a770d6d
--- /dev/null
@@ -0,0 +1,35 @@
+import React from 'react';
+
+// V1 根站点提示页: 默认访问 https://words.acesimba.cloud/ 时显示,
+// 告知用户已切换到分组模式并引导到 /split/。开发者模式(?dev=1 或 localStorage.v1_dev=1)下不显示。
+export default function V1Notice() {
+  return (
+    <div
+      style={{
+        minHeight: '100vh',
+        display: 'flex',
+        alignItems: 'center',
+        justifyContent: 'center',
+        padding: '24px',
+        textAlign: 'center',
+        background: '#fff',
+        color: '#333',
+        fontFamily: 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',
+        lineHeight: 1.9,
+      }}
+    >
+      <p style={{ maxWidth: '680px', fontSize: '18px', margin: 0 }}>
+        您已经开始使用分组模式,请进入链接{' '}
+        <a
+          href="https://words.acesimba.cloud/split/"
+          target="_blank"
+          rel="noreferrer"
+          style={{ color: '#2563eb' }}
+        >
+          https://words.acesimba.cloud/split/
+        </a>
+        。如需要打开,请在开发者模式中进行打开(请联系你最爱的妈妈)。
+      </p>
+    </div>
+  );
+}
index 3a56c9e100d72c062b74d2d49ad475d209e951f7..b7b091d6d79f9ba445d1769fed9ec50badf7295b 100644 (file)
@@ -3,14 +3,26 @@ import ReactDOM from 'react-dom/client';
 import './index.css';
 import App from './App';
 import ErrorBoundary from './ErrorBoundary';
+import V1Notice from './V1Notice';
 import { isLoggedIn } from './auth';
 import reportWebVitals from './reportWebVitals';
 
+// V1 根站点网关: 默认显示"已切换到分组模式"提示页;
+// 开发者模式(?dev=1 或 localStorage.v1_dev=1)才加载原 V1 应用(进度/数据均保留在后端, 不受影响)。
+function isDevMode() {
+  try {
+    const params = new URLSearchParams(window.location.search);
+    if (params.get('dev') === '1') return true;
+    if (window.localStorage.getItem('v1_dev') === '1') return true;
+  } catch (e) {}
+  return false;
+}
+
 const root = ReactDOM.createRoot(document.getElementById('root'));
 root.render(
   <React.StrictMode>
     <ErrorBoundary>
-      <App />
+      {isDevMode() ? <App /> : <V1Notice />}
     </ErrorBoundary>
   </React.StrictMode>
 );
@@ -20,13 +32,13 @@ root.render(
 // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
 reportWebVitals();
 
-// 注册 Service Worker (PWA 离线支持) — split 用相对路径, 确保在 /split 作用域下注册
+// 注册 Service Worker (PWA 离线支持)
 if ('serviceWorker' in navigator) {
   window.addEventListener('load', () => {
     navigator.serviceWorker.register('sw.js').catch(err => console.error('SW registration failed:', err));
     // SW 接管页面后, 再触发一次同步+预取, 确保预取请求被 SW 拦截并写入缓存
     navigator.serviceWorker.ready.then(() => {
-      if (isLoggedIn()) {
+      if (isDevMode() && isLoggedIn()) {
         import('./sync').then(m => m.triggerAutoSync()).catch(() => {});
       }
     }).catch(() => {});