Skip to content

Commit 115ab38

Browse files
committed
[feat] 実地とそれ以外を区別する仕組みを追加
* 実地のパソコンはこのサイトを表示した状態で、以下をコンソールで実行すること: `localStorage.setItem("is_offline","true")`
1 parent d44d053 commit 115ab38

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

src/exhibitions.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ type Exhibition = {
1919
alt: string;
2020
};
2121
description: string;
22-
url: string;
22+
url?: string;
23+
dialog?: string;
2324
isNew: boolean;
2425
target: TargetAge;
2526
takes: TimeEst;
2627
disabled?: boolean;
28+
offline_only?: boolean;
2729
};
2830

2931
export const exhibitions: Exhibition[] = [
@@ -61,7 +63,7 @@ export const exhibitions: Exhibition[] = [
6163
takes: timeEst.long,
6264
},
6365
{
64-
// disabled: true,
66+
offline_only: true,
6567
title: "ブラウザハック入門",
6668
image: {
6769
src: "img/browser-hack.png",
@@ -93,7 +95,8 @@ export const exhibitions: Exhibition[] = [
9395
takes: timeEst.short_med,
9496
},
9597
{
96-
disabled: true,
98+
// disabled: true,
99+
offline_only: true,
97100
title: "Hack-shooter",
98101
image: {
99102
src: "img/Hackshooter_theme.png",
@@ -102,7 +105,7 @@ export const exhibitions: Exhibition[] = [
102105
description: `
103106
シューティングゲームの裏側をプログラミングすることによって、より簡単に、よりスマートにゲームを攻略しよう!
104107
`,
105-
url: "https://life-code.utcode.net/",
108+
dialog: "タスクバーにあるペンギンのアイコンをクリックしてください。",
106109
isNew: true,
107110
target: "小学生以上におすすめ",
108111
takes: timeEst.med_long,
@@ -119,7 +122,7 @@ export const exhibitions: Exhibition[] = [
119122
`,
120123
url: "https://plusoperatorgame.onrender.com",
121124
isNew: true,
122-
target: "中高生以上におすすめ",
125+
target: "小学生以上におすすめ",
123126
takes: timeEst.short,
124127
},
125128
{

src/pages/index.tsx

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import Heading from "@theme/Heading";
44
import { exhibitions } from "../exhibitions.ts";
55

66
const trackerURL = "https://" + "tracker.ut-code.workers" + ".dev";
7-
87
export default function Home(): JSX.Element {
8+
const is_offline = !!localStorage.getItem("is_offline");
99
const { siteConfig } = useDocusaurusContext();
1010
return (
1111
<Layout>
@@ -56,27 +56,38 @@ export default function Home(): JSX.Element {
5656
<div className="card__footer">
5757
<button
5858
type="button"
59-
disabled={ex.disabled}
59+
disabled={ex.disabled || (ex.offline_only && !is_offline)}
6060
onClick={async () => {
6161
console.log(`clicked ${ex.title}`);
6262
const url = ex.url;
63-
window.open(url, "_blank").focus();
64-
// CORS の関係でエラーが出るが、特に問題ないので放置。
65-
try {
66-
await fetch(trackerURL, {
67-
method: "POST",
68-
body: JSON.stringify({
69-
url,
70-
key: "2e0c7cad39e09314a46f217c6107f96e08bd13984cd4ae4c29d96f5db440dba8",
71-
kind: "festival",
72-
}),
73-
});
74-
} catch (err) {}
63+
if (url) {
64+
window.open(url, "_blank").focus();
65+
// CORS の関係でエラーが出るが、特に問題ないので放置。
66+
try {
67+
await fetch(trackerURL, {
68+
method: "POST",
69+
body: JSON.stringify({
70+
url,
71+
key: "2e0c7cad39e09314a46f217c6107f96e08bd13984cd4ae4c29d96f5db440dba8",
72+
kind: "festival",
73+
}),
74+
});
75+
} catch (err) {}
76+
} else {
77+
const dialog = ex.dialog;
78+
if (dialog) {
79+
alert(dialog);
80+
}
81+
}
7582
}}
7683
rel="noreferrer"
7784
className="button button--primary button--block"
7885
>
79-
{ex.disabled ? "準備中…" : "この企画を体験する"}
86+
{ex.disabled
87+
? "準備中…"
88+
: ex.offline_only && !is_offline
89+
? "実地のみ"
90+
: "この企画を体験する"}
8091
</button>
8192
</div>
8293
</div>

0 commit comments

Comments
 (0)