25 changed files with 137 additions and 26 deletions
@ -0,0 +1,10 @@ |
|||||
|
<template> |
||||
|
<ClientComp></ClientComp> |
||||
|
</template> |
||||
|
<script setup> |
||||
|
import { defineClientComponent } from 'vitepress' |
||||
|
|
||||
|
const ClientComp = defineClientComponent(() => { |
||||
|
return import('./demo.vue') |
||||
|
}) |
||||
|
</script> |
@ -0,0 +1,10 @@ |
|||||
|
<template> |
||||
|
<ClientComp></ClientComp> |
||||
|
</template> |
||||
|
<script setup> |
||||
|
import { defineClientComponent } from 'vitepress' |
||||
|
|
||||
|
const ClientComp = defineClientComponent(() => { |
||||
|
return import('./demo.vue') |
||||
|
}) |
||||
|
</script> |
@ -0,0 +1,10 @@ |
|||||
|
<template> |
||||
|
<ClientComp></ClientComp> |
||||
|
</template> |
||||
|
<script setup> |
||||
|
import { defineClientComponent } from 'vitepress' |
||||
|
|
||||
|
const ClientComp = defineClientComponent(() => { |
||||
|
return import('./demo.vue') |
||||
|
}) |
||||
|
</script> |
@ -0,0 +1 @@ |
|||||
|
export * from "./padLeftZero"; |
@ -0,0 +1,20 @@ |
|||||
|
import { padLeftZero } from "../index"; |
||||
|
|
||||
|
describe("padLeftZero", async () => { |
||||
|
it("常规补0", async () => { |
||||
|
const str = "aa"; |
||||
|
expect(padLeftZero(str, 3)).toStrictEqual("0aa"); |
||||
|
}); |
||||
|
it("超出长度", async () => { |
||||
|
const str = "aaaaaa"; |
||||
|
expect(padLeftZero(str, 3)).toStrictEqual("aaaaaa"); |
||||
|
}); |
||||
|
it("长度相等", async () => { |
||||
|
const str = "aaa"; |
||||
|
expect(padLeftZero(str, 3)).toStrictEqual("aaa"); |
||||
|
}); |
||||
|
it("空字符串", async () => { |
||||
|
const str = ""; |
||||
|
expect(padLeftZero(str, 3)).toStrictEqual("000"); |
||||
|
}); |
||||
|
}); |
@ -0,0 +1,13 @@ |
|||||
|
/** |
||||
|
* 用来在字符串前面补0 |
||||
|
* @param str 字符串 |
||||
|
* @returns 补0后的字符串 |
||||
|
*/ |
||||
|
export function padLeftZero(str: string, len: number) { |
||||
|
if (typeof str !== "string") return str; |
||||
|
if (str.padStart) { |
||||
|
return str.padStart(len, "0"); |
||||
|
} |
||||
|
if (str.length >= len) return str; |
||||
|
return (Array(len).fill("0").join("") + str).substr(str.length); |
||||
|
} |
@ -1,2 +1,3 @@ |
|||||
export * from "./date"; |
export * from "./date"; |
||||
|
export * from "./common"; |
||||
export * from "./debounce"; |
export * from "./debounce"; |
||||
|
@ -0,0 +1,10 @@ |
|||||
|
<template> |
||||
|
<ClientComp></ClientComp> |
||||
|
</template> |
||||
|
<script setup> |
||||
|
import { defineClientComponent } from 'vitepress' |
||||
|
|
||||
|
const ClientComp = defineClientComponent(() => { |
||||
|
return import('./demo.vue') |
||||
|
}) |
||||
|
</script> |
@ -0,0 +1,10 @@ |
|||||
|
<template> |
||||
|
<ClientComp></ClientComp> |
||||
|
</template> |
||||
|
<script setup> |
||||
|
import { defineClientComponent } from 'vitepress' |
||||
|
|
||||
|
const ClientComp = defineClientComponent(() => { |
||||
|
return import('./demo.vue') |
||||
|
}) |
||||
|
</script> |
@ -0,0 +1,8 @@ |
|||||
|
<template> |
||||
|
<ClientOnly> |
||||
|
<Demo></Demo> |
||||
|
</ClientOnly> |
||||
|
</template> |
||||
|
<script setup> |
||||
|
import Demo from './demo.vue'; |
||||
|
</script> |
@ -0,0 +1,8 @@ |
|||||
|
<template> |
||||
|
<ClientOnly> |
||||
|
<Demo></Demo> |
||||
|
</ClientOnly> |
||||
|
</template> |
||||
|
<script setup> |
||||
|
import Demo from './demo.vue'; |
||||
|
</script> |
@ -0,0 +1,11 @@ |
|||||
|
import { startVitest } from "vitest/node"; |
||||
|
|
||||
|
const [dir] = process.argv.slice(2); |
||||
|
|
||||
|
if (dir) { |
||||
|
startVitest("test", [], { |
||||
|
root: `./packages/${dir}`, |
||||
|
}); |
||||
|
} else { |
||||
|
startVitest("test"); |
||||
|
} |
Loading…
Reference in new issue