优化 主题代码同步
This commit is contained in:
1 parent
92c7b62c5d
commit
80349d54b5
8 files changed
+122
-351
No files matched your search
@@ -4,12 +4,14 @@ import { useLibraryStore } from '../stores/useLibraryStore';
|
||||
import { useImageStore } from '../stores/useImageStore';
|
||||
import { useUIStore } from '../stores/useUIStore';
|
||||
import { useScanStore } from '../stores/useScanStore';
|
||||
import { useTheme } from '../hooks/useTheme';
|
||||
import { libraryAPI, scanAPI, watchAPI } from '../api';
|
||||
|
||||
function Header() {
|
||||
const { currentLibraryId } = useLibraryStore();
|
||||
const { searchKeywords, originalImages, selectedFolder, setSearchKeywords, filters, setFilters, resetFilters } = useImageStore();
|
||||
const { theme, toggleTheme, thumbnailHeight, setThumbnailHeight, mobileView } = useUIStore();
|
||||
const { thumbnailHeight, setThumbnailHeight, mobileView } = useUIStore();
|
||||
const { theme, toggleTheme } = useTheme();
|
||||
|
||||
const [showFilters, setShowFilters] = useState(false);
|
||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||
@@ -226,15 +228,6 @@ function Header() {
|
||||
setFilters({ formats: [], sizes: [], orientation: '' });
|
||||
};
|
||||
|
||||
const handleThemeToggle = async () => {
|
||||
toggleTheme();
|
||||
try {
|
||||
await libraryAPI.updateTheme(theme === 'light' ? 'dark' : 'light');
|
||||
} catch (error) {
|
||||
console.error('Error saving theme:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleThumbnailHeightChange = async (height) => {
|
||||
setThumbnailHeight(height);
|
||||
try {
|
||||
@@ -298,7 +291,7 @@ function Header() {
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={handleThemeToggle}
|
||||
onClick={toggleTheme}
|
||||
className="p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"
|
||||
>
|
||||
{theme === 'light' ? (
|
||||
@@ -514,7 +507,7 @@ function Header() {
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={handleThemeToggle}
|
||||
onClick={toggleTheme}
|
||||
className="p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"
|
||||
title={theme === 'light' ? '切换到暗色模式' : '切换到亮色模式'}
|
||||
>
|
||||
|
||||
@@ -425,11 +425,13 @@ function ImageWaterfall() {
|
||||
style={{ width: `${image.calculatedWidth}px` }}
|
||||
>
|
||||
<div
|
||||
className="relative group cursor-pointer overflow-hidden rounded-lg transition-all hover:shadow-lg"
|
||||
className={`relative group cursor-pointer overflow-hidden rounded-lg transition-all hover:shadow-lg ${
|
||||
isSelected
|
||||
? 'border-2 border-blue-400 dark:border-blue-500'
|
||||
: 'border border-gray-200 dark:border-gray-600'
|
||||
}`}
|
||||
style={{
|
||||
height: `${image.calculatedHeight}px`,
|
||||
backgroundColor: '#2a2a2a',
|
||||
border: isSelected ? '3px solid #3b82f6' : '3px solid transparent'
|
||||
height: `${image.calculatedHeight}px`
|
||||
}}
|
||||
onClick={(e) => handleImageClick(image, e, flatIndex)}
|
||||
onDoubleClick={() => {
|
||||
|
||||
@@ -840,7 +840,7 @@ function RightPanel() {
|
||||
|
||||
{/* Progressive Image Preview */}
|
||||
<div className="p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0">
|
||||
<div className="w-full aspect-square bg-gray-100 dark:bg-gray-700 rounded-lg overflow-hidden relative">
|
||||
<div className="w-full aspect-square bg-transparent border border-gray-200 dark:border-gray-600 rounded-lg overflow-hidden relative">
|
||||
<img
|
||||
src={imageUrl}
|
||||
alt={displayImage.filename}
|
||||
@@ -1019,7 +1019,7 @@ function RightPanel() {
|
||||
className={`w-full flex items-center justify-center gap-2 px-4 py-2 rounded-lg transition-all ${
|
||||
imageCopied
|
||||
? 'bg-green-500 text-white'
|
||||
: 'bg-blue-500 text-white hover:bg-blue-600'
|
||||
: 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600'
|
||||
}`}
|
||||
>
|
||||
{imageCopied ? (
|
||||
@@ -1065,7 +1065,7 @@ function RightPanel() {
|
||||
<button
|
||||
onClick={exportCurrentFolder}
|
||||
disabled={isExportingFolder}
|
||||
className="w-full flex flex-col items-center justify-center gap-2 px-4 py-2 bg-purple-500 text-white rounded-lg hover:bg-purple-600 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
className="w-full flex flex-col items-center justify-center gap-2 px-4 py-2 bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<FolderDown className="w-4 h-4" />
|
||||
@@ -1077,9 +1077,9 @@ function RightPanel() {
|
||||
</span>
|
||||
</div>
|
||||
{isExportingFolder && (
|
||||
<div className="w-full bg-purple-300 rounded-full h-1.5 mt-1">
|
||||
<div className="w-full bg-gray-300 dark:bg-gray-600 rounded-full h-1.5 mt-1">
|
||||
<div
|
||||
className="bg-white h-1.5 rounded-full transition-all duration-300"
|
||||
className="bg-gray-700 dark:bg-gray-300 h-1.5 rounded-full transition-all duration-300"
|
||||
style={{ width: `${folderExportProgress}%` }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -674,7 +674,7 @@ function Sidebar() {
|
||||
<button
|
||||
onClick={handleDeleteLibrary}
|
||||
disabled={isScanning()}
|
||||
className="px-3 py-2 border border-red-300 dark:border-red-600 rounded-lg hover:bg-red-50 dark:hover:bg-red-900 text-red-600 dark:text-red-400 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
className="px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-400 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
title={isScanning() ? "扫描进行中,无法删除" : "删除当前素材库"}
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
|
||||
Reference in new issue
Block a user