Skip to content

Commit

Permalink
A very simple publish
Browse files Browse the repository at this point in the history
  • Loading branch information
sonder-joker committed May 17, 2021
1 parent 82fecd6 commit 21f6d12
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 84 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ Mirai 是一个在全平台下运行,提供 QQ 协议支持的高效率机器

# mirai-compose

[comment]: <> (![]&#40;https://img.shields.io/github/v/release/sonder-joker/mirai-compose?include_prereleases&#41; )

[comment]: <> (console-version:2.7.0-M1-dev-1 )
基于[compose-jb](https://github.com/jetbrains/compose-jb) 实现的[mirai-console](https://github.com/mamoe/mirai-console)
前端
目前正处于测试阶段
前端
目前正处于测试阶段.

## 使用

目前仅提供手动编译使用,文档正在补全
可以在release页面下载.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@file:Suppress("ObjectPropertyName", "SpellCheckingInspection")

object Versions {
const val mirai_compose = "1.1.1"
const val mirai_compose = "1.0.0"

const val kotlin = "1.4.32"

const val mirai = "2.7-M1-dev-1"
const val mirai = "2.6.4"

const val compose = "0.4.0-build188"
const val decompose = "0.2.3"
Expand Down
1 change: 0 additions & 1 deletion mirai-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dependencies {
implementation(yamlkt)
implementation(compose.materialIconsExtended)
//may remove in future
implementation("com.google.zxing:core:3.4.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0")
Expand Down
23 changes: 1 addition & 22 deletions mirai-compose/src/main/kotlin/console/MiraiCompose.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,6 @@ object MiraiCompose : MiraiConsoleImplementation, MiraiComposeRepository,
object MiraiComposeDescription : MiraiConsoleFrontEndDescription {
override val name: String = "MiraiCompose"
override val vendor: String = "Noire"
override val version: SemVersion = SemVersion("1.1.0")
}

internal fun setSystemOut(out: MiraiLogger) {
System.setOut(
PrintStream(
BufferedOutputStream(
logger = out.run { ({ line: String? -> info(line) }) }
),
false,
"UTF-8"
)
)
System.setErr(
PrintStream(
BufferedOutputStream(
logger = out.run { ({ line: String? -> warning(line) }) }
),
false,
"UTF-8"
)
)
override val version: SemVersion = SemVersion("0.1.0-dev1")
}

10 changes: 2 additions & 8 deletions mirai-compose/src/main/kotlin/ui/common/LogBox.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package com.youngerhousea.miraicompose.ui.common

import androidx.compose.animation.animateContentSize
import androidx.compose.desktop.AppManager
import androidx.compose.desktop.AppWindow
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.OutlinedButton
import androidx.compose.material.Button
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.plus
import androidx.compose.ui.input.key.shortcuts
import com.youngerhousea.miraicompose.console.ComposeLog
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -46,11 +43,8 @@ internal fun LogBox(modifier: Modifier = Modifier, logs: List<ComposeLog>, searc
}
}
}

}



LaunchedEffect(logs.size) {
if (logs.isNotEmpty())
lazyListState.animateScrollToItem(logs.size)
Expand Down Expand Up @@ -86,7 +80,7 @@ internal fun CommandSendBox(logger: MiraiLogger, modifier: Modifier = Modifier)
Modifier.weight(1f)
)

OutlinedButton(
Button(
onClick = onClick,
modifier = Modifier
.weight(2f),
Expand Down
5 changes: 4 additions & 1 deletion mirai-compose/src/main/kotlin/ui/feature/MiraiComposeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import com.youngerhousea.miraicompose.utils.asComponent
import kotlinx.coroutines.cancel
import net.mamoe.mirai.console.MiraiConsoleImplementation.Companion.start
import java.awt.datatransfer.UnsupportedFlavorException
import java.nio.file.Files
import kotlin.io.path.createTempDirectory
import kotlin.io.path.div

// 应用起点
fun MiraiComposeView() {
Expand Down Expand Up @@ -51,4 +54,4 @@ private fun SetDefaultExceptionHandler() {
}
}
}
}
}
1 change: 1 addition & 0 deletions mirai-compose/src/main/kotlin/ui/feature/NavHostView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ fun NavHostUi(navHost: NavHost) {
AvatarWithMenu(
composeBotList = navHost.botList,
onBoxClick = {
navigationIndex = 5
if (navHost.currentBot != null)
navHost.onRouteMessage()
else
Expand Down
31 changes: 1 addition & 30 deletions mirai-compose/src/main/kotlin/ui/feature/bot/LoadingView.kt

Large diffs are not rendered by default.

48 changes: 38 additions & 10 deletions mirai-compose/src/main/kotlin/ui/feature/log/LogView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.outlined.Search
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.key.Key
Expand All @@ -21,6 +20,11 @@ import com.youngerhousea.miraicompose.ui.common.CommandSendBox
import com.youngerhousea.miraicompose.ui.common.LogBox
import net.mamoe.mirai.utils.MiraiLogger
import java.awt.event.MouseEvent
import java.io.File
import java.time.LocalDate
import javax.swing.JFileChooser
import javax.swing.UIManager
import javax.swing.filechooser.FileNameExtensionFilter

/**
* Compose的所有日志
Expand Down Expand Up @@ -51,21 +55,45 @@ fun ConsoleLogUi(consoleLog: ConsoleLog) {
}) {
Box(
modifier = Modifier
.padding(top = offset.y - 80.dp)
.offset(x = offset.x)
.padding(top = offset.y)
.offset(x = offset.x - 160.dp)
) {
DropdownMenu(
isExpand,
onDismissRequest = { isExpand = false }
) {
DropdownMenuItem(onClick = { isExpand = false }) {
Text("OpenLog")
//TODO open log file in editor such as notepad
}
DropdownMenuItem(onClick = { isExpand = false }) {
Text("Report")
//TODO report error or do else
DropdownMenuItem(onClick = {
isExpand = false
// open maybe slow
val previousLF = UIManager.getLookAndFeel();
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
val fc = JFileChooser()
UIManager.setLookAndFeel(previousLF);
fc.selectedFile = File("${LocalDate.now()}.log")
fc.dialogTitle = "Save log"
fc.dragEnabled = true
fc.fileSelectionMode = JFileChooser.FILES_ONLY
fc.fileFilter = FileNameExtensionFilter("log(*.log, *.txt)", "log", "txt")
if (fc.showSaveDialog(AppManager.focusedWindow!!.window) == JFileChooser.APPROVE_OPTION) {
val f = fc.selectedFile
consoleLog.logger.info("储存当前日志到文件: ${f.absolutePath}")
if (f.exists()) {
consoleLog.logger.error("储存失败,文件已存在")
} else {
f.createNewFile()
f.writeText(consoleLog.loggerStorage.joinToString("\n"))
consoleLog.logger.info("写入完成")
}
}
}) {
Text("Save log")
}
// DropdownMenuItem(onClick = {
// //TODO report error or do else
// isExpand = false
// }) {
// Text("Report")
// }
}
}
Column {
Expand Down
4 changes: 0 additions & 4 deletions mirai-compose/src/main/kotlin/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ inline fun <T> ColumnScope.itemsWithIndexed(
}
}

fun AnnotatedString.replace() {

}

class ComponentScope(private val scope: CoroutineScope = MainScope()) :
InstanceKeeper.Instance,
CoroutineScope by scope {
Expand Down

0 comments on commit 21f6d12

Please sign in to comment.