Skip to content

Commit e295fbc

Browse files
committed
fix: drafts
1 parent 623cc9b commit e295fbc

9 files changed

Lines changed: 340 additions & 40 deletions

File tree

content/posts/HelloWorld.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
date: '2025-10-21T14:58:51+08:00'
3-
draft: true
3+
draft: false
44
title: 'HelloWorld'
55
---
66
#Hello, wrold!

content/posts/基于MVVM模式手把手写出可测试性强的SwiftUI代码.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
date: '2025-10-21T15:43:57+08:00'
3-
draft: true
3+
draft: false
44
title: '基于MVVM模式手把手写出可测试性强的SwiftUI代码'
55
---
66
# 用SwiftUI框架绘制视图

public/index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,34 @@
125125
</nav>
126126
</header>
127127
<main class="main">
128+
129+
<article class="first-entry">
130+
<header class="entry-header">
131+
<h2 class="entry-hint-parent">基于MVVM模式手把手写出可测试性强的SwiftUI代码
132+
</h2>
133+
</header>
134+
<div class="entry-content">
135+
<p>用SwiftUI框架绘制视图 首先在Xcode里新建一个Swift Package包,要写UI库选择Library,git版本管理可以不勾,带SwiftTesting确保在Swift6的较新环境。 项目结构:
136+
ImmutableState ├── Package.swift ├── Sources │ └── ImmutableState │ └── ImmutableState.swift └── Tests └── ImmutableStateTests └── ImmutableStateTests.swift Package.swift(模板生成):
137+
let package = Package( name: &#34;ImmutableState&#34;, products: [ // Products define the executables and libraries a package produces, making them visible to other packages. .library( name: &#34;ImmutableState&#34;, targets: [&#34;ImmutableState&#34;]), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. .target( name: &#34;ImmutableState&#34;), .testTarget( name: &#34;ImmutableStateTests&#34;, dependencies: [&#34;ImmutableState&#34;] ), ] ) 上方展示了创建时的工程结构和模板生成Package.swift。 其次在ImmutableState.swift 旁边创建 ImmutableDemo 文件夹安放接下来的整套代码,也就在ImmutableDemo文件夹下使用 SwiftUIView 模板创建代码,然后右键struct的名称,refactor重构rename改名为 ImmutableView。
138+
...</p>
139+
</div>
140+
<footer class="entry-footer"><span title='2025-10-21 15:43:57 +0800 CST'>October 21, 2025</span></footer>
141+
<a class="entry-link" aria-label="post link to 基于MVVM模式手把手写出可测试性强的SwiftUI代码" href="https://winterarch.github.io/posts/%E5%9F%BA%E4%BA%8Emvvm%E6%A8%A1%E5%BC%8F%E6%89%8B%E6%8A%8A%E6%89%8B%E5%86%99%E5%87%BA%E5%8F%AF%E6%B5%8B%E8%AF%95%E6%80%A7%E5%BC%BA%E7%9A%84swiftui%E4%BB%A3%E7%A0%81/"></a>
142+
</article>
143+
144+
<article class="post-entry">
145+
<header class="entry-header">
146+
<h2 class="entry-hint-parent">HelloWorld
147+
</h2>
148+
</header>
149+
<div class="entry-content">
150+
<p>#Hello, wrold!
151+
</p>
152+
</div>
153+
<footer class="entry-footer"><span title='2025-10-21 14:58:51 +0800 CST'>October 21, 2025</span></footer>
154+
<a class="entry-link" aria-label="post link to HelloWorld" href="https://winterarch.github.io/posts/helloworld/"></a>
155+
</article>
128156
</main>
129157

130158
<footer class="footer">

public/index.xml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,53 @@
66
<description>Recent content on WinterArch&#39;s WebLog</description>
77
<generator>Hugo -- 0.151.2</generator>
88
<language>en-us</language>
9-
<lastBuildDate></lastBuildDate>
9+
<lastBuildDate>Tue, 21 Oct 2025 15:43:57 +0800</lastBuildDate>
1010
<atom:link href="https://winterarch.github.io/index.xml" rel="self" type="application/rss+xml" />
11+
<item>
12+
<title>基于MVVM模式手把手写出可测试性强的SwiftUI代码</title>
13+
<link>https://winterarch.github.io/posts/%E5%9F%BA%E4%BA%8Emvvm%E6%A8%A1%E5%BC%8F%E6%89%8B%E6%8A%8A%E6%89%8B%E5%86%99%E5%87%BA%E5%8F%AF%E6%B5%8B%E8%AF%95%E6%80%A7%E5%BC%BA%E7%9A%84swiftui%E4%BB%A3%E7%A0%81/</link>
14+
<pubDate>Tue, 21 Oct 2025 15:43:57 +0800</pubDate>
15+
<guid>https://winterarch.github.io/posts/%E5%9F%BA%E4%BA%8Emvvm%E6%A8%A1%E5%BC%8F%E6%89%8B%E6%8A%8A%E6%89%8B%E5%86%99%E5%87%BA%E5%8F%AF%E6%B5%8B%E8%AF%95%E6%80%A7%E5%BC%BA%E7%9A%84swiftui%E4%BB%A3%E7%A0%81/</guid>
16+
<description>&lt;h1 id=&#34;用swiftui框架绘制视图&#34;&gt;用SwiftUI框架绘制视图&lt;/h1&gt;
17+
&lt;p&gt;首先在Xcode里新建一个Swift Package包,要写UI库选择Library,git版本管理可以不勾,带SwiftTesting确保在Swift6的较新环境。
18+
项目结构:&lt;/p&gt;
19+
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ImmutableState
20+
├── Package.swift
21+
├── Sources
22+
│ └── ImmutableState
23+
│ └── ImmutableState.swift
24+
└── Tests
25+
└── ImmutableStateTests
26+
└── ImmutableStateTests.swift
27+
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Package.swift(模板生成):&lt;/p&gt;
28+
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-Swift&#34; data-lang=&#34;Swift&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; package = Package(
29+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; name: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;ImmutableState&amp;#34;&lt;/span&gt;,
30+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; products: [
31+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; &lt;span style=&#34;color:#75715e&#34;&gt;// Products define the executables and libraries a package produces, making them visible to other packages.&lt;/span&gt;
32+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; .library(
33+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; name: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;ImmutableState&amp;#34;&lt;/span&gt;,
34+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; targets: [&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;ImmutableState&amp;#34;&lt;/span&gt;]),
35+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; ],
36+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; targets: [
37+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; &lt;span style=&#34;color:#75715e&#34;&gt;// Targets are the basic building blocks of a package, defining a module or a test suite.&lt;/span&gt;
38+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; &lt;span style=&#34;color:#75715e&#34;&gt;// Targets can depend on other targets in this package and products from dependencies.&lt;/span&gt;
39+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; .target(
40+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; name: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;ImmutableState&amp;#34;&lt;/span&gt;),
41+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; .testTarget(
42+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; name: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;ImmutableStateTests&amp;#34;&lt;/span&gt;,
43+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; dependencies: [&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;ImmutableState&amp;#34;&lt;/span&gt;]
44+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; ),
45+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; ]
46+
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;)
47+
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;上方展示了创建时的工程结构和模板生成Package.swift。
48+
其次在ImmutableState.swift 旁边创建 ImmutableDemo 文件夹安放接下来的整套代码,也就在ImmutableDemo文件夹下使用 SwiftUIView 模板创建代码,然后右键struct的名称,refactor重构rename改名为 ImmutableView。&lt;/p&gt;</description>
49+
</item>
50+
<item>
51+
<title>HelloWorld</title>
52+
<link>https://winterarch.github.io/posts/helloworld/</link>
53+
<pubDate>Tue, 21 Oct 2025 14:58:51 +0800</pubDate>
54+
<guid>https://winterarch.github.io/posts/helloworld/</guid>
55+
<description>&lt;p&gt;#Hello, wrold!&lt;/p&gt;</description>
56+
</item>
1157
</channel>
1258
</rss>

public/posts/helloworld/index.html

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<!DOCTYPE html>
22
<html lang="en" dir="auto">
33

4-
<head><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script><meta charset="utf-8">
4+
<head><meta charset="utf-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7-
<meta name="robots" content="noindex, nofollow">
7+
<meta name="robots" content="index, follow">
88
<title>HelloWorld | WinterArch&#39;s WebLog</title>
99
<meta name="keywords" content="">
1010
<meta name="description" content="#Hello, wrold!">
1111
<meta name="author" content="">
12-
<link rel="canonical" href="http://localhost:1313/posts/helloworld/">
12+
<link rel="canonical" href="https://winterarch.github.io/posts/helloworld/">
1313
<link crossorigin="anonymous" href="/assets/css/stylesheet.a090830a421002426baafbd314e38f149d77b4c48a12ee9312700d770b27fb26.css" integrity="sha256-oJCDCkIQAkJrqvvTFOOPFJ13tMSKEu6TEnANdwsn&#43;yY=" rel="preload stylesheet" as="style">
14-
<link rel="icon" href="http://localhost:1313/favicon.ico">
15-
<link rel="icon" type="image/png" sizes="16x16" href="http://localhost:1313/favicon-16x16.png">
16-
<link rel="icon" type="image/png" sizes="32x32" href="http://localhost:1313/favicon-32x32.png">
17-
<link rel="apple-touch-icon" href="http://localhost:1313/apple-touch-icon.png">
18-
<link rel="mask-icon" href="http://localhost:1313/safari-pinned-tab.svg">
14+
<link rel="icon" href="https://winterarch.github.io/favicon.ico">
15+
<link rel="icon" type="image/png" sizes="16x16" href="https://winterarch.github.io/favicon-16x16.png">
16+
<link rel="icon" type="image/png" sizes="32x32" href="https://winterarch.github.io/favicon-32x32.png">
17+
<link rel="apple-touch-icon" href="https://winterarch.github.io/apple-touch-icon.png">
18+
<link rel="mask-icon" href="https://winterarch.github.io/safari-pinned-tab.svg">
1919
<meta name="theme-color" content="#2e2e33">
2020
<meta name="msapplication-TileColor" content="#2e2e33">
21-
<link rel="alternate" hreflang="en" href="http://localhost:1313/posts/helloworld/">
21+
<link rel="alternate" hreflang="en" href="https://winterarch.github.io/posts/helloworld/">
2222
<noscript>
2323
<style>
2424
#theme-toggle,
@@ -55,7 +55,69 @@
5555
}
5656

5757
</style>
58-
</noscript>
58+
</noscript><meta property="og:url" content="https://winterarch.github.io/posts/helloworld/">
59+
<meta property="og:site_name" content="WinterArch&#39;s WebLog">
60+
<meta property="og:title" content="HelloWorld">
61+
<meta property="og:description" content="#Hello, wrold!">
62+
<meta property="og:locale" content="en-us">
63+
<meta property="og:type" content="article">
64+
<meta property="article:section" content="posts">
65+
<meta property="article:published_time" content="2025-10-21T14:58:51+08:00">
66+
<meta property="article:modified_time" content="2025-10-21T14:58:51+08:00">
67+
<meta name="twitter:card" content="summary">
68+
<meta name="twitter:title" content="HelloWorld">
69+
<meta name="twitter:description" content="#Hello, wrold!">
70+
71+
72+
<script type="application/ld+json">
73+
{
74+
"@context": "https://schema.org",
75+
"@type": "BreadcrumbList",
76+
"itemListElement": [
77+
{
78+
"@type": "ListItem",
79+
"position": 1 ,
80+
"name": "Posts",
81+
"item": "https://winterarch.github.io/posts/"
82+
},
83+
{
84+
"@type": "ListItem",
85+
"position": 2 ,
86+
"name": "HelloWorld",
87+
"item": "https://winterarch.github.io/posts/helloworld/"
88+
}
89+
]
90+
}
91+
</script>
92+
<script type="application/ld+json">
93+
{
94+
"@context": "https://schema.org",
95+
"@type": "BlogPosting",
96+
"headline": "HelloWorld",
97+
"name": "HelloWorld",
98+
"description": "#Hello, wrold!\n",
99+
"keywords": [
100+
101+
],
102+
"articleBody": "#Hello, wrold!\n",
103+
"wordCount" : "2",
104+
"inLanguage": "en",
105+
"datePublished": "2025-10-21T14:58:51+08:00",
106+
"dateModified": "2025-10-21T14:58:51+08:00",
107+
"mainEntityOfPage": {
108+
"@type": "WebPage",
109+
"@id": "https://winterarch.github.io/posts/helloworld/"
110+
},
111+
"publisher": {
112+
"@type": "Organization",
113+
"name": "WinterArch's WebLog",
114+
"logo": {
115+
"@type": "ImageObject",
116+
"url": "https://winterarch.github.io/favicon.ico"
117+
}
118+
}
119+
}
120+
</script>
59121
</head>
60122

61123
<body class="" id="top">
@@ -73,7 +135,7 @@
73135
<header class="header">
74136
<nav class="nav">
75137
<div class="logo">
76-
<a href="http://localhost:1313/" accesskey="h" title="WinterArch&#39;s WebLog (Alt + H)">WinterArch&#39;s WebLog</a>
138+
<a href="https://winterarch.github.io/" accesskey="h" title="WinterArch&#39;s WebLog (Alt + H)">WinterArch&#39;s WebLog</a>
77139
<div class="logo-switches">
78140
<button id="theme-toggle" accesskey="t" title="(Alt + T)" aria-label="Toggle theme">
79141
<svg id="moon" xmlns="http://www.w3.org/2000/svg" width="24" height="18" viewBox="0 0 24 24"
@@ -108,12 +170,6 @@
108170

109171
<h1 class="post-title entry-hint-parent">
110172
HelloWorld
111-
<span class="entry-hint" title="Draft">
112-
<svg xmlns="http://www.w3.org/2000/svg" height="35" viewBox="0 -960 960 960" fill="currentColor">
113-
<path
114-
d="M160-410v-60h300v60H160Zm0-165v-60h470v60H160Zm0-165v-60h470v60H160Zm360 580v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q9 9 13 20t4 22q0 11-4.5 22.5T862.09-380L643-160H520Zm300-263-37-37 37 37ZM580-220h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19Z" />
115-
</svg>
116-
</span>
117173
</h1>
118174
<div class="post-meta"><span title='2025-10-21 14:58:51 +0800 CST'>October 21, 2025</span>
119175

@@ -132,7 +188,7 @@ <h1 class="post-title entry-hint-parent">
132188
</main>
133189

134190
<footer class="footer">
135-
<span>&copy; 2025 <a href="http://localhost:1313/">WinterArch&#39;s WebLog</a></span> ·
191+
<span>&copy; 2025 <a href="https://winterarch.github.io/">WinterArch&#39;s WebLog</a></span> ·
136192

137193
<span>
138194
Powered by

public/posts/index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,34 @@ <h1>
131131
Posts
132132
</h1>
133133
</header>
134+
135+
<article class="post-entry">
136+
<header class="entry-header">
137+
<h2 class="entry-hint-parent">基于MVVM模式手把手写出可测试性强的SwiftUI代码
138+
</h2>
139+
</header>
140+
<div class="entry-content">
141+
<p>用SwiftUI框架绘制视图 首先在Xcode里新建一个Swift Package包,要写UI库选择Library,git版本管理可以不勾,带SwiftTesting确保在Swift6的较新环境。 项目结构:
142+
ImmutableState ├── Package.swift ├── Sources │ └── ImmutableState │ └── ImmutableState.swift └── Tests └── ImmutableStateTests └── ImmutableStateTests.swift Package.swift(模板生成):
143+
let package = Package( name: &#34;ImmutableState&#34;, products: [ // Products define the executables and libraries a package produces, making them visible to other packages. .library( name: &#34;ImmutableState&#34;, targets: [&#34;ImmutableState&#34;]), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. .target( name: &#34;ImmutableState&#34;), .testTarget( name: &#34;ImmutableStateTests&#34;, dependencies: [&#34;ImmutableState&#34;] ), ] ) 上方展示了创建时的工程结构和模板生成Package.swift。 其次在ImmutableState.swift 旁边创建 ImmutableDemo 文件夹安放接下来的整套代码,也就在ImmutableDemo文件夹下使用 SwiftUIView 模板创建代码,然后右键struct的名称,refactor重构rename改名为 ImmutableView。
144+
...</p>
145+
</div>
146+
<footer class="entry-footer"><span title='2025-10-21 15:43:57 +0800 CST'>October 21, 2025</span></footer>
147+
<a class="entry-link" aria-label="post link to 基于MVVM模式手把手写出可测试性强的SwiftUI代码" href="https://winterarch.github.io/posts/%E5%9F%BA%E4%BA%8Emvvm%E6%A8%A1%E5%BC%8F%E6%89%8B%E6%8A%8A%E6%89%8B%E5%86%99%E5%87%BA%E5%8F%AF%E6%B5%8B%E8%AF%95%E6%80%A7%E5%BC%BA%E7%9A%84swiftui%E4%BB%A3%E7%A0%81/"></a>
148+
</article>
149+
150+
<article class="post-entry">
151+
<header class="entry-header">
152+
<h2 class="entry-hint-parent">HelloWorld
153+
</h2>
154+
</header>
155+
<div class="entry-content">
156+
<p>#Hello, wrold!
157+
</p>
158+
</div>
159+
<footer class="entry-footer"><span title='2025-10-21 14:58:51 +0800 CST'>October 21, 2025</span></footer>
160+
<a class="entry-link" aria-label="post link to HelloWorld" href="https://winterarch.github.io/posts/helloworld/"></a>
161+
</article>
134162
</main>
135163

136164
<footer class="footer">

0 commit comments

Comments
 (0)