Skip to content

Commit

Permalink
fix: 修复importmap动态更新问题
Browse files Browse the repository at this point in the history
  • Loading branch information
fewismuch committed Oct 26, 2023
1 parent bd828b2 commit 2edce32
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Playground/PlaygroundContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const PlaygroundProvider = (props: { children: React.ReactElement }) => {
const newFile = {
[newFieldName]: {
...value,
language: fileName2Language(newFieldName),
name: newFieldName
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Playground/components/Message/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
max-height: calc(100% - 300px);
min-height: 40px;
margin-bottom: 8px;
font-family: var(--font-code);
color: var(--color);
white-space: pre-wrap;
background-color: var(--bg-color);
Expand Down
4 changes: 3 additions & 1 deletion src/Playground/components/Output/Preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import type { IPreview, IMessage } from '../../../types'
interface Props {
hidden: boolean
data?: IPreview
iframeKey?: string
}

const iframeUrl = getIframeUrl()

export const Preview: React.FC<Props> = props => {
const { hidden, data } = props
const { hidden, data, iframeKey } = props
const iframeRef = useRef<HTMLIFrameElement>(null)
const [error, setError] = useState('')

Expand Down Expand Up @@ -42,6 +43,7 @@ export const Preview: React.FC<Props> = props => {
return (
<>
<iframe
key={iframeKey}
ref={iframeRef}
src={iframeUrl}
style={{
Expand Down
2 changes: 1 addition & 1 deletion src/Playground/components/Output/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const Output: React.FC<IOutput> = props => {
/>

<Preview
key={files[IMPORT_MAP_FILE_NAME].value}
iframeKey={files[IMPORT_MAP_FILE_NAME].value}
hidden={activedType !== 'PREVIEW'}
data={compiledFiles}
/>
Expand Down

0 comments on commit 2edce32

Please sign in to comment.