liuyun ff0e1dcd27 feat(layout): 多页签 keep-alive(默认缓存,meta.keepAlive:false 可关)
- 11 个菜单页面补 defineOptions name(缓存标识)
- tabs store 加 keepAlive 字段 + pathToName 辅助
- layout 用 keep-alive 包裹 router-view,按打开且未关闭缓存的页签缓存

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-11 22:13:18 +08:00

63 lines
1.9 KiB
Vue

<template>
<ty-crud
entity-name="配置"
:columns="columns"
:search-schema="searchSchema"
:form-schema="formSchema"
:list="list"
:create="create"
:update="update"
:remove="remove"
id-key="id"
name-key="key"
:edit-readonly-keys="['key']"
/>
</template>
<script setup lang="ts">
defineOptions({ name: 'config' })
import type { JsonSchema, PageQuery, TableColumn } from '@/types/crud'
import { createConfig, deleteConfig, listConfigs, updateConfig, type ConfigListQuery } from '@/api/config'
const columns: TableColumn[] = [
{ prop: 'key', label: '键名', minWidth: 160 },
{ prop: 'value', label: '值', minWidth: 220 },
{ prop: 'remark', label: '备注', minWidth: 160 },
{ prop: 'createdAt', label: '创建时间', width: 160, type: 'datetime' },
]
const searchSchema: JsonSchema = {
type: 'object',
properties: {
key: { type: 'string', title: '键名', placeholder: '请输入键名' },
value: { type: 'string', title: '值', placeholder: '请输入值' },
},
}
const formSchema: JsonSchema = {
type: 'object',
properties: {
key: { type: 'string', title: '键名', placeholder: '请输入键名', minLength: 1 },
value: { type: 'string', title: '值', format: 'textarea', placeholder: '请输入值' },
remark: { type: 'string', title: '备注', placeholder: '请输入备注' },
},
required: ['key'],
}
function toListQuery(query: PageQuery): ConfigListQuery {
const str = (v: unknown): string | undefined => (typeof v === 'string' && v !== '' ? v : undefined)
return {
page: query.page,
pageSize: query.pageSize,
key: str(query.key),
value: str(query.value),
}
}
const list = (query: PageQuery, signal?: AbortSignal) => listConfigs(toListQuery(query), signal)
const create = (data: Record<string, any>) => createConfig(data)
const update = (id: string, data: Record<string, any>) => updateConfig(id, data)
const remove = (id: string) => deleteConfig(id)
</script>