Skip to content

Commit

Permalink
feat: 优化代码结构并增强功能
Browse files Browse the repository at this point in the history
- 重新组织`createDemo`函数中的文件写入操作,避免重复写入并优化流程。
  • Loading branch information
Null committed Jul 31, 2024
1 parent 1f4aeb5 commit 1f988d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 2 additions & 3 deletions cli/util.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ export async function createDemo(path, folderName) {
const demoExists = await fs.pathExists(demoPath);
if (!demoExists) {
await fs.ensureDir(join(path, 'demo'));
await fs.writeFile(join(path, 'demo', 'index.vue'), createUseHooksDemo(folderName));
}

await fs.writeFile(join(path, 'demo', 'index.vue'), createUseHooksDemo(folderName));
}

// 通用的检查和创建文件的方法
Expand All @@ -68,6 +67,6 @@ async function ensureFile(filePath, contentGenerator) {
if (!exists) {
await fs.writeFile(filePath, contentGenerator());
} else {
console.log(`File ${filePath} already exists. Skipping creation.`);
// console.log(`File ${filePath} already exists. Skipping creation.`);
}
}
17 changes: 9 additions & 8 deletions packages/hooks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import useEventListener from './useEventListener';
import useWindowSize from './useWindowSize';
import useClickAway from './useClickAway';
import useHover from './useHover';
import useFullscreen from "./useFullscreen";
import useLocalStorage from "./useLocalStorage";
import useDebounce from "./useDebounce";
import useDebounceFn from "./useDebounceFn";
import useThrottle from "./useThrottle";
import useThrottleFn from "./useThrottleFn";
import useFullscreen from './useFullscreen';
import useLocalStorage from './useLocalStorage';
import useDebounce from './useDebounce';
import useDebounceFn from './useDebounceFn';
import useThrottle from './useThrottle';
import useThrottleFn from './useThrottleFn';
export {
useBoolean,
useToggle,
Expand All @@ -26,5 +26,6 @@ export {
useDebounce,
useDebounceFn,
useThrottle,
useThrottleFn
};
useThrottleFn,
useFDF,
};

0 comments on commit 1f988d0

Please sign in to comment.