diff --git a/package.json b/package.json index 234331e2..9435b728 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hydralauncher", - "version": "3.1.5", + "version": "3.2.0", "description": "Hydra", "main": "./out/main/index.js", "author": "Los Broxas", diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 6b2376f7..e05159c7 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -311,7 +311,7 @@ "web_store": "Web store", "clear_themes": "Clear", "add_theme": "Add", - "add_theme_modal_title": "Add custom theme", + "add_theme_modal_title": "Create custom theme", "add_theme_modal_description": "Create a new theme to customize Hydra's appearance", "theme_name": "Name", "insert_theme_name": "Insert theme name", diff --git a/src/locales/pt-BR/translation.json b/src/locales/pt-BR/translation.json index a470e628..3bc54a43 100644 --- a/src/locales/pt-BR/translation.json +++ b/src/locales/pt-BR/translation.json @@ -294,6 +294,26 @@ "subscription_renew_cancelled": "A renovação automática está desativada", "subscription_renews_on": "Sua assinatura renova dia {{date}}", "bill_sent_until": "Sua próxima cobrança será enviada até esse dia", + "no_themes": "Parace que você ainda não tem nenhum tema. Não se preocupe, clique aqui para criar sua primeira obra de arte.", + "editor_tab_code": "Código", + "editor_tab_info": "Info", + "editor_tab_save": "Salvar", + "web_store": "Loja de temas", + "clear_themes": "Limpar", + "add_theme": "Adicionar", + "add_theme_modal_title": "Criar tema customizado", + "add_theme_modal_description": "Criar novo tema para customizar a aparência do Hydra", + "theme_name": "Nome", + "insert_theme_name": "Insira o nome do tema", + "set_theme": "Habilitar tema", + "unset_theme": "Desabilitar tema", + "delete_theme": "Deletar tema", + "edit_theme": "Editar tema", + "delete_all_themes": "Deletar todos os temas", + "delete_all_themes_description": "Isso irá deletar todos os seus temas", + "delete_theme_description": "Isso irá deletar o tema {{theme}}", + "cancel": "Cancelar", + "appearance": "Aparência", "enable_torbox": "Habilitar Torbox", "torbox_description": "TorBox é o seu serviço de seedbox premium que rivaliza até com os melhores servidores do mercado.", "torbox_account_linked": "Conta do TorBox vinculada", diff --git a/src/main/events/themes/deeplink.ts b/src/main/events/themes/deeplink.ts new file mode 100644 index 00000000..ca561701 --- /dev/null +++ b/src/main/events/themes/deeplink.ts @@ -0,0 +1,38 @@ +import { themes } from "@main/level/sublevels/themes"; +import { WindowManager } from "@main/services"; +import { Theme } from "@types"; + +export const handleDeepLinkTheme = async ( + themeName: string, + authorCode: string +) => { + const theme: Theme = { + id: crypto.randomUUID(), + name: themeName, + isActive: false, + author: authorCode, + authorName: "spectre", + code: `https://hydrathemes.shop/themes/${themeName}.css`, + createdAt: new Date(), + updatedAt: new Date(), + }; + + await themes.put(theme.id, theme); + + const allThemes = await themes.values().all(); + const activeTheme = allThemes.find((theme: Theme) => theme.isActive); + + if (activeTheme) { + await themes.put(activeTheme.id, { + ...activeTheme, + isActive: false, + }); + } + + WindowManager.mainWindow?.webContents.send("css-injected", theme.code); + + await themes.put(theme.id, { + ...theme, + isActive: true, + }); +}; diff --git a/src/main/index.ts b/src/main/index.ts index 2a18fa31..18423ee8 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -10,6 +10,7 @@ import { PythonRPC } from "./services/python-rpc"; import { Aria2 } from "./services/aria2"; import { db, levelKeys } from "./level"; import { loadState } from "./main"; +import { handleDeepLinkTheme } from "./events/themes/deeplink"; const { autoUpdater } = updater; @@ -86,6 +87,15 @@ const handleDeepLinkPath = (uri?: string) => { if (url.host === "install-source") { WindowManager.redirect(`settings${url.search}`); } + + if (url.host === "install-theme") { + const themeName = url.searchParams.get("theme"); + const authorCode = url.searchParams.get("author"); + + if (themeName && authorCode) { + handleDeepLinkTheme(themeName, authorCode); + } + } } catch (error) { logger.error("Error handling deep link", uri, error); } diff --git a/src/renderer/src/constants.ts b/src/renderer/src/constants.ts index 1d7aa1b1..83293cb6 100644 --- a/src/renderer/src/constants.ts +++ b/src/renderer/src/constants.ts @@ -1,6 +1,6 @@ import { Downloader } from "@shared"; -export const VERSION_CODENAME = "Spectre"; +export const VERSION_CODENAME = "Polychrome"; export const DOWNLOADER_NAME = { [Downloader.RealDebrid]: "Real-Debrid", diff --git a/src/renderer/src/helpers.ts b/src/renderer/src/helpers.ts index 38f07c04..e7f7ce96 100644 --- a/src/renderer/src/helpers.ts +++ b/src/renderer/src/helpers.ts @@ -61,13 +61,20 @@ export const injectCustomCss = (css: string) => { currentCustomCss.remove(); } - const style = document.createElement("style"); - - style.id = "custom-css"; - style.textContent = ` - ${css} - `; - document.head.appendChild(style); + if (css.startsWith("https://hydrathemes.shop/")) { + const link = document.createElement("link"); + link.id = "custom-css"; + link.rel = "stylesheet"; + link.href = css; + document.head.appendChild(link); + } else { + const style = document.createElement("style"); + style.id = "custom-css"; + style.textContent = ` + ${css} + `; + document.head.appendChild(style); + } } catch (error) { console.error("failed to inject custom css:", error); } diff --git a/src/renderer/src/pages/settings/aparence/components/theme-card.scss b/src/renderer/src/pages/settings/aparence/components/theme-card.scss index fd43893e..8499078b 100644 --- a/src/renderer/src/pages/settings/aparence/components/theme-card.scss +++ b/src/renderer/src/pages/settings/aparence/components/theme-card.scss @@ -85,6 +85,10 @@ flex-direction: row; gap: 8px; + &--external { + display: none; + } + Button { padding: 8px 11px; } diff --git a/src/renderer/src/pages/settings/aparence/components/theme-card.tsx b/src/renderer/src/pages/settings/aparence/components/theme-card.tsx index b8797b82..b9460ffc 100644 --- a/src/renderer/src/pages/settings/aparence/components/theme-card.tsx +++ b/src/renderer/src/pages/settings/aparence/components/theme-card.tsx @@ -81,17 +81,6 @@ export const ThemeCard = ({ theme, onListUpdated }: ThemeCardProps) => { >
{theme.name}
- -
- {Object.entries(theme.colors).map(([key, color]) => ( -
- ))} -
{theme.authorName && ( @@ -122,6 +111,11 @@ export const ThemeCard = ({ theme, onListUpdated }: ThemeCardProps) => {
- -
-