goview_vue/src/utils/index.ts

31 lines
652 B
TypeScript
Raw Normal View History

import { h } from 'vue';
import { NIcon } from 'naive-ui';
2021-12-10 14:11:49 +08:00
/**
* * ID
2021-12-10 14:11:49 +08:00
* @param { Number } randomLength
*/
export function getUUID(randomLength: number) {
2021-12-10 14:11:49 +08:00
return Number(
Math.random()
.toString()
.substr(2, randomLength) + Date.now()
).toString(36);
}
/**
* * render
*/
2021-12-15 14:25:28 +08:00
export const renderIcon = (icon: typeof NIcon) => {
return () => h(NIcon, null, { default: () => h(icon) });
}
2021-12-10 14:11:49 +08:00
2021-12-15 14:25:28 +08:00
/**
* * vite 使 require
* @param name
* @returns
*/
export const requireUrl = (path: string, name: string) => {
return new URL(`${path}/${name}`, import.meta.url).href
}