wgt-node-utils 1.2.28 → 1.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgt-node-utils",
3
- "version": "1.2.28",
3
+ "version": "1.2.29",
4
4
  "description": "WGT工具类包",
5
5
  "main": "dist/bundle.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -843,12 +843,20 @@ class wgtNodeUtils {
843
843
  * 获取网站语言
844
844
  * @param {string} url - 网站语言获取接口
845
845
  * @param {string} hostname - 网站域名
846
+ * @param {string} type - 网站类型
847
+ * @param {string} type.content - 内容网站
848
+ * @param {string} type.novle - 小说网站
846
849
  * @returns {Array} - 格式化后的语言代码列表
847
850
  * */
848
- getSiteLanguage = async (url) => {
851
+ getSiteLanguage = async (url, type) => {
849
852
  return new Promise((resolve) => {
850
853
  axios.get(url).then(res => {
851
- let siteData = res.data.data;
854
+ let siteData;
855
+ if (type === 'content') {
856
+ siteData = res.data && res.data.data && res.data.data;
857
+ } else if (type === 'novle') {
858
+ siteData = res.data.join(',').map(item => item.trim()).filter(item => item !== '');
859
+ }
852
860
  // 如果未获取到数据,使用en做为默认数据
853
861
  if (!siteData) {
854
862
  siteData = ['en']