Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.g985892345.provider.api.annotation.ImplProvider
fun main() {
initKtProvider()
InitialManager.init(isMainProcess = true)
ComposeViewport {
ComposeViewport(viewportContainerId = "composeContainer") {
AppTheme {
MainNavHost()
PlatformToastCompose()
Expand Down
14 changes: 3 additions & 11 deletions cyxbs-applications/multiplatform/src/webMain/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>网上重邮</title>
<link type="text/css" rel="stylesheet" href="styles.css">
<script type="application/javascript" src="CyxbsApplicationsTest.js"></script>
<script type="application/javascript" src="CyxbsApplicationsMultiplatform.js"></script>
</head>
<body>
<div id="composeContainer"></div>
</body>
<style>
body, html {
height: 100%; /* 确保整个页面高度 */
width: 100%;
margin: 0; /* 移除默认边距 */
padding: 0;
overflow: hidden;
}
</style>
</html>
24 changes: 24 additions & 0 deletions cyxbs-applications/multiplatform/src/webMain/resources/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* 重置默认样式 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

/* 确保 html 和 body 占满整个视口 */
html, body {
height: 100%;
width: 100%;
overflow: hidden;
margin: 0;
padding: 0;
}

/* Compose 容器样式 */
#composeContainer {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ import com.cyxbs.components.init.appApplication
* @author 985892345
* @date 2025/1/4
*/
actual val appName: String = appApplication.getString(R.string.config_app_name)
actual val appName: String = appApplication.getString(R.string.config_app_name)

actual val appPlatform: Platform
get() = Platform.Android
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ package com.cyxbs.components.config
expect val appName: String

fun isDebug(): Boolean = ConfigApplicationInfoImpl.isDebug()

expect val appPlatform: Platform

enum class Platform {
Android,
IOS,
Web,
Desktop,
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ package com.cyxbs.components.config
* @date 2025/1/4
*/
actual val appName: String
get() = "桌上重邮"
get() = "桌上重邮"

actual val appPlatform: Platform
get() = Platform.Desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ package com.cyxbs.components.config
* @date 2025/1/4
*/
actual val appName: String
get() = "掌上重邮"
get() = "掌上重邮"

actual val appPlatform: Platform
get() = Platform.IOS
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ package com.cyxbs.components.config
* @date 2025/1/4
*/
actual val appName: String
get() = "网上重邮"
get() = "网上重邮"

actual val appPlatform: Platform
get() = Platform.Web
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import androidx.compose.ui.unit.sp
import androidx.navigation.NavUri
import com.cyxbs.components.account.api.IAccountEditService
import com.cyxbs.components.account.api.IAccountService
import com.cyxbs.components.config.Platform
import com.cyxbs.components.config.appPlatform
import com.cyxbs.components.config.compose.theme.LocalAppColors
import com.cyxbs.components.config.navigation.DestinationParcel
import com.cyxbs.components.config.navigation.HomeNavArgument
Expand All @@ -48,7 +50,7 @@ import com.cyxbs.pages.login.api.LoginNavArgument
// 在这里注册你的 Compose 页面用于 desktop 端的测试
// 如果你的页面没有返回键,则按 ESC 键进行返回
private val itemList = listOf(
ActionItem("地图") {
ActionItem("地图", Platform.Web) {
MainNavController.navigate(deepLink = NavUri("cyxbs://$NAV_MAP"))
},
ActionItem("我的课表") {
Expand All @@ -72,7 +74,7 @@ private val itemList = listOf(



ActionItem("校车查询"){
ActionItem("校车查询", Platform.Web){
MainNavController.navigate(deepLink = NavUri("cyxbs://$NAV_SCHOOL_CAR"))
},
// 退出登陆放到最后,其他测试页面放到上面👆
Expand Down Expand Up @@ -106,6 +108,7 @@ fun AdaptiveHomePage(parcel: DestinationParcel<HomeNavArgument>) {
@Stable
class ActionItem(
val name: String,
vararg val excludePlatform: Platform, // 排除某些平台
val onClick: () -> Unit
)

Expand All @@ -119,7 +122,10 @@ private fun SelectorItem(item: ActionItem, modifier: Modifier = Modifier) {
.clip(RoundedCornerShape(8.dp))
.background(color = 0xFFF5F6F8.dark(0xFF111111))
.clickable {
toast(item.name)
if (item.excludePlatform.contains(appPlatform)) {
toast("当前平台不支持此功能")
return@clickable
}
item.onClick.invoke()
}
) {
Expand Down
Loading