MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / MainLayout

Function MainLayout

src/pages/components/layout/MainLayout.tsx:164–545  ·  view source on GitHub ↗
({ children, className, pageName })

Source from the content-addressed store, hash-verified

162 className: string;
163 pageName?: string;
164}> = ({ children, className, pageName }) => {
165 const [modal, contextHolder] = Modal.useModal();
166 const { colorThemeState, updateColorTheme } = useAppContext();
167
168 const importRef = useRef<RefTextAreaType>(null);
169 const [importVisible, setImportVisible] = useState(false);
170 const [showLanguage, setShowLanguage] = useState(false);
171 const { t } = useTranslation();
172
173 const showImportResult = (stat: TImportStat) => {
174 if (!stat) return;
175 modal.info!({
176 title: t("script_import_result"),
177 content: (
178 <Space direction="vertical" style={{ width: "100%" }}>
179 <div style={{ textAlign: "center" }}>
180 <Space size="small" style={{ fontSize: 18 }}>
181 <IconCheckCircle style={{ color: "green" }} />
182 {stat.success}
183 {""}
184 <IconCloseCircle style={{ color: "red" }} />
185 {stat.fail}
186 </Space>
187 </div>
188 {stat.msg.length > 0 && (
189 <>
190 <b>{t("failure_info") + ":"}</b>
191 {stat.msg}
192 </>
193 )}
194 </Space>
195 ),
196 });
197 };
198
199 const importByUrlsLocal = async (urls: string[]): Promise<void> => {
200 const stat = await importByUrls(urls);
201 if (stat) showImportResult(stat);
202 };
203
204 // 处理 ZIP 文件的 Skill 安装
205 const handleZipSkillInstall = async (file: File) => {
206 const buffer = await file.arrayBuffer();
207 // ArrayBuffer → base64(chrome.runtime 消息不支持直接传 ArrayBuffer)
208 const bytes = new Uint8Array(buffer);
209 let binary = "";
210 for (let i = 0; i < bytes.length; i++) {
211 binary += String.fromCharCode(bytes[i]);
212 }
213 const base64 = btoa(binary);
214 const uuid = await agentClient.prepareSkillInstall(base64);
215 window.open(`/src/install.html?skill=${uuid}`, "_blank");
216 };
217
218 const onDrop = (acceptedFiles: FileWithPath[]) => {
219 // 本地的文件在当前页面处理,打开安装页面,将FileSystemFileHandle传递过去
220 // 实现本地文件的监听
221 const stat: TImportStat = { success: 0, fail: 0, msg: [] };

Callers

nothing calls this directly

Calls 11

useAppContextFunction · 0.90
matchLanguageFunction · 0.90
arcoLocaleFunction · 0.90
getSafePopupParentFunction · 0.85
handleImportFunction · 0.85
onDropFunction · 0.85
updateColorThemeFunction · 0.85
keysMethod · 0.80
setLanguageMethod · 0.80
clickMethod · 0.65
openMethod · 0.65

Tested by

no test coverage detected