迁移格式化逻辑到 iOS 端并删除 Python 脚本

This commit is contained in:
2026-07-12 21:04:15 +08:00
parent b2e36227b6
commit 0c202ac284
+27
View File
@@ -40,6 +40,7 @@ class FormatLogViewController: UIViewController {
formatButton.backgroundColor = .systemBlue formatButton.backgroundColor = .systemBlue
formatButton.setTitleColor(.white, for: .normal) formatButton.setTitleColor(.white, for: .normal)
formatButton.layer.cornerRadius = 12 formatButton.layer.cornerRadius = 12
formatButton.addTarget(self, action: #selector(didTapFormatButton), for: .touchUpInside)
view.addSubview(formatButton) view.addSubview(formatButton)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
@@ -58,6 +59,32 @@ class FormatLogViewController: UIViewController {
@objc private func didTapDoneButton() { @objc private func didTapDoneButton() {
textView.resignFirstResponder() textView.resignFirstResponder()
} }
@objc private func didTapFormatButton() {
textView.text = formatLog(textView.text)
}
private func formatLog(_ text: String) -> String {
var content = text
content = content.replacingOccurrences(of: "# ", with: "")
content = content.replacingOccurrences(of: "#", with: "")
content = content.replacingOccurrences(of: ";", with: "")
content = content.replacingOccurrences(of: "", with: "")
content = content.replacingOccurrences(of: ".", with: "")
content = content.replacingOccurrences(of: "", with: "(")
content = content.replacingOccurrences(of: "", with: ")")
content = content.replacingOccurrences(of: "?", with: "")
content = content.replacingOccurrences(of: ",", with: "")
content = content.replacingOccurrences(of: ":", with: "")
content = content.replacingOccurrences(of: "日星期", with: "日 星期")
content = "# " + content
content = content.replacingOccurrences(of: "一、生活方面", with: "## 一、生活方面")
content = content.replacingOccurrences(of: "二、交易方面", with: "## 二、交易方面")
content = content.replacingOccurrences(of: "三、工作方面", with: "## 三、工作方面")
return content
}
} }
extension FormatLogViewController: UITextViewDelegate { extension FormatLogViewController: UITextViewDelegate {