Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getYunMu(word) {
/**
* 声母数组
*/
var shenMu = pinyin(word, {
style: pinyin.STYLE_FIRST_LETTER, // 设置拼音风格
segment: true,
heteronym: true
})
/**
* 单词全拼数组
*/
var wholePinyinArray = pinyin(word, {
style: pinyin.STYLE_NORMAL, // 设置拼音风格
segment: true,
heteronym: true
})
// console.log(shenMu);
// console.log(wholePinyinArray);
// 全拼 减去 声母 得到韵语 用逗号分隔
var yunMu = wholePinyinArray.map((fullPinyin, index) => {
return fullPinyin[0].replace(shenMu[index][0], '')
static isValidNameHint(nameHint, userName) {
const pinyinRaw = pinyin(userName, {
style: pinyin.STYLE_FIRST_LETTER,
});
let pinyinName = '';
for (const py of pinyinRaw) {
if (py[0] && py[0] !== ' ') {
pinyinName += py[0];
}
}
const nameRe = new RegExp(nameHint[1], 'ig');
return nameRe.test(userName) || nameRe.test(pinyinName);
}
static isValidNameHint(nameHint, userName) {
const pinyinRaw = pinyin(userName, {
style: pinyin.STYLE_FIRST_LETTER,
});
let pinyinName = '';
for (const py of pinyinRaw) {
if (py[0] && py[0] !== ' ') {
pinyinName += py[0];
}
}
const nameRe = new RegExp(nameHint[1], 'ig');
return nameRe.test(userName) || nameRe.test(pinyinName);
}
s.map((item) => {
let py = pinyin(item.name[0], {
style: pinyin.STYLE_FIRST_LETTER
})
item.initial = py[0][0].toUpperCase()
})
this.singers = this._normalizeSinger(s)
var toPinYin = function(text) {
var py1 = mergeString(pinyin(text, {style: pinyin.STYLE_NORMAL}));
if(py1 === '' || py1 === text) return '';
return py1 + ' ' + mergeString(pinyin(text, {style: pinyin.STYLE_FIRST_LETTER}));
};
} else if (!userName) {
message = '请输入用户名';
} else if (!password) {
message = '请输入密码';
} else if (!email) {
message = '请输入Email';
} else if (!phone) {
message = '请输入手机号码';
}
if (message) {
ctx.body = {
code: 100003,
message
};
} else {
const group = pinyin(nick, { style: pinyin.STYLE_FIRST_LETTER })[0][0].toUpperCase().substr(0, 1);
const db = ctx.mongo.db(dbName);
const defaultContacts = ['18958067917', '18958067916'];
const user = { nick, thumb, userName, password: encryptUsingMd5(password), region, email, phone, group, contacts: defaultContacts };
const collection = db.collection('user');
const result = await collection.insertOne(user);
if (result.insertedCount > 0) {
ctx.body = {
code: 0,
message: ''
};
collection.updateMany({
phone: {
$in: defaultContacts
}
}, {
toolName.forEach(name => {
toolPinyin[name] = {
first: group(
pinyin(name.replace(/\s/g, '').toLowerCase(), {
style: pinyin.STYLE_FIRST_LETTER,
heteronym: true
})
),
pinyin: group(
pinyin(name.replace(/\s/g, '').toLowerCase(), {
style: pinyin.STYLE_NORMAL,
heteronym: true
})
)
};
});