Skip to content

Commit dbce640

Browse files
Copilotlyzno1autofix-ci[bot]
authored
refactor: remove isDark conditional logic with Tailwind dark: prefix and optimize images (iflabx#226)
--------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com> Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent d75d9bd commit dbce640

23 files changed

Lines changed: 156 additions & 350 deletions

File tree

app/apps/agent/[instanceId]/page.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ import {
1616
} from '@lib/hooks';
1717
import { useCurrentApp } from '@lib/hooks/use-current-app';
1818
import { useProfile } from '@lib/hooks/use-profile';
19-
import { useThemeColors } from '@lib/hooks/use-theme-colors';
2019
import type { ChatUploadFile } from '@lib/services/dify/types';
2120
import { useAppListStore } from '@lib/stores/app-list-store';
22-
import { useChatInputStore } from '@lib/stores/chat-input-store';
2321
import { useChatLayoutStore } from '@lib/stores/chat-layout-store';
2422
import { useChatStore } from '@lib/stores/chat-store';
2523
import { useSidebarStore } from '@lib/stores/sidebar-store';
@@ -32,7 +30,6 @@ import { useTranslations } from 'next-intl';
3230
import { useParams, usePathname, useRouter } from 'next/navigation';
3331

3432
export default function AppDetailPage() {
35-
const { colors, isDark } = useThemeColors();
3633
const { widthClass, paddingClass } = useChatWidth();
3734
const router = useRouter();
3835
const params = useParams();
@@ -100,12 +97,6 @@ export default function AppDetailPage() {
10097
// get current app instance data
10198
const currentApp = apps.find(app => app.instance_id === instanceId);
10299

103-
// theme synchronization: ensure input box style follows theme changes
104-
const setDarkMode = useChatInputStore(state => state.setDarkMode);
105-
useEffect(() => {
106-
setDarkMode(isDark);
107-
}, [isDark, setDarkMode]);
108-
109100
// useLayoutEffect ensures immediate cleanup of state when switching routes
110101
// this executes earlier than useEffect, allowing state to be cleared before rendering, avoiding display of incorrect content
111102
const { clearConversationState } = useChatInterface();
@@ -301,7 +292,7 @@ export default function AppDetailPage() {
301292
<div
302293
className={cn(
303294
'relative flex h-full w-full flex-col',
304-
colors.mainBackground.tailwind,
295+
'bg-stone-100 dark:bg-stone-800',
305296
'items-center justify-center'
306297
)}
307298
>
@@ -354,7 +345,7 @@ export default function AppDetailPage() {
354345
<div
355346
className={cn(
356347
'relative flex h-full w-full flex-col',
357-
colors.mainBackground.tailwind,
348+
'bg-stone-100 dark:bg-stone-800',
358349
'items-center justify-center'
359350
)}
360351
>
@@ -381,8 +372,8 @@ export default function AppDetailPage() {
381372
<div
382373
className={cn(
383374
'relative flex h-full w-full flex-col',
384-
colors.mainBackground.tailwind,
385-
colors.mainText.tailwind
375+
'bg-stone-100 dark:bg-stone-800',
376+
'text-stone-900 dark:text-gray-100'
386377
)}
387378
>
388379
<div

app/apps/chatbot/[instanceId]/page.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ import {
1616
} from '@lib/hooks';
1717
import { useCurrentApp } from '@lib/hooks/use-current-app';
1818
import { useProfile } from '@lib/hooks/use-profile';
19-
import { useThemeColors } from '@lib/hooks/use-theme-colors';
2019
import type { ChatUploadFile } from '@lib/services/dify/types';
2120
import { useAppListStore } from '@lib/stores/app-list-store';
22-
import { useChatInputStore } from '@lib/stores/chat-input-store';
2321
import { useChatLayoutStore } from '@lib/stores/chat-layout-store';
2422
import { useChatStore } from '@lib/stores/chat-store';
2523
import { useSidebarStore } from '@lib/stores/sidebar-store';
@@ -32,7 +30,6 @@ import { useTranslations } from 'next-intl';
3230
import { useParams, usePathname, useRouter } from 'next/navigation';
3331

3432
export default function AppDetailPage() {
35-
const { colors, isDark } = useThemeColors();
3633
const { widthClass, paddingClass } = useChatWidth();
3734
const router = useRouter();
3835
const params = useParams();
@@ -100,12 +97,6 @@ export default function AppDetailPage() {
10097
// get current app instance data
10198
const currentApp = apps.find(app => app.instance_id === instanceId);
10299

103-
// theme sync: ensure input box style follows theme change
104-
const setDarkMode = useChatInputStore(state => state.setDarkMode);
105-
useEffect(() => {
106-
setDarkMode(isDark);
107-
}, [isDark, setDarkMode]);
108-
109100
const { clearConversationState } = useChatInterface();
110101

111102
useLayoutEffect(() => {
@@ -274,7 +265,7 @@ export default function AppDetailPage() {
274265
<div
275266
className={cn(
276267
'relative flex h-full w-full flex-col',
277-
colors.mainBackground.tailwind,
268+
'bg-stone-100 dark:bg-stone-800',
278269
'items-center justify-center'
279270
)}
280271
>
@@ -327,7 +318,7 @@ export default function AppDetailPage() {
327318
<div
328319
className={cn(
329320
'relative flex h-full w-full flex-col',
330-
colors.mainBackground.tailwind,
321+
'bg-stone-100 dark:bg-stone-800',
331322
'items-center justify-center'
332323
)}
333324
>
@@ -354,8 +345,8 @@ export default function AppDetailPage() {
354345
<div
355346
className={cn(
356347
'relative flex h-full w-full flex-col',
357-
colors.mainBackground.tailwind,
358-
colors.mainText.tailwind
348+
'bg-stone-100 dark:bg-stone-800',
349+
'text-stone-900 dark:text-gray-100'
359350
)}
360351
>
361352
{/* Main content area with simplified layout */}

app/apps/chatflow/[instanceId]/page.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ import { useChatInterface, useChatScroll, useWelcomeScreen } from '@lib/hooks';
1313
import { useChatflowInterface } from '@lib/hooks/use-chatflow-interface';
1414
import { useChatflowState } from '@lib/hooks/use-chatflow-state';
1515
import { useCurrentApp } from '@lib/hooks/use-current-app';
16-
import { useThemeColors } from '@lib/hooks/use-theme-colors';
1716
import type { ChatUploadFile } from '@lib/services/dify/types';
1817
import { useAppListStore } from '@lib/stores/app-list-store';
19-
import { useChatInputStore } from '@lib/stores/chat-input-store';
2018
import { useChatLayoutStore } from '@lib/stores/chat-layout-store';
2119
import { useChatStore } from '@lib/stores/chat-store';
2220
import { useChatflowExecutionStore } from '@lib/stores/chatflow-execution-store';
@@ -30,7 +28,6 @@ import { useTranslations } from 'next-intl';
3028
import { useParams, usePathname, useRouter } from 'next/navigation';
3129

3230
export default function AppDetailPage() {
33-
const { colors, isDark } = useThemeColors();
3431
const router = useRouter();
3532
const params = useParams();
3633
const pathname = usePathname();
@@ -105,12 +102,6 @@ export default function AppDetailPage() {
105102
// get current app instance data
106103
const currentApp = apps.find(app => app.instance_id === instanceId);
107104

108-
// Theme synchronization: ensure input box style follows theme changes
109-
const setDarkMode = useChatInputStore(state => state.setDarkMode);
110-
useEffect(() => {
111-
setDarkMode(isDark);
112-
}, [isDark, setDarkMode]);
113-
114105
// useLayoutEffect ensures immediate cleanup of state when switching routes
115106
// this executes earlier than useEffect, allowing state to be cleared before rendering, avoiding display of incorrect content
116107
const { clearConversationState } = useChatInterface();
@@ -306,7 +297,7 @@ export default function AppDetailPage() {
306297
<div
307298
className={cn(
308299
'relative flex h-full w-full flex-col',
309-
colors.mainBackground.tailwind,
300+
'bg-stone-100 dark:bg-stone-800',
310301
'items-center justify-center'
311302
)}
312303
>
@@ -359,7 +350,7 @@ export default function AppDetailPage() {
359350
<div
360351
className={cn(
361352
'relative flex h-full w-full flex-col',
362-
colors.mainBackground.tailwind,
353+
'bg-stone-100 dark:bg-stone-800',
363354
'items-center justify-center'
364355
)}
365356
>
@@ -386,8 +377,8 @@ export default function AppDetailPage() {
386377
<div
387378
className={cn(
388379
'relative flex h-full w-full flex-col',
389-
colors.mainBackground.tailwind,
390-
colors.mainText.tailwind
380+
'bg-stone-100 dark:bg-stone-800',
381+
'text-stone-900 dark:text-gray-100'
391382
)}
392383
>
393384
<div

app/apps/page.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { AppFilters, AppHeader, AppList, AppLoading } from '@components/apps';
44
import type { AppInstance } from '@components/apps/types';
5-
import { useThemeColors } from '@lib/hooks/use-theme-colors';
65
import { useAppListStore } from '@lib/stores/app-list-store';
76
import { useFavoriteAppsStore } from '@lib/stores/favorite-apps-store';
87
import { useSidebarStore } from '@lib/stores/sidebar-store';
@@ -16,7 +15,6 @@ import { useRouter, useSearchParams } from 'next/navigation';
1615
export default function AppsPage() {
1716
const router = useRouter();
1817
const searchParams = useSearchParams();
19-
const { colors } = useThemeColors();
2018
const { favoriteApps } = useFavoriteAppsStore();
2119
const { selectItem } = useSidebarStore();
2220
const t = useTranslations('pages.apps.market');
@@ -248,7 +246,7 @@ export default function AppsPage() {
248246
<>
249247
<div
250248
className={cn(
251-
colors.mainBackground.tailwind,
249+
'bg-stone-100 dark:bg-stone-800',
252250
'min-h-screen',
253251
'pt-16 md:pt-12'
254252
)}

app/apps/workflow/[instanceId]/page.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { WorkflowLayout } from '@components/workflow/workflow-layout';
44
import { useCurrentApp } from '@lib/hooks/use-current-app';
5-
import { useThemeColors } from '@lib/hooks/use-theme-colors';
65
import { useAppListStore } from '@lib/stores/app-list-store';
76
import { useSidebarStore } from '@lib/stores/sidebar-store';
87
import { cn } from '@lib/utils';
@@ -34,7 +33,6 @@ interface WorkflowPageProps {
3433
export default function WorkflowPage({ params }: WorkflowPageProps) {
3534
const { instanceId } = React.use(params);
3635
const router = useRouter();
37-
const { colors } = useThemeColors();
3836
const t = useTranslations('pages.apps');
3937

4038
// --- app related state ---
@@ -158,7 +156,7 @@ export default function WorkflowPage({ params }: WorkflowPageProps) {
158156
<div
159157
className={cn(
160158
'relative flex h-full w-full flex-col',
161-
colors.mainBackground.tailwind,
159+
'bg-stone-100 dark:bg-stone-800',
162160
'items-center justify-center'
163161
)}
164162
>
@@ -206,7 +204,7 @@ export default function WorkflowPage({ params }: WorkflowPageProps) {
206204
<div
207205
className={cn(
208206
'relative flex h-full w-full flex-col',
209-
colors.mainBackground.tailwind,
207+
'bg-stone-100 dark:bg-stone-800',
210208
'items-center justify-center'
211209
)}
212210
>
@@ -233,8 +231,8 @@ export default function WorkflowPage({ params }: WorkflowPageProps) {
233231
<div
234232
className={cn(
235233
'relative h-screen w-full overflow-hidden',
236-
colors.mainBackground.tailwind,
237-
colors.mainText.tailwind
234+
'bg-stone-100 dark:bg-stone-800',
235+
'text-stone-900 dark:text-gray-100'
238236
)}
239237
>
240238
<div className="h-full overflow-hidden pt-12">

app/chat/[conversationId]/page.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { useChatflowDetection } from '@lib/hooks/use-chatflow-detection';
1919
import { useChatflowState } from '@lib/hooks/use-chatflow-state';
2020
import { useConversationMessages } from '@lib/hooks/use-conversation-messages';
2121
import { useProfile } from '@lib/hooks/use-profile';
22-
import { useThemeColors } from '@lib/hooks/use-theme-colors';
2322
import { useChatLayoutStore } from '@lib/stores/chat-layout-store';
2423
import { useChatStore } from '@lib/stores/chat-store';
2524
import { useChatflowExecutionStore } from '@lib/stores/chatflow-execution-store';
@@ -52,7 +51,6 @@ export default function ChatPage() {
5251

5352
const { inputHeight } = useChatLayoutStore();
5453
const isPreviewOpen = useFilePreviewStore(state => state.isPreviewOpen);
55-
const { colors } = useThemeColors();
5654

5755
// Use the wrapped hook to detect chatflow apps
5856
const { isChatflowApp } = useChatflowDetection();
@@ -124,8 +122,8 @@ export default function ChatPage() {
124122
<div
125123
className={cn(
126124
'relative flex h-full w-full flex-col',
127-
colors.mainBackground.tailwind,
128-
colors.mainText.tailwind
125+
'bg-stone-100 dark:bg-stone-800',
126+
'text-stone-900 dark:text-gray-100'
129127
)}
130128
>
131129
<div

components/admin/content/editor-skeleton.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
'use client';
22

3-
import { useTheme } from '@lib/hooks/use-theme';
43
import { cn } from '@lib/utils';
54

65
export function EditorSkeleton() {
7-
const { isDark } = useTheme();
8-
96
const SkeletonBlock = ({ className }: { className?: string }) => (
107
<div
118
className={cn(
12-
'animate-pulse rounded-lg',
13-
isDark ? 'bg-stone-800' : 'bg-stone-200',
9+
'animate-pulse rounded-lg bg-stone-200 dark:bg-stone-800',
1410
className
1511
)}
1612
/>

0 commit comments

Comments
 (0)