diff --git a/packages/axios/src/index.ts b/packages/axios/src/index.ts index cfbde18e..08af572d 100644 --- a/packages/axios/src/index.ts +++ b/packages/axios/src/index.ts @@ -14,11 +14,12 @@ import type { ResponseType } from './type'; -function createCommonRequest( - axiosConfig?: CreateAxiosDefaults, - options?: Partial> -) { - const opts = createDefaultOptions(options); +function createCommonRequest< + ResponseData, + ApiData = ResponseData, + State extends Record = Record +>(axiosConfig?: CreateAxiosDefaults, options?: Partial>) { + const opts = createDefaultOptions(options); const axiosConf = createAxiosConfig(axiosConfig); const instance = axios.create(axiosConf); @@ -83,14 +84,6 @@ function createCommonRequest( } ); - function cancelRequest(requestId: string) { - const abortController = abortControllerMap.get(requestId); - if (abortController) { - abortController.abort(); - abortControllerMap.delete(requestId); - } - } - function cancelAllRequest() { abortControllerMap.forEach(abortController => { abortController.abort(); @@ -101,7 +94,6 @@ function createCommonRequest( return { instance, opts, - cancelRequest, cancelAllRequest }; } @@ -112,27 +104,27 @@ function createCommonRequest( * @param axiosConfig axios config * @param options request options */ -export function createRequest>( +export function createRequest>( axiosConfig?: CreateAxiosDefaults, - options?: Partial> + options?: Partial> ) { - const { instance, opts, cancelRequest, cancelAllRequest } = createCommonRequest(axiosConfig, options); + const { instance, opts, cancelAllRequest } = createCommonRequest(axiosConfig, options); - const request: RequestInstance = async function request( - config: CustomAxiosRequestConfig - ) { + const request: RequestInstance = async function request< + T extends ApiData = ApiData, + R extends ResponseType = 'json' + >(config: CustomAxiosRequestConfig) { const response: AxiosResponse = await instance(config); const responseType = response.config?.responseType || 'json'; if (responseType === 'json') { - return opts.transformBackendResponse(response); + return opts.transform(response); } return response.data as MappedType; - } as RequestInstance; + } as RequestInstance; - request.cancelRequest = cancelRequest; request.cancelAllRequest = cancelAllRequest; request.state = {} as State; @@ -147,14 +139,14 @@ export function createRequest>( +export function createFlatRequest>( axiosConfig?: CreateAxiosDefaults, - options?: Partial> + options?: Partial> ) { - const { instance, opts, cancelRequest, cancelAllRequest } = createCommonRequest(axiosConfig, options); + const { instance, opts, cancelAllRequest } = createCommonRequest(axiosConfig, options); - const flatRequest: FlatRequestInstance = async function flatRequest< - T = any, + const flatRequest: FlatRequestInstance = async function flatRequest< + T extends ApiData = ApiData, R extends ResponseType = 'json' >(config: CustomAxiosRequestConfig) { try { @@ -163,20 +155,21 @@ export function createFlatRequest, error: null }; + return { data: response.data as MappedType, error: null, response }; } catch (error) { return { data: null, error, response: (error as AxiosError).response }; } - } as FlatRequestInstance; + } as FlatRequestInstance; - flatRequest.cancelRequest = cancelRequest; flatRequest.cancelAllRequest = cancelAllRequest; - flatRequest.state = {} as State; + flatRequest.state = { + ...opts.defaultState + } as State; return flatRequest; } diff --git a/packages/axios/src/options.ts b/packages/axios/src/options.ts index 8b2b116a..e7866397 100644 --- a/packages/axios/src/options.ts +++ b/packages/axios/src/options.ts @@ -4,15 +4,27 @@ import { stringify } from 'qs'; import { isHttpSuccess } from './shared'; import type { RequestOption } from './type'; -export function createDefaultOptions(options?: Partial>) { - const opts: RequestOption = { +export function createDefaultOptions< + ResponseData, + ApiData = ResponseData, + State extends Record = Record +>(options?: Partial>) { + const opts: RequestOption = { + defaultState: {} as State, + transform: async response => response.data as unknown as ApiData, + transformBackendResponse: async response => response.data as unknown as ApiData, onRequest: async config => config, isBackendSuccess: _response => true, onBackendFail: async () => {}, - transformBackendResponse: async response => response.data, onError: async () => {} }; + if (options?.transform) { + opts.transform = options.transform; + } else { + opts.transform = options?.transformBackendResponse || opts.transform; + } + Object.assign(opts, options); return opts; diff --git a/packages/axios/src/type.ts b/packages/axios/src/type.ts index 644847ff..846950c4 100644 --- a/packages/axios/src/type.ts +++ b/packages/axios/src/type.ts @@ -8,7 +8,30 @@ export type ContentType = | 'application/x-www-form-urlencoded' | 'application/octet-stream'; -export interface RequestOption { +export type ResponseTransform = (input: Input) => Output | Promise; + +export interface RequestOption< + ResponseData, + ApiData = ResponseData, + State extends Record = Record +> { + /** + * The default state + */ + defaultState?: State; + /** + * transform the response data to the api data + * + * @param response Axios response + */ + transform: ResponseTransform, ApiData>; + /** + * transform the response data to the api data + * + * @deprecated use `transform` instead, will be removed in the next major version v3 + * @param response Axios response + */ + transformBackendResponse: ResponseTransform, ApiData>; /** * The hook before request * @@ -35,12 +58,6 @@ export interface RequestOption { response: AxiosResponse, instance: AxiosInstance ) => Promise | Promise; - /** - * transform backend response when the responseType is json - * - * @param response Axios response - */ - transformBackendResponse(response: AxiosResponse): any | Promise; /** * The hook to handle error * @@ -68,15 +85,7 @@ export type CustomAxiosRequestConfig = Omit { - /** - * cancel the request by request id - * - * if the request provide abort controller sign from config, it will not collect in the abort controller map - * - * @param requestId - */ - cancelRequest: (requestId: string) => void; +export interface RequestInstanceCommon> { /** * cancel all request * @@ -84,32 +93,35 @@ export interface RequestInstanceCommon { */ cancelAllRequest: () => void; /** you can set custom state in the request instance */ - state: T; + state: State; } /** The request instance */ -export interface RequestInstance> extends RequestInstanceCommon { - (config: CustomAxiosRequestConfig): Promise>; +export interface RequestInstance> extends RequestInstanceCommon { + ( + config: CustomAxiosRequestConfig + ): Promise>; } -export type FlatResponseSuccessData = { - data: T; +export type FlatResponseSuccessData = { + data: ApiData; error: null; response: AxiosResponse; }; -export type FlatResponseFailData = { +export type FlatResponseFailData = { data: null; error: AxiosError; response: AxiosResponse; }; -export type FlatResponseData = - | FlatResponseSuccessData +export type FlatResponseData = + | FlatResponseSuccessData | FlatResponseFailData; -export interface FlatRequestInstance, ResponseData = any> extends RequestInstanceCommon { - ( +export interface FlatRequestInstance> + extends RequestInstanceCommon { + ( config: CustomAxiosRequestConfig - ): Promise, ResponseData>>; + ): Promise>>; } diff --git a/packages/hooks/src/index.ts b/packages/hooks/src/index.ts index a6a330bd..3a73bbc7 100644 --- a/packages/hooks/src/index.ts +++ b/packages/hooks/src/index.ts @@ -3,9 +3,7 @@ import useLoading from './use-loading'; import useCountDown from './use-count-down'; import useContext from './use-context'; import useSvgIconRender from './use-svg-icon-render'; -import useHookTable from './use-table'; +import useTable from './use-table'; -export { useBoolean, useLoading, useCountDown, useContext, useSvgIconRender, useHookTable }; - -export * from './use-signal'; -export * from './use-table'; +export { useBoolean, useLoading, useCountDown, useContext, useSvgIconRender, useTable }; +export type * from './use-table'; diff --git a/packages/hooks/src/use-context.ts b/packages/hooks/src/use-context.ts index 001d8aa6..cea9164f 100644 --- a/packages/hooks/src/use-context.ts +++ b/packages/hooks/src/use-context.ts @@ -1,5 +1,4 @@ import { inject, provide } from 'vue'; -import type { InjectionKey } from 'vue'; /** * Use context @@ -12,7 +11,7 @@ import type { InjectionKey } from 'vue'; * import { ref } from 'vue'; * import { useContext } from '@sa/hooks'; * - * export const { setupStore, useStore } = useContext('demo', () => { + * export const [provideDemoContext, useDemoContext] = useContext('demo', () => { * const count = ref(0); * * function increment() { @@ -35,10 +34,10 @@ import type { InjectionKey } from 'vue'; *
A
* * * ``` // B.vue * ```vue @@ -46,9 +45,9 @@ import type { InjectionKey } from 'vue'; *
B
* * * ```; * @@ -57,40 +56,41 @@ import type { InjectionKey } from 'vue'; * @param contextName Context name * @param fn Context function */ -export default function useContext any>(contextName: string, fn: T) { - type Context = ReturnType; +export default function useContext, T>( + contextName: string, + composable: (...args: Arguments) => T +) { + const key = Symbol(contextName); - const { useProvide, useInject: useStore } = createContext(contextName); + /** + * Injects the context value. + * + * @param consumerName - The name of the component that is consuming the context. If provided, the component must be + * used within the context provider. + * @param defaultValue - The default value to return if the context is not provided. + * @returns The context value. + */ + const useInject = ( + consumerName?: N, + defaultValue?: T + ): N extends null | undefined ? T | null : T => { + const value = inject(key, defaultValue); - function setupStore(...args: Parameters) { - const context: Context = fn(...args); - return useProvide(context); - } + if (consumerName && !value) { + throw new Error(`\`${consumerName}\` must be used within \`${contextName}\``); + } - return { - /** Setup store in the parent component */ - setupStore, - /** Use store in the child component */ - useStore + // @ts-expect-error - we want to return null if the value is undefined or null + return value || null; }; -} -/** Create context */ -function createContext(contextName: string) { - const injectKey: InjectionKey = Symbol(contextName); + const useProvide = (...args: Arguments) => { + const value = composable(...args); - function useProvide(context: T) { - provide(injectKey, context); + provide(key, value); - return context; - } - - function useInject() { - return inject(injectKey) as T; - } - - return { - useProvide, - useInject + return value; }; + + return [useProvide, useInject] as const; } diff --git a/packages/hooks/src/use-request.ts b/packages/hooks/src/use-request.ts index a0a40e63..219ac07f 100644 --- a/packages/hooks/src/use-request.ts +++ b/packages/hooks/src/use-request.ts @@ -6,31 +6,31 @@ import type { CreateAxiosDefaults, CustomAxiosRequestConfig, MappedType, + RequestInstanceCommon, RequestOption, ResponseType } from '@sa/axios'; import useLoading from './use-loading'; -export type HookRequestInstanceResponseSuccessData = { - data: Ref; +export type HookRequestInstanceResponseSuccessData = { + data: Ref; error: Ref; }; -export type HookRequestInstanceResponseFailData = { +export type HookRequestInstanceResponseFailData = { data: Ref; error: Ref>; }; -export type HookRequestInstanceResponseData = { +export type HookRequestInstanceResponseData = { loading: Ref; -} & (HookRequestInstanceResponseSuccessData | HookRequestInstanceResponseFailData); +} & (HookRequestInstanceResponseSuccessData | HookRequestInstanceResponseFailData); -export interface HookRequestInstance { - ( +export interface HookRequestInstance> + extends RequestInstanceCommon { + ( config: CustomAxiosRequestConfig - ): HookRequestInstanceResponseData, ResponseData>; - cancelRequest: (requestId: string) => void; - cancelAllRequest: () => void; + ): HookRequestInstanceResponseData>; } /** @@ -39,25 +39,26 @@ export interface HookRequestInstance { * @param axiosConfig * @param options */ -export default function createHookRequest( +export default function createHookRequest>( axiosConfig?: CreateAxiosDefaults, - options?: Partial> + options?: Partial> ) { - const request = createFlatRequest(axiosConfig, options); + const request = createFlatRequest(axiosConfig, options); - const hookRequest: HookRequestInstance = function hookRequest( - config: CustomAxiosRequestConfig - ) { + const hookRequest: HookRequestInstance = function hookRequest< + T extends ApiData = ApiData, + R extends ResponseType = 'json' + >(config: CustomAxiosRequestConfig) { const { loading, startLoading, endLoading } = useLoading(); - const data = ref | null>(null) as Ref>; - const error = ref | null>(null) as Ref | null>; + const data = ref(null) as Ref>; + const error = ref(null) as Ref | null>; startLoading(); request(config).then(res => { if (res.data) { - data.value = res.data; + data.value = res.data as MappedType; } else { error.value = res.error; } @@ -70,9 +71,8 @@ export default function createHookRequest( data, error }; - } as HookRequestInstance; + } as HookRequestInstance; - hookRequest.cancelRequest = request.cancelRequest; hookRequest.cancelAllRequest = request.cancelAllRequest; return hookRequest; diff --git a/packages/hooks/src/use-signal.ts b/packages/hooks/src/use-signal.ts deleted file mode 100644 index fa9d6265..00000000 --- a/packages/hooks/src/use-signal.ts +++ /dev/null @@ -1,144 +0,0 @@ -import { computed, ref, shallowRef, triggerRef } from 'vue'; -import type { - ComputedGetter, - DebuggerOptions, - Ref, - ShallowRef, - WritableComputedOptions, - WritableComputedRef -} from 'vue'; - -type Updater = (value: T) => T; -type Mutator = (value: T) => void; - -/** - * Signal is a reactive value that can be set, updated or mutated - * - * @example - * ```ts - * const count = useSignal(0); - * - * // `watchEffect` - * watchEffect(() => { - * console.log(count()); - * }); - * - * // watch - * watch(count, value => { - * console.log(value); - * }); - * - * // useComputed - * const double = useComputed(() => count() * 2); - * const writeableDouble = useComputed({ - * get: () => count() * 2, - * set: value => count.set(value / 2) - * }); - * ``` - */ -export interface Signal { - (): Readonly; - /** - * Set the value of the signal - * - * It recommend use `set` for primitive values - * - * @param value - */ - set(value: T): void; - /** - * Update the value of the signal using an updater function - * - * It recommend use `update` for non-primitive values, only the first level of the object will be reactive. - * - * @param updater - */ - update(updater: Updater): void; - /** - * Mutate the value of the signal using a mutator function - * - * this action will call `triggerRef`, so the value will be tracked on `watchEffect`. - * - * It recommend use `mutate` for non-primitive values, all levels of the object will be reactive. - * - * @param mutator - */ - mutate(mutator: Mutator): void; - /** - * Get the reference of the signal - * - * Sometimes it can be useful to make `v-model` work with the signal - * - * ```vue - * ; - * - * - * ``` - */ - getRef(): Readonly>>; -} - -export interface ReadonlySignal { - (): Readonly; -} - -export interface SignalOptions { - /** - * Whether to use `ref` to store the value - * - * @default false use `sharedRef` to store the value - */ - useRef?: boolean; -} - -export function useSignal(initialValue: T, options?: SignalOptions): Signal { - const { useRef } = options || {}; - - const state = useRef ? (ref(initialValue) as Ref) : shallowRef(initialValue); - - return createSignal(state); -} - -export function useComputed(getter: ComputedGetter, debugOptions?: DebuggerOptions): ReadonlySignal; -export function useComputed(options: WritableComputedOptions, debugOptions?: DebuggerOptions): Signal; -export function useComputed( - getterOrOptions: ComputedGetter | WritableComputedOptions, - debugOptions?: DebuggerOptions -) { - const isGetter = typeof getterOrOptions === 'function'; - - const computedValue = computed(getterOrOptions as any, debugOptions); - - if (isGetter) { - return () => computedValue.value as ReadonlySignal; - } - - return createSignal(computedValue); -} - -function createSignal(state: ShallowRef | WritableComputedRef): Signal { - const signal = () => state.value; - - signal.set = (value: T) => { - state.value = value; - }; - - signal.update = (updater: Updater) => { - state.value = updater(state.value); - }; - - signal.mutate = (mutator: Mutator) => { - mutator(state.value); - triggerRef(state); - }; - - signal.getRef = () => state as Readonly>>; - - return signal; -} diff --git a/packages/hooks/src/use-table.ts b/packages/hooks/src/use-table.ts index 46bcf520..5b038525 100644 --- a/packages/hooks/src/use-table.ts +++ b/packages/hooks/src/use-table.ts @@ -1,12 +1,20 @@ -import { computed, reactive, ref } from 'vue'; +import { computed, ref } from 'vue'; import type { Ref, VNodeChild } from 'vue'; -import { jsonClone } from '@sa/utils'; import useBoolean from './use-boolean'; import useLoading from './use-loading'; -export type MaybePromise = T | Promise; +export interface PaginationData { + data: T[]; + pageNum: number; + pageSize: number; + total: number; +} -export type ApiFn = (args: any) => Promise; +type GetApiData = Pagination extends true ? PaginationData : ApiData[]; + +type Transform = ( + response: ResponseData +) => GetApiData; export type TableColumnCheckTitle = string | ((...args: any) => VNodeChild); @@ -14,76 +22,64 @@ export type TableColumnCheck = { key: string; title: TableColumnCheckTitle; checked: boolean; + visible: boolean; }; -export type TableDataWithIndex = T & { index: number }; - -export type TransformedData = { - data: TableDataWithIndex[]; - pageNum: number; - pageSize: number; - total: number; -}; - -export type Transformer = (response: Response) => TransformedData; - -export type TableConfig = { - /** api function to get table data */ - apiFn: A; - /** api params */ - apiParams?: Parameters[0]; - /** transform api response to table data */ - transformer: Transformer>>; - /** columns factory */ - columns: () => C[]; +export interface UseTableOptions { + /** + * api function to get table data + */ + api: () => Promise; + /** + * whether to enable pagination + */ + pagination?: Pagination; + /** + * transform api response to table data + */ + transform: Transform; + /** + * columns factory + */ + columns: () => Column[]; /** * get column checks - * - * @param columns */ - getColumnChecks: (columns: C[]) => TableColumnCheck[]; + getColumnChecks: (columns: Column[]) => TableColumnCheck[]; /** * get columns - * - * @param columns */ - getColumns: (columns: C[], checks: TableColumnCheck[]) => C[]; + getColumns: (columns: Column[], checks: TableColumnCheck[]) => Column[]; /** * callback when response fetched - * - * @param transformed transformed data */ - onFetched?: (transformed: TransformedData) => MaybePromise; + onFetched?: (data: GetApiData) => void | Promise; /** * whether to get data immediately * * @default true */ immediate?: boolean; -}; +} -export default function useHookTable(config: TableConfig) { +export default function useTable( + options: UseTableOptions +) { const { loading, startLoading, endLoading } = useLoading(); const { bool: empty, setBool: setEmpty } = useBoolean(); - const { apiFn, apiParams, transformer, immediate = true, getColumnChecks, getColumns } = config; + const { api, pagination, transform, columns, getColumnChecks, getColumns, onFetched, immediate = true } = options; - const searchParams: NonNullable[0]> = reactive(jsonClone({ ...apiParams })); + const data = ref([]) as Ref; - const allColumns = ref(config.columns()) as Ref; + const columnChecks = ref(getColumnChecks(columns())) as Ref; - const data: Ref[]> = ref([]); - - const columnChecks: Ref = ref(getColumnChecks(config.columns())); - - const columns = computed(() => getColumns(allColumns.value, columnChecks.value)); + const $columns = computed(() => getColumns(columns(), columnChecks.value)); function reloadColumns() { - allColumns.value = config.columns(); - const checkMap = new Map(columnChecks.value.map(col => [col.key, col.checked])); - const defaultChecks = getColumnChecks(allColumns.value); + const defaultChecks = getColumnChecks(columns()); columnChecks.value = defaultChecks.map(col => ({ ...col, @@ -92,47 +88,21 @@ export default function useHookTable(config: TableConfig< } async function getData() { - startLoading(); + try { + startLoading(); - const formattedParams = formatSearchParams(searchParams); + const response = await api(); - const response = await apiFn(formattedParams); + const transformed = transform(response); - const transformed = transformer(response as Awaited>); + data.value = getTableData(transformed, pagination); - data.value = transformed.data; + setEmpty(data.value.length === 0); - setEmpty(transformed.data.length === 0); - - await config.onFetched?.(transformed); - - endLoading(); - } - - function formatSearchParams(params: Record) { - const formattedParams: Record = {}; - - Object.entries(params).forEach(([key, value]) => { - if (value !== null && value !== undefined) { - formattedParams[key] = value; - } - }); - - return formattedParams; - } - - /** - * update search params - * - * @param params - */ - function updateSearchParams(params: Partial[0]>) { - Object.assign(searchParams, params); - } - - /** reset search params */ - function resetSearchParams() { - Object.assign(searchParams, jsonClone(apiParams)); + await onFetched?.(transformed); + } finally { + endLoading(); + } } if (immediate) { @@ -143,12 +113,20 @@ export default function useHookTable(config: TableConfig< loading, empty, data, - columns, + columns: $columns, columnChecks, reloadColumns, - getData, - searchParams, - updateSearchParams, - resetSearchParams + getData }; } + +function getTableData( + data: GetApiData, + pagination?: Pagination +) { + if (pagination) { + return (data as PaginationData).data; + } + + return data as ApiData[]; +} diff --git a/packages/materials/src/libs/admin-layout/index.vue b/packages/materials/src/libs/admin-layout/index.vue index 543f7dc0..8bbc5526 100644 --- a/packages/materials/src/libs/admin-layout/index.vue +++ b/packages/materials/src/libs/admin-layout/index.vue @@ -127,7 +127,6 @@ function handleClickMask() { :class="[ style['layout-header'], commonClass, - headerClass, headerLeftGapClass, { 'absolute top-0 left-0 w-full': fixedHeaderAndTab } ]" diff --git a/packages/materials/src/types/index.ts b/packages/materials/src/types/index.ts index bbcfb9d6..583f0907 100644 --- a/packages/materials/src/types/index.ts +++ b/packages/materials/src/types/index.ts @@ -6,12 +6,6 @@ interface AdminLayoutHeaderConfig { * @default true */ headerVisible?: boolean; - /** - * Header class - * - * @default '' - */ - headerClass?: string; /** * Header height * diff --git a/packages/ofetch/package.json b/packages/ofetch/package.json deleted file mode 100644 index 75929324..00000000 --- a/packages/ofetch/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@sa/fetch", - "version": "1.3.15", - "exports": { - ".": "./src/index.ts" - }, - "typesVersions": { - "*": { - "*": ["./src/*"] - } - }, - "dependencies": { - "ofetch": "1.4.1" - } -} diff --git a/packages/ofetch/src/index.ts b/packages/ofetch/src/index.ts deleted file mode 100644 index dce1ed44..00000000 --- a/packages/ofetch/src/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { ofetch } from 'ofetch'; -import type { FetchOptions } from 'ofetch'; - -export function createRequest(options: FetchOptions) { - const request = ofetch.create(options); - - return request; -} - -export default createRequest; diff --git a/packages/ofetch/tsconfig.json b/packages/ofetch/tsconfig.json deleted file mode 100644 index 5823ed54..00000000 --- a/packages/ofetch/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "jsx": "preserve", - "lib": ["DOM", "ESNext"], - "baseUrl": ".", - "module": "ESNext", - "moduleResolution": "node", - "resolveJsonModule": true, - "types": ["node"], - "strict": true, - "strictNullChecks": true, - "noUnusedLocals": true, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true - }, - "include": ["src/**/*"], - "exclude": ["node_modules", "dist"] -} diff --git a/packages/scripts/package.json b/packages/scripts/package.json index a91405f7..8f60c2be 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -22,6 +22,7 @@ "execa": "9.6.0", "kolorist": "1.8.0", "npm-check-updates": "18.1.1", + "picomatch": "4.0.3", "rimraf": "6.0.1" } } diff --git a/packages/utils/src/storage.ts b/packages/utils/src/storage.ts index 850562ab..e4aad14a 100644 --- a/packages/utils/src/storage.ts +++ b/packages/utils/src/storage.ts @@ -32,7 +32,8 @@ export function createStorage(type: StorageType, storagePrefix storageData = JSON.parse(json); } catch {} - if (storageData) { + // storageData may be `false` if it is boolean type + if (storageData !== null) { return storageData as T[K]; } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a64a1aae..90dbba07 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -309,12 +309,6 @@ importers: specifier: 0.9.1 version: 0.9.1 - packages/ofetch: - dependencies: - ofetch: - specifier: 1.4.1 - version: 1.4.1 - packages/scripts: devDependencies: '@soybeanjs/changelog': @@ -344,6 +338,9 @@ importers: npm-check-updates: specifier: 18.1.1 version: 18.1.1 + picomatch: + specifier: 4.0.3 + version: 4.0.3 rimraf: specifier: 6.0.1 version: 6.0.1 diff --git a/src/App.vue b/src/App.vue index 014a6428..9758e4cb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,7 +4,6 @@ import { NConfigProvider, darkTheme } from 'naive-ui'; import type { WatermarkProps } from 'naive-ui'; import { useAppStore } from './store/modules/app'; import { useThemeStore } from './store/modules/theme'; -import { useAuthStore } from './store/modules/auth'; import { naiveDateLocales, naiveLocales } from './locales/naive'; defineOptions({ @@ -13,7 +12,6 @@ defineOptions({ const appStore = useAppStore(); const themeStore = useThemeStore(); -const authStore = useAuthStore(); const naiveDarkTheme = computed(() => (themeStore.darkMode ? darkTheme : undefined)); @@ -26,13 +24,8 @@ const naiveDateLocale = computed(() => { }); const watermarkProps = computed(() => { - const content = - themeStore.watermark.enableUserName && authStore.userInfo.userName - ? authStore.userInfo.userName - : themeStore.watermark.text; - return { - content, + content: themeStore.watermarkContent, cross: true, fullscreen: true, fontSize: 16, diff --git a/src/components/advanced/table-column-setting.vue b/src/components/advanced/table-column-setting.vue index 014a51ae..10bd35ad 100644 --- a/src/components/advanced/table-column-setting.vue +++ b/src/components/advanced/table-column-setting.vue @@ -22,7 +22,12 @@ const columns = defineModel('columns', { -
+