dm-70
This commit is contained in:
parent
f088fc746f
commit
a65bc05fde
2 changed files with 21 additions and 14 deletions
|
|
@ -184,6 +184,7 @@ fun MessageMessaging(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
//to be animated
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
if (actionMessage != null) {
|
if (actionMessage != null) {
|
||||||
// 顯示動作選單
|
// 顯示動作選單
|
||||||
|
|
@ -330,24 +331,32 @@ fun MessageRow(
|
||||||
val rawContent = message.content ?: ""
|
val rawContent = message.content ?: ""
|
||||||
// 💡 核心修正:利用 remember 根據 message 狀態動態計算正確的圖片 URL
|
// 💡 核心修正:利用 remember 根據 message 狀態動態計算正確的圖片 URL
|
||||||
val finalImageModel = remember(message) {
|
val finalImageModel = remember(message) {
|
||||||
// 1. 如果有 attachment,優先去拿裡面的 filename;如果沒有,再拿一般的 content
|
// 1. 取得原始路徑(優先使用 attachment 的 filename,次之用 content)
|
||||||
// 2. 假設後端儲存路徑通常是在某個特定資料夾(例如 /uploads/),如果 filename 沒帶路徑,記得補上
|
val rawPath = if (isAttachmentImage && !message.attachment?.filename.isNullOrBlank()) {
|
||||||
val rawPath = if (isAttachmentImage && !message.attachment?.filename.isNullTabOrBlank()) {
|
|
||||||
message.attachment!!.filename
|
message.attachment!!.filename
|
||||||
} else {
|
} else {
|
||||||
message.content
|
message.content ?: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
when {
|
when {
|
||||||
rawPath.isBlank() -> ""
|
rawPath.isBlank() -> ""
|
||||||
rawPath.startsWith("https") -> rawPath // 已經是完整網址,直接回傳
|
// 如果後端已經貼心地給了完整網址(包含 http 或 https),就直接使用
|
||||||
|
rawPath.startsWith("http") -> rawPath
|
||||||
|
|
||||||
// 💡 注意:請根據你後端圖片實際存放的路由修改這裡。
|
// 如果後端給的路徑已經包含 "/uploads/"(例如 "/uploads/attachment/dfec7f...jpg")
|
||||||
// 如果後端 filename 只有 "abc.jpg",而實際上網址是 "http://192.168.0.217/uploads/abc.jpg"
|
rawPath.startsWith("/uploads/") -> "https://192.168.0.217$rawPath"
|
||||||
// 你需要把下面改成 "/uploads/$rawPath"
|
rawPath.contains("uploads/") -> "https://192.168.0.217/$rawPath"
|
||||||
rawPath.startsWith("/") -> "https://192.168.0.217$rawPath"
|
|
||||||
|
|
||||||
else -> "https://192.168.0.217/$rawPath"
|
// 💡 關鍵處理:如果後端只給了純檔名(例如 "dfec7f...jpg")或是 "attachment/dfec7f...jpg"
|
||||||
|
// 我們要在前方幫它手動補上標準的存放路徑 "/uploads/"
|
||||||
|
else -> {
|
||||||
|
val cleanPath = rawPath.removePrefix("/") // 移除可能重複的開頭斜線
|
||||||
|
if (cleanPath.startsWith("attachment/")) {
|
||||||
|
"https://192.168.0.217/uploads/$cleanPath"
|
||||||
|
} else {
|
||||||
|
"https://192.168.0.217/uploads/attachment/$cleanPath"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,12 @@
|
||||||
<network-security-config>
|
<network-security-config>
|
||||||
<domain-config cleartextTrafficPermitted="true">
|
<domain-config cleartextTrafficPermitted="true">
|
||||||
<domain includeSubdomains="true">192.168.0.217</domain>
|
<domain includeSubdomains="true">192.168.0.217</domain>
|
||||||
|
|
||||||
<trust-anchors>
|
<trust-anchors>
|
||||||
<certificates src="system" />
|
<certificates src="system" />
|
||||||
<certificates src="@raw/root" />
|
<certificates src="@raw/root" /> </trust-anchors>
|
||||||
</trust-anchors>
|
|
||||||
</domain-config>
|
</domain-config>
|
||||||
|
|
||||||
<base-config cleartextTrafficPermitted="false">
|
<base-config cleartextTrafficPermitted="true">
|
||||||
<trust-anchors>
|
<trust-anchors>
|
||||||
<certificates src="system" />
|
<certificates src="system" />
|
||||||
</trust-anchors>
|
</trust-anchors>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue