Skip to content

Commit f368537

Browse files
authored
Merge pull request #370 from antalike/v2/env-intl-merge
V2/env intl merge
2 parents ab26f7a + b90601f commit f368537

File tree

12 files changed

+124
-7
lines changed

12 files changed

+124
-7
lines changed

app/components/Api/Path.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const props = defineProps<{
1414
}>()
1515
1616
const { server } = useOpenApi(inject('collectionName'))
17+
const { replaceVariables } = useVariableReplacement()
1718
1819
const colorsMap: colorsProps = {
1920
get: {
@@ -52,7 +53,7 @@ function isParameter(path: string) {
5253
5354
// Copy full path
5455
function handleCopy() {
55-
const baseUrl = server.value ?? ''
56+
const baseUrl = replaceVariables(server.value ?? '')
5657
5758
copyText(baseUrl + props.path)
5859
isCopy.value = true

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+
}

app/composables/useVariableReplacement.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export const useVariableReplacement = () => {
1111
'https://statics.memtensor.com.cn': config.public.staticCdnUrl as string,
1212
'https://memos-playground.openmem.net': config.public.playgroundUrl as string,
1313
'https://memos-dashboard.openmem.net': config.public.dashboardUrl as string,
14-
'https://memos.openmem.net': config.public.homeDomain as string
14+
'https://memos.openmem.net': config.public.homeDomain as string,
15+
'https://memos.memtensor.cn': config.public.baseUrl as string
1516
}
1617

1718
Object.keys(domains).forEach((key) => {

envConfig/config.intl.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@ export default {
66
dashboardUrl: 'https://memos-dashboard.memtensor.net',
77
playgroundUrl: 'https://memos-playground.memtensor.net',
88
staticCdnUrl: 'https://cdn.memt.ai/static',
9-
cdnUrl: 'https://cdn.memt.ai'
9+
cdnUrl: 'https://cdn.memt.ai',
10+
docsUrl: 'https://docs-pre.openmem.net',
11+
docsIntl: 'https://memos-docs.memtensor.net',
12+
baseUrl: 'https://api.memt.ai'
1013
}

envConfig/config.pre.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ export default {
55
openMemUrl: 'https://pre.openmem.net',
66
githubMemosUrl: 'https://github.com/MemTensor/MemOS',
77
dashboardUrl: 'https://memos-dashboard-pre.openmem.net',
8-
playgroundUrl: 'https://memos-playground-pre.openmem.net'
8+
playgroundUrl: 'https://memos-playground-pre.openmem.net',
9+
docsUrl: 'https://docs-pre.openmem.net',
10+
docsIntl: 'https://memos-docs.memtensor.net',
11+
baseUrl: 'https://apigw-pre.memtensor.cn'
912
}

envConfig/config.prod.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ export default {
44
openMemUrl: 'https://openmem.net',
55
githubMemosUrl: 'https://github.com/MemTensor/MemOS',
66
dashboardUrl: 'https://memos-dashboard.openmem.net',
7-
playgroundUrl: 'https://memos-playground.openmem.net'
7+
playgroundUrl: 'https://memos-playground.openmem.net',
8+
docsUrl: 'https://memos-docs.openmem.net',
9+
docsIntl: 'https://memos-docs.memtensor.net',
10+
baseUrl: 'https://memos.memtensor.cn'
811
}

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)