Skip to content

Commit

Permalink
perf: import way (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonYong authored Aug 18, 2024
1 parent 2a8fd77 commit b0758bf
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .vscode/setting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"prettier.configPath": ".prettierrc"
}
1 change: 0 additions & 1 deletion packages/hooks/src/createUseStorageState/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-empty */
import { unref, ref, Ref, UnwrapRef, watchEffect, readonly } from 'vue'

export interface IFuncUpdater<T> {
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useAsyncOrder/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTimeout } from '../index'
import useTimeout from '../useTimeout'

export type Resolve = (value: any) => void
export type InterruptibleRejectType = (error: any) => void
Expand Down
3 changes: 2 additions & 1 deletion packages/hooks/src/useCounter/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Ref, readonly, ref } from 'vue'
import { isNumber } from '../utils'

import { Ref, readonly, ref } from 'vue'

export interface UseCounterOptions {
/**
* Min count
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useHover/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Ref } from 'vue'
import { useBoolean } from '../index'
import useBoolean from '../useBoolean'
import useEventListener from '../useEventListener'
import { BasicTarget } from '../utils/domTarget'

Expand Down
4 changes: 3 additions & 1 deletion packages/hooks/src/useInfiniteScroll/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { computed, readonly, ref, shallowReadonly, watch } from "vue";
import { useBoolean, useEventListener, useRequest } from "../index";
import useBoolean from '../useBoolean'
import useEventListener from '../useEventListener'
import useRequest from '../useRequest'

import { getTargetElement } from "../utils/domTarget";

Expand Down
10 changes: 4 additions & 6 deletions packages/hooks/src/useUrlState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
import qs from 'qs'
import { Ref, ref, watch, watchEffect } from 'vue'
import { useLocalStorageState } from '../index'
import useLocalStorageState from '../useLocalStorageState'
import { isFunction } from '../utils'

export interface UseUrlStateOptions {
Expand Down Expand Up @@ -69,8 +69,8 @@ function useUrlState<S extends UrlState = Partial<UrlState>>(

const state_ = (localStorageKey
? useLocalStorageState(localStorageKey, {
defaultValue: defaultState,
})[0]
defaultValue: defaultState,
})[0]
: ref(defaultState)) as Ref<S>

const state = ref<S>() as Ref<S>
Expand All @@ -79,7 +79,6 @@ function useUrlState<S extends UrlState = Partial<UrlState>>(
state.value = state_.value
})


// 初始状态 url > localstorage
if (paramsStr) {
try {
Expand Down Expand Up @@ -115,7 +114,6 @@ function useUrlState<S extends UrlState = Partial<UrlState>>(
const newParamsStr = encodeParams(state.value)
routerPushFn(`${path}?${newParamsStr}`)
}

},
{
deep: true,
Expand All @@ -126,4 +124,4 @@ function useUrlState<S extends UrlState = Partial<UrlState>>(
return state
}

export default useUrlState
export default useUrlState

0 comments on commit b0758bf

Please sign in to comment.