|
222 | 222 | </div> |
223 | 223 | </div> |
224 | 224 |
|
| 225 | + <!-- mcp space env --> |
| 226 | + <el-divider v-if="theSdk === 'mcp_server' && Object.keys(mcpEnv).length > 0"/> |
| 227 | + <div v-if="theSdk === 'mcp_server' && Object.keys(mcpEnv).length > 0"> |
| 228 | + <div class="flex xl:flex-col gap-8"> |
| 229 | + <div class="w-[380px] sm:w-full flex flex-col"> |
| 230 | + <div class="text-sm text-gray-700 leading-[20px] font-medium"> |
| 231 | + {{ $t('mcps.deploy.envDesc') }} |
| 232 | + </div> |
| 233 | + </div> |
| 234 | + <div class="flex flex-col gap-[6px]"> |
| 235 | + <div v-for="(_, envKey) in mcpEnv" :key="envKey" class="mb-3"> |
| 236 | + <label |
| 237 | + :for="envKey" |
| 238 | + class="text-gray-600 text-sm block mb-1" |
| 239 | + > |
| 240 | + {{ envKey }} |
| 241 | + </label> |
| 242 | + <el-input |
| 243 | + v-model="mcpEnv[envKey]" |
| 244 | + size="large" |
| 245 | + class="!w-[400px] sm:!w-full" |
| 246 | + /> |
| 247 | + </div> |
| 248 | + <el-button @click="updateEnv" class="w-[100px]" data-test="update-mcp-env"> |
| 249 | + {{ $t('all.update') }} |
| 250 | + </el-button> |
| 251 | + </div> |
| 252 | + </div> |
| 253 | + </div> |
| 254 | + |
225 | 255 | <el-divider /> |
226 | 256 |
|
227 | 257 | <!-- 修改可见性 --> |
|
408 | 438 | ], |
409 | 439 | uploadCoverImageUrl: '/images/default_cover_image.png', |
410 | 440 | imageUploaded: false, |
| 441 | + mcpEnv: {}, |
411 | 442 | t: useI18n() |
412 | 443 | } |
413 | 444 | }, |
|
471 | 502 | emits: ['showSpaceLogs'], |
472 | 503 | mounted() { |
473 | 504 | this.fetchSpaceResources() |
| 505 | + if (this.theSdk === 'mcp_server') { |
| 506 | + this.fetchSpaceDetail() |
| 507 | + } |
474 | 508 | }, |
475 | 509 | inject: ['fetchRepoDetail'], |
476 | 510 | methods: { |
|
608 | 642 | } |
609 | 643 | }, |
610 | 644 |
|
| 645 | + async fetchSpaceDetail () { |
| 646 | + const { data, error } = await useFetchApi( |
| 647 | + `/spaces/${this.path}` |
| 648 | + ).json() |
| 649 | + if (error.value) { |
| 650 | + console.log(error.value.msg) |
| 651 | + } else { |
| 652 | + const body = data.value |
| 653 | + const envJSON = body.data.env |
| 654 | + if (envJSON) { |
| 655 | + try { |
| 656 | + this.mcpEnv = JSON.parse(envJSON) |
| 657 | + } catch (error) { |
| 658 | + console.log(error) |
| 659 | + } |
| 660 | + } |
| 661 | + } |
| 662 | + }, |
| 663 | +
|
| 664 | + updateEnv() { |
| 665 | + const payload = { env: JSON.stringify(this.mcpEnv) } |
| 666 | + this.updateApplicationSpace(payload) |
| 667 | + }, |
| 668 | +
|
611 | 669 | changeVisibility(value) { |
612 | 670 | ElMessageBox({ |
613 | 671 | title: this.$t('application_spaces.edit.changeVisibility'), |
|
0 commit comments