Skip to content

Commit c6bae79

Browse files
authored
refactor: 🚜 responsive objects can only be read to better distinguish business from tools
refactor: responsive objects can only be read to better distinguish business from tools
2 parents 4cb9b59 + 3e3cc12 commit c6bae79

File tree

81 files changed

+467
-440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+467
-440
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = {
2626
plugins: ['@typescript-eslint', 'vue'],
2727
rules: {
2828
'vue/multi-word-component-names': 'off',
29+
'vue/html-self-closing': 'off',
2930
'react/no-string-refs': 'off',
3031
'react/no-unknown-property': 'off',
3132
'react/display-name': 'off',

packages/hooks/docs/.vitepress/config.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@ export default defineConfig({
8282
{ text: `⒡ Hooks`, link: '/useRequest/' },
8383
isGithub
8484
? {
85-
text: '演武场',
86-
link: 'https://inhiblabcore.github.io/vue-hooks-plus-playground/play',
87-
}
85+
text: '演武场',
86+
link: 'https://inhiblabcore.github.io/vue-hooks-plus-playground/play',
87+
}
8888
: {
89-
text: '演武场',
90-
link: 'https://inhiblab-core.gitee.io/vue-hooks-plus-playground/play',
91-
},
89+
text: '演武场',
90+
link: 'https://inhiblab-core.gitee.io/vue-hooks-plus-playground/play',
91+
},
9292
isGithub
9393
? {
94-
text: '国内镜像 🇨🇳',
95-
link: 'https://inhiblab-core.gitee.io/docs/hooks',
96-
}
94+
text: '国内镜像 🇨🇳',
95+
link: 'https://inhiblab-core.gitee.io/docs/hooks',
96+
}
9797
: null,
9898
{
9999
text: '发行版本',
@@ -107,18 +107,18 @@ export default defineConfig({
107107
{ text: '⒡ Hooks', link: '/en/useRequest/' },
108108
isGithub
109109
? {
110-
text: 'Playground',
111-
link: 'https://inhiblabcore.github.io/vue-hooks-plus-playground/play',
112-
}
110+
text: 'Playground',
111+
link: 'https://inhiblabcore.github.io/vue-hooks-plus-playground/play',
112+
}
113113
: {
114-
text: 'Playground',
115-
link: 'https://inhiblab-core.gitee.io/vue-hooks-plus-playground/play',
116-
},
114+
text: 'Playground',
115+
link: 'https://inhiblab-core.gitee.io/vue-hooks-plus-playground/play',
116+
},
117117
isGithub
118118
? {
119-
text: 'Gitee Mirror 🇨🇳',
120-
link: 'https://inhiblab-core.gitee.io/docs/hooks/',
121-
}
119+
text: 'Gitee Mirror 🇨🇳',
120+
link: 'https://inhiblab-core.gitee.io/docs/hooks/',
121+
}
122122
: null,
123123
{
124124
text: 'Releases',

packages/hooks/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
},
3535
"dependencies": {
3636
"@types/js-cookie": "^3.0.1",
37-
"intersection-observer": "^0.12.2",
3837
"js-cookie": "^3.0.1",
3938
"lodash": "^4.17.21",
4039
"marked": "^4.0.17",

packages/hooks/src/createUseStorageState/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-empty */
2-
import { unref, ref, Ref, UnwrapRef, watchEffect } from 'vue'
2+
import { unref, ref, Ref, UnwrapRef, watchEffect, readonly } from 'vue'
33

44
export interface IFuncUpdater<T> {
55
(previousState?: T): T
@@ -99,7 +99,7 @@ export function createUseStorageState(getStorage: () => Storage | undefined) {
9999
}
100100
}
101101

102-
return [state, updateState]
102+
return [readonly(state), updateState]
103103
}
104104
return useStorageState
105105
}

packages/hooks/src/useBoolean/demo/demo.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
33
<div>{{ flag }}</div>
4-
<br>
4+
<br />
55
<div>
66
<p>
77
<vhp-button @click="() => set(!flag)">Set</vhp-button>

packages/hooks/src/useBoolean/index.en-US.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ defaultValue? : boolean,
3131

3232
## Result
3333

34-
| Property | Description | Type |
35-
| -------- | -------------------------------------- | -------------- |
36-
| state | Current value | `Ref<boolean>` |
37-
| actions | A set of methods to update state value | `Actions` |
34+
| Property | Description | Type |
35+
| -------- | -------------------------------------- | ------------------------ |
36+
| state | Current value | `Readonly<Ref<boolean>>` |
37+
| actions | A set of methods to update state value | `Actions` |
3838

3939
## Actions
4040

packages/hooks/src/useBoolean/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import type { Ref } from "vue";
22
import useToggle from "../useToggle";
33

44
export interface UseBooleanActions {
5-
/**
6-
* Set state to `true`
7-
* @returns void
8-
*/
5+
/**
6+
* Set state to `true`
7+
* @returns void
8+
*/
99
setTrue: () => void;
1010

1111
/**
@@ -28,7 +28,7 @@ export interface UseBooleanActions {
2828
toggle: () => void;
2929
}
3030

31-
export type UseBooleanResult = [Ref<boolean>, UseBooleanActions]
31+
export type UseBooleanResult = [Readonly<Ref<boolean>>, UseBooleanActions]
3232

3333
export default function useBoolean(
3434
defaultValue = false

packages/hooks/src/useBoolean/index.zh-CN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ const [state, { toggle, set, setTrue, setFalse }] = useBoolean(
3131

3232
## Result
3333

34-
| 参数 | 说明 | 类型 |
35-
| ------- | -------- | -------------- |
36-
| state | 状态值 | `Ref<boolean>` |
37-
| actions | 操作集合 | `Actions` |
34+
| 参数 | 说明 | 类型 |
35+
| ------- | -------- | ------------------------ |
36+
| state | 状态值 | `Readonly<Ref<boolean>>` |
37+
| actions | 操作集合 | `Actions` |
3838

3939
## Actions
4040

packages/hooks/src/useCookieState/demo/demo.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
@change="change"
77
placeholder="please input"
88
style="width: 300px;"
9-
>
9+
/>
1010
</div>
1111
</template>
1212

1313
<script lang="ts" setup>
1414
import { useCookieState } from 'vue-hooks-plus'
1515
const [message, setMessage] = useCookieState('useCookieStateString')
16-
1716
const change = (e: any) => {
1817
setMessage(e.target?.value)
1918
}

packages/hooks/src/useCookieState/index.en-US.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ If you want to remove this data from the document.cookie, use the `setState()` o
5353

5454
### Result
5555

56-
| Property | Description | Type |
57-
| -------- | ------------------- | ---------------------------- |
58-
| state | Local Cookie value | `Ref<string` \| `undefined>` |
59-
| setState | Update Cookie value | `SetState` |
56+
| Property | Description | Type |
57+
| -------- | ------------------- | -------------------------------------- |
58+
| state | Local Cookie value | `Readonly<Ref<string>>` \| `undefined` |
59+
| setState | Update Cookie value | `SetState` |
6060

6161
setState can update cookie options, which will be merged with the options set by `useCookieState`
6262

0 commit comments

Comments
 (0)