From 898075cf6e959b737a10b4d5bccaf89d0db31404 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Tue, 21 May 2024 16:00:31 +0800 Subject: [PATCH] Refactor(Playground): Fix the bug that unexpectedly remove styles for base Fix the bug that unexpectedly remove styles for base when editing code --- .../components/Playground/Output/Preview/iframe.html | 2 +- src/renderer/src/pages/System/Tools/Base.tsx | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/components/Playground/Output/Preview/iframe.html b/src/renderer/src/components/Playground/Output/Preview/iframe.html index db6655a..5aae2e3 100644 --- a/src/renderer/src/components/Playground/Output/Preview/iframe.html +++ b/src/renderer/src/components/Playground/Output/Preview/iframe.html @@ -11,7 +11,7 @@ window.addEventListener("message", ({ data }) => { if (data?.type === "UPDATE") { // Record old styles that need to be removed - const appStyleElement = document.querySelectorAll("style[id^=\"style_\"]") || []; + const appStyleElement = document.querySelectorAll("style:not(style[id$=\"_oxygen_base_style.css\"])") || []; // Remove old app const appSrcElement = document.querySelector("#appSrc"); diff --git a/src/renderer/src/pages/System/Tools/Base.tsx b/src/renderer/src/pages/System/Tools/Base.tsx index 40f44b7..46a313d 100644 --- a/src/renderer/src/pages/System/Tools/Base.tsx +++ b/src/renderer/src/pages/System/Tools/Base.tsx @@ -637,8 +637,10 @@ const Base = () => { rules={[ { required: true }, { - pattern: /\.(jsx|tsx|js|ts|css|json)$/, - message: '仅支持 *.jsx, *.tsx, *.js, *.ts, *.css, *.json 文件' + pattern: + /(\.jsx|\.tsx|\.js|\.ts|_oxygen_base_style\.css|\.json)$/, + message: + '仅支持 *.jsx, *.tsx, *.js, *.ts, *_oxygen_base_style.css, *.json 文件' }, ({ getFieldValue }) => ({ validator() { @@ -829,9 +831,10 @@ const Base = () => { rules={[ { required: true }, { - pattern: /\.(jsx|tsx|js|ts|css|json)$/, + pattern: + /(\.jsx|\.tsx|\.js|\.ts|_oxygen_base_style\.css|\.json)$/, message: - '仅支持 *.jsx, *.tsx, *.js, *.ts, *.css, *.json 文件' + '仅支持 *.jsx, *.tsx, *.js, *.ts, *_oxygen_base_style.css, *.json 文件' }, ({ getFieldValue }) => ({ validator() {