Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

オフラインでも時間割を確認できるように #601

Closed
wants to merge 2 commits into from

Conversation

HosokawaR
Copy link
Member

@HosokawaR HosokawaR commented Nov 11, 2022

Resolves #594

基本的な機能は完成したが、以下が決まっていないので Draft

  1. オフライン時の仕様
    1. どのページが見れるのか?
    2. オフライン時に操作できない操作が行われた場合どうするのか?
  2. 上記のデザイン

またビルド構成なども乱雑なので議論の余地あり

#600 にあるように、CORS 無効化の拡張機能では動作確認ができません。

変更点

  1. リクエストをキャッシュし、オフライン時にそのキャッシュを見に行く Serviec Worker を作成
    1. WEB APP においてリクエストのキャッシュは Service Worker で行われることが多いのでその流れに乗りたい、ページスクリプト部分では通信部分を考えず Service Worker のレイヤーで考えたいとの理由でこの方針にしました
  2. v2 の Service Worker を削除するコードを削除

@vercel
Copy link

vercel bot commented Nov 11, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
twinte-front ✅ Ready (Inspect) Visit Preview Nov 11, 2022 at 1:17PM (UTC)

if (process.env.NODE_ENV === "development") {
base_url = process.env.BASE_URL || "http://localhost:4000";
} else {
base_url = process.env.BASE_URL;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: 本番ビルド時に環境変数を注入するように設定をする

Production で dotenv (に限らずコミットされるファイルに環境値がかかれたもの)を使用するのは微妙だと思うため。
なぜならアプリが環境を意識しないための環境変数なのに、環境(ファイル)を意識しては元も子もない。

Comment on lines +1 to +18
{
"include": ["./**/*.ts"],
"compilerOptions": {
"sourceMap": true,
"module": "esnext",
"moduleResolution": "node",
"preserveValueImports": false,
"esModuleInterop": true,
"importsNotUsedAsValues": "remove",
"baseUrl": ".",
"paths": {
"~/*": ["./*"]
},
"lib": ["ES2021", "WebWorker"],
"types": ["node"],
"outDir": "../dist"
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/src 以下のページスクリプトと /serviceworker は別世界なのでそれぞれ独自に tsconfig を持ちたい。

例えば /serviceworkers/tsconfig.ts"extends": "@vue/tsconfig/tsconfig.web.json" という設定値を持ったり、
/tsconfig.ts"lib": ["ES2021", "WebWorker"], という設定値をもつのはおかしい

Comment on lines -35 to -42
/** unregister service worker (v2) */
onMounted(() => {
navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (let registration of registrations) {
registration.unregister();
}
});
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v2 公開終了から 1 年半が経過したので流石にもういらないと思われる。

Comment on lines +32 to +34
request.url.startsWith(base_url) ||
request.url.startsWith("https://fonts.googleapis.com/") ||
request.url.startsWith("https://fonts.gstatic.com/")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Google Fonts がないとオフライン時にアイコンが表示されないのでキャッシュをしている。

@@ -5,7 +5,9 @@ const tsconfigFilename = "tsconfig.staged.json";

const typecheckOnlyStaged = (stagedFilenames) => {
const tsconfig = JSON.parse(fs.readFileSync("tsconfig.json"));
tsconfig.include = stagedFilenames;
tsconfig.include = stagedFilenames.filter((filename) =>
filename.includes("/src/")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/tsconfig.ts"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],が指定されていることからわかるように、typecheckOnlyStaged/src 以下の型検査のみに関心を持っている。したがってここでは/src以下を検査するようにして /serviceworkers 以下は除外している。

なお yarn typecheck/serviceworkers 以下の型検査はちゃんと走る。

@HosokawaR
Copy link
Member Author

再開の機運がないのでこの PR は一旦閉じる

@HosokawaR HosokawaR closed this May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

オフラインでも時間割を確認できるようにする
1 participant