Spaces:
Running

steveyehtw commited on
Commit
f1a95fb
·
1 Parent(s): bcbe624

Embed MakeCode projects and configure Appetize APK

Browse files
projects/2026春季班資訊騎士2/蘇珩瑋/計算機android_app/appetize.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ b_qjd7eo537jrokcqxpcoh3lulza
static/js/player.js CHANGED
@@ -255,9 +255,24 @@
255
  iframe.src = `/static_projects/${encodeURIComponent(studentToken)}/${encodeURIComponent(projectName)}/index.html`;
256
  viewportFrame.appendChild(iframe);
257
  } else if (projectType === "external") {
258
- // External sites (MakeCode/Scratch/etc.) may send restrictive
259
- // frame headers. Open them directly instead of embedding an
260
- // iframe, which avoids COEP/CSP "frame blocked" errors.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  const card = document.createElement("div");
262
  card.style.cssText = "display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1rem;min-height:18rem;padding:2rem;text-align:center;color:#e5eefb;";
263
  const title = document.createElement("h2");
 
255
  iframe.src = `/static_projects/${encodeURIComponent(studentToken)}/${encodeURIComponent(projectName)}/index.html`;
256
  viewportFrame.appendChild(iframe);
257
  } else if (projectType === "external") {
258
+ // MakeCode supports an interactive shared-project page. Use a
259
+ // credentialless iframe so the app can load under this
260
+ // platform's cross-origin isolation headers.
261
+ const isMakeCode = /(^|\.)makecode\.com$/i.test(new URL(externalUrl).hostname);
262
+ if (isMakeCode) {
263
+ viewportFrame.classList.add("iframe-mode");
264
+ const iframe = document.createElement("iframe");
265
+ iframe.className = "iframe-viewport";
266
+ iframe.allow = "autoplay; fullscreen; gamepad";
267
+ iframe.setAttribute("allowfullscreen", "true");
268
+ iframe.setAttribute("credentialless", "");
269
+ iframe.src = externalUrl;
270
+ viewportFrame.appendChild(iframe);
271
+ return;
272
+ }
273
+
274
+ // Other external sites may send restrictive frame headers;
275
+ // open them directly instead of embedding an iframe.
276
  const card = document.createElement("div");
277
  card.style.cssText = "display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1rem;min-height:18rem;padding:2rem;text-align:center;color:#e5eefb;";
278
  const title = document.createElement("h2");