sqlite显示
This commit is contained in:
+6
-1
@@ -173,8 +173,13 @@ export default async function RootLayout({
|
||||
}
|
||||
|
||||
// 将运行时配置注入到全局 window 对象,供客户端在运行时读取
|
||||
const runtimeStorageType = process.env.NEXT_PUBLIC_STORAGE_TYPE || 'localstorage';
|
||||
const isCloudflare = process.env.CF_PAGES === '1' || process.env.BUILD_TARGET === 'cloudflare';
|
||||
const displayStorageType = runtimeStorageType === 'd1' && !isCloudflare ? 'sqlite' : runtimeStorageType;
|
||||
|
||||
const runtimeConfig = {
|
||||
STORAGE_TYPE: process.env.NEXT_PUBLIC_STORAGE_TYPE || 'localstorage',
|
||||
STORAGE_TYPE: runtimeStorageType,
|
||||
DISPLAY_STORAGE_TYPE: displayStorageType,
|
||||
DOUBAN_PROXY_TYPE: doubanProxyType,
|
||||
DOUBAN_PROXY: doubanProxy,
|
||||
DOUBAN_IMAGE_PROXY_TYPE: doubanImageProxyType,
|
||||
|
||||
@@ -73,6 +73,7 @@ export const UserMenu: React.FC = () => {
|
||||
const [isDownloadManagementOpen, setIsDownloadManagementOpen] = useState(false);
|
||||
const [authInfo, setAuthInfo] = useState<AuthInfo | null>(null);
|
||||
const [storageType, setStorageType] = useState<string>('localstorage');
|
||||
const [displayStorageType, setDisplayStorageType] = useState<string>('localstorage');
|
||||
const [mounted, setMounted] = useState(false);
|
||||
const [unreadCount, setUnreadCount] = useState(0);
|
||||
|
||||
@@ -413,9 +414,11 @@ export const UserMenu: React.FC = () => {
|
||||
const auth = getAuthInfoFromBrowserCookie();
|
||||
setAuthInfo(auth);
|
||||
|
||||
const type =
|
||||
(window as any).RUNTIME_CONFIG?.STORAGE_TYPE || 'localstorage';
|
||||
const runtimeConfig = (window as any).RUNTIME_CONFIG || {};
|
||||
const type = runtimeConfig.STORAGE_TYPE || 'localstorage';
|
||||
const displayType = runtimeConfig.DISPLAY_STORAGE_TYPE || type;
|
||||
setStorageType(type);
|
||||
setDisplayStorageType(displayType);
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -1498,7 +1501,7 @@ export const UserMenu: React.FC = () => {
|
||||
</div>
|
||||
<div className='text-[10px] text-gray-400 dark:text-gray-500'>
|
||||
数据存储:
|
||||
{storageType === 'localstorage' ? '本地' : storageType}
|
||||
{displayStorageType === 'localstorage' ? '本地' : displayStorageType}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user