执行以下命令安装posh-git和oh-my-posh两个模块,遇到提示选y确认即可
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
| /** ========== 滚动条样式 ========== */ | |
| ::-webkit-scrollbar { | |
| width: 12px !important; | |
| height: 12px !important; | |
| background-color: transparent; | |
| } | |
| ::-webkit-scrollbar-thumb { | |
| background-color: rgba(116 120 141 / 0.22) !important; |
| type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>> | |
| // usage: | |
| interface A { | |
| requireX: string | |
| requireY: string | |
| requireZ: string | |
| } |
| import { createContext, useContext, useEffect, useState } from 'react'; | |
| const XxxContext = createContext({}); | |
| export function XxxContextProvider(props: { children: React.ReactNode }) { | |
| const [state, setState] = useState(); | |
| const value = { state, setState }; | |
| return <XxxContext.Provider value={value}>{props.children}</XxxContext.Provider>; |
| import type { FormInstance } from 'antd'; | |
| import { Button, Form, Input, Popconfirm, Table } from 'antd'; | |
| import React, { useContext, useEffect, useRef, useState } from 'react'; | |
| const EditableContext = React.createContext<FormInstance | null>(null); | |
| const EditableRow = ({ index, ...props }: { index: number; [x: string]: any }) => { | |
| const [form] = Form.useForm(); | |
| return ( |
| export function highlightJSON(json: string): string { | |
| if (!json) { | |
| return '' | |
| } | |
| if (typeof json !== 'string') { | |
| json = JSON.stringify(json, undefined, 2) | |
| } | |
| json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>') |
| /** | |
| * 创建表单 shouldUpdate 函数的简易工具方法 | |
| * | |
| * @param namePath - 要响应变化的表单字段,路径格式与调用 Form.getFieldValue 方法的传参一致 | |
| */ | |
| export function shouldFormItemUpdate<Values>( | |
| namePath: string | (string | number)[] | |
| ): (...value: [Values, Values]) => boolean { | |
| const shouldUpdate = (...value: [Values, Values]) => { | |
| const [prevValue, curValue] = value; |
| const none = Symbol('lazyRef.Uninitialized') | |
| export default useJitRef(init) { | |
| const value = useRef(none) | |
| const ref = useLazyRef(() => ({ | |
| get current() { | |
| if (value.current === none) { | |
| value.current = init() | |
| } | |
| return value.current |
| /** | |
| * RuntimeGlobalsChecker | |
| * | |
| * You can use this utility to quickly check what variables have been added (or | |
| * leaked) to the global window object at runtime (by JavaScript code). | |
| * By running this code, the globals checker itself is attached as a singleton | |
| * to the window object as "__runtimeGlobalsChecker__". | |
| * You can check the runtime globals programmatically at any time by invoking | |
| * "window.__runtimeGlobalsChecker__.getRuntimeGlobals()". | |
| * |
| import { useRef } from 'react'; | |
| type AnyFunction = (...args: any[]) => any; | |
| /** | |
| * 对目标函数进行 memoized,并保证每次调用目标函数时都是最新的。 | |
| * | |
| * 当你需要把函数加入诸如 `useEffect` 的 dependencyList,而又不希望函数的 update/recreate 造成 hook 执行,就需要用到此方法。 | |
| */ | |
| export function useEvent<T extends AnyFunction | undefined>(callback: T): T { |