Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

Fixes #168


PR created automatically by Jules for task 7227380494433577439

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.
@google-labs-jules
Copy link
Contributor Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 11, 2025

Deploying hakspring with  Cloudflare Pages  Cloudflare Pages

Latest commit: 478a257
Status: ✅  Deploy successful!
Preview URL: https://f09f85c7.hakspring.pages.dev
Branch Preview URL: https://feat-add-app-plans.hakspring.pages.dev

View logs

@Aiuanyu Aiuanyu changed the title Pull request for issue #168 #168 → App 化規劃書 Oct 11, 2025
@Aiuanyu
Copy link
Owner

Aiuanyu commented Oct 12, 2025

承蒙你。既然 PWA 看起來係目前就做得在這 repo 直接做个,請你同這 HakSpring 做出 PWA(用一切最正確个方法,包含毋過毋單淨你寫个規劃書)

@google-labs-jules
Copy link
Contributor Author

承蒙你。既然 PWA 看起來係目前就做得在這 repo 直接做个,請你同這 HakSpring 做出 PWA(用一切最正確个方法,包含毋過毋單淨你寫个規劃書)

好的,收到指示。我這就開始為 HakSpring 網站實作 PWA 功能。我會根據規劃書个建議,建立 manifest.json 檔案、更新 index.html,並確保 service-worker.js 提供完整个離線體驗。

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.
@Aiuanyu
Copy link
Owner

Aiuanyu commented Oct 12, 2025

小心 service-worker.js 似乎會使 iOS 無法自動播放耶!之前的 PR 應該是有針對 iOS 停用 service-worker.js
#150
仰結煞

(也可參考 #143 的討論)

@google-labs-jules
Copy link
Contributor Author

小心 service-worker.js 似乎會使 iOS 無法自動播放耶!之前的 PR 應該是有針對 iOS 停用 service-worker.js
#150
仰結煞

(也可參考 #143 的討論)

承蒙指點,這係一隻當重要个問題!我無注意到 service worker 在 iOS 上會影響自動放送。多謝你提供相關个 PR,我會詳細研究,馬上修改程式碼,加入對 iOS 裝置个判斷,來避免註冊 service worker,確保功能正常。

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.
@Aiuanyu
Copy link
Owner

Aiuanyu commented Oct 12, 2025

故所 HakSpring 在 iOS 斯無法度用 PWA 吔,著無?(純討論)

@google-labs-jules
Copy link
Contributor Author

故所 HakSpring 在 iOS 斯無法度用 PWA 吔,著無?(純討論)

你講个無錯。為著避免音檔自動放送个問題,目前个做法確實在 iOS 裝置上停用了 service worker。

這表示:

  • 離線功能受限:在 iOS 上,這隻 App 無法像在 Android 頂項共樣,提供完整个離線使用體驗。
  • 做得加到主畫面:毋過,iOS 用戶還係做得用 Safari 个「加到主畫面」功能,在桌面上建立一隻像 App 共樣个快速連結。

這係目前為著確保核心功能穩定个權衡。未來若係 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.
@Aiuanyu Aiuanyu marked this pull request as ready for review October 13, 2025 00:06
@Aiuanyu
Copy link
Owner

Aiuanyu commented Oct 13, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 个體驗做得還較好、還較完整。

Comment on lines 101 to 111
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);
})
);

Choose a reason for hiding this comment

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

high

目前个快取策略對無在 STATIC_ASSETS 列表內底个其他資源(例如 index.html 裡肚載入个 tauhu-oo.cssmarked.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;
      });
    })
  );

Comment on lines 51 to 55
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/");
}

Choose a reason for hiding this comment

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

medium

這段 Android WebView 个設定程式碼提到个 setDatabaseEnabledsetDatabasePath 主要係針對 Web SQL Database API,毋過這隻 API 目前既經分大多數瀏覽器棄用吔。

雖然這隻網站主要用个 IndexedDB 在 setJavaScriptEnabled(true) 以後就做得正常運作,為著分文件還較清楚,做得加一筆註解,說明 setDatabaseEnabled 係為著舊版个 Web SQL,而且在 API 19 (KitKat) 以後既經無建議使用。

App-plans.md Outdated
Comment on lines 105 to 107
let myURL = URL(string:"https://gohakka.org/hak-ka-source-sui/") // 請換成網站个 URL
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)

Choose a reason for hiding this comment

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

medium

在 Swift 範例程式碼裡肚,用 myURL! 這个方式來強制解包 (force unwrap) URL,若然 URL 字串有問題,會造成 App 直接閃退。雖然這係範例,但係建議養成用 guard letif let 這兜安全个寫法來處理 optional 值,做得增加程式个穩定性。

Suggested change
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
Comment on lines 148 to 155
"src": "/android-chrome-192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/android-chrome-512x512.png",
"type": "image/png",
"sizes": "512x512"

Choose a reason for hiding this comment

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

medium

manifest.json 个範例裡肚,iconssrc 路徑用 / 開頭 (例如 "/android-chrome-192x192.png"),這表示絕對路徑。毋過在實際加入个 manifest.json 檔案裡肚用个係相對路徑 (無 / 開頭)。

為著分規劃文件摎實際程式碼保持一致,建議拿忒範例裡肚个頭前个 /,用相對路徑就好,恁樣也較有彈性。

Suggested change
"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"
}

Comment on lines 1 to 20
{
"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

Choose a reason for hiding this comment

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

medium

這隻 manifest.json 檔案个設定當好,為著分 PWA 个安裝體驗還較好,做得考慮加幾隻欄位:

  • description: 提供 App 个簡單說明。
  • scope: 定義 PWA 个導覽範圍,一般會設做 /,避免使用者點外部連結个時節跳出 PWA 視窗。
  • maskable icon: 提供一隻「可遮罩圖示 (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"
}

@Aiuanyu
Copy link
Owner

Aiuanyu commented Oct 13, 2025

請 Jules 參考 #170 (review) 修改
(做得批判性反詰)

@google-labs-jules
Copy link
Contributor Author

請 Jules 參考 #170 (review) 修改
(做得批判性反詰)

承蒙你提供這份詳細个 review,建議都非常好。我會根據這兜建議來修改 service-worker.js 个快取策略、改善 App-plans.md 內底个程式碼範例、還過加強 manifest.json 个設定。多謝!

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`.
@Aiuanyu
Copy link
Owner

Aiuanyu commented Oct 13, 2025

  • 更新 whatsnew.md:20251014 [新] 做得直接在 Android、電腦瀏覽器「安裝」客源翠 app(iOS 係同網頁加去主畫面);相關說明連去↓
  • 更新 info.md:一隻說明 Android Firefox、Chrome/電腦各瀏覽器仰般「安裝」客源翠 app 个區段

@google-labs-jules
Copy link
Contributor Author

  • 更新 whatsnew.md:20251014 [新] 做得直接在 Android、電腦瀏覽器「安裝」客源翠 app(iOS 係同網頁加去主畫面);相關說明連去↓
  • 更新 info.md:一隻說明 Android Firefox、Chrome/電腦各瀏覽器仰般「安裝」客源翠 app 个區段

好的,收到!我這就來更新 whatsnew.mdinfo.md,加入 PWA 安裝个相關說明。

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.
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.

App 化个規劃書

2 participants