Bläddra i källkod

update: hook增加注释

xyh 2 år sedan
förälder
incheckning
5fb8af25d3

+ 1 - 0
src/hooks/use-fetch-table-list/index.ts

@@ -33,6 +33,7 @@ type UseQueryListOptions<
   formatResult?: (data: Awaited<R>) => T;
 };
 
+/** table内容请求hook */
 export function useFetchTableList<
   P extends ListParams,
   R extends BaseListResult,

+ 1 - 0
src/hooks/use-put-data/index.ts

@@ -11,6 +11,7 @@ type UsePutDataOptions<A, E> = {
   onClose: () => void;
 };
 
+/** 新增和修改通用hook */
 function useQuery<P>(options: {
   fn: (params: P) => BaseResult;
   isAdd: boolean;

+ 2 - 1
src/hooks/use-query-data-info/index.tsx

@@ -10,7 +10,7 @@ type UseQueryDataInfoOptions<R, P extends unknown[]> = {
   label?: string;
 };
 
-// 获取详情不加signal 不然可能导致取消后重新进入报错
+/** 获取详情数据,一般用于Modal的修改获取数据 */
 export function useQueryDataInfo<R, P extends unknown[]>({
   queryFn,
   params,
@@ -20,6 +20,7 @@ export function useQueryDataInfo<R, P extends unknown[]>({
  [Ref<R | undefined>, () => Promise<QueryObserverResult<R, unknown>>] {
   const {data, suspense} = useQuery(
     [queryFn.name, ...params.value, ...extraKeys.value],
+    // 获取详情不加signal 不然可能导致取消后重新进入报错
     async function() {
       const data = await queryFn(...params.value);
 

+ 8 - 0
src/hooks/use-table-event/index.ts

@@ -5,6 +5,11 @@ import {useMessage, useDialog} from 'naive-ui';
 import {type Ref, ref} from 'vue';
 import {useI18n} from 'vue-i18n';
 
+/**
+ * table中的modal事件hook
+ *
+ * 修改 新增
+ */
 export function useTableModalEvent<T = string>(initValue?: T, init?: boolean) {
   const initData = (initValue ?? '') as T;
   const visible = ref<boolean>(init ?? false);
@@ -32,6 +37,9 @@ export function useTableModalEvent<T = string>(initValue?: T, init?: boolean) {
   ] as const;
 }
 
+/**
+ * table中的modal删除事件hook
+ */
 export function useTableDeleteEvent<P>(
   fn: (params: P) => BaseResult,
   onFetch: () => void,

+ 1 - 0
src/hooks/use-table-export-event/index.ts

@@ -19,6 +19,7 @@ function exportFile(blob: Blob, name: string) {
   URL.revokeObjectURL(url);
 }
 
+/** tableTool中导出事件hook */
 export function useTableExportEvent<P extends ListParams>(
   filterKey: symbol,
   pageKey: symbol,

+ 1 - 0
src/hooks/use-table-filter-context/index.ts

@@ -1,5 +1,6 @@
 import {provide, reactive} from 'vue';
 
+/** 注入过滤数据hook */
 export function useTableFilterContext(
   key: symbol,
   data: Record<string, unknown>,

+ 1 - 1
src/hooks/use-table-page-context/index.ts

@@ -6,7 +6,7 @@ export type TablePageContext = {
   limit: number,
 };
 
-/** 页面内table页面和数量管理 */
+/** 页面内table页面和数量管理hook */
 export function useTablePageContext(key: symbol, limit?: number) {
   const data = reactive({page: 1, limit: limit ?? TABLE_PAGE_SIZES[0]});
 

+ 1 - 1
src/hooks/use-table-search-context/index.ts

@@ -5,7 +5,7 @@ export type TableSearchContext = {
   refetch: () => void,
 };
 
-/** 表格搜索状态内容 */
+/** 注入表格搜索状态内容hook */
 export function useTableSearchContext(key: symbol) {
   const data = reactive({isSearching: false, refetch: () => void 0});
 

+ 1 - 0
src/hooks/use-table-search-tool-context/index.ts

@@ -1,5 +1,6 @@
 import {inject, provide, reactive, ref} from 'vue';
 
+/** 搜索框事件hook */
 export function useTableSearchToolContext<T extends Record<string, unknown>>(
   initialValues: T,
   key: symbol,

+ 1 - 0
src/hooks/use-table-title/index.ts

@@ -4,6 +4,7 @@ import {toRefs, computed} from 'vue';
 import {useI18n} from 'vue-i18n';
 import {useRoute} from 'vue-router';
 
+/** 获取表格对应的标题hook */
 export function useTableTitle() {
   const {locale} = useI18n();
   const route = useRoute();