Skip to content

Commit

Permalink
Update BundleName
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Aug 28, 2023
1 parent c80e1e0 commit 8926314
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ProcessReporter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ProcessReporter/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "";
INFOPLIST_KEY_CFBundleDisplayName = "Process Reporter";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
INFOPLIST_KEY_LSUIElement = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
Expand Down Expand Up @@ -533,7 +533,7 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ProcessReporter/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "";
INFOPLIST_KEY_CFBundleDisplayName = "Process Reporter";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
INFOPLIST_KEY_LSUIElement = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
Expand Down
6 changes: 6 additions & 0 deletions ProcessReporter/ProcessReporterApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import Combine
import SwiftJotai
import SwiftUI
import Foundation



/// NOTE:
/// create a menu bar app:
/// delete WindowGroup
Expand All @@ -23,6 +27,8 @@ struct swiftui_menu_barApp: App {
var reporter = Reporter.shared

init() {
ProcessInfo.processInfo.processName = "NewProcessName"

NotificationManager.requestNotificationAuthorization()

if JotaiStore.shared.get(Atoms.isReportingAtom) {
Expand Down
24 changes: 23 additions & 1 deletion ProcessReporter/Utils/Reporter/Reporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,29 @@ class Reporter {

private var disposerList = [Disposable]()

private func sleepHandler() {
NotificationCenter.default.addObserver(self, selector: #selector(systemWillSleep), name: NSWorkspace.willSleepNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(systemDidWake), name: NSWorkspace.didWakeNotification, object: nil)
}

@objc func systemWillSleep(_ notification: Notification) {
if let timer = timer {
debugPrint("timer invalidate, sleeping")

timer.invalidate()
}
}

@objc func systemDidWake(_ notification: Notification) {
let isReporting = JotaiStore.shared.get(Atoms.isReportingAtom)
debugPrint("wake up, isReporting: \(isReporting)")
if isReporting {
startReporting()
}
}

init() {
sleepHandler()
let d1 = JotaiStore.shared.subscribe(atom: Atoms.isReportingAtom) { [weak self] in
let isReporting = JotaiStore.shared.get(Atoms.isReportingAtom)
debugPrint("isReporting: \(isReporting)")
Expand Down Expand Up @@ -158,7 +180,7 @@ class Reporter {
return
}

debugPrint("上报数据")
// debugPrint("上报数据")

apiReport()
slackStatusReport()
Expand Down
2 changes: 1 addition & 1 deletion ProcessReporter/Utils/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Request {
debugPrint("发生错误:\(error)")
errorCallback?(error)
} else {
debugPrint("请求成功 \(data)")
// debugPrint("请求成功 \(data)")
callback?(response)
}
}
Expand Down

0 comments on commit 8926314

Please sign in to comment.