-
Notifications
You must be signed in to change notification settings - Fork 40
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
12 changed files
with
146 additions
and
64 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
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
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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
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 |
---|---|---|
|
@@ -12,11 +12,45 @@ import SwiftData | |
struct WenYanApp: App { | ||
|
||
@State private var appState = AppState() | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
ContentView(appState: appState) | ||
.alert(isPresented: appState.showError, error: appState.appError) {} | ||
} | ||
.commands { | ||
CommandGroup(replacing: .appInfo) { | ||
Button("About 文颜") { | ||
NSApplication.shared.orderFrontStandardAboutPanel( | ||
options: [ | ||
NSApplication.AboutPanelOptionKey.credits: str(), | ||
NSApplication.AboutPanelOptionKey( | ||
rawValue: "Copyright" | ||
): "© 2024 Lei Cao. All rights reserved." | ||
] | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func str() -> NSMutableAttributedString { | ||
let contactInfo = "问题反馈:[email protected]" | ||
let email = "[email protected]" | ||
|
||
// 创建一个可变的富文本字符串 | ||
let attributedString = NSMutableAttributedString( | ||
string: contactInfo, | ||
attributes: [ | ||
.font: NSFont.systemFont(ofSize: NSFont.smallSystemFontSize) | ||
] | ||
) | ||
|
||
// 获取 email 在字符串中的范围 | ||
let emailRange = (contactInfo as NSString).range(of: email) | ||
|
||
// 设置 email 为可点击链接 | ||
attributedString.addAttribute(.link, value: "mailto:\(email)", range: emailRange) | ||
return attributedString | ||
} | ||
} |