|
1 | 1 | <script setup lang="ts"> |
2 | 2 | import { ref, watch } from 'vue'; |
3 | 3 | import { Codemirror } from 'vue-codemirror'; |
| 4 | +import { ElMessage } from 'element-plus' |
4 | 5 | import yaml from 'js-yaml'; |
5 | 6 | import { jsonSchema } from "codemirror-json-schema"; |
6 | 7 | import { NewTemplateLangComplete, NewHeaderLangComplete } from './languageComplete' |
@@ -34,6 +35,10 @@ interface MockConfig { |
34 | 35 | ConfigAsJSON: string |
35 | 36 | Prefix: string |
36 | 37 | Port: number |
| 38 | + storeKind: string |
| 39 | + storeLocalFile?: string |
| 40 | + storeURL?: string |
| 41 | + storeRemote?: string |
37 | 42 | } |
38 | 43 |
|
39 | 44 | const tabActive = ref('yaml') |
@@ -64,10 +69,18 @@ function jsonToYaml(jsonData: object | string): string { |
64 | 69 | } |
65 | 70 |
|
66 | 71 | const link = ref('') |
67 | | -API.GetMockConfig((d) => { |
68 | | - mockConfig.value = d |
69 | | - link.value = `http://${window.location.hostname}:${d.Port}${d.Prefix}/api.json` |
70 | | -}) |
| 72 | +const loadConfig = () => { |
| 73 | + API.GetMockConfig((d) => { |
| 74 | + ElMessage({ |
| 75 | + showClose: true, |
| 76 | + message: 'Config loaded!', |
| 77 | + type: 'success' |
| 78 | + }); |
| 79 | + mockConfig.value = d |
| 80 | + link.value = `http://${window.location.hostname}:${d.Port}${d.Prefix}/api.json` |
| 81 | + }) |
| 82 | +} |
| 83 | +loadConfig() |
71 | 84 | const prefixChanged = (p: string) => { |
72 | 85 | mockConfig.value.Prefix = p |
73 | 86 | } |
@@ -96,13 +109,23 @@ items: |
96 | 109 | <template> |
97 | 110 | <div> |
98 | 111 | <el-button type="primary" @click="insertSample">{{t('button.insertSample')}}</el-button> |
99 | | - <el-button type="warning" @click="API.ReloadMockServer(mockConfig)">{{t('button.reload')}}</el-button> |
| 112 | + <el-button type="warning" @click="API.ReloadMockServer(mockConfig).then(() => loadConfig())">{{t('button.reload')}}</el-button> |
100 | 113 | <el-divider direction="vertical" /> |
101 | 114 | <el-link target="_blank" :href="link">{{ link }}</el-link> <!-- Noncompliant --> |
102 | 115 | </div> |
103 | 116 | <div class="config"> |
104 | 117 | API Prefix:<EditButton :value="mockConfig.Prefix" @changed="prefixChanged"/> |
105 | 118 | Port:<EditButton :value="mockConfig.Port" @changed="portChanged"/> |
| 119 | + Store: |
| 120 | + <el-select v-model="mockConfig.storeKind" placeholder="Select Store Kind"> |
| 121 | + <el-option label="Memory" value="memory"></el-option> |
| 122 | + <el-option label="Local File" value="localFile"></el-option> |
| 123 | + <el-option label="Remote" value="remote"></el-option> |
| 124 | + <el-option label="URL" value="url"></el-option> |
| 125 | + </el-select> |
| 126 | + <span v-if="mockConfig.storeKind === 'localFile'"> |
| 127 | + File:<el-input v-model="mockConfig.storeLocalFile" placeholder="Local File Path"></el-input> |
| 128 | + </span> |
106 | 129 | </div> |
107 | 130 | <el-splitter layout="vertical" style="height: calc(100vh - 100px);"> |
108 | 131 | <el-splitter-panel size="70%"> |
|
0 commit comments