【新增】在翻译文件中添加多吉云AccessKey和SecretKey的相关翻译,更新阿里云ESA的配置接口,优化CA管理功能,增强表单验证逻辑,提升用户体验。

This commit is contained in:
chudong
2025-06-20 10:07:56 +08:00
parent cc5b8aada4
commit eb6172436c
107 changed files with 1008 additions and 406 deletions

View File

@@ -1,5 +1,6 @@
import useForm, { useFormHooks } from './useForm' // 表单
import useTable, { useTableOperation } from './useTable' // 表格
import useSearch from './useSearch' // 搜索
import useTabs from './useTabs' // 标签页
import useDialog from './useDialog' // 对话框
import useMessage from './useMessage' // 消息
@@ -21,6 +22,7 @@ import useFullScreen from './useFullScreen' // 全屏
export {
useForm,
useTable,
useSearch,
useTabs,
useDialog,
useMessage,

View File

@@ -0,0 +1,206 @@
import { ref, computed, watch, VNode, isRef } from 'vue'
import type { Ref } from 'vue'
import { NInput, NIcon } from 'naive-ui'
import { Search } from '@vicons/ionicons5'
import { useTimeoutFn, useDebounceFn } from '@vueuse/core'
/**
* 搜索回调函数类型
*/
export type SearchCallback = (value: string, isReset?: boolean) => void | Promise<void>
/**
* 搜索配置选项接口
*/
export interface UseSearchOptions {
/** 搜索回调函数 */
onSearch?: SearchCallback
/** 初始搜索值 */
value?: string | Ref<string>
/** 输入框占位符文本 */
placeholder?: string
/** 清空搜索时的延迟时间(毫秒) */
clearDelay?: number
/** 输入框尺寸 */
size?: 'small' | 'medium' | 'large'
/** 是否可清空 */
clearable?: boolean
/** 自定义输入框类名 */
className?: string
/** 是否禁用 */
disabled?: boolean
/** 是否自动去除首尾空格 */
trim?: boolean
/** 输入时是否实时搜索 */
immediate?: boolean
/** 实时搜索的防抖延迟(毫秒) */
debounceDelay?: number
}
/**
* useSearch 返回值接口
*/
export interface UseSearchReturn {
/** 搜索值的响应式引用 */
value: Ref<string>
/** 是否有搜索内容 */
hasSearchValue: Ref<boolean>
/** 处理键盘事件的函数 */
handleKeydown: (event: KeyboardEvent) => void
/** 处理清空事件的函数 */
handleClear: () => void
/** 处理搜索图标点击事件的函数 */
handleSearchClick: () => void
/** 手动触发搜索的函数 */
search: (isReset?: boolean) => void
/** 防抖搜索函数 */
debouncedSearch: () => void
/** 清空搜索内容的函数 */
clear: () => void
/** 设置搜索值的函数 */
setValue: (value: string) => void
/** 渲染搜索输入框组件的函数 */
SearchComponent: (customProps?: Record<string, any>) => VNode
}
/**
* 搜索功能的 hooks 函数
* @param options 搜索配置选项
* @returns 搜索相关的状态和方法
*/
export default function useSearch(options: UseSearchOptions = {}): UseSearchReturn {
const {
onSearch,
value = '',
placeholder = '请输入搜索内容',
clearDelay = 100,
size = 'large',
clearable = true,
className = 'min-w-[300px]',
disabled = false,
trim = true,
immediate = false,
debounceDelay = 300,
} = options
// 搜索值的响应式状态
const searchValue = isRef(value) ? value : ref<string>(value)
// 计算属性:是否有搜索内容
const hasSearchValue = computed(() => {
const value = trim ? searchValue.value.trim() : searchValue.value
return value.length > 0
})
/**
* 执行搜索操作
* @param isReset 是否为重置操作
*/
const search = (isReset: boolean = false): void => {
if (onSearch) {
const value = trim ? searchValue.value.trim() : searchValue.value
onSearch(value, isReset)
}
}
// 防抖搜索函数
const debouncedSearch = useDebounceFn(() => {
search()
}, debounceDelay)
// 实时搜索监听
if (immediate && onSearch) {
watch(searchValue, () => {
debouncedSearch()
})
}
/**
* 处理键盘按下事件
* @param event 键盘事件
*/
const handleKeydown = (event: KeyboardEvent): void => {
if (event.key === 'Enter') search()
}
/**
* 处理清空事件
*/
const handleClear = (): void => {
searchValue.value = ''
// 使用延迟执行清空后的搜索
useTimeoutFn(() => {
search(true)
}, clearDelay)
}
/**
* 处理搜索图标点击事件
*/
const handleSearchClick = (): void => {
search(true)
}
/**
* 清空搜索内容
*/
const clear = (): void => {
searchValue.value = ''
}
/**
* 设置搜索值
* @param value 要设置的值
*/
const setValue = (value: string): void => {
searchValue.value = value
}
/**
* 渲染搜索输入框组件
* @param customProps 自定义属性
* @returns 搜索输入框的 VNode
*/
const renderSearchInput = (customProps: Record<string, any> = {}): VNode => {
const mergedProps = {
value: searchValue.value,
'onUpdate:value': (value: string) => {
searchValue.value = value
},
onKeydown: handleKeydown,
onClear: handleClear,
placeholder,
clearable,
size,
disabled,
class: className,
...customProps,
}
return (
<NInput
{...mergedProps}
v-slots={{
suffix: () => (
<div class="flex items-center cursor-pointer" onClick={handleSearchClick}>
<NIcon component={Search} class="text-[var(--text-color-3)] w-[1.6rem] font-bold" />
</div>
),
}}
/>
)
}
return {
value: searchValue,
hasSearchValue,
handleKeydown,
handleClear,
handleSearchClick,
search,
debouncedSearch,
clear,
setValue,
SearchComponent: renderSearchInput,
}
}

View File

@@ -100,7 +100,7 @@ export default function useTable<T = Record<string, any>, Z extends Record<strin
if ((param.value as Record<string, unknown>)[page]) {
;(param.value as Record<string, unknown>)[page] = 1 // 当前页码
}
console.log(param.value, pageSize)
if ((param.value as Record<string, unknown>)[pageSize]) {
;(param.value as Record<string, unknown>)[pageSize] = getStoredPageSize(storage, 10, pageSizeOptionsRef.value) // 每页条数
console.log('初始化每页条数', (param.value as Record<string, unknown>)[pageSize])
@@ -130,7 +130,7 @@ export default function useTable<T = Record<string, any>, Z extends Record<strin
/**
* 获取表格数据
*/
const fetchData = async <T,>() => {
const fetchData = async <T,>(resetPage?: boolean) => {
try {
loading.value = true
const rdata: TableResponse<T> = await request(param.value)
@@ -139,6 +139,8 @@ export default function useTable<T = Record<string, any>, Z extends Record<strin
list: rdata[tableAlias.value.list as keyof TableResponse<T>] as [],
total: rdata[tableAlias.value.total as keyof TableResponse<T>] as number,
}
// 如果需要重置页码,则重置页码
if (resetPage) (param.value as Record<string, unknown>)[page] = 1
return data.value
} catch (error: any) {
errorMsg(error.message)
@@ -197,7 +199,10 @@ export default function useTable<T = Record<string, any>, Z extends Record<strin
onUpdatePage={handlePageChange}
onUpdatePageSize={handlePageSizeChange}
{...paginationProps}
v-slots={mergedSlots}
v-slots={{
...mergedSlots,
prefix: () => <span>{hookT('total', `${total.value}`)}</span>,
}}
/>
)
}
@@ -206,7 +211,7 @@ export default function useTable<T = Record<string, any>, Z extends Record<strin
if (Array.isArray(watchValue)) {
// 只监听指定的字段
const source = computed(() => watchValue.map((key) => param.value[key]))
watch(source, fetchData, { deep: true })
watch(source, (value) => fetchData(), { deep: true })
}
onUnmounted(() => {

View File

@@ -79,6 +79,7 @@ export const translation = {
},
useTable: {
operation: '操作',
total: (total: number) => formatString('共 {} 条', total),
},
}),
zhTW: createTranslation({
@@ -109,6 +110,7 @@ export const translation = {
},
useTable: {
operation: '操作',
total: (total: number) => formatString('共 {} 條', total),
},
}),
enUS: createTranslation({
@@ -139,6 +141,7 @@ export const translation = {
},
useTable: {
operation: 'Operation',
total: (total: number) => formatString('Total {} items', total),
},
}),
jaJP: createTranslation({
@@ -169,6 +172,7 @@ export const translation = {
},
useTable: {
operation: '操作',
total: (total: number) => formatString('合計 {} 件', total),
},
}),
ruRU: createTranslation({
@@ -199,6 +203,7 @@ export const translation = {
},
useTable: {
operation: 'Операция',
total: (total: number) => formatString('Всего {} элементов', total),
},
}),
koKR: createTranslation({
@@ -229,6 +234,7 @@ export const translation = {
},
useTable: {
operation: '작업',
total: (total: number) => formatString('총 {} 페이지', total),
},
}),
ptBR: createTranslation({
@@ -259,6 +265,7 @@ export const translation = {
},
useTable: {
operation: 'Operação',
total: (total: number) => formatString('Total {} páginas', total),
},
}),
frFR: createTranslation({
@@ -289,6 +296,7 @@ export const translation = {
},
useTable: {
operation: 'Opération',
total: (total: number) => formatString('Total {} pages', total),
},
}),
esAR: createTranslation({
@@ -319,6 +327,7 @@ export const translation = {
},
useTable: {
operation: 'Operación',
total: (total: number) => formatString('Total {} páginas', total),
},
}),
arDZ: createTranslation({
@@ -349,6 +358,7 @@ export const translation = {
},
useTable: {
operation: 'العملية',
total: (total: number) => formatString('إجمالي {} صفحات', total),
},
}),
}

View File

@@ -48,7 +48,7 @@ export interface TableInstanceWithComponent<T = Record<string, unknown>, Z = Rec
config: Ref<DataTableColumns<T>> // 表格列配置引
props: Ref<DataTableProps> // 表格属性引用
reset: () => Promise<void> // 重置方法
fetch: <T>() => Promise<T> // 触发方法
fetch: <T>(resetPage?: boolean) => Promise<T> // 触发方法
example: Ref<DataTableInst> // 表格实例引用
handlePageChange: (currentPage: number) => void // 分页改变
handlePageSizeChange: (size: number) => void // 分页大小改变