KevinnZou / compose-webview-multiplatform

WebView for JetBrains Compose Multiplatform
https://kevinnzou.github.io/compose-webview-multiplatform/
Apache License 2.0
305 stars 39 forks source link

用于idea plugin开发中, 根据预览/运行都显示空白, 如何解决? #121

Closed over-space closed 1 month ago

over-space commented 2 months ago

build.gradle.kts配置

plugins {
    id("java")
    id("org.jetbrains.kotlin.jvm") version "1.9.21"
    id("org.jetbrains.intellij") version "1.16.1"
    id("org.jetbrains.compose") version "1.6.0"
}

group = "com.learning.boot"
version = "1.0-SNAPSHOT"

repositories {
    google()
    mavenCentral()
    maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
    maven { url = uri("https://jogamp.org/deployment/maven")}
}

dependencies {
    implementation(compose.desktop.currentOs)
    api("io.github.kevinnzou:compose-webview-multiplatform:1.9.0")
}

代码

@Preview
@Composable
fun MinimalExampleContent() {
    Column {
        val state = rememberWebViewState("https://github.com/KevinnZou/compose-webview-multiplatform")
        Text(text = "${state.pageTitle}")
        val loadingState = state.loadingState
        if (loadingState is LoadingState.Loading) {
            LinearProgressIndicator(
                progress = loadingState.progress,
                modifier = Modifier.fillMaxWidth()
            )
        }
        WebView(
            state
        )
    }
}

预览结果

image

KevinnZou commented 2 months ago

@over-space To run this library on the Desktop target, it needs to download the kcef-bundle first and then refresh the page. For more details, you can refer to this sample.