Skip to content

Commit

Permalink
Merge branch 'vlcj'
Browse files Browse the repository at this point in the history
# Conflicts:
#	composeApp/src/desktopMain/rules.pro
  • Loading branch information
Greatwallcorner committed Jul 7, 2024
2 parents e06f455 + 342dfbf commit aee71ed
Show file tree
Hide file tree
Showing 106 changed files with 3,398 additions and 1,302 deletions.
121 changes: 121 additions & 0 deletions .github/workflows/github-action-pre_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: TV-Multiplatform Build Pre Release
on:
push:
branches: [pre-release]
env:
tag: ${{ github.run_id }}
jobs:
build-win:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- run: ls
# - run: ./gradlew packageReleaseDistributionForCurrentOS
- run: ./gradlew createReleaseDistributable
- run: ls && tree ./desktopApp /f
- name: compress
shell: pwsh
run: Compress-Archive -Path "./composeApp/build/compose/binaries/main-release/app/TV" -DestinationPath ./TV-win-$Env:tag.zip
# - name: move result to root
# shell: pwsh
# run: Move-Item -Path "./composeApp/build/compose/binaries/main-release/app/*.zip" -Destination "./" && Move-Item -Path "./composeApp/build/compose/binaries/main-release/msi/*.msi" -Destination "./"
- run: ls
- uses: actions/upload-artifact@v4
with:
name: win-file
path: |
*.msi
*.zip
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- run: ls
- run: chmod +x ./gradlew && ./gradlew createReleaseDistributable
- run: ./gradlew packageReleaseDistributionForCurrentOS
- run: ls && tree
- name: compress
run: cd ./composeApp/build/compose/binaries/main-release/app && zip -q -r ./TV-linux-$tag.zip ./TV
- name: move file
run: mv ./composeApp/build/compose/binaries/main-release/deb/*.deb ./TV-linux-$tag.deb && mv ./composeApp/build/compose/binaries/main-release/app/*.zip ./
- run: ls
- uses: actions/upload-artifact@v4
with:
name: linux-file
path: |
*.deb
*.zip
# https://github.com/JetBrains/compose-multiplatform/blob/master/tutorials/Signing_and_notarization_on_macOS/README.md
build-mac:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- run: ls
- run: chmod +x ./gradlew && ./gradlew createReleaseDistributable
# - run: ./gradlew packageReleaseDistributionForCurrentOS
- run: ls
- name: compress
run: zip -q -r ./TV-mac-$tag.zip ./composeApp/build/compose/binaries/main-release/app
# - name: move file
# run: mv ./composeApp/build/compose/binaries/main-release/dmg/*.dmg ./TV-mac-$tag.dmg
- run: ls
- uses: actions/upload-artifact@v4
with:
name: mac-file
path: |
*.dmg
*.zip
release:
runs-on: ubuntu-latest
needs: [ build-win, build-linux, build-mac]
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
- run: ls && tree
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
**/*.zip
**/*.deb
**/*.pkg
**/*.dmg
**/*.msi
tag_name: ${{env.tag}}
prerelease: true
permissions:
contents: write
sendMsg:
name: sendMsg
runs-on: ubuntu-latest
needs:
- release
steps:
- uses: colutius/Telegram-Msg@main
with:
token: ${{ secrets.TG_TOKEN }}
chatid: ${{ secrets.TG_GROUP_ID }}
message: |
👇新的预发布👇
📦仓库: ${{ github.repository }}
button: true
button_name: 👀下载👀
button_url: https://github.com/${{ github.repository }}/releases/tag/${{env.tag}}
is_notify: true
is_preview: true
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@
![](readme_images/home.png)
## 搜索
![](readme_images/search.png)
## 搜索结果页
![](readme_images/search_result.png)
## 历史记录
![](readme_images/history.png)


# 讨论群
[TG](https://t.me/tv_multiplatform)
[TG](https://t.me/tv_multiplatform)

# 引用
player: https://github.com/numq/jetpack-compose-desktop-media-player
21 changes: 10 additions & 11 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ kotlin {
val desktopMain by getting

commonMain.dependencies {
val ktorVer = "2.3.8"
val ktorVer = "2.3.12"
val logbackVer = "1.3.14"
val imageLoader = "1.7.4"
val imageLoader = "1.8.1"
val hutoolVer = "5.8.27"
// val kotlinVersion = extra["kotlin.version"] as String
implementation(compose.runtime)
Expand Down Expand Up @@ -66,8 +66,8 @@ kotlin {
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVer")
implementation("io.ktor:ktor-server-swagger:$ktorVer")
implementation("io.ktor:ktor-client-core:$ktorVer")
implementation("io.ktor:ktor-client-cio:$ktorVer")
implementation("io.ktor:ktor-server-call-logging:$ktorVer")
implementation("io.ktor:ktor-client-okhttp:$ktorVer")
// implementation("io.ktor:ktor-server-call-logging:$ktorVer")

// log
implementation("ch.qos.logback:logback-classic:$logbackVer")
Expand All @@ -76,7 +76,7 @@ kotlin {
// optional - Moko Resources Decoder
// api("io.github.qdsfdhvh:image-loader-extension-moko-resources:$imageLoader")

api(project.dependencies.platform("com.squareup.okhttp3:okhttp-bom:5.0.0-alpha.12"))
api(project.dependencies.platform("com.squareup.okhttp3:okhttp-bom:5.0.0-alpha.14"))
api("com.squareup.okhttp3:okhttp")
api("com.squareup.okhttp3:okhttp-dnsoverhttps")

Expand Down Expand Up @@ -132,23 +132,22 @@ compose.desktop {
"jdk.httpserver",
"jdk.unsupported"
)
val dir = project.layout.projectDirectory.dir("/src/desktopMain/resources/res")
val dir = project.layout.projectDirectory.dir("src/desktopMain/resources/res")
println(dir)
appResourcesRootDir.set(project.layout.projectDirectory.dir("/src/desktopMain/resources/res"))
appResourcesRootDir.set(project.layout.projectDirectory.dir("src/desktopMain/resources/res"))
// app icons https://github.com/JetBrains/compose-multiplatform/tree/master/tutorials/Native_distributions_and_local_execution#app-icon
windows {
iconFile.set(project.file("src/commonMain/composeResources/icon/icon-s.ico"))
iconFile.set(project.file("src/commonMain/resources/pic/icon-s.ico"))
dirChooser = true
upgradeUuid = "161FA5A0-A30B-4568-9E84-B3CD637CC8FE"
}

linux {
iconFile.set(project.file("src/commonMain/composeResources/icon/TV-icon-s.png"))

iconFile.set(project.file("src/commonMain/resources/pic/TV-icon-s.png"))
}

macOS {
iconFile.set(project.file("src/commonMain/composeResources/icon/icon.icns"))
iconFile.set(project.file("src/commonMain/resources/pic/icon.icns"))
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
android:fillColor="#00000000"
android:strokeColor="#083042"
android:fillType="nonZero"/>
</vector>
</vector>

This file was deleted.

29 changes: 17 additions & 12 deletions composeApp/src/commonMain/kotlin/com/corner/bean/Hot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,33 @@ import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.decodeFromStream
import okhttp3.Headers.Companion.toHeaders
import okhttp3.Response
import org.slf4j.LoggerFactory

private val log = LoggerFactory.getLogger("Hot")

@Serializable
data class Hot(val data:List<HotData>) {
companion object{
data class Hot(val data: List<HotData>) {
companion object {
@OptIn(ExperimentalSerializationApi::class)
public fun getHotList() {
SiteViewModel.viewModelScope.launch {
val response = Http.Get("https://api.web.360kan.com/v1/rank?cat=1", headers = mapOf(HttpHeaders.Referrer to "https://www.360kan.com/rank/general").toHeaders()).execute()
// val response = KtorClient.client.get("https://api.web.360kan.com/v1/rank?cat=1") {
// headers {
// set(HttpHeaders.Referrer, "https://www.360kan.com/rank/general")
// }
// }
var response: Response? = null
try {
response = Http.Get(
"https://api.web.360kan.com/v1/rank?cat=1",
headers = mapOf(HttpHeaders.Referrer to "https://www.360kan.com/rank/general").toHeaders()
).execute()
} catch (e: Exception) {
log.error("请求热搜失败", e)
}

if(response.isSuccessful)
if (response?.isSuccessful == true)
GlobalModel.hotList.value = Jsons.decodeFromStream<Hot>(response.body.byteStream()).data
// GlobalModel.hotList.update { it. = Jsons.decodeFromStream<Hot>(response.bodyAsChannel().toInputStream()).data}
// GlobalModel.hotList.value.addAll()
}
}
}
}

@Serializable
data class HotData(val title:String, val comment:String, val upinfo:String, val description:String)
data class HotData(val title: String, val comment: String, val upinfo: String, val description: String)
49 changes: 40 additions & 9 deletions composeApp/src/commonMain/kotlin/com/corner/bean/Setting.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,44 @@ class SearchHistoryCache:Cache{

private val maxSize:Int = 30

private var searchHistoryList:MutableSet<String> = mutableSetOf()
private var searchHistoryList:LinkedHashSet<String> = linkedSetOf()
override fun getName(): String {
return "searchHistory"
}

override fun add(t:String) {
if(searchHistoryList.size >= maxSize){
searchHistoryList = searchHistoryList.drop(1).toMutableSet()
val list:LinkedHashSet<String> = linkedSetOf()
list.addAll(searchHistoryList.drop(1))
searchHistoryList = list
}
searchHistoryList.remove(t)
searchHistoryList.add(t)
}

fun getSearchList():Set<String>{
return searchHistoryList
fun getSearchList():List<String>{
return searchHistoryList.reversed()
}

}

@Serializable
class PlayerStateCache:Cache{
private val map:MutableMap<String, String> = mutableMapOf();
override fun getName(): String {
return "playerState"
}

override fun add(t: String) {

}

fun add(key:String, value: String){
map.put(key,value)
}

fun get(key: String):String?{
return map.get(key)
}

}
Expand All @@ -59,8 +83,8 @@ enum class SettingType(val id: String) {
object SettingStore {
private val defaultList = listOf(
Setting("vod", "点播", ""),
Setting("player", "外部播放器", ""),
Setting("log", "日志级别", Level.DEBUG.levelStr)
Setting("log", "日志级别", Level.DEBUG.levelStr),
Setting("player", "播放器", "false#")
)

private var settingFile = SettingFile(mutableListOf<Setting>(), mutableMapOf())
Expand All @@ -79,6 +103,12 @@ object SettingStore {
return settingFile.list
}

fun reset(){
settingFile = SettingFile(mutableListOf(), mutableMapOf())
initSetting()
write()
}

fun write() {
Files.write(Paths.setting(), Jsons.encodeToString(settingFile).toByteArray())
}
Expand All @@ -88,8 +118,9 @@ object SettingStore {
write()
}

fun setCache(name:String, value: String){
settingFile.cache[name]?.add(value)
fun doWithCache(func:(MutableMap<String, Cache>) -> Unit){
func(settingFile.cache)
write()
}

fun getCache(name:String): Cache? {
Expand Down Expand Up @@ -120,7 +151,7 @@ object SettingStore {
}
val cache = getCache(SettingType.SEARCHHISTORY.id)
if (cache != null) {
return (cache as SearchHistoryCache).getSearchList()
return (cache as SearchHistoryCache).getSearchList().toSet()
}
return setOf()
}
Expand Down
Loading

0 comments on commit aee71ed

Please sign in to comment.