From 545e023ffc004e05ee69bf57b48ade8ec09a912f Mon Sep 17 00:00:00 2001 From: fish Date: Wed, 15 Jul 2026 22:43:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=94=B6=E9=9B=86=E7=AE=B1?= =?UTF-8?q?=E6=9C=89=E5=86=85=E5=AE=B9=E6=97=B6=E6=97=A0=E6=B3=95=E8=BF=9B?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Note/ViewController.swift | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Note/ViewController.swift b/Note/ViewController.swift index 25af822..3d919c5 100644 --- a/Note/ViewController.swift +++ b/Note/ViewController.swift @@ -15,15 +15,16 @@ class ViewController: UIViewController { let icon: String let iconColor: UIColor let title: String + let identifier: String } private var menuItems: [[MenuItem]] = [ [ - MenuItem(icon: "tray.full", iconColor: .systemIndigo, title: "收集箱"), - MenuItem(icon: "note.text", iconColor: .systemYellow, title: "打开备忘录"), - MenuItem(icon: "doc.text", iconColor: .systemBlue, title: "格式化日志"), - MenuItem(icon: "text.alignleft", iconColor: .systemGreen, title: "格式化笔记"), - MenuItem(icon: "folder", iconColor: .systemOrange, title: "打开文件") + MenuItem(icon: "tray.full", iconColor: .systemIndigo, title: "收集箱", identifier: "inbox"), + MenuItem(icon: "note.text", iconColor: .systemYellow, title: "打开备忘录", identifier: "notes"), + MenuItem(icon: "doc.text", iconColor: .systemBlue, title: "格式化日志", identifier: "formatLog"), + MenuItem(icon: "text.alignleft", iconColor: .systemGreen, title: "格式化笔记", identifier: "formatNote"), + MenuItem(icon: "folder", iconColor: .systemOrange, title: "打开文件", identifier: "files") ] ] @@ -92,19 +93,19 @@ extension ViewController: UITableViewDelegate { tableView.deselectRow(at: indexPath, animated: true) let item = menuItems[indexPath.section][indexPath.row] - switch item.title { - case "收集箱": + switch item.identifier { + case "inbox": let viewController = ClipInboxViewController() navigationController?.pushViewController(viewController, animated: true) - case "打开备忘录": + case "notes": openSystemNotesApp() - case "格式化日志": + case "formatLog": let viewController = FormatLogViewController() navigationController?.pushViewController(viewController, animated: true) - case "格式化笔记": + case "formatNote": let viewController = FormatNoteViewController() navigationController?.pushViewController(viewController, animated: true) - case "打开文件": + case "files": openFilesApp() default: break @@ -128,11 +129,12 @@ extension ViewController: UITableViewDelegate { private func updateInboxTitle(_ title: String) { for (sectionIndex, section) in menuItems.enumerated() { for (rowIndex, item) in section.enumerated() { - if item.title.hasPrefix("收集箱") { + if item.identifier == "inbox" { menuItems[sectionIndex][rowIndex] = MenuItem( icon: item.icon, iconColor: item.iconColor, - title: title + title: title, + identifier: item.identifier ) let indexPath = IndexPath(row: rowIndex, section: sectionIndex) tableView.reloadRows(at: [indexPath], with: .none)