Spaces:
Sleeping
Sleeping
Update src/App.tsx
Browse files- src/App.tsx +8 -6
src/App.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
// src/App.tsx (نسخه نهایی و کامل با قابلیت
|
| 2 |
import React, { useEffect, useRef, useState, FC } from "react";
|
| 3 |
import './App.scss';
|
| 4 |
import { AppProvider, useAppContext, PersonalityType, PersonalityInstructions } from "./contexts/AppContext";
|
|
@@ -91,6 +91,7 @@ const AppInternal: React.FC = () => {
|
|
| 91 |
const notificationButtonRef = useRef<HTMLButtonElement>(null);
|
| 92 |
const notificationPopoverRef = useRef<HTMLDivElement>(null);
|
| 93 |
|
|
|
|
| 94 |
useEffect(() => {
|
| 95 |
const metaThemeColor = document.querySelector('meta[name="theme-color"]');
|
| 96 |
if (isDarkMode) {
|
|
@@ -103,14 +104,15 @@ const AppInternal: React.FC = () => {
|
|
| 103 |
if (metaThemeColor) metaThemeColor.setAttribute('content', '#ffffff');
|
| 104 |
}
|
| 105 |
|
| 106 |
-
//
|
| 107 |
-
window.parent
|
|
|
|
| 108 |
type: 'THEME_CHANGE',
|
| 109 |
isDarkMode: isDarkMode
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
}, [isDarkMode]);
|
|
|
|
| 114 |
|
| 115 |
const handleSelectPersonality = (p: PersonalityType) => {
|
| 116 |
setIsPersonalityMenuOpen(false);
|
|
|
|
| 1 |
+
// src/App.tsx (نسخه نهایی و کامل - با قابلیت ارسال پیام به Iframe)
|
| 2 |
import React, { useEffect, useRef, useState, FC } from "react";
|
| 3 |
import './App.scss';
|
| 4 |
import { AppProvider, useAppContext, PersonalityType, PersonalityInstructions } from "./contexts/AppContext";
|
|
|
|
| 91 |
const notificationButtonRef = useRef<HTMLButtonElement>(null);
|
| 92 |
const notificationPopoverRef = useRef<HTMLDivElement>(null);
|
| 93 |
|
| 94 |
+
// --- تغییر این بخش برای ارسال پیام به Parent (index.html) ---
|
| 95 |
useEffect(() => {
|
| 96 |
const metaThemeColor = document.querySelector('meta[name="theme-color"]');
|
| 97 |
if (isDarkMode) {
|
|
|
|
| 104 |
if (metaThemeColor) metaThemeColor.setAttribute('content', '#ffffff');
|
| 105 |
}
|
| 106 |
|
| 107 |
+
// ارسال پیام به iframe والد برای تغییر رنگ نوار مرورگر اصلی
|
| 108 |
+
if (window.parent) {
|
| 109 |
+
window.parent.postMessage({
|
| 110 |
type: 'THEME_CHANGE',
|
| 111 |
isDarkMode: isDarkMode
|
| 112 |
+
}, '*');
|
| 113 |
+
}
|
|
|
|
| 114 |
}, [isDarkMode]);
|
| 115 |
+
// ------------------------------------------------------------
|
| 116 |
|
| 117 |
const handleSelectPersonality = (p: PersonalityType) => {
|
| 118 |
setIsPersonalityMenuOpen(false);
|