chore: 初始化 trans-form 项目脚手架
Node.js Build / build (push) Has been skipped

- 基于 grill-me Q1-Q61 决策
- Vitest 测试与 CI workflow
- middleware: parseFilters 核心实现
- component: Vue3 TransForm 基础组件 + Storybook

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-07 00:47:58 +00:00
commit fc1d8df60f
21 changed files with 5420 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
import { describe, expect, it } from 'vitest';
import {
applyFilters,
buildFilters,
createFieldState,
groupRows,
} from '../src/composables/useFilters.js';
const schema = [
{
row: 6,
field: 'name',
'field-name': '名称',
'query-option': [{ value: 'EQ', label: '=' }],
},
{
row: 6,
logic: 'OR',
field: 'status',
'query-option': [{ value: 'NE', label: '≠' }],
},
];
describe('createFieldState', () => {
it('initializes default query from first option', () => {
const state = createFieldState(schema);
expect(state.name.query).toBe('EQ');
expect(state.status.logic).toBe('OR');
});
});
describe('buildFilters', () => {
it('emits logic from second item onward', () => {
const state = createFieldState(schema);
state.name.value = 'alice';
state.status.value = 'active';
const filters = buildFilters(schema, state);
expect(filters[0].logic).toBeUndefined();
expect(filters[1].logic).toBe('OR');
});
it('marks empty values', () => {
const state = createFieldState(schema);
const filters = buildFilters(schema, state);
expect(filters[0].empty).toBe(true);
expect(filters[0].value).toBeNull();
});
});
describe('applyFilters', () => {
it('loads filters back into state', () => {
const loaded = applyFilters(schema, [
{ field: 'name', value: 'bob', query: 'EQ' },
]);
expect(loaded.name.value).toBe('bob');
});
});
describe('groupRows', () => {
it('wraps when row spans exceed 12', () => {
const groups = groupRows([
{ row: 2, field: 'a' },
{ row: 9, field: 'b' },
{ row: 4, field: 'c' },
]);
expect(groups).toHaveLength(2);
expect(groups[0]).toHaveLength(2);
expect(groups[1]).toHaveLength(1);
});
});