-
-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
73 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package me.leon.ext | ||
|
||
import java.util.prefs.Preferences | ||
|
||
object Prefs { | ||
private const val IGNORE_UPDATE = "isIgnoreUpdate" | ||
private val preference = Preferences.userNodeForPackage(Prefs::class.java) | ||
var isIgnoreUpdate | ||
get() = preference.getBoolean(IGNORE_UPDATE, false) | ||
set(value) { | ||
preference.putBoolean(IGNORE_UPDATE, value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,47 @@ | ||
package me.leon.view | ||
|
||
import javafx.beans.property.SimpleBooleanProperty | ||
import javafx.geometry.Pos | ||
import javafx.scene.image.Image | ||
import javafx.scene.text.Font | ||
import me.leon.CHECK_UPDATE_URL | ||
import me.leon.LAN_ZOU_DOWNLOAD_URL | ||
import me.leon.REPO_URL | ||
import me.leon.VERSION | ||
import me.leon.ext.DEFAULT_SPACING | ||
import me.leon.ext.openInBrowser | ||
import me.leon.ext.readFromNet | ||
import javafx.scene.text.Text | ||
import me.leon.* | ||
import me.leon.ext.* | ||
import tornadofx.* | ||
|
||
class AboutView : View("关于") { | ||
|
||
override val closeable = SimpleBooleanProperty(false) | ||
lateinit var latestVersion: Text | ||
|
||
override val root = vbox { | ||
alignment = Pos.TOP_CENTER | ||
spacing = DEFAULT_SPACING | ||
paddingAll = DEFAULT_SPACING | ||
imageview(Image("/tb.png")) | ||
text("版本 v$VERSION") { font = Font.font(18.0) } | ||
hyperlink("github地址") { action { REPO_URL.openInBrowser() } } | ||
text("构建时间 ${times()}") | ||
hyperlink("吾爱破解地址") { action { PJ52_URL.openInBrowser() } } | ||
hyperlink("github开源地址") { | ||
font = Font.font(18.0) | ||
action { REPO_URL.openInBrowser() } | ||
} | ||
hyperlink("开源协议 ISC") { action { LICENSE.openInBrowser() } } | ||
button("检测新版本") { action { checkUpdate() } } | ||
latestVersion = text() | ||
hyperlink("蓝奏云下载 密码52pj") { action { LAN_ZOU_DOWNLOAD_URL.openInBrowser() } } | ||
button("检测新版本") { | ||
action { | ||
CHECK_UPDATE_URL.readFromNet() | ||
find<MyFragment>().openModal() | ||
checkUpdate(!Prefs.isIgnoreUpdate) | ||
} | ||
|
||
private fun checkUpdate(isAuto: Boolean = true) { | ||
if (!isAuto) return | ||
runAsync { CHECK_UPDATE_URL.readFromNet() } ui | ||
{ | ||
latestVersion.text = | ||
if (it.isEmpty()) "未知错误" | ||
else if (VERSION != it) | ||
"发现新版本 v$it".also { find<UpdateFragment>().openModal() } | ||
else "已是最新版本" | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package me.leon.view | ||
|
||
import javafx.geometry.Pos | ||
import me.leon.REPO_URL | ||
import me.leon.ext.* | ||
import tornadofx.* | ||
|
||
class UpdateFragment : Fragment("检测到新版本") { | ||
override val root = hbox { | ||
prefWidth = DEFAULT_SPACING_40X | ||
prefHeight = DEFAULT_SPACING_20X | ||
paddingAll = DEFAULT_SPACING | ||
spacing = DEFAULT_SPACING_2X | ||
alignment = Pos.CENTER | ||
|
||
button("马上升级") { action { action { REPO_URL.openInBrowser() } } } | ||
button("忽略本次") { action { close() } } | ||
button("永久忽略") { | ||
action { | ||
Prefs.isIgnoreUpdate = true | ||
close() | ||
} | ||
} | ||
} | ||
} |