Skip to content

Commit 81da606

Browse files
committed
優化文檔內容(zh)。
1 parent f074df0 commit 81da606

25 files changed

+1755
-563
lines changed

dist/QuickUI.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/QuickUI.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pardnchiu/quickui",
3-
"version": "0.6.16",
3+
"version": "0.6.17",
44
"description": "QuickUI is a lightweight frontend framework built on pure JavaScript and native APIs. Supports data binding, i18n support, event binding, conditional rendering, and loop rendering.",
55
"main": "dist/QuickUI.js",
66
"module": "dist/QuickUI.esm.js",

page/test.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ <h4 :else>{{ title }} 4
122122
<p>{{ UPPER(test1) }} {{ LOWER(test2) }}</p>
123123
<p>{{ DATE(now, YYYY-MM-DD hh:mm:ss) }}</p>
124124
<hr>
125-
<img :for="e in icons" :lazyload="https://skillicons.dev/icons?i={{e}}">
125+
<!-- <img :for="e in icons" :lazyload="https://skillicons.dev/icons?i={{e}}"> -->
126126
<script>
127127
document.addEventListener("DOMContentLoaded", () => {
128128
let icons = "ableton,activitypub,actix,adonis,ae,aiscript,alpinejs,anaconda,androidstudio,angular,ansible,apollo,apple,appwrite,arch,arduino,astro,atom,au,autocad,aws,azul,azure,babel,bash,bevy,bitbucket,blender,bootstrap,bsd,bun,c,cs,cpp,crystal,cassandra,clion,clojure,cloudflare,cmake,codepen,coffeescript,css,cypress,d3,dart,debian,deno,devto,discord,bots,discordjs,django,docker,dotnet,dynamodb,eclipse,elasticsearch,electron,elixir,elysia,emacs,ember,emotion,express,fastapi,fediverse,figma,firebase,flask,flutter,forth,fortran,gamemakerstudio,gatsby,gcp,git,github,githubactions,gitlab,gmail,gherkin,go,gradle,godot,grafana,graphql,gtk,gulp,haskell,haxe,haxeflixel,heroku,hibernate,html,htmx,idea,ai,instagram,ipfs,java,js,jenkins,jest,jquery,kafka,kali,kotlin,ktor,kubernetes,laravel,latex,less,linkedin,linux,lit,lua,md,mastodon,materialui,matlab,maven,mint,misskey,mongodb,mysql,neovim,nestjs,netlify,nextjs,nginx,nim,nix,nodejs,notion,npm,nuxtjs,obsidian,ocaml,octave,opencv,openshift,openstack,p5js,perl,ps,php,phpstorm,pinia,pkl,plan9,planetscale,pnpm,postgres,postman,powershell,pr,prisma,processing,prometheus,pug,pycharm,py,pytorch,qt,r,rabbitmq,rails,raspberrypi,react,reactivex,redhat,redis,redux,regex,remix,replit,rider,robloxstudio,rocket,rollupjs,ros,ruby,rust,sass,spring,sqlite,stackoverflow,styledcomponents,sublime,supabase,scala,sklearn,selenium,sentry,sequelize,sketchup,solidity,solidjs,svelte,svg,swift,symfony,tailwind,tauri,tensorflow,terraform,threejs,twitter,ts,ubuntu,unity,unreal,v,vala,vercel,vim,visualstudio,vite,vitest,vscode,vscodium,vue,vuetify,wasm,webflow,webpack,webstorm,windicss,windows,wordpress,workers,xd,yarn,yew,zig".split(",");
@@ -237,15 +237,15 @@ <h4 :else>{{ title }} 4
237237
alert("good2");
238238
},
239239
input: _ => {
240-
console.log(app.data)
240+
// console.log(app.data)
241241
}
242242
},
243243
when: {
244244
beforeRender: _ => {
245-
console.log("準備渲染");
245+
// console.log("準備渲染");
246246
// return false;
247247
},
248-
rendered: _ => {
248+
rendered: sec => {
249249
// const html = app.parseToHTML(`
250250
// div#main-card.primary.highlighted {
251251
// style: "background: red;",
@@ -272,15 +272,15 @@ <h4 :else>{{ title }} 4
272272
app.data.obj.home.ary[0].name = "Test"
273273

274274
}, 2000)
275-
console.log("已渲染")
275+
// console.log("已渲染", sec)
276276
},
277277
beforeUpdate: _ => {
278-
console.log("準備更新")
278+
// console.log("準備更新")
279279
// alert(true)
280280
// return false;
281281
},
282-
updated: _ => {
283-
console.log("已更新")
282+
updated: sec => {
283+
// console.log("已更新", sec)
284284
}
285285
}
286286
});

src/*.ts

301 Bytes
Binary file not shown.

src/QuickUI.debug.js

-524 Bytes
Binary file not shown.

src/function/calc.ts

1 Byte
Binary file not shown.

src/function/check200.ts

5 Bytes
Binary file not shown.

src/function/createElement.ts

16 Bytes
Binary file not shown.

src/listener/LazyloadListener.ts

-1.23 KB
Binary file not shown.

src/model/Lifecycle.ts

92 Bytes
Binary file not shown.

src/model/QUI.ts

289 Bytes
Binary file not shown.

static/md/zh/binding.md

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,56 @@
1-
## 雙向綁定
1+
# QuickUI 雙向綁定
2+
3+
> [!NOTE]
4+
> 將表單元素與資料模型同步。當使用者與表單元素進行互動時,相應的資料會自動更新,而當資料變更時,相關 UI 元素也會即時反映這些變化。
5+
6+
## 語法
7+
8+
```html
9+
<input type="text" :model="屬性名稱">
10+
```
11+
12+
## 範例
13+
14+
展示了密碼輸入框的雙向綁定實現:
215

316
```html
417
<body id="app">
518
<input type="password" :model="password">
619
<button @click="show">test</button>
720
</body>
21+
822
<script>
9-
const app = new QUI({
10-
id: "app",
11-
data: {
12-
password: null,
13-
},
14-
event: {
15-
show: function(e){
16-
alert("Password:", app.data.password);
17-
}
23+
const app = new QUI({
24+
id: "app",
25+
data: {
26+
password: "",
27+
},
28+
event: {
29+
show: e => {
30+
alert("Password: " + app.data.password);
1831
}
19-
});
32+
}
33+
});
2034
</script>
21-
```
35+
```
36+
37+
## 支持
38+
39+
- 文本輸入框(`<input type="text">`
40+
- 密碼輸入框(`<input type="password">`
41+
- 文本區域(`<textarea>`
42+
- 複選框(`<input type="checkbox">`
43+
- 單選按鈕(`<input type="radio">`
44+
- 下拉選單(`<select>`
45+
46+
## 實現
47+
48+
1. 監聽表單元素的 `keyup``change` 事件
49+
2. 當事件觸發時,自動更新 `data` 中對應的屬性值
50+
3.`data` 中的屬性值變化時,自動更新表單元素的顯示
51+
52+
## 注意事項
53+
54+
- 對於 `checkbox``radio` 類型的輸入框,綁定的值會是勾選的元素的 `value`
55+
- 若多個 `checkbox` 擁有相同的 `name` 屬性,結果會以逗號分隔的字串形式保存
56+
- 確保在初始化時提供相應的資料屬性,以避免未定義錯誤

static/md/zh/block.md

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,67 @@
1+
# QuickUI 插入區塊
2+
13
> [!NOTE]
2-
> 確保測試時已禁用瀏覽器中的本地文件限制或使用實時服務器。
4+
> 動態載入和插入外部 HTML 檔案的內容到當前頁面中。模組化網頁結構,將不同的 HTML 區塊分離成獨立檔案。
5+
6+
## 語法
7+
8+
`:path` 指令需與 `<temp>` 標籤配合使用,語法如下:
9+
10+
```html
11+
<temp :path="檔案路徑"></temp>
12+
```
313

4-
#### `:path`
14+
自動將指定路徑的 HTML 檔案內容載入並替換整個 `<temp>` 元素。
515

6-
- test.html
7-
```html
16+
## 範例
17+
18+
### test.html
19+
```html
20+
<h1>path heading</h1>
21+
<p>path content</p>
22+
```
23+
24+
### index.html
25+
```html
26+
<body id="app">
27+
<temp :path="./test.html"></temp>
28+
</body>
29+
<script>
30+
const app = new QUI({
31+
id: "app"
32+
});
33+
</script>
34+
```
35+
36+
### 渲染結果
37+
```html
38+
<body id="app">
39+
<!-- 直接插入 PATH 內容 -->
840
<h1>path heading</h1>
941
<p>path content</p>
10-
```
11-
- index.html
12-
```html
13-
<body id="app">
14-
<temp :path="./test.html"></temp>
15-
</body>
16-
<script>
17-
const app = new QUI({
18-
id: "app"
19-
});
20-
</script>
21-
```
22-
- Result
23-
```html
24-
<body id="app">
25-
<!-- 直接插入 PATH 內容 -->
26-
<h1>path heading</h1>
27-
<p>path content</p>
28-
</body>
29-
```
42+
</body>
43+
```
44+
45+
## 實現
46+
47+
1. 使用 `fetch` 發送請求獲取指定路徑的 HTML 內容
48+
2. 解析並創建對應的 DOM 節點
49+
3. 使用解析後的 DOM 節點替換原始的 `<temp>` 元素
50+
4. 如果請求失敗或檔案不存在,`<temp>` 元素將保留在頁面中且不會有任何變化
51+
52+
## 注意事項
53+
54+
> [!NOTE]
55+
> 本地測試時請確保測試時已禁用瀏覽器中的本地文件限制或使用實時服務器。
56+
57+
- 在本地環境測試時,由於瀏覽器的安全限制,直接打開 HTML 檔案可能無法正常加載外部 HTML 內容
58+
- 推薦使用本地服務器(如 Live Server、http-server 等)進行開發和測試
59+
- 相對路徑基於當前頁面的位置,使用時需注意檔案結構
60+
- 所有載入的內容將在頁面初始化過程中替換,不會產生額外的閃爍
61+
62+
## 應用場景
63+
64+
- 將重複使用的 UI 組件(如頁首、頁尾、導航欄)抽取為獨立檔案
65+
- 在多頁應用中共享相同的 HTML 片段
66+
- 實現簡單的模板複用,減少重複代碼
67+
- 將複雜的頁面結構分解為更小的、更易管理的檔案

static/md/zh/css.md

Lines changed: 73 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,77 @@
1-
## CSS 設置
1+
# QuickUI CSS 設置
2+
3+
> [!NOTE]
4+
> 透過 `:[CSS屬性]` 的方式直接將資料綁定到元素的樣式屬性上。無需手動操作 DOM 元素的 style 屬性。
5+
6+
## 語法
7+
8+
```html
9+
<元素 :[CSS屬性]="資料屬性"></元素>
10+
```
11+
12+
初始化或資料更新時會自動將指定的資料屬性值設定到元素的對應 CSS 樣式上。支援所有標準的 CSS 屬性名稱,並會自動處理 camelCase 與 kebab-case 之間的轉換。
13+
14+
## 範例
15+
16+
展示了如何使用 CSS 設置功能來動態綁定元素的寬度和背景顏色:
17+
18+
### index.html
19+
```html
20+
<body id="app">
21+
<button :width="width" :background-color="red">test</button>
22+
</body>
23+
<script>
24+
const app = new QUI({
25+
id: "app",
26+
data: {
27+
width: "100px"
28+
}
29+
});
30+
</script>
31+
```
32+
33+
### 渲染結果
34+
```html
35+
<body id="app">
36+
<button style="width: 100px; background-color: red;">test</button>
37+
</body>
38+
```
39+
40+
## 支持
41+
42+
支持所有標準的 CSS 屬性,包括但不限於:
43+
44+
- 尺寸:`:width``:height``:max-width``:min-height`
45+
- 顏色:`:color``:background-color``:border-color`
46+
- 定位:`:position``:top``:left``:z-index`
47+
- 邊框:`:border``:border-radius``:border-width`
48+
- 間距:`:margin``:padding``:gap`
49+
- 顯示:`:display``:opacity``:visibility`
50+
- 字體:`:font-size``:font-weight``:line-height`
51+
52+
## 實現
53+
54+
1. 識別所有以 `:` 開頭的非指令性屬性
55+
2. 判斷是否為 CSS 屬性(根據內部映射表)
56+
3. 獲取對應資料屬性的值
57+
4. 設定元素的 `style.屬性名` 為對應的值
58+
59+
## 動態更新
60+
61+
當資料模型中的值發生變化時,綁定的 CSS 樣式也會自動更新:
62+
63+
```javascript
64+
// 動態更新按鈕樣式
65+
// 按鈕樣式會自動更新為 width: 200px;
66+
app.data.width = "200px";
67+
```
68+
69+
## 注意事項
270

371
> [!NOTE]
472
> 支援 `:[CSS屬性]` 的簡易設定方式,直接將資料綁定到樣式屬性。
573
6-
- index.html
7-
```html
8-
<body id="app">
9-
<button :width="width" :backdround-color="color">test</button>
10-
</body>
11-
<script>
12-
const app = new QUI({
13-
id: "app",
14-
data: {
15-
width: "100px",
16-
color: "red"
17-
}
18-
});
19-
</script>
20-
```
21-
- Result:
22-
```html
23-
<body id="app">
24-
<button style="width: 100px; backdround-color: red;">test</button>
25-
</body>
26-
```
74+
- CSS 屬性名稱可以使用 kebab-case(如 `background-color`)或 camelCase(如 `backgroundColor`
75+
- 當值為 `null``undefined` 或空字串時,對應的樣式屬性會被移除
76+
- 數值型屬性會自動添加單位(如 `width: 100` 會被轉換為 `width: 100px`
77+
- 可以與 `:style` 指令共用,但直接指定的 CSS 屬性會優先於 `:style` 中的同名屬性

0 commit comments

Comments
 (0)