Skip to content

Commit e94cb81

Browse files
authored
fix:FullScreenRunner gameCanvas no center and dispatch no effection (#2185)
* fix:FullScreenRunner gameCanvas no center and dispatch no effection * fix:project blank and projectRunner getgetScreenshot * fix:format * delete: irrelevant
1 parent 94b2b55 commit e94cb81

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

spx-gui/.env.staging

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

33
VITE_API_BASE_URL="https://goplus-builder.qiniu.io/api"
44
VITE_VERCEL_PROXIED_API_BASE_URL="https://goplus-builder.qiniu.io/api"
5-
5+
# VITE_API_BASE_URL="http://localhost:8080"
66
VITE_USERCONTENT_BASE_URL="https://builder-usercontent-test.gopluscdn.com"
77
VITE_USERCONTENT_UPLOAD_BASE_URL="https://upload-na0.qiniup.com"
88

spx-gui/src/components/project/runner/FullScreenProjectRunner.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ async function handleOnKeyEvent(type: KeyboardEventType, key: KeyCode) {
104104
</div>
105105
<div class="main">
106106
<MobileKeyboardView
107-
v-if="isMobile && project.mobileKeyboardType === 2"
107+
v-if="isMobile"
108108
:zone-to-key-mapping="project.mobileKeyboardZoneToKey || {}"
109109
@key="handleOnKeyEvent"
110110
@rerun="handleRerun.fn"

spx-gui/src/components/project/runner/v2/ProjectRunnerV2.vue

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,18 @@ defineExpose({
200200
return await win.stopRecording?.()
201201
},
202202
dispatchKeyboardEvent(type: KeyboardEventType, key: KeyCode) {
203-
const iframe = iframeRef.value
204-
if (iframe == null || iframe == undefined) return
205-
const win = iframe.contentWindow as IframeWindow | null
203+
const win = iframeRef.value?.contentWindow as IframeWindow | null
206204
if (win == null) return
205+
const doc = win.document
206+
const canvas = doc.querySelector('#game-canvas') as HTMLCanvasElement | null
207207
const keyboardEvent = new KeyboardEvent(type, { key, bubbles: true })
208-
return win.dispatchEvent?.(keyboardEvent)
208+
if (canvas) {
209+
canvas.focus()
210+
return canvas.dispatchEvent(keyboardEvent)
211+
} else {
212+
win.focus()
213+
return doc.dispatchEvent(keyboardEvent)
214+
}
209215
},
210216
async run(signal?: AbortSignal) {
211217
loading.value = true
@@ -353,12 +359,20 @@ defineExpose({
353359
</template>
354360

355361
<style lang="scss" scoped>
362+
@import '@/components/ui/responsive.scss';
363+
356364
.iframe-container {
357365
position: relative;
358366
aspect-ratio: 4 / 3;
359367
display: flex;
360368
justify-content: center;
361369
align-items: center;
370+
371+
@include responsive(mobile) {
372+
aspect-ratio: 16 / 9;
373+
width: 100%;
374+
height: 100%;
375+
}
362376
}
363377
364378
.iframe {

spx-gui/src/pages/community/project.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,10 @@ watchEffect((onCleanup) => {
884884
.left {
885885
flex: 1 1 744px;
886886
887+
@include responsive(mobile) {
888+
flex: 1 1 0;
889+
}
890+
887891
.project-wrapper {
888892
position: relative;
889893
width: 100%;

0 commit comments

Comments
 (0)