### Start Documentation Development Server Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/CONTRIBUTING.md Use this command in the root folder to start the documentation development server. Alternatively, run 'pnpm initial' and then 'pnpm docs:dev' in the 'packages/hooks' folder. ```bash pnpm docs:dev ``` -------------------------------- ### Install useUrlState Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useUrlState.md Install the package using npm. This command adds the necessary library to your project dependencies. ```bash npm i @vue-hooks-plus/use-url-state ``` -------------------------------- ### Install Dependencies and Build Project Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/superpowers/plans/2026-06-10-toolchain-upgrade.md Install new dependencies and build the project. Expect the build process to pass with exit code 0, potentially requiring minimal type assertion fixes. ```bash pnpm install pnpm build ``` -------------------------------- ### Install vue-hooks-plus Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/guide/getting-started.md Install the library using npm. This is the first step to using vue-hooks-plus in your project. ```bash npm i vue-hooks-plus ``` -------------------------------- ### Install Dependencies Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useRequest/plugins/fetchsing.md Install pinia and the use-request-plugins package. Ensure pinia is already set up in your Vue instance. ```bash npm i pinia npm i @vue-hooks-plus/use-request-plugins ``` -------------------------------- ### Install BroadcastChannel Plugin Dependencies Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useRequest/plugins/broadcastChannel.md Install the necessary packages for the BroadcastChannel plugin. Ensure 'broadcast-channel' is installed before the plugin. ```bash 1. npm i broadcast-channel 2. npm i @vue-hooks-plus/use-request-plugins ``` -------------------------------- ### Install BroadcastChannel and Vue Hooks Plus Plugins Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/packages/hooks/src/useRequest/docs/plugins/broadcastChannel/index.zh-CN.md Ensure the broadcast-channel package is installed for the plugin to function. Then, install the use-request-plugins package. ```bash npm i broadcast-channel npm i @vue-hooks-plus/use-request-plugins ``` -------------------------------- ### Install Dependencies with pnpm Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/CONTRIBUTING.md Use this command in the root folder to install and link dependencies for the monorepo. ```bash pnpm i ``` -------------------------------- ### Install Dependencies and Build Package Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/superpowers/plans/2026-06-10-toolchain-upgrade.md Install dependencies and build the specific package (`@vue-hooks-plus/use-request-plugins`). This step verifies API compatibility with broadcast-channel v7. ```bash pnpm install pnpm --filter @vue-hooks-plus/use-request-plugins build ``` -------------------------------- ### Start VitePress Docs Development Server Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/CLAUDE.md Launches the VitePress documentation development server, allowing for live preview of documentation changes. ```bash pnpm docs:dev ``` -------------------------------- ### Install Dependencies with pnpm Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/CLAUDE.md Installs all project dependencies. This project requires pnpm for package management. ```bash pnpm install ``` -------------------------------- ### Install Pinia and use-request-plugins Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useRequest/plugins/broadcastChannel.md Ensure your application includes Pinia and is used by the Vue instance. Install Pinia and the use-request-plugins package using npm. ```bash # 需要保证应用含有pinia,并且被Vue实例 use。 1. npm i pinia 2. npm i @vue-hooks-plus/use-request-plugins ``` -------------------------------- ### Install useImmer Hook Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useImmer.md Install the useImmer hook package using npm. Ensure Immer is installed in your project for normal operation. ```bash npm i @vue-hooks-plus/use-immer ``` -------------------------------- ### Install useWorker Hook Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useWorker.md Install the useWorker library using npm. This is the initial setup step before using the hook in your Vue project. ```bash npm i @vue-hooks-plus/use-worker ``` -------------------------------- ### Basic useWinResize Demo Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useWinResize.md Demonstrates how to use the useWinResize hook to listen for window dimensions. No specific setup or imports are required beyond using the hook itself. ```vue ``` -------------------------------- ### Directory Structure for Project Setup Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/packages/hooks/src/useRequest/docs/guide/index.en-US.md Illustrates the recommended directory structure for a Vue project utilizing useRequest, including network configuration, views, services, and type definitions. ```bash .\n├── src\n│ ├── network\n│ │ ├── axios.ts\n│ ├── views\n│ │ ├── home\n│ │ │ ├── Home.vue\n│ │ │ ├── Home.less\n│ │ │ ├── services.ts // API\n│ │ │ └── data.d.ts // TS type\n│ ├── services // recommend\n│ │ └── api.ts // global API\n└── typings.d.ts // global ts type ``` -------------------------------- ### Basic useCounter Demo Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useCounter.md A simple example demonstrating the basic usage of the useCounter hook for managing a counter. ```vue ``` -------------------------------- ### useTimeout with Immediate Execution Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useTimeout.md This example shows how to use the `immediate` option to execute the function immediately upon hook initialization, followed by a delay. ```vue ``` -------------------------------- ### Verify Bootstrap Artifacts Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/superpowers/plans/2026-06-10-toolchain-upgrade.md Install dependencies, run the bootstrap script, and check for differences in the generated meta-data file. An empty diff indicates successful formatting. ```bash pnpm install pnpm bootstrap command git diff --stat packages/hooks/meta-data.json ``` -------------------------------- ### useCounter Demo Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useCounter.md A simple example demonstrating the management of a counter using the useCounter Hook. ```vue ``` -------------------------------- ### V1 Formatter Plugin Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useRequest/plugin.md An example of a V1 plugin that formats data upon successful request. It uses `setFetchState` to update the 'data' field. ```typescript const useFormatterPlugin: UseRequestPlugin< { name: string age: number }, [], { formatter?: ({ name, age }?: { name: string; age: number }) => any } > = (fetchInstance, { formatter }) => { return { onSuccess: () => { fetchInstance.setFetchState(formatter?.(fetchInstance.state.data), 'data') }, } } ``` -------------------------------- ### V2 Formatter Plugin Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useRequest/plugin.md An example of a V2 plugin that formats data upon successful request, accessing options via `pluginOptions`. It uses `setFetchState` to update the 'data' field. ```typescript const useFormatterPlugin: UseRequestPlugin< { name: string age: number }, [], { formatter?: ({ name, age }?: { name: string; age: number }) => any } > = (fetchInstance, { pluginOptions }) => { return { onSuccess: () => { fetchInstance.setFetchState(pluginOptions?.formatter?.(fetchInstance.state.data), 'data') }, } } ``` -------------------------------- ### Debounce Request Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useRequest/debounce.md This example demonstrates how to use the debounce functionality. Enter text rapidly in the input box to trigger the `run` function frequently. The request will only execute 1000ms after the last trigger. ```vue ``` -------------------------------- ### Debounce Example with Input Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useRequest/debounce.md This example demonstrates how to use debounce with an input field. Rapid typing in the input will trigger `run` multiple times, but due to the debounce setting (1000ms), the request will only execute 1000ms after the last input event. ```vue ``` -------------------------------- ### Default Request Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/packages/hooks/src/useRequest/docs/basic/index.zh-CN.md Demonstrates the default behavior of `useRequest` where the service function is automatically executed upon component initialization. ```vue ``` -------------------------------- ### SWR Cache Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useRequest/cache.md Demonstrates setting a `cacheKey` to enable caching. When the component reloads, cached data is returned first, followed by a background request. Experience this by clicking the button. ```vue ``` -------------------------------- ### Basic useDrop and useDrag Usage Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useDrop-useDrag.md Demonstrates a basic setup for accepting files, URLs, text, or other dropped content within a designated drop area. ```vue ``` -------------------------------- ### Custom Async Cache Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useRequest/cache.md Demonstrates using asynchronous cache mechanisms like `localforage` or `IndexDB` by implementing custom `setCache` and `getCache` functions that handle asynchronous operations. ```vue ``` -------------------------------- ### Vue Infinite Scroll Demo Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useInfiniteScroll.md A basic Vue component demonstrating the useInfiniteScroll hook. This example likely showcases the initial setup and data fetching. ```vue ``` -------------------------------- ### Build Documentation Site Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/CLAUDE.md Performs a full build of all packages and then builds the VitePress documentation site. ```bash pnpm docs:build ``` -------------------------------- ### Build Project with pnpm Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/CONTRIBUTING.md Run this command in the root folder to build the project. ```bash pnpm run build ``` -------------------------------- ### Feature PR Title Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/CONTRIBUTING.md Example of a pull request title for adding a new feature. ```git feat: xxxxx ``` -------------------------------- ### Basic useHover Demo Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useHover.md Demonstrates the basic usage of the useHover hook with a ref to monitor hover state. ```vue ``` -------------------------------- ### Install Auto Import Resolver Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/guide/getting-started.md Install the necessary package for integrating with unplugin-auto-import. This allows for automatic imports of hooks. ```bash npm i -D @vue-hooks-plus/resolvers ``` -------------------------------- ### Build All Packages Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/CLAUDE.md Performs a bootstrap process, regenerating meta-data.json, and then builds all packages within the monorepo. ```bash pnpm build ``` -------------------------------- ### Fix Bug PR Title Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/CONTRIBUTING.md Example of a pull request title for fixing a bug, including the issue ID. ```git fix: update entities encoding/decoding (fix #3899) ``` -------------------------------- ### useWebSocket Basic Usage Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useWebSocket.md Demonstrates the basic usage of the useWebSocket hook. Ensure the demo.vue file is correctly configured. ```vue ``` -------------------------------- ### Basic Usage of useDrop and useDrag Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useDrop-useDrag.md Demonstrates how to use useDrop and useDrag together. The drop zone accepts files, links, text, and content from the box element. ```vue ``` -------------------------------- ### Debounce Input Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/packages/hooks/src/useRequest/docs/debounce/index.zh-CN.md This example demonstrates how to use debounce with an input field. Frequent typing in the input triggers the `run` function, but due to the debounce setting, the request is only executed 1000ms after the last input event. ```vue ``` -------------------------------- ### Bash Script for Project Structure Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useRequest/guide.md Illustrates a recommended directory structure for a Vue.js project, organizing network, views, services, and type definitions. ```bash . ├── src │ ├── network │ │ ├── axios.ts │ ├── views │ │ ├── home │ │ │ ├── Home.vue │ │ │ ├── Home.less │ │ │ ├── services.ts // 模块 API │ │ │ └── data.d.ts // 模块 TS 类型 │ ├── services // 推荐目录 │ │ └── api.ts // 全局公共的 API └── typings.d.ts // 全局公共的 TS 类型声明 ``` -------------------------------- ### Parameter Caching Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useRequest/cache.md Utilize cached params to initialize the keyword from the previous request's conditions. ```vue ``` -------------------------------- ### Basic Usage of useVirtualList Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useVirtualList.md Use this snippet to render a large list with default settings. Ensure your data is provided as a Ref. ```vue ``` -------------------------------- ### Basic Usage of useAsyncOrder Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useAsyncOrder.md Demonstrates the basic usage of the useAsyncOrder hook. The first data appears after 3000ms, and the second data appears after 2000ms. ```vue ``` -------------------------------- ### useTimeout Basic Usage Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useTimeout.md This example demonstrates the basic usage of the useTimeout hook. The function will execute after a 2000ms delay. ```vue ``` -------------------------------- ### Basic Usage of useFetchs Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useFetchs.md Demonstrates the basic usage of the useFetchs hook for managing multiple requests simultaneously. Ensure the service function and options are correctly defined. ```vue ``` -------------------------------- ### Configure AutoImport for Vite Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/README.md Set up `unplugin-auto-import` with `VueHooksPlusResolver` for Vite to automatically import hooks. This requires installing `unplugin-auto-import` and `@vue-hooks-plus/resolvers`. ```typescript import AutoImport from 'unplugin-auto-import/vite' import { VueHooksPlusResolver } from '@vue-hooks-plus/resolvers' export const AutoImportDeps = () => AutoImport({ imports: ['vue', 'vue-router'], include: [/\[tj]sx?$/, /\.vue$/, /\.vue\?vue/, /\.md$/], dts: 'src/auto-imports.d.ts', resolvers: [VueHooksPlusResolver()], }) ``` -------------------------------- ### Basic Usage of useWebSocket Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useWebSocket.md Demonstrates the fundamental usage of the useWebSocket hook. This snippet shows how to establish a WebSocket connection and utilize its basic functionalities. ```vue ``` -------------------------------- ### SWR Cache Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useRequest/cache.md When cacheKey is set, the component initially displays cached content on re-render and then re-fetches the data in the background. ```vue ``` -------------------------------- ### useSet Basic Usage Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useSet.md Demonstrates the basic usage of the useSet hook for managing a Set state. ```vue ``` -------------------------------- ### Basic Usage of useKeyPress Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useKeyPress.md Demonstrates the basic functionality of the useKeyPress hook. Use this to listen for simple key presses or aliases. ```vue ``` -------------------------------- ### Use useNetwork Hook Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useNetwork.md Returns network status information. No specific setup or imports are required beyond using the hook. ```vue ``` -------------------------------- ### Run Tests with pnpm Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/CONTRIBUTING.md Execute this command in the root folder to run all tests for the project. ```bash pnpm test ``` -------------------------------- ### Vue - Default Mouse Tracking Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useMouse.md Use this snippet to track the cursor's position on the screen. No additional setup is required. ```vue ``` -------------------------------- ### Configure AutoImport for Webpack Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/README.md Configure `unplugin-auto-import` for Webpack to automatically import hooks, using `VueHooksPlusResolver`. Ensure `unplugin-auto-import` and `@vue-hooks-plus/resolvers` are installed. ```javascript const { VueHooksPlusResolver } = require('@vue-hooks-plus/resolvers') module.exports = { /* ... */ plugins: [ require('unplugin-auto-import/webpack')({ imports: ['vue', 'vue-router'], include: [/\[tj]sx?$/, /\.vue$/, /\.vue\?vue/, /\.md$/], dts: 'src/auto-imports.d.ts', resolvers: [VueHooksPlusResolver()], }), ], } ``` -------------------------------- ### Basic useScroll Usage Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useScroll.md Use this snippet to listen to the scroll position of an element. No specific setup is required beyond importing the hook. ```vue ``` -------------------------------- ### useFetchs Basic Usage Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useFetchs.md Demonstrates the basic usage of useFetchs for managing the state of multiple concurrent requests. ```vue ``` -------------------------------- ### Configure Auto Import for useImmer Resolver Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useImmer.md Import the VueHooksPlusUseImmerResolver for automatic import configuration. This setup is necessary for the hook to work correctly. ```typescript import { VueHooksPlusUseImmerResolver } from '@vue-hooks-plus/resolvers' ``` -------------------------------- ### Run and Commit Testing Commands Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/superpowers/plans/2026-06-10-test-completion.md Execute the specified command to run tests for multiple hooks and then add the relevant test files to the staging area before committing the changes with a descriptive message. ```bash pnpm vitest run packages/hooks/src/useFullscreen packages/hooks/src/useDrop packages/hooks/src/useDrag packages/hooks/src/useMouse ``` ```bash git add packages/hooks/src/useFullscreen/__tests__ packages/hooks/src/useDrop/__tests__ packages/hooks/src/useDrag/__tests__ packages/hooks/src/useMouse/__tests__ ``` ```bash git commit -m "test: deepen useFullscreen, useDrop, useDrag and useMouse specs" ``` -------------------------------- ### Basic Usage of useTrackedEffect Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useTrackedEffect.md This example demonstrates the basic usage of the useTrackedEffect hook. Check the console for the printed results to observe dependency changes. ```vue ``` -------------------------------- ### Basic useMedia Hook Usage Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useMedia.md Demonstrates basic usage of the useMedia hook with a minimum width query. Ensure the queries and values arrays align. ```javascript const value = useMedia(['(min-width: 320px)'], [true], false) ``` -------------------------------- ### Monitor Full Page Scrolling Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useScroll.md This example demonstrates how to monitor the scrolling of the entire page. Simply pass `document` as the target to the `useScroll` hook. ```vue ``` -------------------------------- ### Basic Usage of useKeyPress Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useKeyPress.md Demonstrates the fundamental use of the useKeyPress hook. It supports listening for individual keys using their key codes or defined aliases. Press ArrowUp or ArrowDown to see it in action. ```vue ``` -------------------------------- ### Basic Mouse Tracking with useMouse Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useMouse.md Demonstrates the fundamental usage of the useMouse hook to track the mouse's position on the screen. No additional setup is required beyond importing and calling the hook. ```vue ``` -------------------------------- ### Basic useCookieState Usage Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/zh/hooks/useCookieState.md This example demonstrates the fundamental usage of useCookieState. After refreshing the page, the input field's content will be restored from the cookie. ```vue ``` -------------------------------- ### Uncontrolled Mode Example Source: https://github.com/inhiblabcore/vue-hooks-plus/blob/master/docs/en/hooks/useControlledState.md Illustrates the uncontrolled mode of useControlledState. When no reactive value is passed as the first argument, the hook manages its own internal state. ```vue ```