Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b5ed98c
feat: support component (#273)
NelsonYong May 11, 2025
8aee688
version: 2.4.0-alpha.1
NelsonYong May 11, 2025
b5f0cef
version: 2.4.0-alpha.2
NelsonYong May 12, 2025
bcd8648
version: 2.4.0-alpha.3
NelsonYong May 12, 2025
bb4a9ce
feat: Add concurrent request support and enhance parameter management
NelsonYong May 15, 2025
265728b
test: add useBoolean
NelsonYong May 15, 2025
2bd2553
version: 2.4.0-alpha.4
NelsonYong May 15, 2025
08c2452
feat: 更新文档和组件,添加组件 Hook 指南及 useRequest 组件示例
NelsonYong May 26, 2025
5282549
fix: 更新文档链接,修复文件系统模块导入,优化代码结构
NelsonYong May 26, 2025
b1feb18
refactor: update useEventEmitter implementation and improve documenta…
NelsonYong May 31, 2025
a98d2f1
version: bump to 2.4.0-alpha.5
NelsonYong May 31, 2025
6aed6da
test: enhance useEventEmitter tests with subscription, unsubscription…
NelsonYong May 31, 2025
ad21c6b
test: add unit tests for useControlledState to validate controlled an…
NelsonYong May 31, 2025
2b47e9a
test: 🔧 add test
NelsonYong Jun 1, 2025
65711fe
test: 🔧 add test
NelsonYong Jun 1, 2025
8fc74e5
Merge pull request #276 from InhiblabCore/alpha
NelsonYong Jun 1, 2025
a50eec5
docs: mark version
NelsonYong Jun 1, 2025
3f83918
version: 2.4.0-beta.1
NelsonYong Jun 1, 2025
6e76adc
docs: updated
NelsonYong Jun 1, 2025
c2b9960
chore: command opt
NelsonYong Jun 1, 2025
b42f729
style: format
NelsonYong Jun 1, 2025
6874925
chore: rm unuse
NelsonYong Jun 1, 2025
1effaa1
chore: opt 🚛
NelsonYong Jun 2, 2025
bfb0c50
chore: opt 🚛
NelsonYong Jun 2, 2025
0365c72
chore: rm dep
NelsonYong Jun 2, 2025
7b22596
feat: 🚀 useControlledState
NelsonYong Jun 2, 2025
8a864a3
version: 2.4.0-beta.2
NelsonYong Jun 2, 2025
16bf793
docs: opt
NelsonYong Jun 8, 2025
3726ec8
test: update desc
NelsonYong Jun 8, 2025
4b6ec8b
version: 2.4.0
NelsonYong Jun 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
{
"no-inline-html": {
"allowed_elements": ["ul", "li", "div", "img", "a", "br", "script", "Badge", "Home","demo","VPTeamPage","VPTeamPageTitle","VPTeamMembers","VPTeamPageSection"]
"allowed_elements": [
"ul",
"li",
"div",
"img",
"a",
"br",
"script",
"Badge",
"Home",
"demo",
"VPTeamPage",
"VPTeamPageTitle",
"VPTeamMembers",
"VPTeamPageSection"
]
},
"MD013": false,
"MD041": false
}
}
1 change: 0 additions & 1 deletion .vscode/settings.json

This file was deleted.

32 changes: 27 additions & 5 deletions docs/.vitepress/config/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] {
{
text: 'Guide',
items: [
{ text: 'Introduction', link: "/guide" },
{ text: 'Introduction', link: "/guide/introduction" },
{ text: 'Getting Started', link: '/guide/getting-started' },
{ text: '🫶 Migrate to v2 version', link: '/guide/migrate' }
],
Expand All @@ -137,6 +137,7 @@ export const en = defineConfig({
...sidebarHooks(),
]
},
'/components/': sidebarComponents(),
},

editLink: {
Expand All @@ -155,9 +156,9 @@ function nav(): DefaultTheme.NavItem[] {
return [
{
text: 'Guide',
activeMatch: '/guide/',
activeMatch: '^/guide/',
items: [
{ text: 'Introduction', link: '/guide' },
{ text: 'Introduction', link: '/guide/introduction' },
{ text: 'Getting Started', link: '/guide/getting-started' },
{ text: '🫶 Migrate to v2 version', link: '/guide/migrate' }
]
Expand All @@ -167,6 +168,11 @@ function nav(): DefaultTheme.NavItem[] {
link: '/hooks/useRequest/quick-start',
activeMatch: '/hooks'
},
{
text: "Components",
link: '/components/guide',
activeMatch: '/components/'
},
{
text: '🤺 Playground',
link: 'https://inhiblabcore.github.io/vue-hooks-plus-playground/play',
Expand All @@ -191,7 +197,7 @@ export function sidebarHooks(): DefaultTheme.SidebarItem[] {
text: 'State',
items: [
{ text: 'useBoolean', link: 'useBoolean' },
// { text: "useControlledState", link: "useControlledState" },
{ text: "useControlledState", link: "useControlledState" },
{ text: 'useImmer', link: 'useImmer' },
{ text: 'useUrlState', link: 'useUrlState' },
{ text: 'useFormatResult', link: 'useFormatResult' },
Expand Down Expand Up @@ -265,7 +271,7 @@ export function sidebarHooks(): DefaultTheme.SidebarItem[] {
{
text: 'Advanced',
items: [
{ text: 'useEventEmitter', link: '/useEventEmitter/' },
{ text: 'useEventEmitter', link: 'useEventEmitter' },
{
text: 'useAsyncOrder',
link: 'useAsyncOrder',
Expand All @@ -286,3 +292,19 @@ export function sidebarHooks(): DefaultTheme.SidebarItem[] {
})
}



export function sidebarComponents(): DefaultTheme.SidebarItem[] {
return [
{
text: 'Components',
items: [
{
text: 'Guide',
link: '/components/guide',
},
{ text: 'useRequest', link: '/components/useRequest' },
],
}
]
}
8 changes: 4 additions & 4 deletions docs/.vitepress/config/factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fsExtra from 'fs-extra';
import * as fs from 'node:fs';
import { dirname, join, sep } from 'path';
import { MarkdownRenderer } from 'vitepress';

Expand Down Expand Up @@ -48,13 +48,13 @@ export function genDemoByCode(
while (true) {
demoName = `demo-${fenceIndex++}.vue`;
demoPath = join(dirname(path), 'dist', demoName);
if (!fsExtra.existsSync(demoPath)) {
if (!fs.existsSync(demoPath)) {
break;
}
}

fsExtra.createFileSync(demoPath);
fsExtra.writeFileSync(demoPath, code);
fs.writeFileSync(demoPath, '');
fs.writeFileSync(demoPath, code);

codeFileMap[code] = {
demoName,
Expand Down
27 changes: 23 additions & 4 deletions docs/.vitepress/config/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] {
}
]
}

function sidebarComponents(): DefaultTheme.SidebarItem[] {
return [
{
text: 'Components',
items: [
{ text: 'Guide', link: '/zh/components/guide' },
{ text: 'useRequest', link: '/zh/components/useRequest' },
],
}
]
}

export const zh = defineConfig({
lang: 'zh-Hans',
description: '高性能的 Vue 组合式函数库',
Expand All @@ -138,7 +151,8 @@ export const zh = defineConfig({
...siderbarUseRequestPlugin(),
...sidebarHooks()
]
}
},
'/zh/components/': sidebarComponents(),
},

editLink: {
Expand Down Expand Up @@ -182,18 +196,23 @@ function nav(): DefaultTheme.NavItem[] {
return [
{
text: '指南',
activeMatch: '/zh/guide/',
activeMatch: '^/zh/guide/',
items: [
{ text: '介绍', link: '/zh/guide' },
{ text: '介绍', link: '/zh/guide/introduction' },
{ text: '开始使用', link: '/zh/guide/getting-started' },
{ text: '🫶 迁移到 v2 版本', link: '/zh/guide/migrate' }
]
},
{
text: 'Hooks',
text: 'Hooks 函数',
link: '/zh/hooks/useRequest/quick-start',
activeMatch: '/zh/hooks'
},
{
text: '函数组件',
link: '/zh/components/guide',
activeMatch: '/zh/components/'
},
{
text: '🤺 演武场',
link: 'https://inhiblabcore.github.io/vue-hooks-plus-playground/play',
Expand Down
6 changes: 3 additions & 3 deletions docs/.vitepress/plugins/applyMdPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { parseProps } from "../config/utils";
import { resolve } from 'path'
import fsExtra from 'fs-extra'
import * as fs from 'node:fs'
import { getDemoComponent } from "../config/factory";
export const applyMdPlugin = (md: any) => {
const htmlBlock = md.renderer.rules.html_block!
md.renderer.rules.html_block = function (tokens, idx, options, env, self) {
md.renderer.rules.html_block = function (tokens: any, idx: any, options: any, env: any, self: any) {
const token = tokens[idx];
const content = token.content.trim();
const { path } = env;
Expand All @@ -17,7 +17,7 @@ export const applyMdPlugin = (md: any) => {
}

const srcPath = resolve(process.cwd(), "docs", "demo", props.src);
const code = fsExtra.readFileSync(srcPath, 'utf8');
const code = fs.readFileSync(srcPath, 'utf8');
const demoScripts = getDemoComponent(md, env, {
title: props?.title,
desc: props?.desc,
Expand Down
15 changes: 15 additions & 0 deletions docs/demo/useControlledState/demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<div>
<div>Show default value: {{ count }}</div>
<div>Show form value: {{ countFormValue }}</div>
<vhp-button @click="() => (value = 10)">Set value</vhp-button>
</div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { useControlledState } from 'vue-hooks-plus'
const value = ref<number | undefined>(undefined)
const [count] = useControlledState(undefined, 10)
const [countFormValue] = useControlledState(value, 0)
</script>
21 changes: 21 additions & 0 deletions docs/demo/useControlledState/demo1.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<div>
<vhp-button
:style="{ backgroundColor: color }"
@click="
() => {
setColor(randomColor())
}
"
>Uncontrolled color</vhp-button
>
</div>
</template>

<script lang="ts" setup>
import { useControlledState } from 'vue-hooks-plus'
const [color, setColor] = useControlledState(undefined, 'red')
const randomColor = () => {
return '#' + Math.floor(Math.random() * 16777215).toString(16)
}
</script>
41 changes: 41 additions & 0 deletions docs/demo/useControlledState/demo2.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<div>
<vhp-button
style="margin-right: 10px"
:style="{ backgroundColor: color1 }"
@click="
() => {
setColor1(randomColor())
}
"
>Controlled unvalid value</vhp-button
>

<vhp-button
:style="{ backgroundColor: color }"
@click="
() => {
setColor(randomColor())
}
"
>Controlled color</vhp-button
>
</div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { useControlledState } from 'vue-hooks-plus'

const value = ref<string | undefined>('red')

const value2 = ref<string | undefined>('red')

const [color1, setColor1] = useControlledState(value2, undefined)
const [color, setColor] = useControlledState(value, undefined, v => {
value.value = v
})
const randomColor = () => {
return '#' + Math.floor(Math.random() * 16777215).toString(16)
}
</script>
18 changes: 18 additions & 0 deletions docs/demo/useEventEmitter/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<div>
<vhp-button @click="refRouter = !refRouter" style="margin-bottom: 16px;">
toggle router</vhp-button
>
<demo v-if="refRouter" />
<div v-else>
SHOW TEXT
</div>
</div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import Demo from './demo.vue'

const refRouter = ref(true)
</script>
21 changes: 15 additions & 6 deletions docs/demo/useEventEmitter/DemoA.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,30 @@
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { onMounted, onUnmounted, ref } from 'vue'

import { useEventEmitter } from 'vue-hooks-plus'
import { EventEmitter } from 'vue-hooks-plus/src/useEventEmitter/event'

const event = useEventEmitter({ global: true })
const event_ = useEventEmitter({ global: true })
const props = defineProps<{
event: any
event: EventEmitter<any>
}>()
const count = ref(0)

props.event.useSubscription('change', () => {
count.value += 1
let unsubscribe: (() => void) | null = null

onMounted(() => {
unsubscribe = props.event.subscribe('change', () => {
console.log('props', props.event)
count.value += 1
})
})
onUnmounted(() => {
if (unsubscribe) unsubscribe()
})

const changeGlobal = () => {
event.emit('change')
event_.emit('change')
}
</script>
3 changes: 2 additions & 1 deletion docs/demo/useEventEmitter/GlobalDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
const event = useEventEmitter({ global: true })
const globalCount = ref(0)

event.useSubscription('change', () => {
event.subscribe('change', () => {
console.log('global', event)
globalCount.value += 1
})
</script>
1 change: 0 additions & 1 deletion docs/demo/useEventEmitter/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
}

const changeA = () => {
// globalCount.value += 1
eventA.emit('change')
}
</script>
5 changes: 4 additions & 1 deletion docs/demo/useMouse/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
<p>Client - x: {{ mouse.clientX }}, y: {{ mouse.clientY }}</p>
<p>Page - x: {{ mouse.pageX }}, y: {{ mouse.pageY }}</p>
<p>Screen - x: {{ mouse.screenX }}, y: {{ mouse.screenY }}</p>
<UseMouse v-slot="{ clientX, clientY }">
<p>component use: {{ clientX }}, y: {{ clientY }}</p>
</UseMouse>
</div>
</template>

<script lang="ts" setup>
import { useMouse } from 'vue-hooks-plus'
import { useMouse, UseMouse } from 'vue-hooks-plus'
const mouse = useMouse()
</script>
Loading