Skip to content

Commit

Permalink
add update time to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeLulin committed Mar 31, 2022
1 parent cd8cbc1 commit 06819db
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 38 deletions.
12 changes: 4 additions & 8 deletions EarthLiveX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
64779BE627E9D677001ED0F5 /* EarthLiveXUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64779BE527E9D677001ED0F5 /* EarthLiveXUITests.swift */; };
64779BE827E9D677001ED0F5 /* EarthLiveXUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64779BE727E9D677001ED0F5 /* EarthLiveXUITestsLaunchTests.swift */; };
64779C0227EAB3A8001ED0F5 /* EarthLiveX.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64779C0127EAB3A8001ED0F5 /* EarthLiveX.swift */; };
64779C0427EABAF2001ED0F5 /* StatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64779C0327EABAF2001ED0F5 /* StatusBarController.swift */; };
64ACB8D627EAECCE00AFEB0D /* WallPaperTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64ACB8D527EAECCE00AFEB0D /* WallPaperTool.swift */; };
64ACB8DE27EB0BBA00AFEB0D /* Json in Frameworks */ = {isa = PBXBuildFile; productRef = 64ACB8DD27EB0BBA00AFEB0D /* Json */; };
64ACB8E027EB0BBA00AFEB0D /* Request in Frameworks */ = {isa = PBXBuildFile; productRef = 64ACB8DF27EB0BBA00AFEB0D /* Request */; };
Expand Down Expand Up @@ -49,7 +48,6 @@
64779BE727E9D677001ED0F5 /* EarthLiveXUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EarthLiveXUITestsLaunchTests.swift; sourceTree = "<group>"; };
64779BF427E9D77A001ED0F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
64779C0127EAB3A8001ED0F5 /* EarthLiveX.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EarthLiveX.swift; sourceTree = "<group>"; };
64779C0327EABAF2001ED0F5 /* StatusBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; };
64ACB8D527EAECCE00AFEB0D /* WallPaperTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WallPaperTool.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -105,7 +103,6 @@
isa = PBXGroup;
children = (
64779C0127EAB3A8001ED0F5 /* EarthLiveX.swift */,
64779C0327EABAF2001ED0F5 /* StatusBarController.swift */,
64ACB8D527EAECCE00AFEB0D /* WallPaperTool.swift */,
64779BF427E9D77A001ED0F5 /* Info.plist */,
64779BCD27E9D677001ED0F5 /* Assets.xcassets */,
Expand Down Expand Up @@ -302,7 +299,6 @@
files = (
64ACB8D627EAECCE00AFEB0D /* WallPaperTool.swift in Sources */,
64779C0227EAB3A8001ED0F5 /* EarthLiveX.swift in Sources */,
64779C0427EABAF2001ED0F5 /* StatusBarController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -462,7 +458,7 @@
CODE_SIGN_ENTITLEMENTS = EarthLiveX/EarthLiveX.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 102;
CURRENT_PROJECT_VERSION = 103;
DEVELOPMENT_ASSET_PATHS = "\"EarthLiveX/Preview Content\"";
DEVELOPMENT_TEAM = PPC69QRUTZ;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -475,7 +471,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
PRODUCT_BUNDLE_IDENTIFIER = cn.lulin.EarthLiveX;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -491,7 +487,7 @@
CODE_SIGN_ENTITLEMENTS = EarthLiveX/EarthLiveX.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 102;
CURRENT_PROJECT_VERSION = 103;
DEVELOPMENT_ASSET_PATHS = "\"EarthLiveX/Preview Content\"";
DEVELOPMENT_TEAM = PPC69QRUTZ;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -504,7 +500,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
PRODUCT_BUNDLE_IDENTIFIER = cn.lulin.EarthLiveX;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
Binary file not shown.
14 changes: 14 additions & 0 deletions EarthLiveX/EarthLiveX.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
var oneHourItem: NSMenuItem!

var refreshItem: NSMenuItem!
var lastUpdateItem: NSMenuItem!
var quitItem: NSMenuItem!

var timer: Timer!
Expand All @@ -60,6 +61,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
oneHourItem.state = .on

refreshItem = NSMenuItem(title: "刷新", action: #selector(refresh), keyEquivalent: "r")
lastUpdateItem = NSMenuItem(title: "上次更新: ", action: nil, keyEquivalent: "")
quitItem = NSMenuItem(title: "退出", action: #selector(quit), keyEquivalent: "q")

intervalSubMenu.addItem(tenMinutesItem)
Expand All @@ -72,6 +74,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
statusMenu.addItem(startItem)
statusMenu.addItem(intervalItem)
statusMenu.addItem(refreshItem)
statusMenu.addItem(lastUpdateItem)
statusMenu.addItem(.separator())
statusMenu.addItem(quitItem)
statusMenu.minimumWidth = 200
Expand Down Expand Up @@ -128,6 +131,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

func updateLastTime() {
let date = Date()
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let time = dateFormatter.string(from: date)
print("update time: \(time)")
UserDefaults.standard.set(time, forKey: "upatetime")
statusItem.menu?.item(at: 3)?.title = "上次更新: \(time)"
}

@objc func startOnLunch() {
LaunchAtLogin.isEnabled = !LaunchAtLogin.isEnabled
statusItem.menu?.item(at: 0)?.state = LaunchAtLogin.isEnabled ? .on : .off
Expand All @@ -146,6 +159,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@objc func getWallPaper() {
print("start get wallper...")
getLaestImg()
updateLastTime()
}

}
29 changes: 0 additions & 29 deletions EarthLiveX/StatusBarController.swift

This file was deleted.

1 change: 0 additions & 1 deletion EarthLiveX/WallPaperTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ func setWallpaper(path: String){
print("set wallpeper error: \(error)")
}
}

}

func resizeImage(sourceImage: NSImage, forSize targetSize: CGSize) -> NSImage {
Expand Down

0 comments on commit 06819db

Please sign in to comment.