fix: type
parent
2694c179d2
commit
8c3efaae21
|
@ -6,7 +6,7 @@ export interface AppProviderContextProps {
|
||||||
isMobile: Ref<boolean>
|
isMobile: Ref<boolean>
|
||||||
}
|
}
|
||||||
|
|
||||||
const key: InjectionKey<AppProviderContextProps> = Symbol()
|
const key: InjectionKey<AppProviderContextProps> = Symbol('app-context')
|
||||||
|
|
||||||
export function createAppProviderContext(context: AppProviderContextProps) {
|
export function createAppProviderContext(context: AppProviderContextProps) {
|
||||||
return createContext<AppProviderContextProps>(context, key)
|
return createContext<AppProviderContextProps>(context, key)
|
||||||
|
|
|
@ -6,7 +6,7 @@ export interface FormContextProps {
|
||||||
submitAction: () => Promise<void>
|
submitAction: () => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
const key: InjectionKey<FormContextProps> = Symbol()
|
const key: InjectionKey<FormContextProps> = Symbol('form-context')
|
||||||
|
|
||||||
export function createFormContext(context: FormContextProps) {
|
export function createFormContext(context: FormContextProps) {
|
||||||
return createContext<FormContextProps>(context, key)
|
return createContext<FormContextProps>(context, key)
|
||||||
|
|
|
@ -5,7 +5,7 @@ export interface ModalContextProps {
|
||||||
redoModalHeight: () => void
|
redoModalHeight: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const key: InjectionKey<ModalContextProps> = Symbol()
|
const key: InjectionKey<ModalContextProps> = Symbol('modal-context')
|
||||||
|
|
||||||
export function createModalContext(context: ModalContextProps) {
|
export function createModalContext(context: ModalContextProps) {
|
||||||
return createContext<ModalContextProps>(context, key)
|
return createContext<ModalContextProps>(context, key)
|
||||||
|
|
|
@ -7,7 +7,7 @@ export interface SimpleRootMenuContextProps {
|
||||||
activeName: Ref<string | number>
|
activeName: Ref<string | number>
|
||||||
}
|
}
|
||||||
|
|
||||||
const key: InjectionKey<SimpleRootMenuContextProps> = Symbol()
|
const key: InjectionKey<SimpleRootMenuContextProps> = Symbol('simple-menu-context')
|
||||||
|
|
||||||
export function createSimpleRootMenuContext(context: SimpleRootMenuContextProps) {
|
export function createSimpleRootMenuContext(context: SimpleRootMenuContextProps) {
|
||||||
return createContext<SimpleRootMenuContextProps>(context, key, { readonly: false, native: true })
|
return createContext<SimpleRootMenuContextProps>(context, key, { readonly: false, native: true })
|
||||||
|
|
|
@ -7,7 +7,7 @@ export interface PageContextProps {
|
||||||
setPageHeight: (height: number) => Promise<void>
|
setPageHeight: (height: number) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
const key: InjectionKey<PageContextProps> = Symbol()
|
const key: InjectionKey<PageContextProps> = Symbol('page-context')
|
||||||
|
|
||||||
export function createPageContext(context: PageContextProps) {
|
export function createPageContext(context: PageContextProps) {
|
||||||
return createContext<PageContextProps>(context, key, { native: true })
|
return createContext<PageContextProps>(context, key, { native: true })
|
||||||
|
|
|
@ -11,7 +11,7 @@ type ShallowUnwrap<T> = {
|
||||||
[P in keyof T]: UnwrapRef<T[P]>
|
[P in keyof T]: UnwrapRef<T[P]>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createContext<T>(context: any, key: InjectionKey<T> = Symbol(), options: CreateContextOptions = {}) {
|
export function createContext<T>(context: any, key: InjectionKey<T> = Symbol('create-context'), options: CreateContextOptions = {}) {
|
||||||
const { readonly = true, createProvider = true, native = false } = options
|
const { readonly = true, createProvider = true, native = false } = options
|
||||||
|
|
||||||
const state = reactive(context)
|
const state = reactive(context)
|
||||||
|
@ -25,6 +25,6 @@ export function createContext<T>(context: any, key: InjectionKey<T> = Symbol(),
|
||||||
|
|
||||||
export function useContext<T>(key: InjectionKey<T>, native?: boolean): T
|
export function useContext<T>(key: InjectionKey<T>, native?: boolean): T
|
||||||
|
|
||||||
export function useContext<T>(key: InjectionKey<T> = Symbol(), defaultValue?: any): ShallowUnwrap<T> {
|
export function useContext<T>(key: InjectionKey<T> = Symbol('use-context'), defaultValue?: any): ShallowUnwrap<T> {
|
||||||
return inject(key, defaultValue || {})
|
return inject(key, defaultValue || {})
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ export interface ContentContextProps {
|
||||||
setPageHeight: (height: number) => Promise<void>
|
setPageHeight: (height: number) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
const key: InjectionKey<ContentContextProps> = Symbol()
|
const key: InjectionKey<ContentContextProps> = Symbol('content-context')
|
||||||
|
|
||||||
export function createContentContext(context: ContentContextProps) {
|
export function createContentContext(context: ContentContextProps) {
|
||||||
return createContext<ContentContextProps>(context, key, { native: true })
|
return createContext<ContentContextProps>(context, key, { native: true })
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { getRawRoute } from '@/utils'
|
||||||
|
|
||||||
const emitter = mitt()
|
const emitter = mitt()
|
||||||
|
|
||||||
const key = Symbol()
|
const key = Symbol('route-change')
|
||||||
|
|
||||||
let lastChangeTab: RouteLocationNormalized
|
let lastChangeTab: RouteLocationNormalized
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ export function getSlot(slots: Slots, slot = 'default', data?: any, opts?: Rende
|
||||||
export function extendSlots(slots: Slots, excludeKeys: string[] = []) {
|
export function extendSlots(slots: Slots, excludeKeys: string[] = []) {
|
||||||
const slotKeys = Object.keys(slots)
|
const slotKeys = Object.keys(slots)
|
||||||
const ret: any = {}
|
const ret: any = {}
|
||||||
|
// eslint-disable-next-line array-callback-return
|
||||||
slotKeys.map((key) => {
|
slotKeys.map((key) => {
|
||||||
if (excludeKeys.includes(key))
|
if (excludeKeys.includes(key))
|
||||||
return null
|
return null
|
||||||
|
|
|
@ -266,7 +266,7 @@ export class VAxios {
|
||||||
.then((res: AxiosResponse<Result>) => {
|
.then((res: AxiosResponse<Result>) => {
|
||||||
resolve(res as unknown as Promise<T>)
|
resolve(res as unknown as Promise<T>)
|
||||||
// download file
|
// download file
|
||||||
if (typeof res != undefined)
|
if (typeof res != 'undefined')
|
||||||
downloadByData(res?.data as unknown as BlobPart, title || 'export')
|
downloadByData(res?.data as unknown as BlobPart, title || 'export')
|
||||||
})
|
})
|
||||||
.catch((e: Error | AxiosError) => {
|
.catch((e: Error | AxiosError) => {
|
||||||
|
@ -309,7 +309,7 @@ export class VAxios {
|
||||||
.then((res: AxiosResponse<Result>) => {
|
.then((res: AxiosResponse<Result>) => {
|
||||||
resolve(res as unknown as Promise<T>)
|
resolve(res as unknown as Promise<T>)
|
||||||
// download file
|
// download file
|
||||||
if (typeof res != undefined)
|
if (typeof res != 'undefined')
|
||||||
downloadByData(res?.data as unknown as BlobPart, title)
|
downloadByData(res?.data as unknown as BlobPart, title)
|
||||||
})
|
})
|
||||||
.catch((e: Error | AxiosError) => {
|
.catch((e: Error | AxiosError) => {
|
||||||
|
|
|
@ -122,6 +122,7 @@ const transform: AxiosTransform = {
|
||||||
let url = `${config.url}?`
|
let url = `${config.url}?`
|
||||||
for (const propName of Object.keys(params)) {
|
for (const propName of Object.keys(params)) {
|
||||||
const value = params[propName]
|
const value = params[propName]
|
||||||
|
// eslint-disable-next-line no-void
|
||||||
if (value !== void 0 && value !== null && typeof value !== 'undefined') {
|
if (value !== void 0 && value !== null && typeof value !== 'undefined') {
|
||||||
if (typeof value === 'object') {
|
if (typeof value === 'object') {
|
||||||
for (const val of Object.keys(value)) {
|
for (const val of Object.keys(value)) {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||||
const toString = Object.prototype.toString
|
const toString = Object.prototype.toString
|
||||||
|
|
||||||
export function is(val: unknown, type: string) {
|
export function is(val: unknown, type: string) {
|
||||||
|
@ -57,7 +58,7 @@ export function isString(val: unknown): val is string {
|
||||||
return is(val, 'String')
|
return is(val, 'String')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFunction(val: unknown): val is Function {
|
export function isFunction(val: unknown): val is Fn {
|
||||||
return typeof val === 'function'
|
return typeof val === 'function'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable array-callback-return */
|
||||||
/**
|
/**
|
||||||
* copy to https://github.com/developit/mitt
|
* copy to https://github.com/developit/mitt
|
||||||
* Expand clear method
|
* Expand clear method
|
||||||
|
|
|
@ -6,10 +6,10 @@ import type { ExtractPropTypes } from 'vue'
|
||||||
import type { Mutable } from './types'
|
import type { Mutable } from './types'
|
||||||
import { isObject } from '@/utils/is'
|
import { isObject } from '@/utils/is'
|
||||||
|
|
||||||
const wrapperKey = Symbol()
|
const wrapperKey = Symbol('wrapperKey')
|
||||||
export interface PropWrapper<T> { [wrapperKey]: T }
|
export interface PropWrapper<T> { [wrapperKey]: T }
|
||||||
|
|
||||||
export const propKey = Symbol()
|
export const propKey = Symbol('propKey')
|
||||||
|
|
||||||
type ResolveProp<T> = ExtractPropTypes<{
|
type ResolveProp<T> = ExtractPropTypes<{
|
||||||
key: { type: T; required: true }
|
key: { type: T; required: true }
|
||||||
|
|
Loading…
Reference in New Issue