Skip to content

Commit

Permalink
Merge pull request #5 from samzong/refactor/gitignore
Browse files Browse the repository at this point in the history
♻️ refactor: Clean cache files,add .gitignore
  • Loading branch information
samzong authored Sep 20, 2024
2 parents 99ca78b + df5564c commit dbb7801
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 40 deletions.
93 changes: 93 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .gitignore file,
# but if you remove the entire directory, it may regenerate without the .gitignore
.swiftpm

.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

# macOS
.DS_Store
14 changes: 12 additions & 2 deletions AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,19 @@ class AppDelegate: NSObject, NSApplicationDelegate {

func setupMenu() {
menu = NSMenu()
menu.minimumWidth = 200 // 设置固定宽

// Current track info
let trackInfoItem = NSMenuItem(title: "No selected", action: nil, keyEquivalent: "")
trackInfoItem.isEnabled = false
trackInfoItem.view = NSView(frame: NSRect(x: 0, y: 0, width: 180, height: 20)) // 设置固定宽度的视图
let trackLabel = NSTextField(frame: NSRect(x: 10, y: 0, width: 160, height: 20))
trackLabel.isEditable = false
trackLabel.isBordered = false
trackLabel.backgroundColor = .clear
trackLabel.lineBreakMode = .byTruncatingTail // 文本过长时显示省略号
trackInfoItem.view?.addSubview(trackLabel)

menu.addItem(trackInfoItem)

menu.addItem(NSMenuItem.separator())
Expand Down Expand Up @@ -97,8 +106,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

@objc func updateMenuItems() {
if let trackInfoItem = menu.item(at: 0) {
trackInfoItem.title = playerManager.currentTrack?.title ?? "No track selected"
if let trackInfoItem = menu.item(at: 0),
let trackLabel = trackInfoItem.view?.subviews.first as? NSTextField {
trackLabel.stringValue = playerManager.currentTrack?.title ?? "No track selected"
}

if let playPauseItem = menu.item(at: 2) {
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit dbb7801

Please sign in to comment.