change from testSuite api from input to history-input

This commit is contained in:
rick 2025-03-28 09:56:46 +00:00
parent 2558d5dee3
commit 185fb0de7e
3 changed files with 9 additions and 13 deletions

View File

@ -28,7 +28,7 @@ const props = defineProps({
type: Number,
default: 10
},
key: {
group: {
type: String,
default: 'history'
},
@ -74,7 +74,7 @@ const handleEnter = async () => {
return;
}
const history = JSON.parse(getStorage().getItem(props.key) || '[]')
const history = JSON.parse(getStorage().getItem(props.group) || '[]')
const existingItem = history.find((item: HistoryItem) => item.value === input.value)
if (existingItem) {
@ -89,18 +89,18 @@ const handleEnter = async () => {
history.shift()
}
getStorage().setItem(props.key, JSON.stringify(history))
getStorage().setItem(props.group, JSON.stringify(history))
suggestions.value = history
}
const loadHistory = () => {
suggestions.value = JSON.parse(getStorage().getItem('history') || '[]')
suggestions.value = JSON.parse(getStorage().getItem(props.group) || '[]')
}
const deleteHistoryItem = (item: HistoryItem) => {
const history = JSON.parse(getStorage().getItem(props.key) || '[]')
const history = JSON.parse(getStorage().getItem(props.group) || '[]')
const updatedHistory = history.filter((historyItem: HistoryItem) => historyItem.value !== item.value)
getStorage().setItem(props.key, JSON.stringify(updatedHistory))
getStorage().setItem(props.group, JSON.stringify(updatedHistory))
suggestions.value = updatedHistory
}

View File

@ -139,7 +139,7 @@ const keyValueDataHandler = (data: QueryData) => {
}
const executeQuery = async () => {
executeWithQuery(sqlQuery.value)
return executeWithQuery(sqlQuery.value)
}
const executeWithQuery = async (sql: string) => {
switch (kind.value) {

View File

@ -6,6 +6,7 @@ import type { FormInstance, FormRules } from 'element-plus'
import type { Suite, TestCase, Pair } from './types'
import { NewSuggestedAPIsQuery, GetHTTPMethods, SwaggerSuggestion } from './types'
import EditButton from '../components/EditButton.vue'
import HistoryInput from '../components/HistoryInput.vue'
import { Cache } from './cache'
import { useI18n } from 'vue-i18n'
import { API } from './net'
@ -301,12 +302,7 @@ const renameTestSuite = (name: string) => {
{{ t('tip.testsuite') }}<EditButton :value="suite.name" @changed="renameTestSuite"/>
<el-form-item :label="t('tip.apiAddress')" prop="api">
<el-input
class="w-50 m-2"
v-model="suite.api"
placeholder="API"
test-id="suite-editor-api"
></el-input>
<HistoryInput placeholder="API" v-model="suite.api" group="apiAddress" />
</el-form-item>
<table style="width: 100%">
<tr>