Skip to content

Commit

Permalink
fix: use iframe to enhance UX
Browse files Browse the repository at this point in the history
- Avoids opening new browsers
- Make URL simple
  • Loading branch information
MrOrz committed Mar 25, 2024
1 parent 35703f7 commit ae57f0a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/liff/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import Comment from './pages/Comment.svelte';
import UserSetting from './pages/UserSetting.svelte';
import Feedback from './pages/Feedback.svelte';
import Mgp from './pages/Mgp.svelte';
const routes = {
article: Article,
articles: Articles,
setting: UserSetting,
comment: Comment,
feedback: Feedback,
mgp: Mgp,
};
// Send pageview with correct path on each page change.
Expand Down
10 changes: 1 addition & 9 deletions src/liff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ liff.init({ liffId: LIFF_ID }).then(() => {
redirectUri: location.href,
});
} else {
const userId = liff.getDecodedIDToken().sub;
dataLayer.push({ userId });

const params = new URLSearchParams(location.search);
if (params.get('p') === 'mgp') {
// Replace login with survey
window.location.href = `https://www.surveycake.com/s/eqNpB?ssn0=${userId}&ssn58=cofacts&openExternalBrowser=1`;
return;
}
dataLayer.push({ userId: liff.getDecodedIDToken().sub });

// Kickstart app loading; fire assertions
new App({ target: document.body });
Expand Down
18 changes: 18 additions & 0 deletions src/liff/pages/Mgp.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script>
const userId = liff.getDecodedIDToken().sub;
let iframeUrl = `https://www.surveycake.com/s/eqNpB?ssn0=${userId}&ssn58=cofacts`
</script>

<style>
iframe {
width: 100vw;
height: 100vh;
border: 0;
}
</style>

<svelte:head>
<title>Cofacts x 第四屆 MyGoPen 謠言惑眾獎</title>
</svelte:head>

<iframe title="謠言惑眾獎" src={iframeUrl} />

0 comments on commit ae57f0a

Please sign in to comment.