-
Notifications
You must be signed in to change notification settings - Fork 0
#168 → App 化規劃書 #170
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
base: main
Are you sure you want to change the base?
#168 → App 化規劃書 #170
Conversation
Create `App-plans.md` to outline the strategy for developing mobile and desktop applications. This document covers: - Evaluation of Tauri for cross-platform development. - Steps for creating Android and iOS apps using WebView. - Recommendation to implement a Progressive Web App (PWA) as a first step.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. |
Deploying hakspring with
|
| Latest commit: |
478a257
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f09f85c7.hakspring.pages.dev |
| Branch Preview URL: | https://feat-add-app-plans.hakspring.pages.dev |
|
承蒙你。既然 PWA 看起來係目前就做得在這 repo 直接做个,請你同這 HakSpring 做出 PWA(用一切最正確个方法,包含毋過毋單淨你寫个規劃書) |
好的,收到指示。我這就開始為 HakSpring 網站實作 PWA 功能。我會根據規劃書个建議,建立 |
This commit implements the Progressive Web App (PWA) functionality for the HakSpring website, based on the user's request to proceed with the plan outlined in `App-plans.md`. Changes include: - Creating `manifest.json` to define the app's properties. - Linking the manifest in `index.html`. - Overhauling `service-worker.js` to cache the entire app shell (HTML, CSS, JS, images, etc.), ensuring a complete offline experience.
This commit implements the Progressive Web App (PWA) functionality for the HakSpring website, based on the user's request to proceed with the plan outlined in `App-plans.md`. Changes include: - Creating `manifest.json` to define the app's properties. - Linking the manifest in `index.html`. - Overhauling `service-worker.js` to cache the entire app shell (HTML, CSS, JS, images, etc.), ensuring a complete offline experience. - Verified that the service worker registration in `main.js` correctly excludes iOS devices to prevent audio playback issues.
|
故所 HakSpring 在 iOS 斯無法度用 PWA 吔,著無?(純討論) |
你講个無錯。為著避免音檔自動放送个問題,目前个做法確實在 iOS 裝置上停用了 service worker。 這表示:
這係目前為著確保核心功能穩定个權衡。未來若係 Apple 對 PWA 支援有改善,做得再重新評估這隻策略。 |
This commit implements the Progressive Web App (PWA) functionality for the HakSpring website, based on the user's request to proceed with the plan outlined in `App-plans.md`. Changes include: - Creating `manifest.json` to define the app's properties. - Linking the manifest in `index.html`. - Overhauling `service-worker.js` to cache the entire app shell (HTML, CSS, JS, images, etc.), ensuring a complete offline experience. - Verified that the service worker registration in `main.js` correctly excludes iOS devices to prevent audio playback issues.
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
這次个 PR 主要係為著將網站 App 化,特別係透過 PWA 个方式,做吔規劃還有一寡基礎个實作。規劃書 (App-plans.md) 寫到當詳細,對 Tauri、WebView 包裝 App、PWA 這幾種方案都有分析,結論建議優先做 PWA 也當合理。相關个程式碼修改,包括加入 manifest.json、更新 index.html、還有大幅改善 service-worker.js,都係正確个方向。
我个回饋主要會針對規劃書內底个程式碼範例、manifest.json 个完整性、還有 service-worker.js 離線快取策略个部分,提供一寡建議,希望分 PWA 个體驗做得還較好、還較完整。
| event.respondWith( | ||
| caches.match(request).then((cachedResponse) => { | ||
| // If the request is in the cache, return it. | ||
| if (cachedResponse) { | ||
| return cachedResponse; | ||
| } | ||
|
|
||
| // If not in cache, go to the network. | ||
| return fetch(request); | ||
| }) | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前个快取策略對無在 STATIC_ASSETS 列表內底个其他資源(例如 index.html 裡肚載入个 tauhu-oo.css、marked.min.js 等外部 CDN 資源)淨係會從網路去捉,但係無存到快取裡肚。恁樣會造成在離線个時節,這兜資源無法度載入,影響 App 个正常運作。
建議修改這段个邏輯,對無在快取裡肚个請求,在從網路捉轉來了後,也存到 STATIC_CACHE_NAME 裡肚,恁樣正做得確保所有資源在第一擺載入後,就做得離線使用。
event.respondWith(
caches.match(request).then((cachedResponse) => {
return cachedResponse || fetch(request).then((networkResponse) => {
if (networkResponse && networkResponse.status === 200) {
const responseToCache = networkResponse.clone();
caches.open(STATIC_CACHE_NAME).then((cache) => {
cache.put(request, responseToCache);
});
}
return networkResponse;
});
})
);| webView.getSettings().setDomStorageEnabled(true); | ||
| webView.getSettings().setDatabaseEnabled(true); | ||
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { | ||
| webView.getSettings().setDatabasePath("/data/data/" + this.getPackageName() + "/databases/"); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
App-plans.md
Outdated
| let myURL = URL(string:"https://gohakka.org/hak-ka-source-sui/") // 請換成網站个 URL | ||
| let myRequest = URLRequest(url: myURL!) | ||
| webView.load(myRequest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 Swift 範例程式碼裡肚,用 myURL! 這个方式來強制解包 (force unwrap) URL,若然 URL 字串有問題,會造成 App 直接閃退。雖然這係範例,但係建議養成用 guard let 或 if let 這兜安全个寫法來處理 optional 值,做得增加程式个穩定性。
| let myURL = URL(string:"https://gohakka.org/hak-ka-source-sui/") // 請換成網站个 URL | |
| let myRequest = URLRequest(url: myURL!) | |
| webView.load(myRequest) | |
| guard let myURL = URL(string:"https://gohakka.org/hak-ka-source-sui/") else { | |
| print("Error: Invalid URL") | |
| return | |
| } | |
| let myRequest = URLRequest(url: myURL) | |
| webView.load(myRequest) |
App-plans.md
Outdated
| "src": "/android-chrome-192x192.png", | ||
| "type": "image/png", | ||
| "sizes": "192x192" | ||
| }, | ||
| { | ||
| "src": "/android-chrome-512x512.png", | ||
| "type": "image/png", | ||
| "sizes": "512x512" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 manifest.json 个範例裡肚,icons 个 src 路徑用 / 開頭 (例如 "/android-chrome-192x192.png"),這表示絕對路徑。毋過在實際加入个 manifest.json 檔案裡肚用个係相對路徑 (無 / 開頭)。
為著分規劃文件摎實際程式碼保持一致,建議拿忒範例裡肚个頭前个 /,用相對路徑就好,恁樣也較有彈性。
| "src": "/android-chrome-192x192.png", | |
| "type": "image/png", | |
| "sizes": "192x192" | |
| }, | |
| { | |
| "src": "/android-chrome-512x512.png", | |
| "type": "image/png", | |
| "sizes": "512x512" | |
| { | |
| "src": "android-chrome-192x192.png", | |
| "type": "image/png", | |
| "sizes": "192x192" | |
| }, | |
| { | |
| "src": "android-chrome-512x512.png", | |
| "type": "image/png", | |
| "sizes": "512x512" | |
| } |
| { | ||
| "short_name": "客源翠", | ||
| "name": "客源翠 HakSpring", | ||
| "icons": [ | ||
| { | ||
| "src": "android-chrome-192x192.png", | ||
| "type": "image/png", | ||
| "sizes": "192x192" | ||
| }, | ||
| { | ||
| "src": "android-chrome-512x512.png", | ||
| "type": "image/png", | ||
| "sizes": "512x512" | ||
| } | ||
| ], | ||
| "start_url": ".", | ||
| "display": "standalone", | ||
| "theme_color": "#ffffff", | ||
| "background_color": "#ffffff" | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這隻 manifest.json 檔案个設定當好,為著分 PWA 个安裝體驗還較好,做得考慮加幾隻欄位:
description: 提供 App 个簡單說明。scope: 定義 PWA 个導覽範圍,一般會設做/,避免使用者點外部連結个時節跳出 PWA 視窗。maskableicon: 提供一隻「可遮罩圖示 (maskable icon)」,做得分圖示在無共樣形狀个 Android 裝置上看起來還較自然。(愛另外準備一隻符合規格个圖示檔)
{
"short_name": "客源翠",
"name": "客源翠 HakSpring",
"description": "客話詞典、認證詞彙分類放送學習網站",
"icons": [
{
"src": "android-chrome-192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "android-chrome-512x512.png",
"type": "image/png",
"sizes": "512x512"
},
{
"src": "maskable-icon.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
],
"start_url": ".",
"scope": "/",
"display": "standalone",
"theme_color": "#ffffff",
"background_color": "#ffffff"
}|
請 Jules 參考 #170 (review) 修改 |
承蒙你提供這份詳細个 review,建議都非常好。我會根據這兜建議來修改 |
This commit implements the Progressive Web App (PWA) functionality and incorporates feedback from the code review. PWA Implementation: - Creates `manifest.json` with app properties. - Links the manifest in `index.html`. - Overhauls `service-worker.js` to cache the app shell and external resources for a full offline experience. Review Improvements: - Enhanced the service worker's caching strategy to include network-fetched resources. - Added `description` and `scope` to `manifest.json`. - Improved code examples and added clarifications in `App-plans.md`.
|
好的,收到!我這就來更新 |
This commit finalizes the PWA implementation by adding user-facing documentation. PWA Implementation: - Creates `manifest.json` with app properties. - Links the manifest in `index.html`. - Overhauls `service-worker.js` to cache the app shell and external resources for a full offline experience. Review Improvements & Documentation: - Enhanced the service worker's caching strategy. - Added `description` and `scope` to `manifest.json`. - Improved code examples in `App-plans.md`. - Updated `whatsnew.md` to announce the PWA feature. - Added a new section to `info.md` with detailed PWA installation instructions.
Fixes #168
PR created automatically by Jules for task 7227380494433577439