11<script setup lang="ts">
22import { ref , watch } from ' vue' ;
33import { Codemirror } from ' vue-codemirror' ;
4+ import { ElMessage } from ' element-plus'
45import yaml from ' js-yaml' ;
56import { jsonSchema } from " codemirror-json-schema" ;
67import { NewTemplateLangComplete , NewHeaderLangComplete } from ' ./languageComplete'
@@ -34,6 +35,10 @@ interface MockConfig {
3435 ConfigAsJSON: string
3536 Prefix: string
3637 Port: number
38+ storeKind: string
39+ storeLocalFile? : string
40+ storeURL? : string
41+ storeRemote? : string
3742}
3843
3944const tabActive = ref (' yaml' )
@@ -64,10 +69,18 @@ function jsonToYaml(jsonData: object | string): string {
6469}
6570
6671const 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 ()
7184const prefixChanged = (p : string ) => {
7285 mockConfig .value .Prefix = p
7386}
@@ -96,13 +109,21 @@ items:
96109<template >
97110 <div >
98111 <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 >
100113 <el-divider direction =" vertical" />
101114 <el-link target =" _blank" :href =" link" >{{ link }}</el-link > <!-- Noncompliant -->
102115 </div >
103116 <div class =" config" >
104117 API Prefix:<EditButton :value =" mockConfig.Prefix" @changed =" prefixChanged" />
105118 Port:<EditButton :value =" mockConfig.Port" @changed =" portChanged" />
119+ Store:
120+ <el-select v-model =" mockConfig.storeKind" placeholder =" Select Store Kind"
121+ class =" m-2 select"
122+ size =" default" >
123+ <el-option label =" Memory" value =" memory" ></el-option >
124+ <el-option label =" Local File" value =" localFile" ></el-option >
125+ </el-select >
126+ <el-input v-model =" mockConfig.storeLocalFile" placeholder =" Local File Path" v-if =" mockConfig.storeKind === 'localFile'" ></el-input >
106127 </div >
107128 <el-splitter layout =" vertical" style =" height : calc (100vh - 100px );" >
108129 <el-splitter-panel size =" 70%" >
@@ -118,12 +139,12 @@ items:
118139 </el-tabs >
119140 </el-splitter-panel >
120141 <el-splitter-panel size =" 30%" >
121- <el-card class = " log-output " shadow =" hover" >
142+ <el-card shadow =" hover" >
122143 <template #header >
123144 <span >{{ t('title.logs') }}</span >
124145 </template >
125- <el-scrollbar ref = " logScrollbar " >
126- <pre style =" white-space : pre-wrap ; word-break : break-all ;" >{{ logOutput }}</pre >
146+ <el-scrollbar >
147+ <pre style =" white-space : pre-wrap ; word-break : break-all ;" >{{logOutput}}</pre >
127148 </el-scrollbar >
128149 </el-card >
129150 </el-splitter-panel >
@@ -137,8 +158,10 @@ items:
137158 align-items : center ;
138159 gap : 8px ;
139160}
140- .log-output {
141- height : 100% ;
142- overflow : auto ;
161+ .select {
162+ width : 150px !important ;
163+ }
164+ .el-input {
165+ --el-input-width : 300px !important ;
143166}
144167 </style >
0 commit comments