From 631289b75e3e7786947023849ec2f8a899477ec6 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Mon, 6 Oct 2025 22:39:21 +0800 Subject: [PATCH] feat(banner): add community support banner with Ko-fi integration and translations --- locales/de.json | 6 ++ locales/en.json | 6 ++ locales/es.json | 6 ++ locales/fr.json | 6 ++ locales/he.json | 8 ++- locales/ja.json | 6 ++ locales/ko.json | 6 ++ locales/ru.json | 6 ++ locales/zh-CN.json | 6 ++ locales/zh-TW.json | 6 ++ static/js/managers/BannerService.js | 102 +++++++++++++++++++++++++++- 11 files changed, 162 insertions(+), 2 deletions(-) diff --git a/locales/de.json b/locales/de.json index ef24e8dd..fcab555a 100644 --- a/locales/de.json +++ b/locales/de.json @@ -1256,6 +1256,12 @@ "refreshNow": "Jetzt aktualisieren", "refreshingIn": "Aktualisierung in", "seconds": "Sekunden" + }, + "communitySupport": { + "title": "Keep LoRA Manager Thriving with Your Support ❤️", + "content": "LoRA Manager is a passion project maintained full-time by a solo developer. Your support on Ko-fi helps cover development costs, keeps new updates coming, and unlocks a license key for the LM Civitai Extension as a thank-you gift. Every contribution truly makes a difference.", + "supportCta": "Support on Ko-fi", + "learnMore": "LM Civitai Extension Tutorial" } } } diff --git a/locales/en.json b/locales/en.json index 23592daf..9fff5e22 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1256,6 +1256,12 @@ "refreshNow": "Refresh Now", "refreshingIn": "Refreshing in", "seconds": "seconds" + }, + "communitySupport": { + "title": "Keep LoRA Manager Thriving with Your Support ❤️", + "content": "LoRA Manager is a passion project maintained full-time by a solo developer. Your support on Ko-fi helps cover development costs, keeps new updates coming, and unlocks a license key for the LM Civitai Extension as a thank-you gift. Every contribution truly makes a difference.", + "supportCta": "Support on Ko-fi", + "learnMore": "LM Civitai Extension Tutorial" } } } diff --git a/locales/es.json b/locales/es.json index eaa58d02..3cb739a0 100644 --- a/locales/es.json +++ b/locales/es.json @@ -1256,6 +1256,12 @@ "refreshNow": "Actualizar ahora", "refreshingIn": "Actualizando en", "seconds": "segundos" + }, + "communitySupport": { + "title": "Keep LoRA Manager Thriving with Your Support ❤️", + "content": "LoRA Manager is a passion project maintained full-time by a solo developer. Your support on Ko-fi helps cover development costs, keeps new updates coming, and unlocks a license key for the LM Civitai Extension as a thank-you gift. Every contribution truly makes a difference.", + "supportCta": "Support on Ko-fi", + "learnMore": "LM Civitai Extension Tutorial" } } } diff --git a/locales/fr.json b/locales/fr.json index 4740d931..21e965c4 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -1256,6 +1256,12 @@ "refreshNow": "Actualiser maintenant", "refreshingIn": "Actualisation dans", "seconds": "secondes" + }, + "communitySupport": { + "title": "Keep LoRA Manager Thriving with Your Support ❤️", + "content": "LoRA Manager is a passion project maintained full-time by a solo developer. Your support on Ko-fi helps cover development costs, keeps new updates coming, and unlocks a license key for the LM Civitai Extension as a thank-you gift. Every contribution truly makes a difference.", + "supportCta": "Support on Ko-fi", + "learnMore": "LM Civitai Extension Tutorial" } } } diff --git a/locales/he.json b/locales/he.json index 1ddcc49a..a273c451 100644 --- a/locales/he.json +++ b/locales/he.json @@ -1256,6 +1256,12 @@ "refreshNow": "רענן כעת", "refreshingIn": "מרענן בעוד", "seconds": "שניות" + }, + "communitySupport": { + "title": "Keep LoRA Manager Thriving with Your Support ❤️", + "content": "LoRA Manager is a passion project maintained full-time by a solo developer. Your support on Ko-fi helps cover development costs, keeps new updates coming, and unlocks a license key for the LM Civitai Extension as a thank-you gift. Every contribution truly makes a difference.", + "supportCta": "Support on Ko-fi", + "learnMore": "LM Civitai Extension Tutorial" } } -} \ No newline at end of file +} diff --git a/locales/ja.json b/locales/ja.json index 85cde4f8..61bfb9ea 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -1256,6 +1256,12 @@ "refreshNow": "今すぐ更新", "refreshingIn": "更新まで", "seconds": "秒" + }, + "communitySupport": { + "title": "Keep LoRA Manager Thriving with Your Support ❤️", + "content": "LoRA Manager is a passion project maintained full-time by a solo developer. Your support on Ko-fi helps cover development costs, keeps new updates coming, and unlocks a license key for the LM Civitai Extension as a thank-you gift. Every contribution truly makes a difference.", + "supportCta": "Support on Ko-fi", + "learnMore": "LM Civitai Extension Tutorial" } } } diff --git a/locales/ko.json b/locales/ko.json index b0aa9a7e..aae9ed40 100644 --- a/locales/ko.json +++ b/locales/ko.json @@ -1256,6 +1256,12 @@ "refreshNow": "지금 새로고침", "refreshingIn": "새로고침까지", "seconds": "초" + }, + "communitySupport": { + "title": "Keep LoRA Manager Thriving with Your Support ❤️", + "content": "LoRA Manager is a passion project maintained full-time by a solo developer. Your support on Ko-fi helps cover development costs, keeps new updates coming, and unlocks a license key for the LM Civitai Extension as a thank-you gift. Every contribution truly makes a difference.", + "supportCta": "Support on Ko-fi", + "learnMore": "LM Civitai Extension Tutorial" } } } diff --git a/locales/ru.json b/locales/ru.json index 19c2d111..7ae561ae 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -1256,6 +1256,12 @@ "refreshNow": "Обновить сейчас", "refreshingIn": "Обновление через", "seconds": "секунд" + }, + "communitySupport": { + "title": "Keep LoRA Manager Thriving with Your Support ❤️", + "content": "LoRA Manager is a passion project maintained full-time by a solo developer. Your support on Ko-fi helps cover development costs, keeps new updates coming, and unlocks a license key for the LM Civitai Extension as a thank-you gift. Every contribution truly makes a difference.", + "supportCta": "Support on Ko-fi", + "learnMore": "LM Civitai Extension Tutorial" } } } diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 39ec697f..d8a20d70 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -1262,6 +1262,12 @@ "refreshNow": "立即刷新", "refreshingIn": "将在", "seconds": "秒后刷新" + }, + "communitySupport": { + "title": "Keep LoRA Manager Thriving with Your Support ❤️", + "content": "LoRA Manager is a passion project maintained full-time by a solo developer. Your support on Ko-fi helps cover development costs, keeps new updates coming, and unlocks a license key for the LM Civitai Extension as a thank-you gift. Every contribution truly makes a difference.", + "supportCta": "Support on Ko-fi", + "learnMore": "LM Civitai Extension Tutorial" } } } diff --git a/locales/zh-TW.json b/locales/zh-TW.json index e658bd3f..09856038 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -1256,6 +1256,12 @@ "refreshNow": "立即重新整理", "refreshingIn": "將於", "seconds": "秒後重新整理" + }, + "communitySupport": { + "title": "Keep LoRA Manager Thriving with Your Support ❤️", + "content": "LoRA Manager is a passion project maintained full-time by a solo developer. Your support on Ko-fi helps cover development costs, keeps new updates coming, and unlocks a license key for the LM Civitai Extension as a thank-you gift. Every contribution truly makes a difference.", + "supportCta": "Support on Ko-fi", + "learnMore": "LM Civitai Extension Tutorial" } } } diff --git a/static/js/managers/BannerService.js b/static/js/managers/BannerService.js index 2793198d..27fc36ea 100644 --- a/static/js/managers/BannerService.js +++ b/static/js/managers/BannerService.js @@ -1,4 +1,14 @@ -import { getStorageItem, setStorageItem } from '../utils/storageHelpers.js'; +import { + getStorageItem, + setStorageItem +} from '../utils/storageHelpers.js'; +import { translate } from '../utils/i18nHelpers.js'; + +const COMMUNITY_SUPPORT_BANNER_ID = 'community-support'; +const COMMUNITY_SUPPORT_BANNER_DELAY_MS = 5 * 24 * 60 * 60 * 1000; // 5 days +const COMMUNITY_SUPPORT_FIRST_SEEN_AT_KEY = 'community_support_banner_first_seen_at'; +const COMMUNITY_SUPPORT_SHOWN_KEY = 'community_support_banner_shown'; +const KO_FI_URL = 'https://ko-fi.com/pixelpawsai'; /** * Banner Service for managing notification banners @@ -8,6 +18,8 @@ class BannerService { this.banners = new Map(); this.container = null; this.initialized = false; + this.communitySupportBannerTimer = null; + this.communitySupportBannerRegistered = false; } /** @@ -51,6 +63,8 @@ class BannerService { priority: 1 }); + this.prepareCommunitySupportBanner(); + this.showActiveBanners(); this.initialized = true; } @@ -198,6 +212,92 @@ class BannerService { setStorageItem('dismissed_banners', []); location.reload(); } + + prepareCommunitySupportBanner() { + if (this.communitySupportBannerTimer) { + clearTimeout(this.communitySupportBannerTimer); + this.communitySupportBannerTimer = null; + } + + if (getStorageItem(COMMUNITY_SUPPORT_SHOWN_KEY, false)) { + return; + } + + const now = Date.now(); + let firstSeenAt = getStorageItem(COMMUNITY_SUPPORT_FIRST_SEEN_AT_KEY, null); + + if (typeof firstSeenAt !== 'number') { + firstSeenAt = now; + setStorageItem(COMMUNITY_SUPPORT_FIRST_SEEN_AT_KEY, firstSeenAt); + } + + const availableAt = firstSeenAt + COMMUNITY_SUPPORT_BANNER_DELAY_MS; + const delay = Math.max(availableAt - now, 0); + + this.registerCommunitySupportBanner(); + + if (delay === 0) { + this.registerCommunitySupportBanner(); + } else { + this.communitySupportBannerTimer = setTimeout(() => { + this.registerCommunitySupportBanner(); + }, delay); + } + } + + registerCommunitySupportBanner() { + if (this.communitySupportBannerRegistered || getStorageItem(COMMUNITY_SUPPORT_SHOWN_KEY, false)) { + return; + } + + if (this.communitySupportBannerTimer) { + clearTimeout(this.communitySupportBannerTimer); + this.communitySupportBannerTimer = null; + } + + this.communitySupportBannerRegistered = true; + setStorageItem(COMMUNITY_SUPPORT_SHOWN_KEY, true); + + this.registerBanner(COMMUNITY_SUPPORT_BANNER_ID, { + id: COMMUNITY_SUPPORT_BANNER_ID, + title: translate( + 'banners.communitySupport.title', + {}, + 'Keep LoRA Manager Thriving with Your Support ❤️' + ), + content: translate( + 'banners.communitySupport.content', + {}, + 'LoRA Manager is a passion project maintained full-time by a solo developer. Your support on Ko-fi helps cover development costs, keeps new updates coming, and unlocks a license key for the LM Civitai Extension as a thank-you gift. Every contribution truly makes a difference.' + ), + actions: [ + { + text: translate( + 'banners.communitySupport.supportCta', + {}, + 'Support on Ko-fi' + ), + icon: 'fas fa-heart', + url: KO_FI_URL, + type: 'primary' + }, + { + text: translate( + 'banners.communitySupport.learnMore', + {}, + 'LM Civitai Extension Tutorial' + ), + icon: 'fas fa-book', + url: 'https://github.com/willmiao/ComfyUI-Lora-Manager/wiki/LoRA-Manager-Civitai-Extension-(Chrome-Extension)', + type: 'tertiary' + } + ], + dismissible: true, + priority: 2 + }); + + this.updateContainerVisibility(); + } } // Create and export singleton instance