├── .nvmrc ├── .gitattributes ├── playgrounds ├── solid │ ├── .gitignore │ ├── src │ │ ├── assets │ │ │ └── favicon.ico │ │ ├── index.tsx │ │ ├── App.tsx │ │ ├── index.css │ │ ├── App.module.css │ │ └── logo.svg │ ├── vite.config.ts │ ├── tsconfig.json │ ├── package.json │ └── index.html ├── preact │ ├── src │ │ ├── preact.d.ts │ │ ├── vite-env.d.ts │ │ ├── main.tsx │ │ ├── app.tsx │ │ ├── app.css │ │ ├── assets │ │ │ └── preact.svg │ │ └── index.css │ ├── tsconfig.node.json │ ├── vite.config.ts │ ├── .gitignore │ ├── index.html │ ├── package.json │ ├── tsconfig.json │ └── public │ │ └── vite.svg ├── react │ ├── src │ │ ├── vite-env.d.ts │ │ ├── main.tsx │ │ ├── App.tsx │ │ ├── App.css │ │ └── index.css │ ├── tsconfig.node.json │ ├── vite.config.ts │ ├── .gitignore │ ├── index.html │ ├── package.json │ ├── tsconfig.json │ └── public │ │ └── vite.svg ├── next │ ├── .eslintrc.json │ ├── app │ │ ├── favicon.ico │ │ ├── page.tsx │ │ ├── layout.tsx │ │ └── globals.css │ ├── next.config.js │ ├── postcss.config.js │ ├── .gitignore │ ├── tailwind.config.ts │ ├── public │ │ ├── vercel.svg │ │ └── next.svg │ ├── tsconfig.json │ └── package.json ├── vue-vite │ ├── src │ │ ├── vite-env.d.ts │ │ ├── main.ts │ │ ├── assets │ │ │ └── vue.svg │ │ ├── App.vue │ │ ├── components │ │ │ └── HelloWorld.vue │ │ └── style.css │ ├── .vscode │ │ └── extensions.json │ ├── vite.config.ts │ ├── tsconfig.node.json │ ├── .gitignore │ ├── index.html │ ├── package.json │ ├── tsconfig.json │ └── public │ │ └── vite.svg ├── svelte │ ├── .vscode │ │ └── extensions.json │ ├── src │ │ ├── vite-env.d.ts │ │ ├── main.ts │ │ ├── App.svelte │ │ ├── lib │ │ │ └── Counter.svelte │ │ ├── app.css │ │ └── assets │ │ │ └── svelte.svg │ ├── tsconfig.node.json │ ├── svelte.config.js │ ├── vite.config.ts │ ├── .gitignore │ ├── index.html │ ├── package.json │ ├── tsconfig.json │ └── public │ │ └── vite.svg ├── nuxt3 │ └── README.md ├── vue-cli │ ├── babel.config.js │ ├── src │ │ ├── main.js │ │ ├── assets │ │ │ └── logo.png │ │ └── App.vue │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ ├── vue.config.js │ ├── .gitignore │ ├── jsconfig.json │ └── package.json ├── node │ ├── .gitignore │ ├── package.json │ └── index.js └── html │ ├── index.html │ └── hooks │ ├── useWatermark.html │ └── useDark.html ├── .npmrc ├── docs ├── public │ ├── logo.png │ ├── avatar.jpg │ ├── echarts1.jpg │ ├── echarts2.jpg │ ├── favicon.ico │ ├── pwa-192x192.png │ ├── pwa-512x512.png │ ├── custom-theme.jpg │ ├── apple-touch-icon.png │ ├── start.svg │ ├── favicon.svg │ ├── table.svg │ ├── github.svg │ └── logo.svg ├── utils │ ├── mouseEvent │ │ ├── types │ │ │ └── mouse.ts │ │ ├── banMouseEvent.vue │ │ ├── allowMouseEvent.vue │ │ └── mouseEvent.md │ ├── link │ │ ├── types │ │ │ └── openLink.ts │ │ ├── link.vue │ │ └── link.md │ ├── download │ │ ├── types │ │ │ └── downloadByUrl.ts │ │ ├── downloadByOnlineUrl.vue │ │ ├── downloadByUrl.vue │ │ └── downloadByData.vue │ ├── debounce │ │ ├── types │ │ │ └── debounce.ts │ │ ├── delay.vue │ │ ├── throttle.vue │ │ └── debounce.vue │ ├── device │ │ ├── types │ │ │ └── getBrowserInfo.ts │ │ ├── deviceDetection.vue │ │ └── getBrowserInfo.vue │ ├── substring │ │ ├── types │ │ │ └── hideTextAtIndex.ts │ │ ├── splitNum.vue │ │ ├── subAfter.vue │ │ ├── subBefore.vue │ │ ├── subBothSides.vue │ │ ├── subBetween.vue │ │ ├── subTextAddEllipsis.vue │ │ └── hideTextAtIndex.vue │ ├── amount │ │ ├── types │ │ │ └── priceToThousands.ts │ │ ├── addZero.vue │ │ ├── dollarsToCents.vue │ │ ├── centsToDollars.vue │ │ ├── getDecimalPlaces.vue │ │ ├── priceUppercase.vue │ │ └── priceToThousands.vue │ ├── date │ │ ├── types │ │ │ ├── getTime.ts │ │ │ └── getCurrentDate.ts │ │ ├── monthDays.vue │ │ ├── getCurrentWeek.vue │ │ ├── createYear.vue │ │ ├── getCurrentDate.vue │ │ ├── getTime.vue │ │ └── dateFormat.vue │ ├── packageSize │ │ ├── types │ │ │ └── getPackageSize.ts │ │ └── packageSize.md │ ├── color │ │ ├── types │ │ │ ├── randomColor.ts │ │ │ └── randomGradient.ts │ │ ├── hexToRgb.vue │ │ ├── rgbToHex.vue │ │ ├── randomColor.vue │ │ ├── darken.vue │ │ ├── lighten.vue │ │ └── randomGradient.vue │ ├── svg │ │ ├── types │ │ │ └── getSvgInfo.ts │ │ └── svg.md │ ├── is │ │ └── types │ │ │ └── hasCNChars.ts │ ├── base64Conver │ │ ├── types │ │ │ └── convertImageToGray.ts │ │ ├── convertImageToGray.vue │ │ └── urlToBase64.vue │ ├── url │ │ ├── getLocation.vue │ │ ├── getQueryMap.vue │ │ └── url.md │ ├── array │ │ ├── types │ │ │ └── randomDivide.ts │ │ ├── getKeyList.vue │ │ ├── intersection.vue │ │ ├── extractFields.vue │ │ ├── swapOrder.vue │ │ ├── randomDivide.vue │ │ ├── arrayAnyExist.vue │ │ ├── arrayAllExist.vue │ │ ├── isIncludeAllChildren.vue │ │ ├── arrayAllExistDeep.vue │ │ └── arrayAnyExistDeep.vue │ ├── class │ │ ├── getClass.vue │ │ ├── hasClass.vue │ │ ├── addClass.vue │ │ ├── removeClass.vue │ │ └── toggleClass.vue │ ├── math │ │ ├── addition.vue │ │ ├── formatBytes.vue │ │ ├── subtraction.vue │ │ ├── multiplication.vue │ │ ├── divisionOperation.vue │ │ ├── sum.vue │ │ ├── max.vue │ │ ├── min.vue │ │ ├── average.vue │ │ └── numberToChinese.vue │ ├── formData │ │ └── types │ │ │ └── createFormData.ts │ ├── clone │ │ ├── hasOwnProp.vue │ │ ├── cloneDeep.vue │ │ └── clone.vue │ ├── performance │ │ └── performance.md │ ├── nameTransform │ │ ├── nameCamelize.vue │ │ ├── nameHyphenate.vue │ │ └── nameTransform.md │ ├── uuid │ │ ├── buildGUID.vue │ │ ├── buildUUID.vue │ │ ├── uuid.vue │ │ └── buildPrefixUUID.vue │ ├── object │ │ └── object.md │ ├── convertPath │ │ ├── convertPath.md │ │ └── convertPath.vue │ ├── equal │ │ ├── isEqualArray.vue │ │ └── isEqualObject.vue │ ├── space │ │ ├── removeAllSpace.vue │ │ ├── removeLeftSpace.vue │ │ ├── removeRightSpace.vue │ │ └── removeBothSidesSpace.vue │ ├── install │ │ └── install.md │ └── storage │ │ ├── storage.md │ │ └── storageLocal.vue ├── components │ ├── divider │ │ ├── type.vue │ │ ├── use.vue │ │ ├── options.vue │ │ ├── target.vue │ │ ├── param.vue │ │ └── base.vue │ ├── preview-image.vue │ ├── visual-load.vue │ ├── message.ts │ ├── theme-change.vue │ ├── description-popover.vue │ ├── typeit.ts │ ├── description.vue │ ├── wordcloud │ │ └── data.ts │ ├── theme.vue │ ├── index.ts │ └── layout.vue ├── hooks │ ├── useGlobal │ │ ├── demo.vue │ │ └── useGlobal.md │ ├── useLoader │ │ └── types │ │ │ └── useLoader.ts │ ├── useResizeObserver │ │ ├── types │ │ │ └── useResizeObserver.ts │ │ ├── demo2.vue │ │ └── demo1.vue │ ├── useDark │ │ └── dark.vue │ ├── useWatermark │ │ └── demo │ │ │ ├── index.ts │ │ │ ├── forever.vue │ │ │ ├── wrap.vue │ │ │ └── image.vue │ ├── useECharts │ │ └── demo │ │ │ ├── business │ │ │ ├── index.ts │ │ │ └── customTheme.vue │ │ │ ├── advanced │ │ │ └── index.ts │ │ │ └── simple │ │ │ ├── gauge.vue │ │ │ ├── candlestick.vue │ │ │ ├── bar.vue │ │ │ ├── line.vue │ │ │ ├── radar.vue │ │ │ ├── scatter.vue │ │ │ ├── pie.vue │ │ │ ├── sankey.vue │ │ │ └── sunburst.vue │ ├── useCopyToClipboard │ │ ├── code.vue │ │ └── input.vue │ └── useDraggable │ │ ├── naiveuiBase.vue │ │ └── naiveuiDialog.vue ├── .vitepress │ ├── plugins │ │ ├── echarts.ts │ │ └── wordcloud │ │ │ └── WordCloudSeries.js │ ├── utils │ │ └── sortHooks.ts │ └── theme │ │ └── style │ │ └── code.css ├── global.d.ts ├── client.d.ts └── guide │ ├── tags.vue │ └── guide.md ├── .vscode ├── extensions.json └── vue3.2.code-snippets ├── .prettierignore ├── .prettierrc.js ├── unocss.config.ts ├── README.md ├── tsconfig.json ├── LICENSE └── .gitignore /.nvmrc: -------------------------------------------------------------------------------- 1 | v22.13.0 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.css linguist-language=Typescript -------------------------------------------------------------------------------- /playgrounds/solid/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist -------------------------------------------------------------------------------- /playgrounds/preact/src/preact.d.ts: -------------------------------------------------------------------------------- 1 | import JSX = preact.JSX 2 | -------------------------------------------------------------------------------- /playgrounds/preact/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /playgrounds/react/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /playgrounds/next/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | shamefully-hoist=true 2 | strict-peer-dependencies=false 3 | shell-emulator=true -------------------------------------------------------------------------------- /docs/public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/docs/public/logo.png -------------------------------------------------------------------------------- /docs/utils/mouseEvent/types/mouse.ts: -------------------------------------------------------------------------------- 1 | export type MouseEvent = "contextmenu" | "selectstart" | "copy"; 2 | -------------------------------------------------------------------------------- /playgrounds/svelte/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["svelte.svelte-vscode"] 3 | } 4 | -------------------------------------------------------------------------------- /docs/public/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/docs/public/avatar.jpg -------------------------------------------------------------------------------- /docs/utils/link/types/openLink.ts: -------------------------------------------------------------------------------- 1 | export type Target = "_blank" | "_self" | "_parent" | "_top" | "framename"; 2 | -------------------------------------------------------------------------------- /docs/public/echarts1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/docs/public/echarts1.jpg -------------------------------------------------------------------------------- /docs/public/echarts2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/docs/public/echarts2.jpg -------------------------------------------------------------------------------- /docs/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/docs/public/favicon.ico -------------------------------------------------------------------------------- /playgrounds/nuxt3/README.md: -------------------------------------------------------------------------------- 1 | 仓库地址:[pure-admin-utils-nuxt3](https://github.com/pure-admin/pure-admin-utils-nuxt3) 2 | -------------------------------------------------------------------------------- /playgrounds/svelte/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /docs/public/pwa-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/docs/public/pwa-192x192.png -------------------------------------------------------------------------------- /docs/public/pwa-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/docs/public/pwa-512x512.png -------------------------------------------------------------------------------- /docs/utils/download/types/downloadByUrl.ts: -------------------------------------------------------------------------------- 1 | export type Target = "_blank" | "_self" | "_parent" | "_top" | "framename"; 2 | -------------------------------------------------------------------------------- /docs/public/custom-theme.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/docs/public/custom-theme.jpg -------------------------------------------------------------------------------- /playgrounds/vue-cli/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /docs/public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/docs/public/apple-touch-icon.png -------------------------------------------------------------------------------- /playgrounds/next/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/playgrounds/next/app/favicon.ico -------------------------------------------------------------------------------- /playgrounds/vue-vite/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] 3 | } 4 | -------------------------------------------------------------------------------- /playgrounds/vue-cli/src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import App from './App.vue' 3 | 4 | createApp(App).mount('#app') 5 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "esbenp.prettier-vscode", 4 | "antfu.unocss", 5 | "Vue.volar" 6 | ] 7 | } -------------------------------------------------------------------------------- /docs/components/divider/type.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /playgrounds/next/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = {} 3 | 4 | module.exports = nextConfig 5 | -------------------------------------------------------------------------------- /playgrounds/next/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /docs/components/divider/use.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /playgrounds/solid/src/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/playgrounds/solid/src/assets/favicon.ico -------------------------------------------------------------------------------- /playgrounds/vue-cli/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/playgrounds/vue-cli/public/favicon.ico -------------------------------------------------------------------------------- /playgrounds/vue-cli/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pure-admin/pure-admin-utils-docs/HEAD/playgrounds/vue-cli/src/assets/logo.png -------------------------------------------------------------------------------- /docs/components/divider/options.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /docs/components/divider/target.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /docs/utils/debounce/types/debounce.ts: -------------------------------------------------------------------------------- 1 | export type FunctionArgs = ( 2 | ...args: Args 3 | ) => Return; 4 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import './style.css' 3 | import App from './App.vue' 4 | 5 | createApp(App).mount('#app') 6 | -------------------------------------------------------------------------------- /docs/utils/device/types/getBrowserInfo.ts: -------------------------------------------------------------------------------- 1 | export interface BrowserType { 2 | /** 浏览器型号 */ 3 | browser: string; 4 | /** 浏览器版本 */ 5 | version: string; 6 | } 7 | -------------------------------------------------------------------------------- /playgrounds/vue-cli/vue.config.js: -------------------------------------------------------------------------------- 1 | const { defineConfig } = require('@vue/cli-service') 2 | module.exports = defineConfig({ 3 | transpileDependencies: true 4 | }) 5 | -------------------------------------------------------------------------------- /docs/utils/substring/types/hideTextAtIndex.ts: -------------------------------------------------------------------------------- 1 | export interface HideTextIndex { 2 | /** 文字隐藏的开始位置 */ 3 | start: number; 4 | /** 文字隐藏的结束位置 */ 5 | end: number; 6 | } 7 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .DS_Store 3 | playgrounds 4 | pnpm-lock.yaml 5 | config.*.timestamp* 6 | docs/dev-dist 7 | docs/.vitepress/dist 8 | docs/.vitepress/.temp 9 | docs/.vitepress/cache -------------------------------------------------------------------------------- /docs/utils/amount/types/priceToThousands.ts: -------------------------------------------------------------------------------- 1 | export interface AmountOpt { 2 | /** 保留几位小数,默认 `0` */ 3 | digit?: number; 4 | /** 小数位是否四舍五入,默认 `false` 不进行四舍五入 */ 5 | round?: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /docs/utils/date/types/getTime.ts: -------------------------------------------------------------------------------- 1 | export interface hmsType { 2 | /** 小时 */ 3 | h: number | string; 4 | /** 分钟 */ 5 | m: number | string; 6 | /** 秒 */ 7 | s: number | string; 8 | } 9 | -------------------------------------------------------------------------------- /playgrounds/preact/src/main.tsx: -------------------------------------------------------------------------------- 1 | import { render } from 'preact' 2 | import { App } from './app' 3 | import './index.css' 4 | 5 | render(, document.getElementById('app') as HTMLElement) 6 | -------------------------------------------------------------------------------- /playgrounds/svelte/src/main.ts: -------------------------------------------------------------------------------- 1 | import './app.css' 2 | import App from './App.svelte' 3 | 4 | const app = new App({ 5 | target: document.getElementById('app') 6 | }) 7 | 8 | export default app 9 | -------------------------------------------------------------------------------- /playgrounds/preact/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "module": "ESNext", 5 | "moduleResolution": "Node" 6 | }, 7 | "include": ["vite.config.ts"] 8 | } 9 | -------------------------------------------------------------------------------- /playgrounds/react/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "module": "ESNext", 5 | "moduleResolution": "Node" 6 | }, 7 | "include": ["vite.config.ts"] 8 | } 9 | -------------------------------------------------------------------------------- /playgrounds/svelte/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "module": "ESNext", 5 | "moduleResolution": "Node" 6 | }, 7 | "include": ["vite.config.ts"] 8 | } 9 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import vue from '@vitejs/plugin-vue' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [vue()], 7 | }) 8 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | /** @type {import("prettier").Config} */ 4 | export default { 5 | bracketSpacing: true, 6 | singleQuote: false, 7 | arrowParens: "avoid", 8 | trailingComma: "none" 9 | }; 10 | -------------------------------------------------------------------------------- /docs/hooks/useGlobal/demo.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /playgrounds/solid/src/index.tsx: -------------------------------------------------------------------------------- 1 | /* @refresh reload */ 2 | import { render } from 'solid-js/web'; 3 | 4 | import './index.css'; 5 | import App from './App'; 6 | 7 | render(() => , document.getElementById('root') as HTMLElement); 8 | -------------------------------------------------------------------------------- /docs/.vitepress/plugins/echarts.ts: -------------------------------------------------------------------------------- 1 | import { type App } from "vue"; 2 | import * as echarts from "echarts"; 3 | 4 | export function useECharts(app: App) { 5 | app.config.globalProperties.$echarts = echarts; 6 | } 7 | 8 | export default echarts; 9 | -------------------------------------------------------------------------------- /playgrounds/svelte/src/App.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 |
6 |

{ `${dateFormat("YYYY/MM/DD HH:mm")} ${getCurrentWeek()} ${uuid()}` }

7 |
8 | -------------------------------------------------------------------------------- /docs/components/divider/param.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | -------------------------------------------------------------------------------- /docs/utils/packageSize/types/getPackageSize.ts: -------------------------------------------------------------------------------- 1 | export type packageOpt = { 2 | /** 文件夹名(默认:`dist`) */ 3 | folder?: string; 4 | /** 是否返回已经转化好单位的包总大小(默认:`true`) */ 5 | format?: boolean; 6 | /** 回调函数,返回包总大小(单位:字节) */ 7 | callback: CallableFunction; 8 | }; 9 | -------------------------------------------------------------------------------- /playgrounds/svelte/svelte.config.js: -------------------------------------------------------------------------------- 1 | import sveltePreprocess from 'svelte-preprocess' 2 | 3 | export default { 4 | // Consult https://github.com/sveltejs/svelte-preprocess 5 | // for more information about preprocessors 6 | preprocess: sveltePreprocess() 7 | } 8 | -------------------------------------------------------------------------------- /docs/global.d.ts: -------------------------------------------------------------------------------- 1 | // global.d.ts 2 | import type { ECharts } from "echarts"; 3 | 4 | // 在 declare global 中声明后项目中所有组件实例都能访问到全局属性对象的类型 5 | declare global { 6 | interface GlobalPropertiesApi { 7 | $echarts: ECharts; 8 | // ... 填写其他的全局属性类型 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /docs/utils/color/types/randomColor.ts: -------------------------------------------------------------------------------- 1 | export type ColorType = "rgb" | "hex" | "hsl"; 2 | export interface ColorOptions { 3 | /** 颜色格式 `rgb` 、 `hex` 、 `hsl` ,默认 `rgb` */ 4 | type?: ColorType; 5 | /** 生成颜色的数量。指定数量,则返回生成颜色数组,数量为 `0` 或不指定,返回生成颜色字符串 */ 6 | num?: number; 7 | } 8 | -------------------------------------------------------------------------------- /docs/.vitepress/utils/sortHooks.ts: -------------------------------------------------------------------------------- 1 | // 指定hooks顺序 2 | export const hooks = [ 3 | "useECharts", 4 | "useDraggable", 5 | "useWatermark", 6 | "useResizeObserver", 7 | "useDark", 8 | "useScrollTo", 9 | "useLoader", 10 | "useCopyToClipboard", 11 | "useGlobal" 12 | ]; 13 | -------------------------------------------------------------------------------- /docs/utils/svg/types/getSvgInfo.ts: -------------------------------------------------------------------------------- 1 | export interface SvgInfo { 2 | /** SVG的宽度,基于`viewBox`属性的第三个值 */ 3 | width: number; 4 | /** SVG的高度,基于`viewBox`属性的第四个值 */ 5 | height: number; 6 | /** `` 元素内部的所有 HTML 内容(即 `innerHTML`),包含所有子元素如 ``, ``, `` 等 */ 7 | body: string; 8 | }; 9 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /playgrounds/preact/src/app.tsx: -------------------------------------------------------------------------------- 1 | import './app.css' 2 | import { dateFormat, getCurrentWeek, uuid } from '@pureadmin/utils' 3 | 4 | export function App() { 5 | return ( 6 | <> 7 |

{ `${dateFormat("YYYY/MM/DD HH:mm")} ${getCurrentWeek()} ${uuid()}` }

8 | 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /playgrounds/react/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import App from './App' 4 | import './index.css' 5 | 6 | ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( 7 | 8 | 9 | 10 | ) 11 | -------------------------------------------------------------------------------- /docs/components/preview-image.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 14 | -------------------------------------------------------------------------------- /docs/utils/is/types/hasCNChars.ts: -------------------------------------------------------------------------------- 1 | export interface isParams { 2 | /** 自定义 `unicode`,不会覆盖默认的 `unicode` */ 3 | unicode?: string; 4 | /** 自定义 `unicode`,会覆盖默认的 `unicode` */ 5 | replaceUnicode?: string; 6 | /** 是否全部是中文,默认 `false` */ 7 | all?: boolean; 8 | /** 是否删除全部空格,默认 `false` */ 9 | pure?: boolean; 10 | } 11 | -------------------------------------------------------------------------------- /playgrounds/preact/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import preact from '@preact/preset-vite'; 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [preact()], 7 | resolve: { 8 | alias: { 9 | 'vue': '@pureadmin/utils/alias' 10 | } 11 | }, 12 | }); 13 | -------------------------------------------------------------------------------- /playgrounds/react/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import react from '@vitejs/plugin-react'; 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | resolve: { 8 | alias: { 9 | 'vue': '@pureadmin/utils/alias' 10 | } 11 | }, 12 | }); 13 | -------------------------------------------------------------------------------- /.vscode/vue3.2.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "Vue3.2+快速生成模板": { 3 | "prefix": "Vue3.2+", 4 | "body": [ 5 | "\n", 7 | "\n", 11 | "$2" 12 | ], 13 | "description": "Vue3.2+" 14 | } 15 | } -------------------------------------------------------------------------------- /playgrounds/next/app/page.tsx: -------------------------------------------------------------------------------- 1 | import { dateFormat, getCurrentWeek, uuid } from '@pureadmin/utils' 2 | // https://pure-admin-utils.netlify.app/ 3 | 4 | export default function Home() { 5 | return ( 6 |
7 |

{ `${dateFormat("YYYY/MM/DD HH:mm")} ${getCurrentWeek()} ${uuid()}` }

8 |
9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /docs/utils/base64Conver/types/convertImageToGray.ts: -------------------------------------------------------------------------------- 1 | interface grayOpt { 2 | /** `RGB`颜色模型中的红色,默认`0.3` */ 3 | red?: number; 4 | /** `RGB`颜色模型中的绿色,默认`0.59` */ 5 | green?: number; 6 | /** `RGB`颜色模型中的蓝色,默认`0.11` */ 7 | blue?: number; 8 | /** 使用`canvas`缩放图像比例,默认`1`不缩放保持原始比例,建议范围`0.2 < scale < 2` */ 9 | scale?: number; 10 | } 11 | -------------------------------------------------------------------------------- /playgrounds/svelte/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import { svelte } from '@sveltejs/vite-plugin-svelte'; 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [svelte()], 7 | resolve: { 8 | alias: { 9 | 'vue': '@pureadmin/utils/alias' 10 | } 11 | }, 12 | }); 13 | -------------------------------------------------------------------------------- /playgrounds/react/src/App.tsx: -------------------------------------------------------------------------------- 1 | import './App.css' 2 | import { dateFormat, getCurrentWeek, uuid } from '@pureadmin/utils' 3 | 4 | function App() { 5 | return ( 6 |
7 |

{ `${dateFormat("YYYY/MM/DD HH:mm")} ${getCurrentWeek()} ${uuid()}` }

8 |
9 | ); 10 | } 11 | 12 | export default App; 13 | -------------------------------------------------------------------------------- /playgrounds/solid/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import solidPlugin from 'vite-plugin-solid'; 3 | 4 | export default defineConfig({ 5 | plugins: [solidPlugin()], 6 | resolve: { 7 | alias: { 8 | 'vue': '@pureadmin/utils/alias' 9 | } 10 | }, 11 | server: { 12 | port: 3000, 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /docs/utils/url/getLocation.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 15 | -------------------------------------------------------------------------------- /docs/client.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module "*.vue" { 4 | import { DefineComponent } from "vue"; 5 | // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types 6 | const component: DefineComponent<{}, {}>; 7 | export default component; 8 | } 9 | 10 | declare module "echarts-gl"; 11 | -------------------------------------------------------------------------------- /docs/utils/array/types/randomDivide.ts: -------------------------------------------------------------------------------- 1 | export type OrderType = "asc" | "desc" | "random"; 2 | 3 | export interface DivideOptions { 4 | /** 每一份的最小阀值。默认`0` */ 5 | minPerPart?: number; 6 | /** 每一份的最大阀值。默认最大阀值不会超过总数 */ 7 | maxPerPart?: number; 8 | /** 返回数组的排序方式:递增(`'asc'`)、递减(`'desc'`)、随机(`'random'`)。默认为`'random'` */ 9 | order?: OrderType; 10 | } 11 | -------------------------------------------------------------------------------- /playgrounds/vue-cli/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /docs/public/start.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/utils/amount/addZero.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 14 | -------------------------------------------------------------------------------- /playgrounds/node/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /playgrounds/preact/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /playgrounds/react/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /playgrounds/svelte/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /docs/utils/amount/dollarsToCents.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 14 | -------------------------------------------------------------------------------- /docs/utils/link/link.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 16 | -------------------------------------------------------------------------------- /playgrounds/vue-cli/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "esnext", 5 | "baseUrl": "./", 6 | "moduleResolution": "node", 7 | "paths": { 8 | "@/*": [ 9 | "src/*" 10 | ] 11 | }, 12 | "lib": [ 13 | "esnext", 14 | "dom", 15 | "dom.iterable", 16 | "scripthost" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /docs/utils/amount/centsToDollars.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 14 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/src/assets/vue.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/utils/amount/getDecimalPlaces.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 14 | -------------------------------------------------------------------------------- /playgrounds/node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-demo", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "node index.js", 7 | "start": "node index.js" 8 | }, 9 | "dependencies": { 10 | "@koa/router": "^12.0.1", 11 | "@pureadmin/utils": "^2.1.1", 12 | "koa": "^2.14.2", 13 | "koa-logger": "^3.2.1", 14 | "koa-pino-logger": "^4.0.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /docs/components/divider/base.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 15 | 16 | 21 | -------------------------------------------------------------------------------- /docs/utils/class/getClass.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 16 | -------------------------------------------------------------------------------- /docs/utils/date/types/getCurrentDate.ts: -------------------------------------------------------------------------------- 1 | export interface currentDateType { 2 | /** 当前年月日 */ 3 | ymd: string; 4 | /** 当前时分秒 */ 5 | hms: string; 6 | /** 当前周几 */ 7 | week: string; 8 | } 9 | export type dateType = 1 | 2 | 3; 10 | export interface currentDateOpt { 11 | /** 当前返回的年月日和时分秒的格式 1:汉字模式(默认) 2:- 连接符 3:/ 连接符 */ 12 | type?: dateType; 13 | /** 自定义 `week` 返回格式前缀,默认 `星期` */ 14 | prefix?: string; 15 | } 16 | -------------------------------------------------------------------------------- /playgrounds/solid/src/App.tsx: -------------------------------------------------------------------------------- 1 | import type { Component } from 'solid-js'; 2 | 3 | import styles from './App.module.css'; 4 | import { dateFormat, getCurrentWeek, uuid } from '@pureadmin/utils' 5 | 6 | const App: Component = () => { 7 | return ( 8 |
9 |

{ `${dateFormat("YYYY/MM/DD HH:mm")} ${getCurrentWeek()} ${uuid()}` }

10 |
11 | ); 12 | }; 13 | 14 | export default App; 15 | -------------------------------------------------------------------------------- /playgrounds/solid/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "target": "ESNext", 5 | "module": "ESNext", 6 | "moduleResolution": "node", 7 | "allowSyntheticDefaultImports": true, 8 | "esModuleInterop": true, 9 | "jsx": "preserve", 10 | "jsxImportSource": "solid-js", 11 | "types": ["vite/client"], 12 | "noEmit": true, 13 | "isolatedModules": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /playgrounds/preact/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + Preact + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /playgrounds/react/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + React + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /playgrounds/solid/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /playgrounds/svelte/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + Svelte + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + Vue + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/hooks/useLoader/types/useLoader.ts: -------------------------------------------------------------------------------- 1 | declare type documentElement = "head" | "body"; 2 | export interface OptionsScript { 3 | /** 要加载的资源链接地址 */ 4 | src: string | string[]; 5 | /** 标签插入到哪个元素里。默认`CSS`(`link`标签)插入到`head`,`JavaScript`(`script`标签)插入到`body` */ 6 | element?: documentElement | HTMLElement; 7 | } 8 | export interface LoadResult { 9 | /** 加载的资源链接地址 */ 10 | src?: string; 11 | /** 加载状态(加载成功、加载失败) */ 12 | message?: string; 13 | } 14 | -------------------------------------------------------------------------------- /playgrounds/preact/src/app.css: -------------------------------------------------------------------------------- 1 | #app { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | text-align: center; 6 | } 7 | 8 | .logo { 9 | height: 6em; 10 | padding: 1.5em; 11 | } 12 | .logo:hover { 13 | filter: drop-shadow(0 0 2em #646cffaa); 14 | } 15 | .logo.preact:hover { 16 | filter: drop-shadow(0 0 2em #673ab8aa); 17 | } 18 | 19 | .card { 20 | padding: 2em; 21 | } 22 | 23 | .read-the-docs { 24 | color: #888; 25 | } 26 | -------------------------------------------------------------------------------- /docs/utils/math/addition.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 16 | -------------------------------------------------------------------------------- /docs/utils/class/hasClass.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 20 | -------------------------------------------------------------------------------- /docs/hooks/useResizeObserver/types/useResizeObserver.ts: -------------------------------------------------------------------------------- 1 | interface ElementRef { 2 | value: T; 3 | } 4 | interface UseResizeObserverOptions { 5 | /** 防抖延迟时间,默认`40`毫秒 */ 6 | time?: number; 7 | /** 初始化时是否立刻触发回调,默认`true` */ 8 | immediate?: boolean; 9 | /** `content-box`(默认)指的是元素的内容区域尺寸,不包括边框和内边距;`border-box`指的是元素的边框盒尺寸,包括内容、内边距和边框,但不包括外边距;`device-pixel-content-box`指的是设备像素级别观察尺寸变化 */ 10 | box?: "content-box" | "border-box" | "device-pixel-content-box"; 11 | } 12 | -------------------------------------------------------------------------------- /docs/utils/download/downloadByOnlineUrl.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 19 | -------------------------------------------------------------------------------- /docs/utils/math/formatBytes.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 16 | -------------------------------------------------------------------------------- /docs/utils/math/subtraction.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 16 | -------------------------------------------------------------------------------- /docs/utils/download/downloadByUrl.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 19 | -------------------------------------------------------------------------------- /docs/utils/url/getQueryMap.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 18 | -------------------------------------------------------------------------------- /docs/hooks/useDark/dark.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 19 | -------------------------------------------------------------------------------- /docs/utils/formData/types/createFormData.ts: -------------------------------------------------------------------------------- 1 | export interface HandleFileType { 2 | /** `File`或`Blob`文件 */ 3 | file?: File | Blob; 4 | /** 传过来的文件字段键名 */ 5 | key?: string; 6 | /** `new FormData()` 可以使用它的所有方法 */ 7 | formData?: FormData; 8 | } 9 | export interface FormDataOptions { 10 | /** 用于指定文件字段的键名,默认`file` */ 11 | fileKey?: string; 12 | /** 自定义处理文件的函数 */ 13 | handleFile?: (params: HandleFileType) => void; 14 | /** 定义需要过滤掉的值,它们不会出现在请求参数中 */ 15 | filter?: any[]; 16 | } 17 | -------------------------------------------------------------------------------- /playgrounds/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |

打开控制台查看所有utils

12 |

13 | 14 | 15 | 21 | 22 | -------------------------------------------------------------------------------- /docs/utils/color/hexToRgb.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 18 | -------------------------------------------------------------------------------- /docs/utils/math/multiplication.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 17 | -------------------------------------------------------------------------------- /docs/utils/math/divisionOperation.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 17 | -------------------------------------------------------------------------------- /playgrounds/preact/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "preact-demo", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "preview": "vite build && vite preview" 10 | }, 11 | "devDependencies": { 12 | "@preact/preset-vite": "^2.7.0", 13 | "typescript": "^5.3.3", 14 | "vite": "^5.0.10" 15 | }, 16 | "dependencies": { 17 | "@pureadmin/utils": "^2.1.1", 18 | "preact": "^10.19.3" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /docs/utils/date/monthDays.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 20 | -------------------------------------------------------------------------------- /docs/utils/amount/priceUppercase.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 17 | -------------------------------------------------------------------------------- /docs/utils/color/rgbToHex.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 20 | -------------------------------------------------------------------------------- /docs/hooks/useWatermark/demo/index.ts: -------------------------------------------------------------------------------- 1 | import { withInstall } from "@pureadmin/utils"; 2 | 3 | import wwhole from "./whole.vue"; 4 | import wpart from "./part.vue"; 5 | import wwrap from "./wrap.vue"; 6 | import wimage from "./image.vue"; 7 | import wforever from "./forever.vue"; 8 | 9 | const Wwhole = withInstall(wwhole); 10 | const Wpart = withInstall(wpart); 11 | const Wwrap = withInstall(wwrap); 12 | const Wimage = withInstall(wimage); 13 | const Wforever = withInstall(wforever); 14 | 15 | export { Wwhole, Wpart, Wwrap, Wimage, Wforever }; 16 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuevite-demo", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vue-tsc && vite build", 9 | "preview": "vite build && vite preview" 10 | }, 11 | "dependencies": { 12 | "@pureadmin/utils": "^2.1.1", 13 | "vue": "^3.4.0" 14 | }, 15 | "devDependencies": { 16 | "@vitejs/plugin-vue": "^5.0.0", 17 | "typescript": "^5.3.3", 18 | "vite": "^5.0.10", 19 | "vue-tsc": "^1.8.27" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /playgrounds/solid/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "solid-demo", 3 | "type": "module", 4 | "version": "0.0.0", 5 | "description": "", 6 | "scripts": { 7 | "start": "vite", 8 | "dev": "vite", 9 | "build": "vite build", 10 | "preview": "vite build && vite preview" 11 | }, 12 | "license": "MIT", 13 | "devDependencies": { 14 | "typescript": "^5.3.3", 15 | "vite": "^5.0.10", 16 | "vite-plugin-solid": "^2.8.0" 17 | }, 18 | "dependencies": { 19 | "@pureadmin/utils": "^2.1.1", 20 | "solid-js": "^1.8.7" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /unocss.config.ts: -------------------------------------------------------------------------------- 1 | import { 2 | transformerVariantGroup, 3 | transformerDirectives, 4 | presetAttributify, 5 | defineConfig, 6 | presetMini, 7 | presetUno 8 | } from "unocss"; 9 | 10 | // https://github.com/unocss/unocss#readme 11 | export default defineConfig({ 12 | content: { 13 | pipeline: { 14 | exclude: ["node_modules", "docs/.vitepress/dist", ".git", ".vscode"] 15 | } 16 | }, 17 | presets: [presetMini({ dark: "class" }), presetAttributify(), presetUno()], 18 | transformers: [transformerDirectives(), transformerVariantGroup()] 19 | }); 20 | -------------------------------------------------------------------------------- /playgrounds/next/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from 'next' 2 | import { Inter } from 'next/font/google' 3 | import './globals.css' 4 | 5 | const inter = Inter({ subsets: ['latin'] }) 6 | 7 | export const metadata: Metadata = { 8 | title: 'Create Next App', 9 | description: 'Generated by create next app', 10 | } 11 | 12 | export default function RootLayout({ 13 | children, 14 | }: { 15 | children: React.ReactNode 16 | }) { 17 | return ( 18 | 19 | {children} 20 | 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /playgrounds/svelte/src/lib/Counter.svelte: -------------------------------------------------------------------------------- 1 | 17 | 18 | 21 | -------------------------------------------------------------------------------- /docs/utils/clone/hasOwnProp.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 22 | -------------------------------------------------------------------------------- /playgrounds/next/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/src/App.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | 9 | 25 | -------------------------------------------------------------------------------- /playgrounds/solid/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Solid App 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /docs/utils/performance/performance.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | ::: tip 支持任意运行在浏览器的 `JavaScript` 语言 9 | 浏览器性能计时信息 10 | ::: 11 | 12 | ## getPerformance 13 | 14 | 获取当前页面在加载和使用期间发生各种事件的性能计时信息 15 | 16 |
17 | 18 | 19 | 20 |
21 | 22 | 查看代码 23 | 24 | <<< @/utils/performance/getPerformance.vue 25 | 26 |
27 | 28 |
29 | -------------------------------------------------------------------------------- /docs/utils/download/downloadByData.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 23 | -------------------------------------------------------------------------------- /docs/utils/nameTransform/nameCamelize.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 19 | -------------------------------------------------------------------------------- /playgrounds/next/tailwind.config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from 'tailwindcss' 2 | 3 | const config: Config = { 4 | content: [ 5 | './pages/**/*.{js,ts,jsx,tsx,mdx}', 6 | './components/**/*.{js,ts,jsx,tsx,mdx}', 7 | './app/**/*.{js,ts,jsx,tsx,mdx}', 8 | ], 9 | theme: { 10 | extend: { 11 | backgroundImage: { 12 | 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))', 13 | 'gradient-conic': 14 | 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))', 15 | }, 16 | }, 17 | }, 18 | plugins: [], 19 | } 20 | export default config 21 | -------------------------------------------------------------------------------- /docs/components/visual-load.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 24 | -------------------------------------------------------------------------------- /docs/utils/mouseEvent/banMouseEvent.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 17 | -------------------------------------------------------------------------------- /docs/utils/nameTransform/nameHyphenate.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 21 | -------------------------------------------------------------------------------- /playgrounds/next/public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/components/message.ts: -------------------------------------------------------------------------------- 1 | import { 2 | darkTheme, 3 | lightTheme, 4 | createDiscreteApi, 5 | ConfigProviderProps 6 | } from "naive-ui"; 7 | import { computed } from "vue"; 8 | import { useData } from "vitepress"; 9 | 10 | export function useMessage() { 11 | const { isDark } = useData(); 12 | 13 | const configProviderPropsRef = computed(() => ({ 14 | theme: isDark.value ? darkTheme : lightTheme 15 | })); 16 | 17 | const { message } = createDiscreteApi(["message"], { 18 | configProviderProps: configProviderPropsRef 19 | }); 20 | 21 | return { 22 | message 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /docs/utils/math/sum.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /playgrounds/react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-demo", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "preview": "vite build && vite preview" 10 | }, 11 | "dependencies": { 12 | "@pureadmin/utils": "^2.1.1", 13 | "react": "^18.2.0", 14 | "react-dom": "^18.2.0" 15 | }, 16 | "devDependencies": { 17 | "@types/react": "^18.2.46", 18 | "@types/react-dom": "^18.2.18", 19 | "@vitejs/plugin-react": "^4.2.1", 20 | "typescript": "^5.3.3", 21 | "vite": "^5.0.10" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /docs/utils/math/max.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /docs/utils/math/min.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /docs/hooks/useECharts/demo/business/index.ts: -------------------------------------------------------------------------------- 1 | import { withInstall } from "@pureadmin/utils"; 2 | 3 | import edynamic from "./dynamic.vue"; 4 | import erequest from "./request.vue"; 5 | import eloading from "./loading.vue"; 6 | import ecustomTheme from "./customTheme.vue"; 7 | 8 | const Edynamic = withInstall(edynamic); 9 | const Erequest = withInstall(erequest); 10 | const Eloading = withInstall(eloading); 11 | const EcustomTheme = withInstall(ecustomTheme); 12 | 13 | export { 14 | /** 加载动画 */ 15 | Eloading, 16 | /** 动态图表 */ 17 | Edynamic, 18 | /** 接口请求 */ 19 | Erequest, 20 | /** 自定义主题 */ 21 | EcustomTheme 22 | }; 23 | -------------------------------------------------------------------------------- /docs/hooks/useECharts/demo/advanced/index.ts: -------------------------------------------------------------------------------- 1 | import { withInstall } from "@pureadmin/utils"; 2 | 3 | import edemo1 from "./demo1.vue"; 4 | import edemo2 from "./demo2.vue"; 5 | import edemo3 from "./demo3.vue"; 6 | import edemo4 from "./demo4.vue"; 7 | import edemo5 from "./demo5.vue"; 8 | import edemo6 from "./demo6.vue"; 9 | 10 | const Edemo1 = withInstall(edemo1); 11 | const Edemo2 = withInstall(edemo2); 12 | const Edemo3 = withInstall(edemo3); 13 | const Edemo4 = withInstall(edemo4); 14 | const Edemo5 = withInstall(edemo5); 15 | const Edemo6 = withInstall(edemo6); 16 | 17 | export { Edemo1, Edemo2, Edemo3, Edemo4, Edemo5, Edemo6 }; 18 | -------------------------------------------------------------------------------- /docs/utils/uuid/buildGUID.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /docs/utils/uuid/buildUUID.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /playgrounds/node/index.js: -------------------------------------------------------------------------------- 1 | const Koa = require('koa') 2 | const logger = require('koa-logger') 3 | const router = require('@koa/router')() 4 | const { dateFormat, getCurrentWeek, uuid } = require('@pureadmin/utils') 5 | // https://pure-admin-utils.netlify.app/ 6 | 7 | const app = new Koa() 8 | 9 | // middlewares 10 | 11 | app.use(logger()) 12 | 13 | 14 | const helloWorld = ctx => { 15 | ctx.body = `${dateFormat("YYYY/MM/DD HH:mm")} ${getCurrentWeek()} ${uuid()}` 16 | } 17 | 18 | router.get('/', helloWorld) 19 | 20 | app.use(router.routes()) 21 | 22 | app.listen(3000, () => { 23 | console.log('Server Address: http://localhost:3000 ') 24 | }) 25 | -------------------------------------------------------------------------------- /docs/utils/math/average.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /docs/utils/substring/splitNum.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 21 | -------------------------------------------------------------------------------- /playgrounds/solid/src/App.module.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .logo { 6 | animation: logo-spin infinite 20s linear; 7 | height: 40vmin; 8 | pointer-events: none; 9 | } 10 | 11 | .header { 12 | background-color: #282c34; 13 | min-height: 100vh; 14 | display: flex; 15 | flex-direction: column; 16 | align-items: center; 17 | justify-content: center; 18 | font-size: calc(10px + 2vmin); 19 | color: white; 20 | } 21 | 22 | .link { 23 | color: #b318f0; 24 | } 25 | 26 | @keyframes logo-spin { 27 | from { 28 | transform: rotate(0deg); 29 | } 30 | to { 31 | transform: rotate(360deg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /docs/utils/date/getCurrentWeek.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 23 | -------------------------------------------------------------------------------- /docs/utils/math/numberToChinese.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 23 | -------------------------------------------------------------------------------- /docs/utils/mouseEvent/allowMouseEvent.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 19 | -------------------------------------------------------------------------------- /docs/utils/substring/subAfter.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 21 | -------------------------------------------------------------------------------- /docs/utils/substring/subBefore.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 21 | -------------------------------------------------------------------------------- /docs/utils/substring/subBothSides.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 21 | -------------------------------------------------------------------------------- /playgrounds/react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "react-jsx" 18 | }, 19 | "include": ["src"], 20 | "references": [{ "path": "./tsconfig.node.json" }] 21 | } 22 | -------------------------------------------------------------------------------- /docs/hooks/useWatermark/demo/forever.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 26 | -------------------------------------------------------------------------------- /docs/utils/debounce/delay.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 27 | -------------------------------------------------------------------------------- /docs/utils/substring/subBetween.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 21 | -------------------------------------------------------------------------------- /playgrounds/next/app/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | :root { 6 | --foreground-rgb: 0, 0, 0; 7 | --background-start-rgb: 214, 219, 220; 8 | --background-end-rgb: 255, 255, 255; 9 | } 10 | 11 | @media (prefers-color-scheme: dark) { 12 | :root { 13 | --foreground-rgb: 255, 255, 255; 14 | --background-start-rgb: 0, 0, 0; 15 | --background-end-rgb: 0, 0, 0; 16 | } 17 | } 18 | 19 | body { 20 | color: rgb(var(--foreground-rgb)); 21 | background: linear-gradient( 22 | to bottom, 23 | transparent, 24 | rgb(var(--background-end-rgb)) 25 | ) 26 | rgb(var(--background-start-rgb)); 27 | } 28 | -------------------------------------------------------------------------------- /playgrounds/vue-cli/src/App.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 19 | 20 | 30 | -------------------------------------------------------------------------------- /docs/utils/date/createYear.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 23 | -------------------------------------------------------------------------------- /docs/components/theme-change.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 21 | -------------------------------------------------------------------------------- /docs/utils/device/deviceDetection.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 25 | -------------------------------------------------------------------------------- /docs/public/favicon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/utils/color/types/randomGradient.ts: -------------------------------------------------------------------------------- 1 | export interface GradientOptions { 2 | /** 基础色相(`0`-`360`度),默认为一个随机色相 */ 3 | baseHue?: number; 4 | /** 从基础色相偏移的度数,用于创建第二种和谐色相,默认为`30`度 */ 5 | hueOffset?: number; 6 | /** 饱和度百分比(`50`-`100%`),颜色的鲜艳程度,默认为`70%` */ 7 | saturation?: number; 8 | /** 亮度百分比(`40`-`70%`),颜色的明亮程度,默认为`60%` */ 9 | lightness?: number; 10 | /** 渐变角度(`0`-`360`度),决定渐变的方向,默认为`135`度 */ 11 | angle?: number; 12 | /** 是否随机生成色相,默认为`false` */ 13 | randomizeHue?: boolean; 14 | /** 是否随机生成饱和度,默认为`false` */ 15 | randomizeSaturation?: boolean; 16 | /** 是否随机生成亮度,默认为`false` */ 17 | randomizeLightness?: boolean; 18 | /** 是否随机生成渐变角度,默认为`false` */ 19 | randomizeAngle?: boolean; 20 | } 21 | -------------------------------------------------------------------------------- /docs/utils/object/object.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | ::: tip 支持任意 `JavaScript` 环境或框架 7 | 处理对象 8 | ::: 9 | 10 | ## delObjectProperty 11 | 12 | 从对象中删除指定的属性,返回修改后的新对象,不会修改原始对象 13 | 14 |
15 | 16 | 接收两个参数,第一个 `obj`,第二个 `props` 17 | 18 | | **参数属性** | **说明** | 19 | | ------------ | ---------------------------------------------------------------- | 20 | | `obj` | 需要删除属性的对象 | 21 | | `props` | 指定要删除的属性,可以是单个属性名(字符串)或一个属性名字符串数组 | 22 | 23 |
24 | -------------------------------------------------------------------------------- /docs/utils/substring/subTextAddEllipsis.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 21 | -------------------------------------------------------------------------------- /playgrounds/vue-cli/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/utils/class/addClass.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 27 | -------------------------------------------------------------------------------- /playgrounds/svelte/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "svelte-demo", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vite build", 9 | "preview": "vite build && vite preview", 10 | "check": "svelte-check --tsconfig ./tsconfig.json" 11 | }, 12 | "dependencies": { 13 | "@pureadmin/utils": "^2.1.1" 14 | }, 15 | "devDependencies": { 16 | "@sveltejs/vite-plugin-svelte": "^3.0.1", 17 | "@tsconfig/svelte": "^5.0.2", 18 | "svelte": "^4.2.8", 19 | "svelte-check": "^3.6.2", 20 | "svelte-preprocess": "^5.1.3", 21 | "tslib": "^2.6.2", 22 | "typescript": "^5.3.3", 23 | "vite": "^5.0.10" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /docs/utils/svg/svg.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | ::: tip 支持任意运行在浏览器的 `JavaScript` 语言 7 | 处理`SVG` 8 | ::: 9 | 10 | ## getSvgInfo 11 | 12 | 解析传入的SVG字符串并提取其关键信息 13 | 14 |
15 | 16 | #### {#param1} 17 | 18 | 接收一个参数 `svgStr`,返回值类型为 `SvgInfo` 19 | 20 | | **参数属性** | **说明** | **类型** | 21 | | ------------ | ------------------------------------------ | -------- | 22 | | `svgStr` | 包含SVG内容的字符串,格式为标准的`SVG XML` | `string` | 23 | 24 | #### {#type1} 25 | 26 | <<< @/utils/svg/types/getSvgInfo.ts 27 | 28 |
29 | -------------------------------------------------------------------------------- /docs/utils/uuid/uuid.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /playgrounds/next/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "noEmit": true, 9 | "esModuleInterop": true, 10 | "module": "esnext", 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "jsx": "preserve", 15 | "incremental": true, 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ], 21 | "paths": { 22 | "@/*": ["./*"] 23 | } 24 | }, 25 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 26 | "exclude": ["node_modules"] 27 | } 28 | -------------------------------------------------------------------------------- /playgrounds/preact/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 6 | "allowJs": false, 7 | "skipLibCheck": true, 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": true, 10 | "strict": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "module": "ESNext", 13 | "moduleResolution": "Node", 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noEmit": true, 17 | "jsx": "preserve", 18 | "jsxFactory": "h", 19 | "jsxFragmentFactory": "Fragment" 20 | }, 21 | "include": ["src"], 22 | "references": [{ "path": "./tsconfig.node.json" }] 23 | } 24 | -------------------------------------------------------------------------------- /docs/utils/class/removeClass.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 27 | -------------------------------------------------------------------------------- /docs/utils/array/getKeyList.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

3 | 4 | pure-admin-utils 5 | 6 |

7 | 8 |

9 | pure-admin-utils 保姆级文档 10 |

11 | 12 |

13 | 采用 vitepressnaive-ui 搭配编写 15 |

16 | 17 | ## 👀 预览 18 | 19 | [查看文档](https://pure-admin-utils.netlify.app) 20 | 21 | ## 📡 安装依赖 22 | 23 | ``` 24 | pnpm install 25 | ``` 26 | 27 | ## 🚀 运行 28 | 29 | ``` 30 | pnpm dev 31 | ``` 32 | 33 | ## 🕋 打包 34 | 35 | ``` 36 | pnpm build 37 | ``` 38 | -------------------------------------------------------------------------------- /docs/utils/class/toggleClass.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 27 | -------------------------------------------------------------------------------- /docs/utils/clone/cloneDeep.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 30 | -------------------------------------------------------------------------------- /docs/components/description-popover.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 28 | -------------------------------------------------------------------------------- /playgrounds/next/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "next-demo", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@pureadmin/utils": "^2.1.1", 13 | "next": "^14.0.4", 14 | "react": "^18.2.0", 15 | "react-dom": "^18.2.0" 16 | }, 17 | "devDependencies": { 18 | "@types/node": "^20.10.5", 19 | "@types/react": "^18.2.46", 20 | "@types/react-dom": "^18.2.18", 21 | "autoprefixer": "^10.4.16", 22 | "eslint": "^8.56.0", 23 | "eslint-config-next": "^14.0.4", 24 | "postcss": "^8.4.32", 25 | "tailwindcss": "^3.4.0", 26 | "typescript": "^5.3.3" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /playgrounds/svelte/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/svelte/tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ESNext", 5 | "useDefineForClassFields": true, 6 | "module": "ESNext", 7 | "resolveJsonModule": true, 8 | "baseUrl": ".", 9 | /** 10 | * Typecheck JS in `.svelte` and `.js` files by default. 11 | * Disable checkJs if you'd like to use dynamic types in JS. 12 | * Note that setting allowJs false does not prevent the use 13 | * of JS in `.svelte` files. 14 | */ 15 | "allowJs": true, 16 | "checkJs": true, 17 | "isolatedModules": true 18 | }, 19 | "include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"], 20 | "references": [{ "path": "./tsconfig.node.json" }] 21 | } 22 | -------------------------------------------------------------------------------- /docs/utils/uuid/buildPrefixUUID.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "preserve", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"], 24 | "references": [{ "path": "./tsconfig.node.json" }] 25 | } 26 | -------------------------------------------------------------------------------- /playgrounds/react/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | text-align: center; 6 | } 7 | 8 | .logo { 9 | height: 6em; 10 | padding: 1.5em; 11 | will-change: filter; 12 | } 13 | .logo:hover { 14 | filter: drop-shadow(0 0 2em #646cffaa); 15 | } 16 | .logo.react:hover { 17 | filter: drop-shadow(0 0 2em #61dafbaa); 18 | } 19 | 20 | @keyframes logo-spin { 21 | from { 22 | transform: rotate(0deg); 23 | } 24 | to { 25 | transform: rotate(360deg); 26 | } 27 | } 28 | 29 | @media (prefers-reduced-motion: no-preference) { 30 | a:nth-of-type(2) .logo { 31 | animation: logo-spin infinite 20s linear; 32 | } 33 | } 34 | 35 | .card { 36 | padding: 2em; 37 | } 38 | 39 | .read-the-docs { 40 | color: #888; 41 | } 42 | -------------------------------------------------------------------------------- /docs/utils/date/getCurrentDate.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 26 | -------------------------------------------------------------------------------- /docs/guide/tags.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 33 | -------------------------------------------------------------------------------- /docs/utils/convertPath/convertPath.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | ::: tip 支持任意 `JavaScript` 环境或框架 9 | 路径转换 10 | ::: 11 | 12 | ## convertPath 13 | 14 | 将 `Windows` 反斜杠路径转换为斜杠路径 15 | 16 |
17 | 18 | #### {#base1} 19 | 20 | 21 | 22 |
23 | 24 | 查看代码 25 | 26 | <<< @/utils/convertPath/convertPath.vue 27 | 28 |
29 | 30 | #### {#param1} 31 | 32 | 接收一个参数 `path` ,返回值类型 `string` 33 | 34 | | **参数属性** | **说明** | **类型** | 35 | | ------------ | -------- | -------- | 36 | | `path` | 路径地址 | `string` | 37 | 38 |
39 | -------------------------------------------------------------------------------- /docs/utils/array/intersection.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 34 | -------------------------------------------------------------------------------- /docs/utils/color/randomColor.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 27 | -------------------------------------------------------------------------------- /docs/utils/date/getTime.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 28 | -------------------------------------------------------------------------------- /docs/utils/equal/isEqualArray.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 31 | -------------------------------------------------------------------------------- /docs/hooks/useCopyToClipboard/code.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 32 | -------------------------------------------------------------------------------- /docs/utils/array/extractFields.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 31 | -------------------------------------------------------------------------------- /docs/utils/color/darken.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 29 | -------------------------------------------------------------------------------- /docs/utils/color/lighten.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 29 | -------------------------------------------------------------------------------- /docs/utils/date/dateFormat.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 32 | -------------------------------------------------------------------------------- /docs/hooks/useCopyToClipboard/input.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 34 | -------------------------------------------------------------------------------- /docs/hooks/useWatermark/demo/wrap.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 32 | -------------------------------------------------------------------------------- /docs/components/typeit.ts: -------------------------------------------------------------------------------- 1 | import { h, defineComponent } from "vue"; 2 | import TypeIt from "typeit"; 3 | 4 | // 打字机效果组件 5 | export default defineComponent({ 6 | name: "TypeIt", 7 | // 配置项参考 https://www.typeitjs.com/docs/vanilla/usage#options 8 | props: { 9 | /** 打字速度,以每一步之间的毫秒数为单位 */ 10 | speed: { 11 | type: Number, 12 | default: 200 13 | }, 14 | values: { 15 | type: Array, 16 | defalut: [] 17 | }, 18 | className: { 19 | type: String, 20 | default: "type-it" 21 | } 22 | }, 23 | render() { 24 | return h( 25 | "span", 26 | { 27 | class: this.className 28 | }, 29 | { 30 | default: () => [] 31 | } 32 | ); 33 | }, 34 | mounted() { 35 | new TypeIt(`.${this.className}`, { 36 | strings: this.values, 37 | speed: this.speed, 38 | cursor: false 39 | }).go(); 40 | } 41 | }); 42 | -------------------------------------------------------------------------------- /docs/public/table.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/hooks/useECharts/demo/simple/gauge.vue: -------------------------------------------------------------------------------- 1 | 37 | 38 | 41 | -------------------------------------------------------------------------------- /docs/public/github.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/utils/array/swapOrder.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 35 | -------------------------------------------------------------------------------- /docs/utils/space/removeAllSpace.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 34 | -------------------------------------------------------------------------------- /docs/utils/space/removeLeftSpace.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 34 | -------------------------------------------------------------------------------- /docs/utils/space/removeRightSpace.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 34 | -------------------------------------------------------------------------------- /docs/utils/device/getBrowserInfo.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 34 | -------------------------------------------------------------------------------- /docs/utils/install/install.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | ::: tip 仅用于`Vue3` 7 | 组件注册 8 | ::: 9 | 10 | ## withInstall 11 | 12 | 向组件中添加 `install` 方法,使其既可以使用 `app.component` 注册又可以使用 `app.use` 安装,且无需考虑 `TypeScript` 类型 13 | 14 |
15 | 16 | 接收两个参数,第一个 `main`,第二个 `extra` 17 | 18 | | **参数属性** | **说明** | 19 | | ------------ | ---------------------------------------------- | 20 | | `main` | 主组件(第一个被注册的组件) | 21 | | `extra` | 额外组件,对象格式(会按照传入的先后顺序注册) | 22 | 23 |
24 | 25 | ::: info 提示信息 26 | 每个使用 `withInstall` 的组件都应该有个唯一 `name`,以便兼容各种场景。如果要在全局中使用,组件名需传 `name` 值 27 | ::: 28 | 29 | ## withNoopInstall 30 | 31 | 向组件中添加空的`install`方法,接收一个参数 `component` 组件 32 | 33 | ::: info 使用场景 34 | 不希望组件自动注册,或者想要在控制注册时机和方式时提供灵活性。例如,想要在某些条件满足时才注册组件,或者已经有了注册逻辑的其他实现方式 35 | ::: 36 | -------------------------------------------------------------------------------- /docs/utils/space/removeBothSidesSpace.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 34 | -------------------------------------------------------------------------------- /docs/utils/debounce/throttle.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 38 | -------------------------------------------------------------------------------- /docs/utils/equal/isEqualObject.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 31 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 33 | 34 | 39 | -------------------------------------------------------------------------------- /docs/hooks/useDraggable/naiveuiBase.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 39 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "bundler", 6 | "strict": false, 7 | "jsx": "preserve", 8 | "importHelpers": true, 9 | "experimentalDecorators": true, 10 | "strictFunctionTypes": false, 11 | "skipLibCheck": true, 12 | "esModuleInterop": true, 13 | "isolatedModules": true, 14 | "allowSyntheticDefaultImports": true, 15 | "forceConsistentCasingInFileNames": true, 16 | "sourceMap": true, 17 | "baseUrl": ".", 18 | "allowJs": false, 19 | "resolveJsonModule": true, 20 | "lib": ["ESNext", "DOM"], 21 | "types": [ 22 | "vitepress", 23 | "vite/client", 24 | "naive-ui/volar", 25 | "@vue-macros/reactivity-transform/macros-global" 26 | ] 27 | }, 28 | "include": [ 29 | "docs/**/*.ts", 30 | "docs/**/*.vue", 31 | "unocss.config.ts", 32 | "docs/.vitepress/**/*.ts" 33 | ], 34 | "exclude": ["dist", "node_modules", "docs/.vitepress/dist"] 35 | } 36 | -------------------------------------------------------------------------------- /playgrounds/html/hooks/useWatermark.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | useWatermark 9 | 10 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /docs/public/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/hooks/useECharts/demo/simple/candlestick.vue: -------------------------------------------------------------------------------- 1 | 40 | 41 | 44 | -------------------------------------------------------------------------------- /docs/hooks/useResizeObserver/demo2.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 30 | 31 | 40 | -------------------------------------------------------------------------------- /docs/hooks/useDraggable/naiveuiDialog.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 36 | -------------------------------------------------------------------------------- /docs/components/description.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 43 | -------------------------------------------------------------------------------- /docs/utils/array/randomDivide.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 39 | -------------------------------------------------------------------------------- /docs/utils/url/url.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | ::: tip 支持任意运行在浏览器的 `JavaScript` 语言 10 | 提取 `url` 中所有参数、获取当前的 `location` 信息 11 | ::: 12 | 13 | ## getQueryMap 14 | 15 | 提取浏览器 `url` 中所有参数 16 | 17 |
18 | 19 | #### {#base1} 20 | 21 | 22 | 23 |
24 | 25 | 查看代码 26 | 27 | <<< @/utils/url/getQueryMap.vue 28 | 29 |
30 | 31 | #### {#param1} 32 | 33 | 接收一个参数 `url` ,返回值类型 `object` 34 | 35 | | **参数属性** | **说明** | **类型** | 36 | | ------------ | ---------- | -------- | 37 | | `url` | 超链接地址 | `string` | 38 | 39 |
40 | 41 | ## getLocation 42 | 43 | 获取浏览器当前的 `location` 信息 44 | 45 |
46 | 47 | 48 | 49 |
50 | 51 | 查看代码 52 | 53 | <<< @/utils/url/getLocation.vue 54 | 55 |
56 | 57 |
58 | -------------------------------------------------------------------------------- /docs/utils/array/arrayAnyExist.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 42 | -------------------------------------------------------------------------------- /docs/utils/array/arrayAllExist.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 42 | -------------------------------------------------------------------------------- /docs/components/wordcloud/data.ts: -------------------------------------------------------------------------------- 1 | import { ref } from "vue"; 2 | import { subBetween } from "@pureadmin/utils"; 3 | import type { WorldCloudDataItem } from "../../.vitepress/plugins/wordcloud/index.d.ts"; // 路径要写完整,确保打包时引用正确 4 | 5 | const modules: any = import.meta.glob("../../{hooks,utils}/**/*.md", { 6 | eager: true 7 | }); 8 | 9 | export function useData() { 10 | let utilsList = []; 11 | let hooksList = []; 12 | let dataList = ref([]); 13 | 14 | Object.keys(modules).forEach(v => { 15 | if (v.includes("/utils/")) utilsList.push(v); 16 | if (v.includes("/hooks/")) hooksList.push(v); 17 | }); 18 | 19 | Object.keys(modules).map(key => { 20 | if (!modules[key].default?.name) return; 21 | dataList.value.push({ 22 | name: subBetween(modules[key].default?.name, "/", "/"), 23 | value: 1 24 | }); 25 | }); 26 | dataList.value.push( 27 | { name: "Hooks", value: hooksList.length }, 28 | { name: "Utils", value: utilsList.length } 29 | ); 30 | 31 | return { 32 | data: dataList, 33 | hooksLen: hooksList.length, 34 | utilsLen: utilsList.length 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /docs/utils/array/isIncludeAllChildren.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 41 | -------------------------------------------------------------------------------- /docs/utils/base64Conver/convertImageToGray.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022-present, pure-admin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docs/utils/convertPath/convertPath.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 36 | -------------------------------------------------------------------------------- /playgrounds/vue-cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuecli-demo", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "vue-cli-service serve", 7 | "serve": "vue-cli-service serve", 8 | "build": "vue-cli-service build", 9 | "lint": "vue-cli-service lint" 10 | }, 11 | "dependencies": { 12 | "@pureadmin/utils": "^2.1.1", 13 | "core-js": "^3.8.3", 14 | "vue": "^3.2.13" 15 | }, 16 | "devDependencies": { 17 | "@babel/core": "^7.12.16", 18 | "@babel/eslint-parser": "^7.12.16", 19 | "@vue/cli-plugin-babel": "~5.0.0", 20 | "@vue/cli-plugin-eslint": "~5.0.0", 21 | "@vue/cli-service": "~5.0.0", 22 | "eslint": "^7.32.0", 23 | "eslint-plugin-vue": "^8.0.3" 24 | }, 25 | "eslintConfig": { 26 | "root": true, 27 | "env": { 28 | "node": true 29 | }, 30 | "extends": [ 31 | "plugin:vue/vue3-essential", 32 | "eslint:recommended" 33 | ], 34 | "parserOptions": { 35 | "parser": "@babel/eslint-parser" 36 | }, 37 | "rules": {} 38 | }, 39 | "browserslist": [ 40 | "> 1%", 41 | "last 2 versions", 42 | "not dead", 43 | "not ie 11" 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /playgrounds/preact/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /playgrounds/react/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /playgrounds/svelte/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /playgrounds/vue-vite/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/hooks/useECharts/demo/simple/bar.vue: -------------------------------------------------------------------------------- 1 | 53 | 54 | 57 | -------------------------------------------------------------------------------- /docs/hooks/useECharts/demo/simple/line.vue: -------------------------------------------------------------------------------- 1 | 50 | 51 | 54 | -------------------------------------------------------------------------------- /docs/hooks/useECharts/demo/simple/radar.vue: -------------------------------------------------------------------------------- 1 | 52 | 53 | 56 | -------------------------------------------------------------------------------- /docs/utils/base64Conver/urlToBase64.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 51 | -------------------------------------------------------------------------------- /docs/hooks/useGlobal/useGlobal.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | # useGlobal 6 | 7 | ::: tip 适用于 `Vue3`、`Nuxt3`、`HTML` 8 | 获取已经注册的全局属性对象 [globalProperties](https://cn.vuejs.org/api/application.html#app-config-globalproperties) 9 | ::: 10 | 11 | `useGlobal`只做两件事,第一快速提取`globalProperties`,第二更方便、明确的类型提示 12 | 13 | #### 既然想获取全局`globalProperties`,肯定要先注册它呀(第一步) 14 | 15 | ::: code-group 16 | 17 | ```ts [Vue3] 18 | // main.ts 19 | import { type App, createApp } from "vue"; 20 | import App from "./App.vue"; 21 | 22 | import * as echarts from "echarts"; 23 | 24 | const app = createApp(App); 25 | // 这里我们就以注册$echarts为例 26 | app.config.globalProperties.$echarts = echarts; 27 | 28 | app.mount("#app"); 29 | ``` 30 | 31 | ```ts [Nuxt3] 32 | // plugins/config.ts 33 | import * as echarts from "echarts"; 34 | 35 | export default defineNuxtPlugin(nuxtApp => { 36 | // 这里我们就以注册$echarts为例 37 | nuxtApp.vueApp.config.globalProperties.$echarts = echarts; 38 | }); 39 | ``` 40 | 41 | ::: 42 | 43 | #### 全局类型声明(第二步) 44 | 45 | <<< ../../global.d.ts 46 | 47 | #### 在组件中使用它(第三步即最后一步) 48 | 49 | <<< @/hooks/useGlobal/demo.vue 50 | 51 | ##### 获得类型提示,如下图 52 | 53 | 54 | 55 | ##### 获得实例的属性和方法,如下图 56 | 57 | 58 | -------------------------------------------------------------------------------- /docs/utils/storage/storage.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | ::: tip 支持任意运行在浏览器的 `JavaScript` 语言 10 | 本地存储 11 | ::: 12 | 13 | ## storageLocal 14 | 15 | 处理 `localStorage` 16 | 17 |
18 | 19 | 20 | 21 |
22 | 23 | 查看代码 24 | 25 | <<< @/utils/storage/storageLocal.vue 26 | 27 |
28 | 29 |
30 | 31 | ## storageSession 32 | 33 | 处理 `sessionStorage` 34 | 35 |
36 | 37 | 38 | 39 |
40 | 41 | 查看代码 42 | 43 | <<< @/utils/storage/storageSession.vue 44 | 45 |
46 | 47 |
48 | 49 | ## 通用方法 50 | 51 | | **方法名** | **说明** | **参数** | 52 | | ------------ | ----------------------------- | -------------------------- | 53 | | `setItem` | 储存对应键名的 `Storage` 对象 | `k` (键名), `v` (键值) | 54 | | `getItem` | 获取对应键名的 `Storage` 对象 | `k` (键名) | 55 | | `removeItem` | 删除对应键名的 `Storage` 对象 | `k` (键名) | 56 | | `clear` | 删除此域的所有 `Storage` 对象 | | 57 | -------------------------------------------------------------------------------- /playgrounds/next/public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/utils/array/arrayAllExistDeep.vue: -------------------------------------------------------------------------------- 1 | 39 | 40 | 52 | -------------------------------------------------------------------------------- /docs/hooks/useECharts/demo/simple/scatter.vue: -------------------------------------------------------------------------------- 1 | 52 | 53 | 56 | -------------------------------------------------------------------------------- /docs/components/theme.vue: -------------------------------------------------------------------------------- 1 | 37 | 38 | 47 | -------------------------------------------------------------------------------- /docs/utils/array/arrayAnyExistDeep.vue: -------------------------------------------------------------------------------- 1 | 39 | 40 | 52 | -------------------------------------------------------------------------------- /playgrounds/preact/src/assets/preact.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/utils/nameTransform/nameTransform.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | ::: tip 支持任意 `JavaScript` 环境或框架 10 | 横线、驼峰命名互转 11 | ::: 12 | 13 | ## nameCamelize 14 | 15 | 横线转驼峰命名 16 | 17 |
18 | 19 | #### {#base1} 20 | 21 | 22 | 23 |
24 | 25 | 查看代码 26 | 27 | <<< @/utils/nameTransform/nameCamelize.vue 28 | 29 |
30 | 31 | #### {#param1} 32 | 33 | 接收一个参数 `str` ,返回值类型 `string` 34 | 35 | | **参数属性** | **说明** | **类型** | 36 | | ------------ | -------- | -------- | 37 | | `str` | 字符串 | `string` | 38 | 39 |
40 | 41 | ## nameHyphenate 42 | 43 | 驼峰命名转横线命名:拆分字符串,使用 `-` 相连,并且全部转换为小写 44 | 45 |
46 | 47 | #### {#base2} 48 | 49 | 50 | 51 |
52 | 53 | 查看代码 54 | 55 | <<< @/utils/nameTransform/nameHyphenate.vue 56 | 57 |
58 | 59 | #### {#param2} 60 | 61 | 接收一个参数 `str` ,返回值类型 `string` 62 | 63 | | **参数属性** | **说明** | **类型** | 64 | | ------------ | -------- | -------- | 65 | | `str` | 字符串 | `string` | 66 | 67 |
68 | -------------------------------------------------------------------------------- /docs/utils/link/link.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | ::: tip 支持任意运行在浏览器的 `JavaScript` 语言 9 | 超链接 10 | ::: 11 | 12 | ## openLink 13 | 14 | 创建超链接 15 | 16 |
17 | 18 | #### {#base1} 19 | 20 | 21 | 22 |
23 | 24 | 查看代码 25 | 26 | <<< @/utils/link/link.vue 27 | 28 |
29 | 30 | #### {#param1} 31 | 32 | 接收两个参数,第一个参数 `href` ,第二个参数 `target` ,无返回值 33 | 34 | | **参数属性** | **说明** | **类型** | **默认值** | 35 | | ------------ | ---------------------------------------- | -------- | ---------- | 36 | | `href` | 要跳转的超链接地址 | `string` | | 37 | | `target` | 拥有五个属性,具体看下面的 `target` 详情 | `Target` | `_blank` | 38 | 39 | #### {#target1} 40 | 41 | | **参数属性** | **说明** | 42 | | ------------ | ---------------------------------- | 43 | | _\_blank_ | _在新窗口中打开被链接文档(默认)_ | 44 | | _\_self_ | _在相同的框架中打开被链接文档_ | 45 | | _\_parent_ | _在父框架集中打开被链接文档_ | 46 | | _\_top_ | _在整个窗口中打开被链接文档_ | 47 | | _framename_ | _在指定的框架中打开被链接文档_ | 48 | 49 | ### 类型声明 50 | 51 | <<< @/utils/link/types/openLink.ts 52 | 53 |
54 | -------------------------------------------------------------------------------- /docs/utils/amount/priceToThousands.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 41 | -------------------------------------------------------------------------------- /docs/hooks/useWatermark/demo/image.vue: -------------------------------------------------------------------------------- 1 | 35 | 36 | 49 | -------------------------------------------------------------------------------- /docs/hooks/useResizeObserver/demo1.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 |