diff --git a/composeApp/src/androidMain/AndroidManifest.xml b/composeApp/src/androidMain/AndroidManifest.xml
index d8b6fa9..9e21e8d 100644
--- a/composeApp/src/androidMain/AndroidManifest.xml
+++ b/composeApp/src/androidMain/AndroidManifest.xml
@@ -13,6 +13,16 @@
android:supportsRtl="true"
android:theme="@android:style/Theme.Material.Light.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
diff --git a/composeApp/src/androidMain/kotlin/cn/xiaobai/openclawapp/platform/AttachmentOpener.android.kt b/composeApp/src/androidMain/kotlin/cn/xiaobai/openclawapp/platform/AttachmentOpener.android.kt
new file mode 100644
index 0000000..e6b7b7f
--- /dev/null
+++ b/composeApp/src/androidMain/kotlin/cn/xiaobai/openclawapp/platform/AttachmentOpener.android.kt
@@ -0,0 +1,42 @@
+package cn.xiaobai.openclawapp.platform
+
+import android.content.ActivityNotFoundException
+import android.content.Context
+import android.content.Intent
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.remember
+import androidx.compose.ui.platform.LocalContext
+import androidx.core.content.FileProvider
+import cn.xiaobai.openclawapp.data.AttachmentOpenPayload
+import java.io.File
+
+@Composable
+actual fun rememberAttachmentOpener(
+ onResult: (String) -> Unit,
+): (AttachmentOpenPayload) -> Unit {
+ val context = LocalContext.current
+ return remember(context, onResult) {
+ { payload ->
+ runCatching {
+ val file = File(context.cacheDir, "attachments/${payload.fileName}")
+ file.parentFile?.mkdirs()
+ file.writeBytes(payload.bytes)
+ val uri = FileProvider.getUriForFile(
+ context,
+ context.packageName + ".fileprovider",
+ file,
+ )
+ val intent = Intent(Intent.ACTION_VIEW).apply {
+ setDataAndType(uri, payload.contentType ?: "*/*")
+ addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ }
+ context.startActivity(intent)
+ onResult("正在打开:${payload.fileName}")
+ }.onFailure {
+ val msg = if (it is ActivityNotFoundException) "没有可用应用打开该附件" else (it.message ?: "打开附件失败")
+ onResult(msg)
+ }
+ }
+ }
+}
diff --git a/composeApp/src/androidMain/res/xml/file_paths.xml b/composeApp/src/androidMain/res/xml/file_paths.xml
new file mode 100644
index 0000000..dc39105
--- /dev/null
+++ b/composeApp/src/androidMain/res/xml/file_paths.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/App.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/App.kt
index f3fbb2a..bd3d812 100644
--- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/App.kt
+++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/App.kt
@@ -26,6 +26,7 @@ import cn.xiaobai.openclawapp.feature.config.ServerConfigScreen
import cn.xiaobai.openclawapp.feature.sessions.SessionListScreen
import cn.xiaobai.openclawapp.feature.settings.SettingsScreen
import cn.xiaobai.openclawapp.feature.status.StatusScreen
+import cn.xiaobai.openclawapp.platform.rememberAttachmentOpener
import cn.xiaobai.openclawapp.platform.rememberAttachmentPicker
import cn.xiaobai.openclawapp.platform.rememberClipboardSetter
import cn.xiaobai.openclawapp.ui.OpenClawTheme
@@ -101,6 +102,9 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
val copyToClipboard = rememberClipboardSetter { message ->
appState.feedbackMessage = message
}
+ val openAttachment = rememberAttachmentOpener { message ->
+ appState.feedbackMessage = message
+ }
LaunchedEffect(appState.feedbackMessage) {
if (appState.feedbackMessage != null) {
@@ -214,6 +218,14 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
onCopyAttachmentName = { fileName ->
copyToClipboard(fileName)
},
+ onOpenAttachment = { messageId ->
+ val payload = appState.repository.attachmentOpenPayload(messageId)
+ if (payload != null) {
+ openAttachment(payload)
+ } else {
+ appState.feedbackMessage = "当前附件暂无可打开内容"
+ }
+ },
)
appState.selectedTab == MainTab.Sessions -> SessionListScreen(
diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/OpenClawRepository.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/OpenClawRepository.kt
index 6ea0678..ec1b214 100644
--- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/OpenClawRepository.kt
+++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/OpenClawRepository.kt
@@ -22,4 +22,11 @@ interface OpenClawRepository {
contentType: String? = null,
)
suspend fun retryAttachment(sessionId: String, messageId: String)
+ fun attachmentOpenPayload(messageId: String): AttachmentOpenPayload?
}
+
+data class AttachmentOpenPayload(
+ val fileName: String,
+ val bytes: ByteArray,
+ val contentType: String? = null,
+)
diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt
index ea6b717..f710193 100644
--- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt
+++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/data/RemoteOpenClawRepository.kt
@@ -67,6 +67,7 @@ class RemoteOpenClawRepository(
private var messageStore by mutableStateOf