Skip to content

Commit fbf244c

Browse files
committed
improve the autocompletion for mock service
1 parent f300ad3 commit fbf244c

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

console/atest-ui/src/views/MockManager.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<script setup lang="ts">
22
import { ref, watch } from 'vue';
33
import { Codemirror } from 'vue-codemirror';
4-
import * as yaml from 'js-yaml';
4+
import yaml from 'js-yaml';
55
import { jsonSchema } from "codemirror-json-schema";
6+
import { NewLanguageComplete } from './languageComplete'
7+
import { jsonLanguage } from "@codemirror/lang-json"
68
import { API } from './net';
79
import {useI18n} from "vue-i18n";
810
import EditButton from '../components/EditButton.vue'
@@ -11,6 +13,7 @@ import mockSchema from '../assets/api-testing-mock-schema.json';
1113
const { t } = useI18n()
1214
1315
const mockschema = ref(mockSchema as any); // Type assertion to any for JSON schema
16+
const jsonComplete = NewLanguageComplete(jsonLanguage)
1417
1518
interface MockConfig {
1619
Config: string
@@ -31,7 +34,6 @@ watch(mockConfig, (newValue) => {
3134
}, { deep: true });
3235
3336
function jsonToYaml(jsonData: object | string): string {
34-
// 如果是字符串,先解析成对象
3537
const data = typeof jsonData === 'string'
3638
? JSON.parse(jsonData)
3739
: jsonData;
@@ -88,11 +90,12 @@ items:
8890
<div>
8991
<el-tabs v-model="tabActive">
9092
<el-tab-pane label="YAML" name="yaml">
91-
<Codemirror v-model="mockConfig.Config" />
93+
<Codemirror v-model="mockConfig.Config"
94+
:extensions="[jsonComplete]" />
9295
</el-tab-pane>
9396
<el-tab-pane label="JSON" name="json">
9497
<Codemirror v-model="mockConfig.ConfigAsJSON"
95-
:extensions="[jsonSchema(mockschema)]" />
98+
:extensions="[jsonSchema(mockschema), jsonComplete]" />
9699
</el-tab-pane>
97100
</el-tabs>
98101
</div>

console/atest-ui/vite.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ export default defineConfig({
3131
'@': fileURLToPath(new URL('./src', import.meta.url))
3232
}
3333
},
34+
build: {
35+
rollupOptions: {
36+
output: {
37+
manualChunks: () => 'everything'
38+
}
39+
}
40+
},
3441
server: {
3542
proxy: {
3643
'/server.Runner': {

pkg/mock/in_memory.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ func (s *inMemoryServer) startItem(item Item) {
392392
} else {
393393
existedRoute.HandlerFunc(adHandler.handle)
394394
}
395-
// s.mux.HandleFunc(item.Request.Path, adHandler.handle).Methods(strings.Split(method, ",")...).Headers(headerSlices...)
396395
}
397396

398397
type advanceHandler struct {

0 commit comments

Comments
 (0)