Skip to content

Commit b90601f

Browse files
author
antalike
committed
feat: add region switcher
1 parent bcf6cdc commit b90601f

8 files changed

Lines changed: 104 additions & 1 deletion

File tree

app/components/AppHeader.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import type { ContentNavigationItem } from '@nuxt/content'
33
import { getHomePath } from '~/utils'
4+
import SiteSwitcher from './SiteSwitcher.vue'
45
56
const { t, locale } = useI18n()
67
const { header } = useAppConfig()
@@ -61,8 +62,9 @@ function gotoHome() {
6162
<!-- <AssistantCollapse class="ml-2.5" /> -->
6263

6364
<template #right>
65+
<SiteSwitcher />
6466
<LanguageSwitcher />
65-
<JoinCommunityButton />
67+
<JoinCommunityButton class="hidden sm:flex" />
6668
<button
6769
class="hidden sm:flex items-center gap-1.5 h-7 px-2.5 bg-linear-270 from-15% from-linear-primary to-118% to-primary-light rounded-md cursor-pointer"
6870
@click="gotoHome"

app/components/SiteSwitcher.vue

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<script setup lang="ts">
2+
type Site = 'cn' | 'intl'
3+
interface ItemProps {
4+
value: Site
5+
label: string
6+
description: string
7+
to: string
8+
}
9+
10+
const { t, locale } = useI18n()
11+
const { docsUrl, docsIntl } = useRuntimeConfig().public
12+
const langPrefix = locale.value === 'cn' ? '/cn' : ''
13+
const items = computed<ItemProps[]>(() => [
14+
{
15+
value: 'cn',
16+
label: t('sites.cn.label'),
17+
description: t('sites.cn.description'),
18+
to: docsUrl as string
19+
},
20+
{
21+
value: 'intl',
22+
label: t('sites.intl.label'),
23+
description: t('sites.intl.description'),
24+
to: docsIntl as string
25+
}
26+
])
27+
const value = ref<Site>(isIntl() ? 'intl' : 'cn')
28+
const selected = computed<ItemProps | undefined>(() => items.value.find(item => item.value === value.value))
29+
30+
function onClick(item: ItemProps) {
31+
if (item.value === value.value) {
32+
return
33+
}
34+
value.value = item.value
35+
navigateTo(`${item.to}${langPrefix}/?site=${item.value}`, { external: true })
36+
}
37+
</script>
38+
39+
<template>
40+
<UPopover
41+
mode="hover"
42+
:content="{
43+
align: 'start'
44+
}"
45+
:ui="{
46+
content: 'min-w-46 p-2 bg-[#192337] border-1 border-white/10'
47+
}"
48+
>
49+
<button
50+
class="group flex items-center h-7 px-2.5 space-x-1.5 text-[#E2E8F0] text-xs font-medium cursor-pointer border border-slate-600 rounded-md hover:border-slate-100 data-[state=open]:border-slate-100"
51+
>
52+
<UIcon
53+
name="i-ri-earth-line"
54+
class="size-4"
55+
/>
56+
<span>{{ selected?.label }}</span>
57+
</button>
58+
<template #content>
59+
<div
60+
v-for="item in items"
61+
:key="item.value"
62+
class="flex flex-col gap-0.5 p-1.5 hover:bg-white/10 rounded-md cursor-pointer"
63+
@click="onClick(item)"
64+
>
65+
<span class="text-sm leading-5 text-slate-50">{{ item.label }}</span>
66+
<span class="text-sm leading-5 text-[#6A7584]">{{ item.description }}</span>
67+
</div>
68+
</template>
69+
</UPopover>
70+
</template>

app/composables/useCommon.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,8 @@ export function useCdnUrl(path = '/') {
5151
const baseUrl = $config.public.cdnUrl || 'https://cdn.memtensor.com.cn'
5252
return `${baseUrl}${path}`
5353
}
54+
55+
export function isIntl() {
56+
const { $config } = useNuxtApp()
57+
return $config.public.env === 'intl'
58+
}

envConfig/config.intl.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ export default {
77
playgroundUrl: 'https://memos-playground.memtensor.net',
88
staticCdnUrl: 'https://cdn.memt.ai/static',
99
cdnUrl: 'https://cdn.memt.ai',
10+
docsUrl: 'https://docs-pre.openmem.net',
11+
docsIntl: 'https://memos-docs.memtensor.net',
1012
baseUrl: 'https://api.memt.ai'
1113
}

envConfig/config.pre.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ export default {
66
githubMemosUrl: 'https://github.com/MemTensor/MemOS',
77
dashboardUrl: 'https://memos-dashboard-pre.openmem.net',
88
playgroundUrl: 'https://memos-playground-pre.openmem.net',
9+
docsUrl: 'https://docs-pre.openmem.net',
10+
docsIntl: 'https://memos-docs.memtensor.net',
911
baseUrl: 'https://apigw-pre.memtensor.cn'
1012
}

envConfig/config.prod.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ export default {
55
githubMemosUrl: 'https://github.com/MemTensor/MemOS',
66
dashboardUrl: 'https://memos-dashboard.openmem.net',
77
playgroundUrl: 'https://memos-playground.openmem.net',
8+
docsUrl: 'https://memos-docs.openmem.net',
9+
docsIntl: 'https://memos-docs.memtensor.net',
810
baseUrl: 'https://memos.memtensor.cn'
911
}

i18n/locales/cn.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,15 @@ export default {
100100
inputPlaceholder: '请输入你想了解的问题...',
101101
welcome: 'Hi,我是MemOS知识库助手小忆,您有什么问题可以直接向我提问!',
102102
systemError: '系统繁忙,请稍后再试'
103+
},
104+
sites: {
105+
cn: {
106+
label: '中国大陆',
107+
description: '阿里云服务'
108+
},
109+
intl: {
110+
label: '全球',
111+
description: '亚马逊云服务'
112+
}
103113
}
104114
}

i18n/locales/en.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,15 @@ export default {
100100
inputPlaceholder: 'Type your messages here...',
101101
welcome: 'Hi, I\'m Xiao Yi, your MemOS Knowledge Base Assistant. Feel free to ask me anything you\'d like to know!',
102102
systemError: 'System is busy, please try again later'
103+
},
104+
sites: {
105+
cn: {
106+
label: 'Mainland China',
107+
description: 'Alibaba Cloud'
108+
},
109+
intl: {
110+
label: 'Global',
111+
description: 'AWS'
112+
}
103113
}
104114
}

0 commit comments

Comments
 (0)