Skip to content

Commit

Permalink
perf: 服务器主页自动连接到设备
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Dec 3, 2023
1 parent a195088 commit c0011a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/src/main/kotlin/li/songe/gkd/debug/HttpService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Intent
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.ServiceUtils
import io.ktor.http.CacheControl
import io.ktor.http.ContentType
import io.ktor.serialization.kotlinx.json.json
import io.ktor.server.application.call
import io.ktor.server.application.install
Expand All @@ -17,6 +18,7 @@ import io.ktor.server.request.receiveText
import io.ktor.server.response.cacheControl
import io.ktor.server.response.respond
import io.ktor.server.response.respondFile
import io.ktor.server.response.respondText
import io.ktor.server.routing.get
import io.ktor.server.routing.post
import io.ktor.server.routing.route
Expand All @@ -43,6 +45,7 @@ import li.songe.gkd.notif.httpChannel
import li.songe.gkd.notif.httpNotif
import li.songe.gkd.service.GkdAbService
import li.songe.gkd.util.Ext.getIpAddressInLocalNetwork
import li.songe.gkd.util.SERVER_SCRIPT_URL
import li.songe.gkd.util.keepNullJson
import li.songe.gkd.util.launchTry
import li.songe.gkd.util.map
Expand Down Expand Up @@ -70,7 +73,7 @@ class HttpService : CompositionService({
install(ContentNegotiation) { json(keepNullJson) }

routing {
get("/") { call.respond("hello world") }
get("/") { call.respondText(ContentType.Text.Html) { "<script type='module' src='$SERVER_SCRIPT_URL'></script>" } }
route("/api") {
get("/device") { call.respond(DeviceInfo.instance) }
get("/snapshot") {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/kotlin/li/songe/gkd/util/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const val DEFAULT_SUBS_UPDATE_URL =
"https://registry.npmmirror.com/@gkd-kit/subscription/latest/files"
const val UPDATE_URL = "https://registry.npmmirror.com/@gkd-kit/app/latest/files/index.json"

const val SERVER_SCRIPT_URL =
"https://registry-direct.npmmirror.com/@gkd-kit/config/latest/files/dist/server.js"

const val REPOSITORY_URL = "https://github.com/gkd-kit/gkd"

val safeRemoteBaseUrls = arrayOf(
Expand Down

0 comments on commit c0011a9

Please sign in to comment.