style: apply vsh lint formatting (#7923)

master^2
leo 2026-05-19 13:40:13 +08:00 committed by GitHub
parent 84e77f64ea
commit d71c81e8ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 193 additions and 193 deletions

View File

@ -1,5 +1,5 @@
--- ---
"@vben/layouts": patch '@vben/layouts': patch
--- ---
fix: update primary color when toggling dark/light mode with custom theme fix: update primary color when toggling dark/light mode with custom theme

View File

@ -1,5 +1,5 @@
--- ---
"@vben/common-ui": patch '@vben/common-ui': patch
--- ---
fix: skip fixed footer height in auto-content-height calculation fix: skip fixed footer height in auto-content-height calculation

View File

@ -1,5 +1,5 @@
--- ---
"@vben/icons": patch '@vben/icons': patch
--- ---
fix: guard svg icon loading during docs SSR fix: guard svg icon loading during docs SSR

View File

@ -1,5 +1,5 @@
--- ---
"@vben-core/shadcn-ui": patch '@vben-core/shadcn-ui': patch
--- ---
fix: preserve tree default value when treeData starts empty fix: preserve tree default value when treeData starts empty

View File

@ -11,10 +11,9 @@ const content = ref('<p>开始编辑你的内容...</p>');
<VbenTiptap v-model="content" /> <VbenTiptap v-model="content" />
<div class="mt-4"> <div class="mt-4">
<p class="text-sm text-gray-500">当前内容:</p> <p class="text-sm text-gray-500">当前内容:</p>
<pre <pre class="mt-2 p-2 bg-gray-100 rounded text-xs overflow-auto max-h-40">
class="mt-2 p-2 bg-gray-100 rounded text-xs overflow-auto max-h-40" {{ content }}
>{{ content }}</pre </pre>
>
</div> </div>
</div> </div>
</template> </template>

View File

@ -1,7 +1,6 @@
# Cache 模块 # Cache 模块
基于**策略模式**的异步存储管理方案支持多种存储后端localStorage、IndexedDB、Memory提供统一的 API 基于**策略模式**的异步存储管理方案支持多种存储后端localStorage、IndexedDB、Memory提供统一的 API 接口。
接口。
## 架构设计 ## 架构设计
@ -23,7 +22,7 @@
**分层职责:** **分层职责:**
| 层级 | 职责 | | 层级 | 职责 |
|------------------|----------------------------| | ---------------- | -------------------------------------------- |
| `StorageManager` | 命名空间前缀隔离、TTL 过期检查、统一对外 API | | `StorageManager` | 命名空间前缀隔离、TTL 过期检查、统一对外 API |
| `IStorageDriver` | 纯粹的 KV 存取抽象接口 | | `IStorageDriver` | 纯粹的 KV 存取抽象接口 |
| 各 Driver 实现 | 对接具体存储引擎,不感知前缀和 TTL | | 各 Driver 实现 | 对接具体存储引擎,不感知前缀和 TTL |
@ -192,14 +191,14 @@ new StorageManager(options?: StorageManagerOptions)
``` ```
| 参数 | 类型 | 默认值 | 说明 | | 参数 | 类型 | 默认值 | 说明 |
|----------|------------------|----------------------------|--------------| | --- | --- | --- | --- |
| `driver` | `IStorageDriver` | `new LocalStorageDriver()` | 存储驱动实例 | | `driver` | `IStorageDriver` | `new LocalStorageDriver()` | 存储驱动实例 |
| `prefix` | `string` | `''` | 键前缀,用于命名空间隔离 | | `prefix` | `string` | `''` | 键前缀,用于命名空间隔离 |
#### 方法 #### 方法
| 方法 | 签名 | 说明 | | 方法 | 签名 | 说明 |
|---------------------|-------------------------------------------------------------------------|-------------------| | --- | --- | --- |
| `getItem` | `getItem<T>(key: string, defaultValue?: T \| null): Promise<T \| null>` | 获取存储项,过期或不存在返回默认值 | | `getItem` | `getItem<T>(key: string, defaultValue?: T \| null): Promise<T \| null>` | 获取存储项,过期或不存在返回默认值 |
| `setItem` | `setItem<T>(key: string, value: T, ttl?: number): Promise<void>` | 设置存储项,可选 TTL毫秒 | | `setItem` | `setItem<T>(key: string, value: T, ttl?: number): Promise<void>` | 设置存储项,可选 TTL毫秒 |
| `removeItem` | `removeItem(key: string): Promise<void>` | 删除指定存储项 | | `removeItem` | `removeItem(key: string): Promise<void>` | 删除指定存储项 |
@ -357,7 +356,7 @@ interface StorageItem<T> {
采用**惰性删除 + 主动清理**双重策略: 采用**惰性删除 + 主动清理**双重策略:
| 策略 | 触发时机 | 说明 | | 策略 | 触发时机 | 说明 |
|------|--------------------------|---------------------| | --- | --- | --- |
| 惰性删除 | 调用 `getItem` 时 | 读取时检查过期,过期则删除并返回默认值 | | 惰性删除 | 调用 `getItem` 时 | 读取时检查过期,过期则删除并返回默认值 |
| 主动清理 | 调用 `clearExpiredItems` 时 | 遍历所有带前缀的 key删除已过期项 | | 主动清理 | 调用 `clearExpiredItems` 时 | 遍历所有带前缀的 key删除已过期项 |
@ -366,7 +365,7 @@ interface StorageItem<T> {
## 各 Driver 对比 ## 各 Driver 对比
| 特性 | LocalStorageDriver | IndexedDBDriver | MemoryStorageDriver | | 特性 | LocalStorageDriver | IndexedDBDriver | MemoryStorageDriver |
|-------|--------------------|-----------------|---------------------| | ---------- | ------------------- | ---------------- | ------------------- |
| 持久化 | ✅ | ✅ | ❌ | | 持久化 | ✅ | ✅ | ❌ |
| 容量 | 5-10 MB | 数百 MB+ | 受内存限制 | | 容量 | 5-10 MB | 数百 MB+ | 受内存限制 |
| 速度 | 快(同步) | 中等(异步 I/O | 最快 | | 速度 | 快(同步) | 中等(异步 I/O | 最快 |
@ -406,8 +405,7 @@ class PreferenceManager {
## 注意事项 ## 注意事项
1. **所有方法都是异步的** — 即使底层是同步的 localStorageAPI 也返回 Promise确保切换 Driver 1. **所有方法都是异步的** — 即使底层是同步的 localStorageAPI 也返回 Promise确保切换 Driver 时无需改动调用方。
时无需改动调用方。
2. **TTL 单位是毫秒**`setItem('key', value, 60000)` 表示 60 秒后过期。 2. **TTL 单位是毫秒**`setItem('key', value, 60000)` 表示 60 秒后过期。
@ -415,8 +413,6 @@ class PreferenceManager {
4. **前缀隔离是逻辑隔离** — `clear()` 只清除当前前缀下的数据,不影响其他前缀或无前缀的数据。 4. **前缀隔离是逻辑隔离** — `clear()` 只清除当前前缀下的数据,不影响其他前缀或无前缀的数据。
5. **错误处理** — LocalStorageDriver 在 JSON 解析失败时自动清除损坏数据; 5. **错误处理** — LocalStorageDriver 在 JSON 解析失败时自动清除损坏数据; `PreferenceManager.saveToCache` 内部 try-catch 防止未捕获异常。
`PreferenceManager.saveToCache` 内部 try-catch 防止未捕获异常。
6. **IndexedDB 版本升级** — 如果需要修改 objectStore 结构,需要递增 `dbVersion`。当前实现在 6. **IndexedDB 版本升级** — 如果需要修改 objectStore 结构,需要递增 `dbVersion`。当前实现在 `upgradeneeded` 事件中自动创建 objectStore。
`upgradeneeded` 事件中自动创建 objectStore。

View File

@ -12,8 +12,11 @@ defineOptions({
name: 'Page', name: 'Page',
}); });
const { autoContentHeight = false, heightOffset = 0, footerFixed = false } = const {
defineProps<PageProps>(); autoContentHeight = false,
heightOffset = 0,
footerFixed = false,
} = defineProps<PageProps>();
const headerHeight = ref(0); const headerHeight = ref(0);
const footerHeight = ref(0); const footerHeight = ref(0);
@ -40,7 +43,7 @@ async function calcContentHeight() {
await nextTick(); await nextTick();
headerHeight.value = headerRef.value?.offsetHeight || 0; headerHeight.value = headerRef.value?.offsetHeight || 0;
footerHeight.value = footerFixed ? 0 : (footerRef.value?.offsetHeight || 0); footerHeight.value = footerFixed ? 0 : footerRef.value?.offsetHeight || 0;
setTimeout(() => { setTimeout(() => {
shouldAutoHeight.value = true; shouldAutoHeight.value = true;

View File

@ -182,11 +182,13 @@ export function useViewedRow<T = any>(
options: ViewedRowOptions<T> & { keyField: string }, options: ViewedRowOptions<T> & { keyField: string },
) { ) {
// ========== 解析持久化配置 ========== // ========== 解析持久化配置 ==========
const persistOpts: null | ViewedRowPersistOptions = options.persist let persistOpts: null | ViewedRowPersistOptions = null;
? (typeof options.persist === 'string' if (options.persist) {
persistOpts =
typeof options.persist === 'string'
? { key: options.persist, type: 'localStorage' } ? { key: options.persist, type: 'localStorage' }
: options.persist) : options.persist;
: null; }
const adapter = createStorageAdapter(options.persist); const adapter = createStorageAdapter(options.persist);
const maxSize = persistOpts?.maxSize ?? 100; const maxSize = persistOpts?.maxSize ?? 100;
@ -519,12 +521,12 @@ export function applyViewedRowOptions(
}; };
// 拦截 CellOperation columns // 拦截 CellOperation columns
const actionCodes = let actionCodes: string[] = [];
!isBoolean(viewedRowConfig) && viewedRowConfig.actionCodes if (!isBoolean(viewedRowConfig) && viewedRowConfig.actionCodes) {
? (Array.isArray(viewedRowConfig.actionCodes) actionCodes = Array.isArray(viewedRowConfig.actionCodes)
? viewedRowConfig.actionCodes ? viewedRowConfig.actionCodes
: [viewedRowConfig.actionCodes]) : [viewedRowConfig.actionCodes];
: []; }
if (actionCodes.length > 0 && Array.isArray(mergedOptions.columns)) { if (actionCodes.length > 0 && Array.isArray(mergedOptions.columns)) {
mergedOptions.columns = wrapColumnsForViewedRow( mergedOptions.columns = wrapColumnsForViewedRow(