|
10 | 10 | <div class="right-panel" :class="{ collapsed: !showTinyRobot }"> |
11 | 11 | <tiny-robot-chat /> |
12 | 12 | </div> |
13 | | - <IconAi @click="showTinyRobot = !showTinyRobot" class="style-settings-icon"></IconAi> |
| 13 | + <IconAi @click="handleShowTinyRobot" class="style-settings-icon"></IconAi> |
| 14 | + <tiny-dialog-box |
| 15 | + v-model:visible="boxVisibility" |
| 16 | + :close-on-click-modal="false" |
| 17 | + title="请填写您的LLM信息, 否则无法体验智能化能力" |
| 18 | + width="30%" |
| 19 | + > |
| 20 | + <div> |
| 21 | + <tiny-form ref="formRef" :model="createData" label-width="120px"> |
| 22 | + <tiny-form-item label="LLM URL" prop="llmUrl" :rules="{ required: true, messages: '必填', trigger: 'blur' }"> |
| 23 | + <tiny-input v-model="createData.llmUrl"></tiny-input> |
| 24 | + </tiny-form-item> |
| 25 | + <tiny-form-item |
| 26 | + label="API Key" |
| 27 | + prop="llmApiKey" |
| 28 | + :rules="{ required: true, messages: '必填', trigger: 'blur' }" |
| 29 | + > |
| 30 | + <tiny-input v-model="createData.llmApiKey"></tiny-input> |
| 31 | + </tiny-form-item> |
| 32 | + <tiny-form-item> |
| 33 | + <tiny-button @click="submit" type="primary">保存</tiny-button> |
| 34 | + </tiny-form-item> |
| 35 | + </tiny-form> |
| 36 | + </div> |
| 37 | + </tiny-dialog-box> |
14 | 38 | </div> |
15 | 39 | </template> |
16 | 40 |
|
17 | 41 | <script setup lang="ts"> |
18 | | -import { onMounted, provide, ref } from 'vue' |
19 | | -import { TinyConfigProvider, TinyModal } from '@opentiny/vue' |
| 42 | +import { onMounted, provide, ref, reactive } from 'vue' |
| 43 | +import { |
| 44 | + TinyConfigProvider, |
| 45 | + TinyModal, |
| 46 | + TinyDialogBox, |
| 47 | + TinyForm, |
| 48 | + TinyFormItem, |
| 49 | + TinyInput, |
| 50 | + TinyButton |
| 51 | +} from '@opentiny/vue' |
20 | 52 | import useTheme from './tools/useTheme' |
21 | 53 | import TinyRobotChat from './components/tiny-robot-chat.vue' |
22 | 54 | import { IconAi } from '@opentiny/tiny-robot-svgs' |
23 | 55 | import { showTinyRobot } from './composable/utils' |
24 | 56 | import { createServer, createInMemoryTransport } from '@opentiny/next-sdk' |
25 | | -
|
26 | 57 | import { createGlobalMcpTool } from './tools/globalMcpTool' |
| 58 | +import { $local, isEnvLLMDefined, isLocalLLMDefined } from './composable/utils' |
| 59 | +
|
| 60 | +const boxVisibility = ref(false) |
| 61 | +const formRef = ref() |
| 62 | +const createData = reactive({ |
| 63 | + llmUrl: $local.llmUrl || import.meta.env.VITE_LLM_URL, |
| 64 | + llmApiKey: $local.llmApiKey || import.meta.env.VITE_LLM_API_KEY |
| 65 | +}) |
| 66 | +
|
| 67 | +const submit = () => { |
| 68 | + formRef.value.validate().then(() => { |
| 69 | + $local.llmUrl = createData.llmUrl |
| 70 | + $local.llmApiKey = createData.llmApiKey |
| 71 | + boxVisibility.value = false |
| 72 | + window.location.reload() |
| 73 | + }) |
| 74 | +} |
27 | 75 |
|
28 | 76 | const previewUrl = ref(import.meta.env.VITE_PLAYGROUND_URL) |
29 | 77 | const modalSHow = ref(false) |
@@ -65,6 +113,14 @@ provide('showPreview', (url) => { |
65 | 113 | previewUrl.value = url |
66 | 114 | modalSHow.value = true |
67 | 115 | }) |
| 116 | +
|
| 117 | +const handleShowTinyRobot = () => { |
| 118 | + if (!isEnvLLMDefined && !isLocalLLMDefined) { |
| 119 | + boxVisibility.value = true |
| 120 | + } else { |
| 121 | + showTinyRobot.value = !showTinyRobot.value |
| 122 | + } |
| 123 | +} |
68 | 124 | </script> |
69 | 125 |
|
70 | 126 | <style scoped lang="less"> |
|
0 commit comments