Skip to content

Commit

Permalink
feat(phonetic): fetch first phonetic symbol crudely
Browse files Browse the repository at this point in the history
close #4;
  • Loading branch information
licoded committed Mar 4, 2023
1 parent b445d47 commit 25280e4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/xhr/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,24 @@ const dict2means = (dict) => {
// return { word_name, word_means, updatetime };
// };

const parsePhonetic = (dictjson) => {
if(!dictjson) return {};
const { symbols } = JSON.parse(dictjson).simple_means;
const { ph_en, ph_am } = symbols[0];
return { ph_en, ph_am };
}

const parseWordItem = (rawData) => {
const {
fanyisrc: word_name,
dict,
dictjson,
fanyidst,
updatetime,
} = JSON.parse(JSON.stringify(rawData));
const _means = dict2means(dict).filter((item) => item !== "");
const word_means = _means.length > 0 ? _means : [].concat(fanyidst);
return { word_name, word_means, updatetime };
return { word_name, word_means, updatetime, ...parsePhonetic(dictjson) };
};

const getCollectionPage = async (page = 1, pagesize = 30) => {
Expand Down

0 comments on commit 25280e4

Please sign in to comment.