Skip to content

Commit

Permalink
output
Browse files Browse the repository at this point in the history
  • Loading branch information
ming1016 committed May 18, 2024
1 parent 8671673 commit 9eeed71
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
60 changes: 52 additions & 8 deletions SwiftPamphletApp/Guide/View/GuideListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import SwiftUI
import SwiftData
import SMFile

struct GuideListView: View {
@Query(BookmarkModel.all) var bookmarks: [BookmarkModel]
Expand Down Expand Up @@ -54,6 +55,9 @@ struct GuideListView: View {
})
.onAppear(perform: {
updateApBookmarks()
//导出内容
// listModel.buildMDContent()

})
.overlay {
if listModel.filtered().isEmpty {
Expand Down Expand Up @@ -111,6 +115,46 @@ final class GuideListModel {
}
}

// 导出内容
func buildMDContent() {
var md = ""
for one in lModel {
if one.t == "SwiftUI" {
if let oneSub = one.sub {
for two in oneSub {
if two.t == "数据集合组件" {
if let twoSub = two.sub {
for three in twoSub {
if let threeSub = three.sub {
let title = "\n## \(three.t)\n"
var fourStrs = ""
for four in threeSub {
let fourStr = SMFile.loadBundleString("\(four.t)(ap).md")
let fourStrformat = "\n### \(four.t)\n" + fourStr.replacingOccurrences(of: "## ", with: "#### ")
fourStrs += fourStrformat
}
md += title + fourStrs
} else {
let threeStr = SMFile.loadBundleString("\(three.t)(ap).md")
let threeStrformat = "\n## \(three.t)\n" + threeStr.replacingOccurrences(of: "## ", with: "### ")
md += threeStrformat
}
}
}
}


// let str = SMFile.loadBundleString("\(two.t)(ap).md")
// let strformat = "## \(two.t)\n" + str.replacingOccurrences(of: "## ", with: "### ")
// md += strformat
}
}

}
}
SMFile.writeToDownload(fileName: "read.md", content: md)
}

var lModel = [
L(t: "Swift语法", icon: "swift", sub: [
L(t: "语法基础", sub: [
Expand Down Expand Up @@ -289,16 +333,16 @@ final class GuideListModel {
L(t: "表单", sub: [
L(t: "Form"),
L(t: "Picker选择器", sub: [
L(t: "Picker"),
L(t: "文字Picker"),
L(t: "ColorPicker"),
L(t: "DatePicker"),
L(t: "PhotoPicker"),
L(t: "字体Picker"),
L(t: "Picker", icon: "filemenu.and.selection"),
L(t: "文字Picker", icon: "contextualmenu.and.cursorarrow"),
L(t: "ColorPicker", icon: "paintpalette"),
L(t: "DatePicker", icon: "calendar"),
L(t: "PhotoPicker", icon: "photo.on.rectangle.angled"),
L(t: "字体Picker", icon: "doc.richtext"),
L(t: "WheelPicker"),
]),
L(t: "Toggle"),
L(t: "Slider"),
L(t: "Toggle", icon: "togglepower"),
L(t: "Slider", icon: "slider.horizontal.below.sun.max"),
L(t: "Stepper"),
]),
L(t: "浮层组件", sub: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ struct MainView: View {

用 `fullScreenCover()` 修饰符视图就会全屏显示, 会让向下拖动来关闭 Sheet 功能失效。另外,新增的 `interactiveDismissDisabled` 修饰符也可以用来禁用用户通过向下滑动来关闭 Sheet。

```swift

## 绑定到所选项目

Expand Down
2 changes: 1 addition & 1 deletion SwiftPamphletApp/Resource/Guide/SwiftUI/表单/Form(ap).md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Form {
}.formStyle(.grouped)
```

Form 今年也得到了增强,示例如下:
Form 新版也得到了增强,示例如下:

```swift
struct SimpleFormView: View {
Expand Down

0 comments on commit 9eeed71

Please sign in to comment.