softleader-nuxt-core 1.0.9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -64
- package/assets/css/layout.css +56 -20
- package/bin/init.mjs +244 -155
- package/commitlint.config.cjs +1 -0
- package/components/templates/Welcome.vue +715 -0
- package/components/uiBusiness/BDataTable.vue +977 -888
- package/components/uiBusiness/CitySelect.vue +2 -2
- package/components/uiBusiness/PolicyForm.vue +9 -3
- package/components/uiInterface/IAvatar.vue +1 -1
- package/components/uiInterface/IBreadcrumbs.vue +1 -1
- package/components/uiInterface/IButton.vue +77 -20
- package/components/uiInterface/ICard.vue +9 -4
- package/components/uiInterface/ICheckbox.vue +12 -6
- package/components/uiInterface/IDataTable.vue +534 -515
- package/components/uiInterface/IRadio.vue +8 -2
- package/components/uiInterface/ISelect.vue +44 -19
- package/components/uiInterface/IStack.vue +9 -2
- package/components/uiInterface/ISwitch.vue +14 -3
- package/components/uiInterface/ITextField.vue +51 -24
- package/components/uiInterface/ITextarea.vue +54 -33
- package/composables/useApiRegistry.ts +1 -1
- package/composables/useErrorHandler.ts +12 -0
- package/composables/useFeatureFlag.ts +1 -1
- package/composables/useFileUpload.ts +2 -1
- package/composables/useFormatter.ts +2 -2
- package/composables/useModules.ts +18 -0
- package/composables/useOptions.ts +41 -22
- package/composables/useRepo.ts +49 -0
- package/configs/default.json +36 -9
- package/core/config/app.ts +10 -21
- package/core/config/components.ts +13 -25
- package/core/config/css.ts +4 -1
- package/core/config/eslint.config.mjs +180 -0
- package/core/config/git/commit-types.cjs +30 -0
- package/core/config/git/commitlint.config.cjs +17 -0
- package/core/config/git/cz-config.cjs +21 -0
- package/core/config/git/lint-staged.config.js +6 -0
- package/core/config/gitignore +30 -0
- package/core/config/i18n.ts +9 -7
- package/core/config/layout.ts +22 -16
- package/core/config/modules.ts +10 -6
- package/core/config/nitro.ts +13 -15
- package/core/config/prettier.json +14 -0
- package/core/config/runtime.ts +5 -29
- package/core/config/security/README.md +3 -1
- package/core/config/theme-tokens.ts +36 -270
- package/core/config/vite.ts +3 -4
- package/core/options/registry.ts +13 -2
- package/core/options/types.ts +1 -1
- package/core/repositories/index.ts +1 -1
- package/core/templates/gitignore +38 -0
- package/core/templates/husky/commit-msg +6 -0
- package/core/templates/husky/pre-commit +6 -0
- package/core/templates/vscode/extensions.json +8 -0
- package/core/templates/vscode/settings.json +69 -0
- package/core/templates/vscode/snippets.code-snippets +16 -0
- package/core/templates/vscode/vue3Template.code-snippets +165 -0
- package/cz.config.cjs +1 -0
- package/eslint.config.mjs +3 -0
- package/i18n/locales/en-US.json +1 -1
- package/i18n/locales/zh-TW.json +1 -1
- package/layouts/default.vue +118 -35
- package/lint-staged.config.js +1 -0
- package/modules/options-scanner.ts +113 -0
- package/modules/repositories-scanner.ts +95 -0
- package/nuxt.config.ts +66 -13
- package/package.json +32 -6
- package/plugins/README.md +2 -0
- package/plugins/api.ts +7 -4
- package/plugins/vuetify.ts +10 -10
- package/prettier.config.cjs +1 -0
- package/schemas/config.schema.json +128 -0
- package/scripts/product-loader.ts +95 -19
- package/scripts/release.mjs +24 -0
- package/scripts/sync-configs.mjs +53 -0
- package/stores/common.ts +3 -3
- package/tsconfig.json +16 -1
- package/types/repo.ts +13 -0
- package/components/uiInterface/layout/IBreadcrumbs.vue +0 -120
package/README.md
CHANGED
|
@@ -1,91 +1,120 @@
|
|
|
1
|
-
|
|
1
|
+
[回到全域首頁](../../README.md)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Nuxt Core 核心開發包 (`softleader-nuxt-core`)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
一個基於 Nuxt 3 的企業級 Layer 開發框架,提供可重用的基礎架構、元件與工具。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 基礎 Layout 與路由設定
|
|
9
|
-
- 全域樣式與設計 Tokens
|
|
10
|
-
- 共用 Composables 與 Utils
|
|
11
|
-
- 統一的開發工具配置(搭配 Nuxt 3 Eslint 等)
|
|
7
|
+
## 快速開始
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
### 1. 安裝相依套件
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
在你的 Nuxt 3 專案中執行:
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
```bash
|
|
14
|
+
npm install softleader-nuxt-core
|
|
15
|
+
```
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
npm install softleader-nuxt-core
|
|
21
|
-
```
|
|
17
|
+
### 2. 層級繼承 (Setup Layer)
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
在你的 `nuxt.config.ts` 中擴寫核心層:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
export default defineNuxtConfig({
|
|
23
|
+
extends: ['softleader-nuxt-core']
|
|
24
|
+
// ... 其他專案設定
|
|
25
|
+
})
|
|
26
|
+
```
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
export default defineNuxtConfig({
|
|
27
|
-
extends: ["softleader-nuxt-core"],
|
|
28
|
-
// ... 其他你的專案設定
|
|
29
|
-
});
|
|
30
|
-
```
|
|
28
|
+
### 3. 配置產品參數 (Configuration)
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
由於此專案依賴 `@nuxt/eslint-config`,建議你的專案也在根目錄設定對應的 Eslint 配置:
|
|
34
|
-
```bash
|
|
35
|
-
npm i -D @nuxt/eslint-config eslint
|
|
36
|
-
```
|
|
37
|
-
並在你的 `eslint.config.mjs` 中繼承 Nuxt 預設配置。
|
|
30
|
+
在專案根目錄建立 `configs/default.json`。核心層會自動讀取此檔案並應用於全域。詳細配置請參考 **[環境與產品配置指南](#)**。
|
|
38
31
|
|
|
39
32
|
---
|
|
40
33
|
|
|
41
|
-
##
|
|
34
|
+
## 開發指南 (Development Guide)
|
|
35
|
+
|
|
36
|
+
為了讓開發人員能順利建立與維護專案,請參考以下文件循序漸進地了解核心功能:
|
|
37
|
+
|
|
38
|
+
### 1. 核心架構與基礎 (Core Architecture & Basics)
|
|
39
|
+
|
|
40
|
+
了解層級設計理念、如何透過繼承快速啟動,以及配置系統。
|
|
41
|
+
|
|
42
|
+
- **[Nuxt Core 導論與介面理念 (README_TEAM.md)](./docs/README_TEAM.md)**
|
|
43
|
+
- **[核心配置系統 (nuxt.schema.ts)](./nuxt.schema.ts)**
|
|
44
|
+
- **[開發環境與 Playground 聯動 (README.md)](../../README.md)**
|
|
45
|
+
|
|
46
|
+
### 2. UI 與組件規範 (UI & Component Standards)
|
|
47
|
+
|
|
48
|
+
學習如何使用介面層組件,確保 UI 一致性與可替換性。
|
|
49
|
+
|
|
50
|
+
- **[UI Interface 封裝理念 (IButton.vue)](./components/uiInterface/IButton.vue)**
|
|
51
|
+
- **[設計系統與 Tokens (styles/)](./styles/)**
|
|
52
|
+
- **[透傳屬性 ($attrs) 與彈性設計 (IDataTable.vue)](./components/uiInterface/IDataTable.vue)**
|
|
53
|
+
|
|
54
|
+
### 3. 資料映射與業務邏輯 (Data Mapping & Logic)
|
|
55
|
+
|
|
56
|
+
掌握自動化的資料層掃描與全域選項系統。
|
|
42
57
|
|
|
43
|
-
|
|
58
|
+
- **[Smart Client 與 API 請求 (useApi.ts)](./composables/useApi.ts)**
|
|
59
|
+
- **[自動化儲存庫掃描 (repositories-scanner.ts)](./modules/repositories-scanner.ts)**
|
|
60
|
+
- **[全域與本地選項管理 (useOptions.ts)](./composables/useOptions.ts)**
|
|
44
61
|
|
|
45
|
-
|
|
46
|
-
你可以直接使用 `npx` 搭配套件名稱,並指定你的專案名稱(例如 `my-new-app`):
|
|
62
|
+
### 4. 架構進階應用 (Advanced Layer Usage)
|
|
47
63
|
|
|
48
|
-
|
|
49
|
-
npx softleader-nuxt-core init my-new-app
|
|
50
|
-
```
|
|
64
|
+
深入了解路由擴充、Mock Server 以及攔截器機制。
|
|
51
65
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
- **[動態路由掃描 (routes-scanner.ts)](./router/routes-scanner.ts)**
|
|
67
|
+
- **[API 請求與回應攔截器 (interceptors/)](./utils/api/interceptors/)**
|
|
68
|
+
- **[純前端 Mock 機制實作 (useApi.ts)](./composables/useApi.ts)**
|
|
69
|
+
|
|
70
|
+
### 5. 發布與維運 (Publish & Maintenance)
|
|
71
|
+
|
|
72
|
+
了解如何維護核心包、發布至套件庫以及版本管理。
|
|
73
|
+
|
|
74
|
+
- **[NPM 套件打包與發布流程 (package.json)](./package.json)**
|
|
75
|
+
- **[Git 工作流與 Commit 規範 (README.md)](../../README.md)**
|
|
76
|
+
- **[疑難排解與除錯指南 (error.ts)](./utils/api/error.ts)**
|
|
77
|
+
- **[CLI 工具設計原理 - 為何 `init` 不放在 scripts? (bin/init.mjs)](./bin/init.mjs)**
|
|
78
|
+
- **全域執行能力**:放到 `bin` 欄位,才能讓使用者在「沒有專案的空目錄」下,直接透過 `npx softleader-nuxt-core init` 從無到有建立專案。如果是 `scripts`,就必須先有專案且安裝了套件才能跑,這會有雞生蛋的問題。
|
|
79
|
+
- **系統整合**:`bin` 腳本(搭配 `#!/usr/bin/env node`)會被 npm 註冊為命令列工具,自動建立符號連結並賦予執行權限。
|
|
80
|
+
- **職責分離**:`scripts` 是給「當下這個專案」的開發者用的任務;而 `bin` 則是提供給「套件的使用者」在終端機呼叫的工具。
|
|
60
81
|
|
|
61
82
|
---
|
|
62
83
|
|
|
63
|
-
##
|
|
84
|
+
## 文件索引
|
|
64
85
|
|
|
65
|
-
|
|
86
|
+
### 1. 核心手冊 (必讀)
|
|
66
87
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
88
|
+
- **[團隊開發指南 (README_TEAM.md)](./docs/README_TEAM.md)**: 小組員如何快速上手與配置。
|
|
89
|
+
- **[核心配置系統 (nuxt.schema.ts)](./nuxt.schema.ts)**: 配置項架構定義。
|
|
90
|
+
- **[核心入口 (nuxt.config.ts)](./nuxt.config.ts)**: Layer 的主配置入口。
|
|
70
91
|
|
|
71
|
-
|
|
72
|
-
npm run lint
|
|
92
|
+
### 2. 結構參考
|
|
73
93
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
94
|
+
- **[產品配置腳本 (scripts/product-loader.ts)](./scripts/product-loader.ts)**: 處理 JSON 配置的載入核心。
|
|
95
|
+
- **[自動掃描器 (modules/)](./modules/)**: Repositories 與 Options 的掃描實作。
|
|
96
|
+
|
|
97
|
+
### 3. 元件與 Composable
|
|
98
|
+
|
|
99
|
+
- **[介面層組件範例 (IButton)](./components/uiInterface/IButton.vue)**: 標準化組件實作。
|
|
100
|
+
- **[核心 Composable (useApi)](./composables/useApi.ts)**: 統一的 API 連線封裝。
|
|
101
|
+
- **[選項管理 (useOptions)](./composables/useOptions.ts)**: 全域選項代理實作。
|
|
102
|
+
|
|
103
|
+
### 4. 設定檔優先級規則 (Configuration Precedence)
|
|
104
|
+
|
|
105
|
+
當你在不同的地方定義了相同的變數時(例如 API URL 或逾時設定),系統會依照以下**嚴格的優先順序**覆蓋:
|
|
106
|
+
|
|
107
|
+
1. **`.env` (最高)**:系統環境變數,通常由 CI/CD 或本地開發者手動設置。
|
|
108
|
+
2. **`nuxt.config.ts` (次之)**:專案層級的 `runtimeConfig`。
|
|
109
|
+
3. **`configs/default.json` (最底)**:全域的預設藍圖設置。
|
|
110
|
+
|
|
111
|
+
> **最佳實踐**:請將「固定的開發結構設定(如模組開關)」寫進 JSON,將「隨環境變動的機敏資訊(如連線字串、API 端點)」寫進 `.env`。
|
|
112
|
+
|
|
113
|
+
### 5. 資料串接
|
|
77
114
|
|
|
78
|
-
|
|
115
|
+
- **[API 錯誤處理](./utils/api/error.ts)**: 統一的報錯處理機制。
|
|
116
|
+
- **[認證攔截器](./utils/api/interceptors/request.ts)**: 處理 Header 注入邏輯。
|
|
79
117
|
|
|
80
|
-
|
|
118
|
+
### 5. 疑難排解
|
|
81
119
|
|
|
82
|
-
|
|
83
|
-
2. **登入 npm** (若尚未登入):
|
|
84
|
-
```bash
|
|
85
|
-
npm login
|
|
86
|
-
```
|
|
87
|
-
3. **發布套件**:
|
|
88
|
-
```bash
|
|
89
|
-
npm publish
|
|
90
|
-
```
|
|
91
|
-
_(若是發布到公司私有 registry,請確認 `.npmrc` 中有設定正確的 registry url)_
|
|
120
|
+
- **[Repository 型別修正範例 (repositories/user.ts)](../../apps/playground-app/repositories/user.ts)**: 解決 TS 推導問題的示範。
|
package/assets/css/layout.css
CHANGED
|
@@ -166,28 +166,64 @@ body {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
/* Margin Utilities */
|
|
169
|
-
.mt-sm {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
.mt-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
.
|
|
179
|
-
|
|
169
|
+
.mt-sm {
|
|
170
|
+
margin-top: var(--spacing-sm);
|
|
171
|
+
}
|
|
172
|
+
.mt-md {
|
|
173
|
+
margin-top: var(--spacing-md);
|
|
174
|
+
}
|
|
175
|
+
.mt-lg {
|
|
176
|
+
margin-top: var(--spacing-lg);
|
|
177
|
+
}
|
|
178
|
+
.mt-xl {
|
|
179
|
+
margin-top: var(--spacing-xl);
|
|
180
|
+
}
|
|
181
|
+
.mt-2xl {
|
|
182
|
+
margin-top: var(--spacing-2xl);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.mb-sm {
|
|
186
|
+
margin-bottom: var(--spacing-sm);
|
|
187
|
+
}
|
|
188
|
+
.mb-md {
|
|
189
|
+
margin-bottom: var(--spacing-md);
|
|
190
|
+
}
|
|
191
|
+
.mb-lg {
|
|
192
|
+
margin-bottom: var(--spacing-lg);
|
|
193
|
+
}
|
|
194
|
+
.mb-xl {
|
|
195
|
+
margin-bottom: var(--spacing-xl);
|
|
196
|
+
}
|
|
197
|
+
.mb-2xl {
|
|
198
|
+
margin-bottom: var(--spacing-2xl);
|
|
199
|
+
}
|
|
180
200
|
|
|
181
201
|
/* Padding Utilities */
|
|
182
|
-
.pt-sm {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
.pt-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
.
|
|
189
|
-
|
|
190
|
-
|
|
202
|
+
.pt-sm {
|
|
203
|
+
padding-top: var(--spacing-sm);
|
|
204
|
+
}
|
|
205
|
+
.pt-md {
|
|
206
|
+
padding-top: var(--spacing-md);
|
|
207
|
+
}
|
|
208
|
+
.pt-lg {
|
|
209
|
+
padding-top: var(--spacing-lg);
|
|
210
|
+
}
|
|
211
|
+
.pt-xl {
|
|
212
|
+
padding-top: var(--spacing-xl);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.pb-sm {
|
|
216
|
+
padding-bottom: var(--spacing-sm);
|
|
217
|
+
}
|
|
218
|
+
.pb-md {
|
|
219
|
+
padding-bottom: var(--spacing-md);
|
|
220
|
+
}
|
|
221
|
+
.pb-lg {
|
|
222
|
+
padding-bottom: var(--spacing-lg);
|
|
223
|
+
}
|
|
224
|
+
.pb-xl {
|
|
225
|
+
padding-bottom: var(--spacing-xl);
|
|
226
|
+
}
|
|
191
227
|
|
|
192
228
|
/* Responsive Utilities */
|
|
193
229
|
.hidden {
|