Skip to content

Commit

Permalink
feat(desktop): update menu links to support dynamic language-based URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
Red-Asuka committed Feb 5, 2025
1 parent a334400 commit 97c7d25
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions apps/desktop/src/main/config/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ function getMenuLabels(lang: Lang) {
const isMac = process.platform === 'darwin'

function getMenuTemplate(win: BrowserWindow, lang?: Lang) {
const labels = getMenuLabels(lang || 'en')
const language = lang || 'en'
const labels = getMenuLabels(language)
const MQTTXWebsite = `https://mqttx.app${['zh', 'ja'].includes(language) ? `/${lang}` : ''}`
const EMQWebsite = `https://emqx.com${['en', 'zh', 'ja'].includes(language) ? `/${lang}` : '/en'}`

const macAppMenu: MenuItemConstructorOptions = {
label: app.getName(),
Expand Down Expand Up @@ -159,7 +162,7 @@ function getMenuTemplate(win: BrowserWindow, lang?: Lang) {
{
label: labels.documentation,
click: async () => {
await shell.openExternal('https://mqttx.app/docs?utm_source=mqttx&utm_medium=referral&utm_campaign=menu-to-docs')
await shell.openExternal(`${MQTTXWebsite}/docs?utm_source=mqttx&utm_medium=referral&utm_campaign=menu-to-docs`)
},
},
{
Expand All @@ -171,7 +174,7 @@ function getMenuTemplate(win: BrowserWindow, lang?: Lang) {
{
label: labels.contactUs,
click: async () => {
await shell.openExternal('https://www.emqx.com/en/contact?utm_source=mqttx&utm_medium=referral&utm_campaign=menu-to-contact')
await shell.openExternal(`${EMQWebsite}/contact?utm_source=mqttx&utm_medium=referral&utm_campaign=menu-to-contact`)
},
},
{ type: 'separator' },
Expand All @@ -191,13 +194,13 @@ function getMenuTemplate(win: BrowserWindow, lang?: Lang) {
{
label: labels.MQTTXWebsite,
click: async () => {
await shell.openExternal('https://mqttx.app?utm_source=mqttx&utm_medium=referral&utm_campaign=menu-to-homepage')
await shell.openExternal(`${MQTTXWebsite}?utm_source=mqttx&utm_medium=referral&utm_campaign=menu-to-homepage`)
},
},
{
label: labels.EMQWebsite,
click: async () => {
await shell.openExternal('https://www.emqx.com/en?utm_source=mqttx&utm_medium=referral&utm_campaign=menu-to-homepage')
await shell.openExternal(`${EMQWebsite}?utm_source=mqttx&utm_medium=referral&utm_campaign=menu-to-homepage`)
},
},
],
Expand Down

0 comments on commit 97c7d25

Please sign in to comment.