Skip to content

Commit ab26f7a

Browse files
authored
Merge pull request #360 from antalike/v2/env-intl-merge
V2/env intl merge
2 parents cc240c3 + 32c25bb commit ab26f7a

11 files changed

Lines changed: 153 additions & 13 deletions

File tree

app/components/Api/Authorizations/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const props = defineProps<{
66
77
const collectionName = inject<CollectionName>('collectionName')
88
const { getSecurityWithTypes } = useOpenApi(collectionName)
9+
const { replaceVariables } = useVariableReplacement()
910
1011
const securitys = computed<SecurityProps[]>(() => {
1112
return getSecurityWithTypes(props.path, props.method)
@@ -47,7 +48,7 @@ const securitys = computed<SecurityProps[]>(() => {
4748
<template v-if="security.scheme.description">
4849
<p
4950
class="mt-4 whitespace-pre-line text-gray-400 text-sm"
50-
v-html="security.scheme.description"
51+
v-html="replaceVariables(security.scheme.description)"
5152
/>
5253
</template>
5354
</div>

app/components/AppFooter.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ const columns = computed(() => [
124124
])
125125
const qrcodeData = computed(() => [
126126
{
127-
img: 'https://statics.memtensor.com.cn/landing-v2/qrcode-wechat-v2.webp',
127+
img: useStaticCdnUrl(`/landing-v2/qrcode-wechat-v2.webp`),
128128
label: t('footer.wechatGroup')
129129
},
130130
{
131-
img: 'https://cdn.memtensor.com.cn/img/1768371361386_sjmr00_compressed.png',
131+
img: useCdnUrl(`/img/1768371361386_sjmr00_compressed.png`),
132132
label: t('footer.officialAccount')
133133
}
134134
])
@@ -153,7 +153,7 @@ const qrcodeData = computed(() => [
153153
<div class="flex flex-col">
154154
<div class="flex flex-row items-center gap-3.5 w-fit ">
155155
<img
156-
src="https://statics.memtensor.com.cn/logo/memtensor-w.png"
156+
:src="useStaticCdnUrl(`/logo/memtensor-w.png`)"
157157
class="sm:w-20 w-15"
158158
>
159159
<p class="sm:mt-1.5 text-[28px] leading-10 font-semibold bg-linear-180 from-8% from-white to-100% to-white/60 bg-clip-text text-transparent">
@@ -240,7 +240,7 @@ const qrcodeData = computed(() => [
240240
<div class="grid grid-cols-2 gap-4">
241241
<div class="space-y-2">
242242
<img
243-
src="https://statics.memtensor.com.cn/landing-v2/qrcode-wechat-v2.webp"
243+
:src="useStaticCdnUrl(`/landing-v2/qrcode-wechat-v2.webp`)"
244244
class="size-30"
245245
>
246246
<div class="flex items-center justify-center gap-1.5">
@@ -253,7 +253,7 @@ const qrcodeData = computed(() => [
253253
</div>
254254
<div class="space-y-2">
255255
<img
256-
src="https://statics.memtensor.com.cn/landing-v2/qrcode-discord-v2.webp"
256+
:src="useStaticCdnUrl(`/landing-v2/qrcode-discord-v2.webp`)"
257257
class="size-30"
258258
>
259259
<div class="flex items-center justify-center gap-1.5">

app/components/JoinCommunityButton.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div class="grid grid-cols-2 gap-4">
1818
<div class="space-y-2">
1919
<img
20-
src="https://statics.memtensor.com.cn/landing-v2/qrcode-wechat-v2.webp"
20+
:src="useStaticCdnUrl(`/landing-v2/qrcode-wechat-v2.webp`)"
2121
class="size-30"
2222
>
2323
<div class="flex items-center justify-center gap-1.5">
@@ -30,7 +30,7 @@
3030
</div>
3131
<div class="space-y-2">
3232
<img
33-
src="https://statics.memtensor.com.cn/landing-v2/qrcode-discord-v2.webp"
33+
:src="useStaticCdnUrl(`/landing-v2/qrcode-discord-v2.webp`)"
3434
class="size-30"
3535
>
3636
<div class="flex items-center justify-center gap-1.5">

app/composables/useCommon.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@ export function useOpenMemUrl() {
3939

4040
return $config.public.openMemUrl || 'https://openmem.net/'
4141
}
42+
43+
export function useStaticCdnUrl(path = '/') {
44+
const { $config } = useNuxtApp()
45+
const baseUrl = $config.public.staticCdnUrl || 'https://statics.memtensor.com.cn'
46+
return `${baseUrl}${path}`
47+
}
48+
49+
export function useCdnUrl(path = '/') {
50+
const { $config } = useNuxtApp()
51+
const baseUrl = $config.public.cdnUrl || 'https://cdn.memtensor.com.cn'
52+
return `${baseUrl}${path}`
53+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export const useVariableReplacement = () => {
2+
const config = useRuntimeConfig()
3+
4+
const replaceVariables = (text: string) => {
5+
if (!text) return text
6+
7+
let newText = text
8+
9+
const domains: Record<string, string> = {
10+
'https://cdn.memtensor.com.cn': config.public.cdnUrl as string,
11+
'https://statics.memtensor.com.cn': config.public.staticCdnUrl as string,
12+
'https://memos-playground.openmem.net': config.public.playgroundUrl as string,
13+
'https://memos-dashboard.openmem.net': config.public.dashboardUrl as string,
14+
'https://memos.openmem.net': config.public.homeDomain as string
15+
}
16+
17+
Object.keys(domains).forEach((key) => {
18+
if (domains[key]) {
19+
newText = newText.split(key).join(domains[key])
20+
}
21+
})
22+
23+
return newText
24+
}
25+
26+
return {
27+
replaceVariables
28+
}
29+
}

app/pages/index.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ const items = computed(() => localeItems.value.map((item, index) => ({
6161
:to="item.to"
6262
>
6363
<div
64-
class="flex items-center justify-center h-40 bg-[#171823] bg-cover rounded-xl mb-8 bg-[url(https://cdn.memtensor.com.cn/img/1766476630033_bbjhot_compressed.png)] group-hover:bg-[url(https://cdn.memtensor.com.cn/img/1766476753478_f7b4hm_compressed.png)]"
64+
class="flex items-center justify-center h-40 bg-[#171823] bg-cover rounded-xl mb-8 bg-(image:--bg) group-hover:bg-(image:--hover-bg)"
65+
:style="{
66+
'--bg': `url(${useCdnUrl('/img/1766476630033_bbjhot_compressed.png')})`,
67+
'--hover-bg': `url(${useCdnUrl('/img/1766476753478_f7b4hm_compressed.png')})`
68+
}"
6569
>
6670
<UIcon
6771
:name="item.icon!"

envConfig/config.intl.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
env: 'intl',
3+
homeDomain: 'https://memos.memtensor.net',
4+
openMemUrl: 'https://openmem.net',
5+
githubMemosUrl: 'https://github.com/MemTensor/MemOS',
6+
dashboardUrl: 'https://memos-dashboard.memtensor.net',
7+
playgroundUrl: 'https://memos-playground.memtensor.net',
8+
staticCdnUrl: 'https://cdn.memt.ai/static',
9+
cdnUrl: 'https://cdn.memt.ai'
10+
}

envConfig/config.prod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default {
22
env: 'prod',
33
homeDomain: 'https://memos.openmem.net',
4-
openMemUrl: 'https://memos.openmem.net/',
4+
openMemUrl: 'https://openmem.net',
55
githubMemosUrl: 'https://github.com/MemTensor/MemOS',
66
dashboardUrl: 'https://memos-dashboard.openmem.net',
77
playgroundUrl: 'https://memos-playground.openmem.net'

nuxt.config.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import yaml from '@rollup/plugin-yaml'
22
import type { NuxtConfig } from '@nuxt/schema'
33
import pkg from './package.json'
44
import { getCnRoutes, getCnApiReferenceRoutes } from './scripts/extract-routes.mjs'
5+
import remarkReplaceDomains from './scripts/remark-replace-domains.mjs'
56

67
const cnRoutes = getCnRoutes()
78
const cnApiRoutes = getCnApiReferenceRoutes()
@@ -15,12 +16,15 @@ const envConfig = await import(`./envConfig/config.${env}.ts`).then(m => m.defau
1516
}
1617
})
1718

19+
const staticCdnUrl = envConfig.staticCdnUrl || 'https://statics.memtensor.com.cn'
20+
const cdnUrl = envConfig.cdnUrl || 'https://cdn.memtensor.com.cn'
21+
1822
const config: NuxtConfig = {
1923
app: {
2024
head: {
2125
script: [
22-
{ src: 'https://cdn.memtensor.com.cn/file/js-cookie-3.0.5.min.js', type: 'text/javascript' },
23-
{ src: 'https://cdn.memtensor.com.cn/file/locale.1.1.2.min.js', type: 'text/javascript' }
26+
{ src: `${cdnUrl}/file/js-cookie-3.0.5.min.js`, type: 'text/javascript' },
27+
{ src: `${cdnUrl}/file/locale.1.1.2.min.js`, type: 'text/javascript' }
2428
]
2529
}
2630
},
@@ -37,7 +41,9 @@ const config: NuxtConfig = {
3741
public: {
3842
...envConfig,
3943
version: pkg.version,
40-
apiBase: 'https://apigw.memtensor.cn'
44+
apiBase: 'https://apigw.memtensor.cn',
45+
staticCdnUrl,
46+
cdnUrl
4147
}
4248
},
4349

@@ -72,6 +78,11 @@ const config: NuxtConfig = {
7278
],
7379
optimizeDeps: {
7480
include: ['debug']
81+
},
82+
build: {
83+
rollupOptions: {
84+
external: ['remark-replace-domains']
85+
}
7586
}
7687
},
7788

@@ -87,6 +98,22 @@ const config: NuxtConfig = {
8798
content: {
8899
build: {
89100
markdown: {
101+
remarkPlugins: {
102+
'remark-replace-domains': {
103+
instance: remarkReplaceDomains,
104+
options: {
105+
imageDomains: {
106+
'https://cdn.memtensor.com.cn': cdnUrl,
107+
'https://statics.memtensor.com.cn': staticCdnUrl
108+
},
109+
linkDomains: {
110+
'https://memos-playground.openmem.net': envConfig.playgroundUrl,
111+
'https://memos-dashboard.openmem.net': envConfig.dashboardUrl,
112+
'https://memos.openmem.net': envConfig.homeDomain
113+
}
114+
}
115+
}
116+
},
90117
highlight: {
91118
langs: ['bash', 'shell', 'ts', 'typescript', 'diff', 'vue', 'json', 'yml', 'css', 'mdc', 'python', 'py', 'mermaid', 'markdown', 'md']
92119
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
"scripts": {
77
"build": "nuxt build",
88
"dev": "nuxt dev",
9+
"dev:intl": "NUXT_ENV_CONFIG=intl nuxt dev",
910
"sync-api": "node scripts/fetch-api.mjs",
1011
"sync-releases": "node scripts/fetch-releases.mjs",
1112
"generate": "node scripts/generate.mjs",
13+
"generate:intl": "node scripts/generate.mjs --env=intl",
1214
"publish": "node scripts/generate.mjs",
1315
"preview": "nuxt preview",
1416
"lint": "eslint .",

0 commit comments

Comments
 (0)