style: apply vsh lint formatting (#7923)
parent
84e77f64ea
commit
d71c81e8ff
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
"@vben/layouts": patch
|
||||
'@vben/layouts': patch
|
||||
---
|
||||
|
||||
fix: update primary color when toggling dark/light mode with custom theme
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
"@vben/common-ui": patch
|
||||
'@vben/common-ui': patch
|
||||
---
|
||||
|
||||
fix: skip fixed footer height in auto-content-height calculation
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
"@vben/icons": patch
|
||||
'@vben/icons': patch
|
||||
---
|
||||
|
||||
fix: guard svg icon loading during docs SSR
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
"@vben-core/shadcn-ui": patch
|
||||
'@vben-core/shadcn-ui': patch
|
||||
---
|
||||
|
||||
fix: preserve tree default value when treeData starts empty
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@ const content = ref('<p>开始编辑你的内容...</p>');
|
|||
<VbenTiptap v-model="content" />
|
||||
<div class="mt-4">
|
||||
<p class="text-sm text-gray-500">当前内容:</p>
|
||||
<pre
|
||||
class="mt-2 p-2 bg-gray-100 rounded text-xs overflow-auto max-h-40"
|
||||
>{{ content }}</pre
|
||||
>
|
||||
<pre class="mt-2 p-2 bg-gray-100 rounded text-xs overflow-auto max-h-40">
|
||||
{{ content }}
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# Cache 模块
|
||||
|
||||
基于**策略模式**的异步存储管理方案,支持多种存储后端(localStorage、IndexedDB、Memory),提供统一的 API
|
||||
接口。
|
||||
基于**策略模式**的异步存储管理方案,支持多种存储后端(localStorage、IndexedDB、Memory),提供统一的 API 接口。
|
||||
|
||||
## 架构设计
|
||||
|
||||
|
|
@ -23,7 +22,7 @@
|
|||
**分层职责:**
|
||||
|
||||
| 层级 | 职责 |
|
||||
|------------------|----------------------------|
|
||||
| ---------------- | -------------------------------------------- |
|
||||
| `StorageManager` | 命名空间前缀隔离、TTL 过期检查、统一对外 API |
|
||||
| `IStorageDriver` | 纯粹的 KV 存取抽象接口 |
|
||||
| 各 Driver 实现 | 对接具体存储引擎,不感知前缀和 TTL |
|
||||
|
|
@ -192,14 +191,14 @@ new StorageManager(options?: StorageManagerOptions)
|
|||
```
|
||||
|
||||
| 参数 | 类型 | 默认值 | 说明 |
|
||||
|----------|------------------|----------------------------|--------------|
|
||||
| --- | --- | --- | --- |
|
||||
| `driver` | `IStorageDriver` | `new LocalStorageDriver()` | 存储驱动实例 |
|
||||
| `prefix` | `string` | `''` | 键前缀,用于命名空间隔离 |
|
||||
|
||||
#### 方法
|
||||
|
||||
| 方法 | 签名 | 说明 |
|
||||
|---------------------|-------------------------------------------------------------------------|-------------------|
|
||||
| --- | --- | --- |
|
||||
| `getItem` | `getItem<T>(key: string, defaultValue?: T \| null): Promise<T \| null>` | 获取存储项,过期或不存在返回默认值 |
|
||||
| `setItem` | `setItem<T>(key: string, value: T, ttl?: number): Promise<void>` | 设置存储项,可选 TTL(毫秒) |
|
||||
| `removeItem` | `removeItem(key: string): Promise<void>` | 删除指定存储项 |
|
||||
|
|
@ -357,7 +356,7 @@ interface StorageItem<T> {
|
|||
采用**惰性删除 + 主动清理**双重策略:
|
||||
|
||||
| 策略 | 触发时机 | 说明 |
|
||||
|------|--------------------------|---------------------|
|
||||
| --- | --- | --- |
|
||||
| 惰性删除 | 调用 `getItem` 时 | 读取时检查过期,过期则删除并返回默认值 |
|
||||
| 主动清理 | 调用 `clearExpiredItems` 时 | 遍历所有带前缀的 key,删除已过期项 |
|
||||
|
||||
|
|
@ -366,7 +365,7 @@ interface StorageItem<T> {
|
|||
## 各 Driver 对比
|
||||
|
||||
| 特性 | LocalStorageDriver | IndexedDBDriver | MemoryStorageDriver |
|
||||
|-------|--------------------|-----------------|---------------------|
|
||||
| ---------- | ------------------- | ---------------- | ------------------- |
|
||||
| 持久化 | ✅ | ✅ | ❌ |
|
||||
| 容量 | 5-10 MB | 数百 MB+ | 受内存限制 |
|
||||
| 速度 | 快(同步) | 中等(异步 I/O) | 最快 |
|
||||
|
|
@ -406,8 +405,7 @@ class PreferenceManager {
|
|||
|
||||
## 注意事项
|
||||
|
||||
1. **所有方法都是异步的** — 即使底层是同步的 localStorage,API 也返回 Promise,确保切换 Driver
|
||||
时无需改动调用方。
|
||||
1. **所有方法都是异步的** — 即使底层是同步的 localStorage,API 也返回 Promise,确保切换 Driver 时无需改动调用方。
|
||||
|
||||
2. **TTL 单位是毫秒** — `setItem('key', value, 60000)` 表示 60 秒后过期。
|
||||
|
||||
|
|
@ -415,8 +413,6 @@ class PreferenceManager {
|
|||
|
||||
4. **前缀隔离是逻辑隔离** — `clear()` 只清除当前前缀下的数据,不影响其他前缀或无前缀的数据。
|
||||
|
||||
5. **错误处理** — LocalStorageDriver 在 JSON 解析失败时自动清除损坏数据;
|
||||
`PreferenceManager.saveToCache` 内部 try-catch 防止未捕获异常。
|
||||
5. **错误处理** — LocalStorageDriver 在 JSON 解析失败时自动清除损坏数据; `PreferenceManager.saveToCache` 内部 try-catch 防止未捕获异常。
|
||||
|
||||
6. **IndexedDB 版本升级** — 如果需要修改 objectStore 结构,需要递增 `dbVersion`。当前实现在
|
||||
`upgradeneeded` 事件中自动创建 objectStore。
|
||||
6. **IndexedDB 版本升级** — 如果需要修改 objectStore 结构,需要递增 `dbVersion`。当前实现在 `upgradeneeded` 事件中自动创建 objectStore。
|
||||
|
|
|
|||
|
|
@ -12,8 +12,11 @@ defineOptions({
|
|||
name: 'Page',
|
||||
});
|
||||
|
||||
const { autoContentHeight = false, heightOffset = 0, footerFixed = false } =
|
||||
defineProps<PageProps>();
|
||||
const {
|
||||
autoContentHeight = false,
|
||||
heightOffset = 0,
|
||||
footerFixed = false,
|
||||
} = defineProps<PageProps>();
|
||||
|
||||
const headerHeight = ref(0);
|
||||
const footerHeight = ref(0);
|
||||
|
|
@ -40,7 +43,7 @@ async function calcContentHeight() {
|
|||
await nextTick();
|
||||
headerHeight.value = headerRef.value?.offsetHeight || 0;
|
||||
|
||||
footerHeight.value = footerFixed ? 0 : (footerRef.value?.offsetHeight || 0);
|
||||
footerHeight.value = footerFixed ? 0 : footerRef.value?.offsetHeight || 0;
|
||||
|
||||
setTimeout(() => {
|
||||
shouldAutoHeight.value = true;
|
||||
|
|
|
|||
|
|
@ -182,11 +182,13 @@ export function useViewedRow<T = any>(
|
|||
options: ViewedRowOptions<T> & { keyField: string },
|
||||
) {
|
||||
// ========== 解析持久化配置 ==========
|
||||
const persistOpts: null | ViewedRowPersistOptions = options.persist
|
||||
? (typeof options.persist === 'string'
|
||||
let persistOpts: null | ViewedRowPersistOptions = null;
|
||||
if (options.persist) {
|
||||
persistOpts =
|
||||
typeof options.persist === 'string'
|
||||
? { key: options.persist, type: 'localStorage' }
|
||||
: options.persist)
|
||||
: null;
|
||||
: options.persist;
|
||||
}
|
||||
|
||||
const adapter = createStorageAdapter(options.persist);
|
||||
const maxSize = persistOpts?.maxSize ?? 100;
|
||||
|
|
@ -519,12 +521,12 @@ export function applyViewedRowOptions(
|
|||
};
|
||||
|
||||
// 拦截 CellOperation columns
|
||||
const actionCodes =
|
||||
!isBoolean(viewedRowConfig) && viewedRowConfig.actionCodes
|
||||
? (Array.isArray(viewedRowConfig.actionCodes)
|
||||
let actionCodes: string[] = [];
|
||||
if (!isBoolean(viewedRowConfig) && viewedRowConfig.actionCodes) {
|
||||
actionCodes = Array.isArray(viewedRowConfig.actionCodes)
|
||||
? viewedRowConfig.actionCodes
|
||||
: [viewedRowConfig.actionCodes])
|
||||
: [];
|
||||
: [viewedRowConfig.actionCodes];
|
||||
}
|
||||
|
||||
if (actionCodes.length > 0 && Array.isArray(mergedOptions.columns)) {
|
||||
mergedOptions.columns = wrapColumnsForViewedRow(
|
||||
|
|
|
|||
Loading…
Reference in New Issue