mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
chore: improve geo
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package app.termora
|
||||
|
||||
import org.apache.commons.lang3.LocaleUtils
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.*
|
||||
@@ -33,6 +34,13 @@ object I18n : AbstractI18n() {
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果使用 zh_CN 则定义为中国大陆用户,应当优先使用国内服务器
|
||||
*/
|
||||
fun isChinaMainland(): Boolean {
|
||||
return StringUtils.equalsIgnoreCase(containsLanguage(Locale.getDefault()), "zh_CN")
|
||||
}
|
||||
|
||||
fun getLanguages(): Map<String, String> {
|
||||
return supportedLanguages
|
||||
}
|
||||
|
||||
@@ -93,8 +93,12 @@ internal class MarketplaceManager private constructor() {
|
||||
val version = Semver.parse(Application.getVersion())
|
||||
?: return emptyList()
|
||||
|
||||
val repositories = PluginRepositoryManager.getInstance().getRepositories().toMutableSet()
|
||||
repositories.add("https://github.com/TermoraDev/termora-marketplace/releases/latest/download/plugins.xml")
|
||||
val repositories = PluginRepositoryManager.getInstance().getRepositories().distinct().toMutableList()
|
||||
if (I18n.isChinaMainland()) {
|
||||
repositories.addFirst("https://plugins.termora.cn/plugins.xml")
|
||||
} else {
|
||||
repositories.addFirst("https://github.com/TermoraDev/termora-marketplace/releases/latest/download/plugins.xml")
|
||||
}
|
||||
|
||||
val plugins = mutableListOf<MarketplacePlugin>()
|
||||
val executorService = Executors.newVirtualThreadPerTaskExecutor()
|
||||
|
||||
Reference in New Issue
Block a user