Skip to content

Commit c6d2058

Browse files
committed
fix(api-post): curl配置默认显示问题
1 parent 06f7971 commit c6d2058

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

plugin-apipost/src/main/kotlin/me/leon/toolsfx/plugin/ApiPostView.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,16 @@ class ApiPostView : PluginFragment("ApiPost") {
153153
}
154154
val curlFiles = ApiConfig.curlDir.toFile().listFiles()?.map { it.nameWithoutExtension }
155155
if (curlFiles != null && curlFiles.isNotEmpty()) {
156-
selectedUrl.set(curlFiles.first())
157-
combobox(selectedUrl, curlFiles.toMutableList()) { cellFormat { text = it } }
156+
val newCurlFiles = curlFiles.toMutableList()
157+
newCurlFiles.add(0, "")
158+
selectedUrl.set("")
159+
combobox(selectedUrl, newCurlFiles) { cellFormat { text = it } }
158160
selectedUrl.addListener { _, _, newValue ->
159-
println("selectedUrl $newValue")
161+
if (newValue.isEmpty()) {
162+
resetUi("https://httpbin.org/anything")
163+
return@addListener
164+
}
160165
tfUrl.text = newValue as String
161-
println("selectedUrl2 ${tfUrl.text}")
162166
val curl = File(ApiConfig.curlDir.toFile(), "$newValue.curl")
163167
resetUi(curl.readText())
164168
}

plugin-apipost/src/main/kotlin/me/leon/toolsfx/plugin/net/Response.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ data class Response(
1111
val statusInfo: String
1212
get() =
1313
"${headers[null]} Time : $time ms " +
14-
"Size : ${headers["Content-Length"] ?: headers["content-length"] ?: "unknown"} Bytes"
14+
"Size : ${headers["Content-Length"] ?: headers["content-length"] ?: "unknown"} Bytes"
1515

1616
val length: Int
1717
get() = "${headers["Content-Length"] ?: headers["content-length"] ?: "-1"}".toInt()

0 commit comments

Comments
 (0)