style: apply vsh lint formatting (#7923)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -272,30 +272,30 @@ function createCustomImage(
|
||||
...this.parent?.(),
|
||||
uploadImage:
|
||||
() =>
|
||||
({ editor: cmdEditor }: { editor: CoreEditor }) => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept = imageUpload.accept ?? DEFAULT_ACCEPT;
|
||||
input.style.display = 'none';
|
||||
({ editor: cmdEditor }: { editor: CoreEditor }) => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept = imageUpload.accept ?? DEFAULT_ACCEPT;
|
||||
input.style.display = 'none';
|
||||
|
||||
input.addEventListener('change', () => {
|
||||
const file = input.files?.[0];
|
||||
if (!file) return;
|
||||
input.addEventListener('change', () => {
|
||||
const file = input.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
const error = validateFile(file, imageUpload);
|
||||
if (error) {
|
||||
handleUploadError(new Error(error), imageUpload);
|
||||
return;
|
||||
}
|
||||
const error = validateFile(file, imageUpload);
|
||||
if (error) {
|
||||
handleUploadError(new Error(error), imageUpload);
|
||||
return;
|
||||
}
|
||||
|
||||
createUploadProcess(cmdEditor, file, imageUpload, blobUrlTracker);
|
||||
input.remove();
|
||||
});
|
||||
createUploadProcess(cmdEditor, file, imageUpload, blobUrlTracker);
|
||||
input.remove();
|
||||
});
|
||||
|
||||
document.body.append(input);
|
||||
input.click();
|
||||
return true;
|
||||
},
|
||||
document.body.append(input);
|
||||
input.click();
|
||||
return true;
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -428,20 +428,20 @@ export function createDefaultTiptapExtensions(
|
||||
}),
|
||||
options.imageUpload
|
||||
? createCustomImage(
|
||||
options.imageUpload,
|
||||
options._blobUrlTracker,
|
||||
).configure({
|
||||
allowBase64: true,
|
||||
HTMLAttributes: {
|
||||
class: 'vben-tiptap__image',
|
||||
},
|
||||
})
|
||||
options.imageUpload,
|
||||
options._blobUrlTracker,
|
||||
).configure({
|
||||
allowBase64: true,
|
||||
HTMLAttributes: {
|
||||
class: 'vben-tiptap__image',
|
||||
},
|
||||
})
|
||||
: Image.configure({
|
||||
allowBase64: true,
|
||||
HTMLAttributes: {
|
||||
class: 'vben-tiptap__image',
|
||||
},
|
||||
}),
|
||||
allowBase64: true,
|
||||
HTMLAttributes: {
|
||||
class: 'vben-tiptap__image',
|
||||
},
|
||||
}),
|
||||
Placeholder.configure({
|
||||
placeholder: options.placeholder ?? $t('ui.tiptap.placeholder'),
|
||||
}),
|
||||
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
} from '@vben-core/form-ui';
|
||||
|
||||
import type { VxeGridProps } from './types';
|
||||
import type {ViewedRowHelper} from './use-viewed-row';
|
||||
import type { ViewedRowHelper } from './use-viewed-row';
|
||||
|
||||
import { toRaw } from 'vue';
|
||||
|
||||
|
||||
@@ -75,29 +75,29 @@ interface ViewedRowPersistBase {
|
||||
*/
|
||||
export type ViewedRowPersistOptions =
|
||||
| ({
|
||||
/** IndexedDB 数据库名称,默认 'viewed-table-db' */
|
||||
dbName?: string;
|
||||
/** IndexedDB 数据库版本,默认 1 */
|
||||
dbVersion?: number;
|
||||
/** 存储 key / prefix(必传) */
|
||||
key: string;
|
||||
/** IndexedDB 对象存储名称,默认 'viewed-table-row' */
|
||||
storeName?: string;
|
||||
type: 'indexedDB';
|
||||
} & ViewedRowPersistBase)
|
||||
/** IndexedDB 数据库名称,默认 'viewed-table-db' */
|
||||
dbName?: string;
|
||||
/** IndexedDB 数据库版本,默认 1 */
|
||||
dbVersion?: number;
|
||||
/** 存储 key / prefix(必传) */
|
||||
key: string;
|
||||
/** IndexedDB 对象存储名称,默认 'viewed-table-row' */
|
||||
storeName?: string;
|
||||
type: 'indexedDB';
|
||||
} & ViewedRowPersistBase)
|
||||
| ({
|
||||
/** 存储 key(必传) */
|
||||
key: string;
|
||||
type: 'localStorage' | 'sessionStorage';
|
||||
} & ViewedRowPersistBase)
|
||||
/** 存储 key(必传) */
|
||||
key: string;
|
||||
type: 'localStorage' | 'sessionStorage';
|
||||
} & ViewedRowPersistBase)
|
||||
| ({
|
||||
/** 自定义存储适配器(必传) */
|
||||
storage: ViewedRowStorageAdapter;
|
||||
type: 'custom';
|
||||
} & ViewedRowPersistBase)
|
||||
/** 自定义存储适配器(必传) */
|
||||
storage: ViewedRowStorageAdapter;
|
||||
type: 'custom';
|
||||
} & ViewedRowPersistBase)
|
||||
| (ViewedRowPersistBase & {
|
||||
type: 'memory';
|
||||
});
|
||||
type: 'memory';
|
||||
});
|
||||
|
||||
/**
|
||||
* 已查看row设置
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type {VxeGridProps as VxeTableGridProps} from 'vxe-table';
|
||||
import type { VxeGridProps as VxeTableGridProps } from 'vxe-table';
|
||||
|
||||
import type {
|
||||
ViewedRowOptions,
|
||||
@@ -6,9 +6,9 @@ import type {
|
||||
ViewedRowStorageAdapter,
|
||||
} from './types';
|
||||
|
||||
import {isRef, shallowRef, toRaw, triggerRef, watch} from 'vue';
|
||||
import { isRef, shallowRef, toRaw, triggerRef, watch } from 'vue';
|
||||
|
||||
import {isBoolean, isFunction} from '@vben/utils';
|
||||
import { isBoolean, isFunction } from '@vben/utils';
|
||||
|
||||
import {
|
||||
IndexedDBDriver,
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
StorageManager,
|
||||
} from '@vben-core/shared/cache';
|
||||
|
||||
import {useDebounceFn} from '@vueuse/core';
|
||||
import { useDebounceFn } from '@vueuse/core';
|
||||
|
||||
const DEFAULT_VIEWED_CLASS = 'vxe-row--viewed';
|
||||
|
||||
@@ -32,7 +32,7 @@ function createWebStorageAdapter(
|
||||
ttl?: number,
|
||||
): ViewedRowStorageAdapter {
|
||||
const manager = new StorageManager({
|
||||
driver: new LocalStorageDriver({storageType}),
|
||||
driver: new LocalStorageDriver({ storageType }),
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -182,11 +182,13 @@ export function useViewedRow<T = any>(
|
||||
options: ViewedRowOptions<T> & { keyField: string },
|
||||
) {
|
||||
// ========== 解析持久化配置 ==========
|
||||
const persistOpts: null | ViewedRowPersistOptions = options.persist
|
||||
? (typeof options.persist === 'string'
|
||||
? {key: options.persist, type: 'localStorage'}
|
||||
: options.persist)
|
||||
: null;
|
||||
let persistOpts: null | ViewedRowPersistOptions = null;
|
||||
if (options.persist) {
|
||||
persistOpts =
|
||||
typeof options.persist === 'string'
|
||||
? { key: options.persist, type: 'localStorage' }
|
||||
: options.persist;
|
||||
}
|
||||
|
||||
const adapter = createStorageAdapter(options.persist);
|
||||
const maxSize = persistOpts?.maxSize ?? 100;
|
||||
@@ -341,7 +343,7 @@ export function useViewedRow<T = any>(
|
||||
function getRowClassName(params: any): string {
|
||||
if (!isViewed(params.row)) return '';
|
||||
|
||||
const {rowClassName} = options;
|
||||
const { rowClassName } = options;
|
||||
if (rowClassName === undefined || rowClassName === null) {
|
||||
return DEFAULT_VIEWED_CLASS;
|
||||
}
|
||||
@@ -358,7 +360,7 @@ export function useViewedRow<T = any>(
|
||||
function getRowStyle(params: any): any {
|
||||
if (!isViewed(params.row)) return undefined;
|
||||
|
||||
const {rowStyle} = options;
|
||||
const { rowStyle } = options;
|
||||
if (rowStyle === undefined || rowStyle === null) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -415,11 +417,11 @@ function wrapColumnsForViewedRow(
|
||||
return columns.map((column) => {
|
||||
if (!column || typeof column !== 'object') return column;
|
||||
|
||||
const nextColumn = {...column};
|
||||
const nextColumn = { ...column };
|
||||
|
||||
if (nextColumn.cellRender?.name === 'CellOperation') {
|
||||
const cellRender = {...nextColumn.cellRender};
|
||||
const attrs = {...cellRender.attrs};
|
||||
const cellRender = { ...nextColumn.cellRender };
|
||||
const attrs = { ...cellRender.attrs };
|
||||
const originalOnClick = attrs.onClick;
|
||||
|
||||
attrs.onClick = (params: { code: string; row: any }) => {
|
||||
@@ -515,16 +517,16 @@ export function applyViewedRowOptions(
|
||||
if (!viewedStyle && !originalStyle) return undefined;
|
||||
if (!originalStyle) return viewedStyle;
|
||||
if (!viewedStyle) return originalStyle;
|
||||
return {...originalStyle, ...viewedStyle};
|
||||
return { ...originalStyle, ...viewedStyle };
|
||||
};
|
||||
|
||||
// 拦截 CellOperation columns
|
||||
const actionCodes =
|
||||
!isBoolean(viewedRowConfig) && viewedRowConfig.actionCodes
|
||||
? (Array.isArray(viewedRowConfig.actionCodes)
|
||||
? viewedRowConfig.actionCodes
|
||||
: [viewedRowConfig.actionCodes])
|
||||
: [];
|
||||
let actionCodes: string[] = [];
|
||||
if (!isBoolean(viewedRowConfig) && viewedRowConfig.actionCodes) {
|
||||
actionCodes = Array.isArray(viewedRowConfig.actionCodes)
|
||||
? viewedRowConfig.actionCodes
|
||||
: [viewedRowConfig.actionCodes];
|
||||
}
|
||||
|
||||
if (actionCodes.length > 0 && Array.isArray(mergedOptions.columns)) {
|
||||
mergedOptions.columns = wrapColumnsForViewedRow(
|
||||
|
||||
@@ -44,7 +44,7 @@ import { VxeGrid, VxeUI } from 'vxe-table';
|
||||
|
||||
import { extendProxyOptions } from './extends';
|
||||
import { useTableForm } from './init';
|
||||
import {applyViewedRowOptions, useViewedRow} from './use-viewed-row';
|
||||
import { applyViewedRowOptions, useViewedRow } from './use-viewed-row';
|
||||
|
||||
import 'vxe-table/styles/cssvar.scss';
|
||||
import 'vxe-pc-ui/styles/cssvar.scss';
|
||||
@@ -93,10 +93,10 @@ watch(
|
||||
if (!cfg) return;
|
||||
|
||||
const keyField = (gridOptions.value?.rowConfig as any)?.keyField || 'id';
|
||||
const resolved = isBoolean(cfg) ? {keyField} : {keyField, ...cfg};
|
||||
const resolved = isBoolean(cfg) ? { keyField } : { keyField, ...cfg };
|
||||
gridApi.viewedRowHelper = useViewedRow(resolved);
|
||||
},
|
||||
{immediate: true},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const { isMobile } = usePreferences();
|
||||
|
||||
Reference in New Issue
Block a user