干燥机配套车间生产管理系统/云平台前端
baoshiwei
10 小时以前 a3e955e801044d8abc2ec575cdf74a6815b8d963
src/utils/common/renderUtils.ts
@@ -7,6 +7,8 @@
import { filterMultiDictText } from '/@/utils/dict/JDictSelectUtil.js';
import { isEmpty } from '/@/utils/is';
import { useMessage } from '/@/hooks/web/useMessage';
import pinyin from 'chinese-to-pinyin';
const { createMessage } = useMessage();
const render = {
@@ -172,4 +174,25 @@
  }
}
/**
 * 获取中文字符串的全拼
 * @param str 中文字符串
 * @returns 拼音字符串
 */
export function getFullWordSpell(str: string): string {
  if (!str) return '';
  return pinyin(str, { toneToNumber: true });
}
/**
 * 获取中文字符串的首字母
 * @param str 中文字符串
 * @returns 首字母组成的字符串
 */
export function getFirstWordSpell(str: string): string {
  if (!str) return '';
  // 获取每个字的拼音首字母并连接
  return pinyin(str, { keepRest: true, firstCharacter: true, removeSpace: true });
}
export { render, downloadFile };