@iflyrpa/actions 1.2.15 → 1.2.16-beta.1

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.
package/dist/index.js CHANGED
@@ -1168,7 +1168,14 @@ var __webpack_exports__ = {};
1168
1168
  };
1169
1169
  }
1170
1170
  constructor(config){
1171
- this.apiClient = external_axios_default().create(config);
1171
+ this.apiClient = external_axios_default().create({
1172
+ ...config,
1173
+ proxy: {
1174
+ host: "localhost",
1175
+ port: 9000,
1176
+ protocol: "http"
1177
+ }
1178
+ });
1172
1179
  }
1173
1180
  addResponseInterceptor(findError) {
1174
1181
  this.apiClient.interceptors.response.use((response)=>{
@@ -1859,12 +1866,20 @@ var __webpack_exports__ = {};
1859
1866
  type: "news"
1860
1867
  }
1861
1868
  });
1862
- return (0, share_namespaceObject.success)(res?.data?.article.activity_list.map((_item)=>({
1869
+ const data = res?.data?.article.activity_list.map((_item)=>({
1863
1870
  id: _item.id,
1864
1871
  name: _item.name,
1865
1872
  detail: _item.detail,
1866
1873
  is_enable: _item.is_enable
1867
- })) ?? [], "获取头条发布配置项成功");
1874
+ })) ?? [];
1875
+ data.push({
1876
+ id: "bjh_publish_num_left",
1877
+ name: "账号剩余发文数",
1878
+ detail: "",
1879
+ is_enable: 1,
1880
+ publish_num_left: res.data.ability.publish_num_left
1881
+ });
1882
+ return (0, share_namespaceObject.success)(data, "获取百家号配置项成功!");
1868
1883
  };
1869
1884
  const searchToutiaoTopicList = async (_task, params)=>{
1870
1885
  const http = new Http({
@@ -2034,7 +2049,7 @@ var __webpack_exports__ = {};
2034
2049
  this.iv = external_node_buffer_namespaceObject.Buffer.from("4uzjr7mbsibcaldp", "utf8");
2035
2050
  }
2036
2051
  }
2037
- const xsEncrypt = new XsEncrypt();
2052
+ const searchXiaohongshuTopicList_xsEncrypt = new XsEncrypt();
2038
2053
  const searchXiaohongshuTopicList = async (_task, params)=>{
2039
2054
  const http = new Http({
2040
2055
  headers: {
@@ -2062,9 +2077,9 @@ var __webpack_exports__ = {};
2062
2077
  page: 1
2063
2078
  }
2064
2079
  };
2065
- const topicDataStr = xsEncrypt.dumps(topicData);
2080
+ const topicDataStr = searchXiaohongshuTopicList_xsEncrypt.dumps(topicData);
2066
2081
  const fatchTopic = `/web_api/sns/v1/search/topic${topicDataStr}`;
2067
- const xs = await xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
2082
+ const xs = await searchXiaohongshuTopicList_xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
2068
2083
  const result = await http.api({
2069
2084
  method: "post",
2070
2085
  url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
@@ -2614,6 +2629,726 @@ var __webpack_exports__ = {};
2614
2629
  }, "获取粉丝数失败,请检查登陆有效性!");
2615
2630
  }
2616
2631
  };
2632
+ const TTSessionCheck = async (_task, params)=>{
2633
+ const http = new Http({
2634
+ headers: {
2635
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2636
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
2637
+ }
2638
+ });
2639
+ try {
2640
+ const res = await http.api({
2641
+ method: "get",
2642
+ url: "https://mp.toutiao.com/mp/agw/creator_center/user_info",
2643
+ defaultErrorMsg: `头条号登录状态失效。`
2644
+ });
2645
+ return (0, share_namespaceObject.success)(0 === res.code ? {
2646
+ isValidSession: true
2647
+ } : {
2648
+ isValidSession: false
2649
+ }, "头条账号有效性检测完成!");
2650
+ } catch (error) {
2651
+ return (0, share_namespaceObject.success)({
2652
+ isValidSession: false
2653
+ }, "头条账号有效性检测失败!");
2654
+ }
2655
+ };
2656
+ const WxSessionCheck = async (_task, params)=>{
2657
+ const http = new Http({
2658
+ headers: {
2659
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2660
+ }
2661
+ });
2662
+ const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
2663
+ try {
2664
+ const res = await http.api({
2665
+ method: "get",
2666
+ url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",
2667
+ params: {
2668
+ fingerprint,
2669
+ sub: "list",
2670
+ begin: 0,
2671
+ count: 10,
2672
+ query: "",
2673
+ type: 1011102103,
2674
+ show_type: "",
2675
+ free_publish_type: 1102103,
2676
+ sub_action: "list_ex",
2677
+ search_card: 0,
2678
+ token: params.token,
2679
+ lang: "zh_CN",
2680
+ f: "json",
2681
+ ajax: 1
2682
+ }
2683
+ });
2684
+ return (0, share_namespaceObject.success)(0 === res.base_resp.ret ? {
2685
+ isValidSession: true
2686
+ } : {
2687
+ isValidSession: false
2688
+ }, "微信账号有效性检测完成!");
2689
+ } catch (error) {
2690
+ return (0, share_namespaceObject.success)({
2691
+ isValidSession: false
2692
+ }, "微信账号有效性检测失败!");
2693
+ }
2694
+ };
2695
+ const XhsSessionCheck = async (_task, params)=>{
2696
+ const http = new Http({
2697
+ headers: {
2698
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2699
+ referer: "https://creator.xiaohongshu.com/new/home?source=official"
2700
+ }
2701
+ });
2702
+ try {
2703
+ const res = await http.api({
2704
+ method: "get",
2705
+ url: "https://creator.xiaohongshu.com/api/galaxy/user/info"
2706
+ });
2707
+ return (0, share_namespaceObject.success)(0 === res.result ? {
2708
+ isValidSession: true
2709
+ } : {
2710
+ isValidSession: false
2711
+ }, "小红书账号有效性检测完成!");
2712
+ } catch (error) {
2713
+ return (0, share_namespaceObject.success)({
2714
+ isValidSession: false
2715
+ }, "小红书账号有效性检测完成!");
2716
+ }
2717
+ };
2718
+ const BjhSessionCheck = async (_task, params)=>{
2719
+ const http = new Http({
2720
+ headers: {
2721
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2722
+ referer: "https://baijiahao.baidu.com/builder/rc/home"
2723
+ }
2724
+ });
2725
+ try {
2726
+ const res = await http.api({
2727
+ method: "get",
2728
+ url: "https://baijiahao.baidu.com/pcui/home/index",
2729
+ defaultErrorMsg: `百家号登录状态失效。`
2730
+ });
2731
+ return (0, share_namespaceObject.success)(0 === res.errno ? {
2732
+ isValidSession: true
2733
+ } : {
2734
+ isValidSession: false
2735
+ }, "百家号账号有效性检测完成!");
2736
+ } catch (error) {
2737
+ return (0, share_namespaceObject.success)({
2738
+ isValidSession: false
2739
+ }, "百家号账号有效性检测失败!");
2740
+ }
2741
+ };
2742
+ const types_errorResponse = (message, code = 500)=>({
2743
+ code,
2744
+ message,
2745
+ data: null
2746
+ });
2747
+ async function getBaijiahaoData(params) {
2748
+ try {
2749
+ const { token } = params;
2750
+ if (!token) return types_errorResponse("缺少token", 200);
2751
+ const http = new Http({
2752
+ headers: {
2753
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2754
+ token: String(token),
2755
+ Referer: "https://baijiahao.baidu.com/builder/rc/home"
2756
+ }
2757
+ });
2758
+ const yesterday = TimeFormatter.format(new Date().setDate(new Date().getDate() - 1), "yyyyMMdd");
2759
+ const [fansData, readData, incomeData, yesterdayData] = await Promise.all([
2760
+ http.api({
2761
+ method: "get",
2762
+ url: "https://baijiahao.baidu.com/pcui/home/index"
2763
+ }),
2764
+ http.api({
2765
+ method: "get",
2766
+ url: "https://baijiahao.baidu.com/author/eco/statistic/getauthorhistory"
2767
+ }),
2768
+ http.api({
2769
+ method: "get",
2770
+ url: "https://baijiahao.baidu.com/author/eco/income4/homepageincome"
2771
+ }),
2772
+ http.api({
2773
+ method: "get",
2774
+ url: "https://baijiahao.baidu.com/author/eco/statistics/appStatistic",
2775
+ params: {
2776
+ type: "all",
2777
+ is_yesterday: false,
2778
+ start_day: yesterday,
2779
+ end_day: yesterday,
2780
+ stat: 0
2781
+ }
2782
+ })
2783
+ ]);
2784
+ const bjhData = {
2785
+ fansNum: fansData.data.coreData.fansCount,
2786
+ fansNumYesterday: -1 == yesterdayData.data.data.fans_increase ? null : yesterdayData.data.data.fans_increase,
2787
+ readNum: readData.data.total.view_count,
2788
+ incomeNum: incomeData.data.all_income.total_income,
2789
+ incomeNumYesterday: -1 == incomeData.data.all_income.yesterday_income ? null : incomeData.data.all_income.yesterday_income,
2790
+ recommendNumYesterday: -1 == yesterdayData.data.data.recommend_count ? null : yesterdayData.data.data.recommend_count,
2791
+ readNumYesterday: -1 == yesterdayData.data.data.view_count ? null : yesterdayData.data.data.view_count,
2792
+ likeNumYesterday: -1 == yesterdayData.data.data.likes_count ? null : yesterdayData.data.data.likes_count,
2793
+ commentNumYesterday: -1 == yesterdayData.data.data.comment_count ? null : yesterdayData.data.data.comment_count
2794
+ };
2795
+ return (0, share_namespaceObject.success)(bjhData, "百家号平台数据获取成功!");
2796
+ } catch (error) {
2797
+ return types_errorResponse(error instanceof Error ? error.message : "百家号平台数据获取失败");
2798
+ }
2799
+ }
2800
+ async function getToutiaoData(params) {
2801
+ const { cookies } = params;
2802
+ try {
2803
+ const http = new Http({
2804
+ headers: {
2805
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2806
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
2807
+ }
2808
+ });
2809
+ const [totalData, contentDataYesterday] = await Promise.all([
2810
+ http.api({
2811
+ method: "get",
2812
+ url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
2813
+ params: {
2814
+ app_id: 1231
2815
+ }
2816
+ }),
2817
+ http.api({
2818
+ method: "get",
2819
+ url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
2820
+ params: {
2821
+ type: 0,
2822
+ app_id: 1231
2823
+ }
2824
+ })
2825
+ ]);
2826
+ const ttData = {
2827
+ fansNum: Number(totalData.data.statistic.data.total_subscribe_count),
2828
+ fansNumYesterday: void 0 !== totalData.data.statistic.data.yesterday_fans ? Number(totalData.data.statistic.data.yesterday_fans) : null,
2829
+ readNum: Number(totalData.data.statistic.data.total_read_play_count),
2830
+ incomeNum: totalData.data.statistic.data.total_income,
2831
+ incomeNumYesterday: totalData.data.statistic.data.is_yesterday_income_ready ? totalData.data.statistic.data.yesterday_income : null,
2832
+ showNumYesterday: contentDataYesterday.author_stat.consume_data.impression_count,
2833
+ readNumYesterday: contentDataYesterday.author_stat.consume_data.go_detail_count,
2834
+ likeNumYesterday: contentDataYesterday.author_stat.interaction_data.digg_count,
2835
+ commentNumYesterday: contentDataYesterday.author_stat.interaction_data.comment_count
2836
+ };
2837
+ return (0, share_namespaceObject.success)(ttData, "头条号粉丝数据获取成功!");
2838
+ } catch (error) {
2839
+ return types_errorResponse(error instanceof Error ? error.message : "头条号数据获取失败");
2840
+ }
2841
+ }
2842
+ async function getWeixinData(params) {
2843
+ const { token } = params;
2844
+ if (!token) return {
2845
+ code: 200,
2846
+ message: "缺少token",
2847
+ data: null
2848
+ };
2849
+ try {
2850
+ const { token } = params;
2851
+ if (!token) return types_errorResponse("缺少token", 200);
2852
+ const http = new Http({
2853
+ headers: {
2854
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2855
+ }
2856
+ });
2857
+ const userInfo = {
2858
+ originalCount: 0,
2859
+ totalUsers: 0,
2860
+ userIncrease: 0,
2861
+ yesterday: {
2862
+ read: 0,
2863
+ share: 0,
2864
+ subscribe: 0
2865
+ }
2866
+ };
2867
+ const userInfoHtml = await http.api({
2868
+ method: "get",
2869
+ url: "https://mp.weixin.qq.com/cgi-bin/home",
2870
+ params: {
2871
+ t: "home/index",
2872
+ token,
2873
+ lang: "zh_CN"
2874
+ }
2875
+ });
2876
+ const originalMatch = userInfoHtml.trim().match(/原创内容[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2877
+ if (originalMatch) userInfo.originalCount = parseInt(originalMatch[1].replace(/,/g, ''), 10);
2878
+ const totalUsersMatch = userInfoHtml.match(/总用户数[\s\S]*?<div[^>]*class=["']weui-desktop-user_sum["'][^>]*>[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2879
+ if (totalUsersMatch) userInfo.totalUsers = parseInt(totalUsersMatch[1].replace(/,/g, ''), 10);
2880
+ const increaseMatch = userInfoHtml.match(/weui-desktop-user_increase_num[^>]*>\s*([+-]?)\s*<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2881
+ if (increaseMatch) {
2882
+ const sign = '-' === increaseMatch[1] ? -1 : 1;
2883
+ userInfo.userIncrease = sign * parseInt(increaseMatch[2].replace(/,/g, ''), 10);
2884
+ }
2885
+ const readMatch = userInfoHtml.match(/昨日阅读[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2886
+ if (readMatch) userInfo.yesterday.read = parseInt(readMatch[1].replace(/,/g, ''), 10);
2887
+ const shareMatch = userInfoHtml.match(/昨日分享[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2888
+ if (shareMatch) userInfo.yesterday.share = parseInt(shareMatch[1].replace(/,/g, ''), 10);
2889
+ const subscribeMatch = userInfoHtml.match(/昨日新增关注[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2890
+ if (subscribeMatch) userInfo.yesterday.subscribe = parseInt(subscribeMatch[1].replace(/,/g, ''), 10);
2891
+ const wxData = {
2892
+ fansNum: userInfo.totalUsers,
2893
+ fansNumYesterday: userInfo.yesterday.subscribe,
2894
+ readNumYesterday: userInfo.yesterday.read,
2895
+ shareNumYesterday: userInfo.yesterday.share
2896
+ };
2897
+ return (0, share_namespaceObject.success)(wxData, "微信平台数据获取成功!");
2898
+ } catch (error) {
2899
+ return types_errorResponse(error instanceof Error ? error.message : "微信平台数据获取失败");
2900
+ }
2901
+ }
2902
+ async function getXiaohongshuData(params) {
2903
+ try {
2904
+ const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
2905
+ if (!a1Cookie) return types_errorResponse("账号数据异常,请重新绑定账号后重试。", 200);
2906
+ const http = new Http({
2907
+ headers: {
2908
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2909
+ referer: "https://creator.xiaohongshu.com",
2910
+ origin: "https://creator.xiaohongshu.com"
2911
+ }
2912
+ });
2913
+ const xsEncrypt = new XsEncrypt();
2914
+ const xt = Date.now().toString();
2915
+ const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
2916
+ const xs = await xsEncrypt.encryptXs(sevenDataUrl, a1Cookie, xt);
2917
+ const [overAllData, sevenData] = await Promise.all([
2918
+ http.api({
2919
+ method: "get",
2920
+ url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
2921
+ }),
2922
+ http.api({
2923
+ method: "get",
2924
+ baseURL: "https://creator.xiaohongshu.com",
2925
+ url: sevenDataUrl,
2926
+ headers: {
2927
+ "x-s": xs,
2928
+ "x-t": xt
2929
+ }
2930
+ })
2931
+ ]);
2932
+ const xhsData = {
2933
+ fansNum: overAllData.data.fans_count,
2934
+ favedNum: overAllData.data.faved_count,
2935
+ watchNumLastWeek: sevenData.data.seven.view_count,
2936
+ likeNumLastWeek: sevenData.data.seven.like_count,
2937
+ collectNumLastWeek: sevenData.data.seven.collect_count,
2938
+ commentNumLastWeek: sevenData.data.seven.comment_count,
2939
+ fansNumLastWeek: sevenData.data.seven.rise_fans_count,
2940
+ fansNumYesterday: sevenData.data.seven.rise_fans_list[0].count
2941
+ };
2942
+ return (0, share_namespaceObject.success)(xhsData, "小红书平台数据获取成功!");
2943
+ } catch (error) {
2944
+ return types_errorResponse(error instanceof Error ? error.message : "小红书平台数据获取失败");
2945
+ }
2946
+ }
2947
+ const SearchAccountInfo = async (_task, params)=>{
2948
+ const { platform } = params;
2949
+ switch(platform){
2950
+ case "toutiao":
2951
+ return getToutiaoData(params);
2952
+ case "xiaohongshu":
2953
+ return getXiaohongshuData(params);
2954
+ case "weixin":
2955
+ return getWeixinData(params);
2956
+ case "baijiahao":
2957
+ return getBaijiahaoData(params);
2958
+ default:
2959
+ return (0, share_namespaceObject.success)(null, "暂不支持该平台");
2960
+ }
2961
+ };
2962
+ const searchPublishInfo_types_errorResponse = (message, code = 500)=>({
2963
+ code,
2964
+ message,
2965
+ data: null
2966
+ });
2967
+ async function handleToutiaoData(params) {
2968
+ try {
2969
+ const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
2970
+ const http = new Http({
2971
+ headers: {
2972
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2973
+ }
2974
+ });
2975
+ const visitedUid = await http.api({
2976
+ url: "https://mp.toutiao.com/mp/agw/creator_center/user_info?",
2977
+ method: "get",
2978
+ params: {
2979
+ app_id: 1231
2980
+ }
2981
+ });
2982
+ const articleInfo = await http.api({
2983
+ method: "get",
2984
+ url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
2985
+ params: {
2986
+ provider_type: "mp_provider",
2987
+ aid: "13",
2988
+ app_name: "news_article",
2989
+ category: "mp_all",
2990
+ channel: "",
2991
+ stream_api_version: "88",
2992
+ genre_type_switch: '{"repost":1,"small_video":1,"toutiao_graphic":1,"weitoutiao":1,"xigua_video":1}',
2993
+ device_platform: "pc",
2994
+ platform_id: "0",
2995
+ visited_uid: visitedUid.user_id_str,
2996
+ offset: (pageNum - 1) * pageSize,
2997
+ count: pageSize,
2998
+ keyword: "",
2999
+ client_extra_params: `{"category":"mp_all","real_app_id":"1231","need_forward":"true","offset_mode":"1","page_index":"1","status":${onlySuccess ? "2" : "8"},"source":"0"}`,
3000
+ app_id: "1231"
3001
+ }
3002
+ });
3003
+ const articleCell = articleInfo.data.map((item)=>({
3004
+ title: item.assembleCell.itemCell.articleBase.title,
3005
+ imageUrl: item.assembleCell.itemCell.imageList.staggerFeedCover[0].url,
3006
+ createTime: item.assembleCell.itemCell.articleBase.publishTime,
3007
+ redirectUrl: item.assembleCell.itemCell.articleBase.articleURL,
3008
+ showNum: item.assembleCell.itemCell.itemCounter.showCount,
3009
+ readNum: item.assembleCell.itemCell.itemCounter.readCount,
3010
+ likeNum: item.assembleCell.itemCell.itemCounter.diggCount,
3011
+ commentNum: item.assembleCell.itemCell.itemCounter.commentCount,
3012
+ ...showOriginalData ? {
3013
+ originalData: item
3014
+ } : {}
3015
+ }));
3016
+ const api_base_info_json = JSON.parse(articleInfo.api_base_info.app_extra_params);
3017
+ return (0, share_namespaceObject.success)({
3018
+ articleCell,
3019
+ ...onlySuccess ? {
3020
+ pagination: {
3021
+ total: api_base_info_json.total_count || -1,
3022
+ pageNum,
3023
+ pageSize
3024
+ }
3025
+ } : null
3026
+ }, "头条号文章文章获取成功");
3027
+ } catch (error) {
3028
+ return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "头条号文章数据获取失败");
3029
+ }
3030
+ }
3031
+ async function handleWeixinData(params) {
3032
+ try {
3033
+ const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3034
+ if (!token) return {
3035
+ code: 200,
3036
+ message: "缺少token",
3037
+ data: null
3038
+ };
3039
+ const http = new Http({
3040
+ headers: {
3041
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
3042
+ }
3043
+ });
3044
+ const ParsePublishPage = (body)=>{
3045
+ const match = body.match(/publish_page\s*=\s*({[\s\S]*?});/);
3046
+ if (!match) throw new Error('无法提取 publish_page 字段');
3047
+ let parsedData = JSON.parse(match[1]);
3048
+ const decodeEntities = function(str, decode = false) {
3049
+ const encodeMap = [
3050
+ "&",
3051
+ "&amp;",
3052
+ "<",
3053
+ "&lt;",
3054
+ ">",
3055
+ "&gt;",
3056
+ " ",
3057
+ "&nbsp;",
3058
+ '"',
3059
+ "&quot;",
3060
+ "'",
3061
+ "&#39;"
3062
+ ];
3063
+ const decodeMap = [
3064
+ "&#39;",
3065
+ "'",
3066
+ "&quot;",
3067
+ '"',
3068
+ "&nbsp;",
3069
+ " ",
3070
+ "&gt;",
3071
+ ">",
3072
+ "&lt;",
3073
+ "<",
3074
+ "&amp;",
3075
+ "&",
3076
+ "&#60;",
3077
+ "<",
3078
+ "&#62;",
3079
+ ">"
3080
+ ];
3081
+ const map = decode ? decodeMap : encodeMap;
3082
+ let result = str;
3083
+ for(let i = 0; i < map.length; i += 2)result = result.replace(new RegExp(map[i], "g"), map[i + 1]);
3084
+ return result;
3085
+ };
3086
+ const finalData = {
3087
+ ...parsedData,
3088
+ publish_list: parsedData.publish_list.map((item)=>{
3089
+ const decoded = decodeEntities(item.publish_info, true);
3090
+ const parsedInfo = JSON.parse(decoded);
3091
+ return {
3092
+ publish_type: item.publish_type,
3093
+ publish_info: parsedInfo
3094
+ };
3095
+ })
3096
+ };
3097
+ return finalData;
3098
+ };
3099
+ async function fetchArticles(begin, pageSize, token) {
3100
+ return http.api({
3101
+ method: "get",
3102
+ url: 'https://mp.weixin.qq.com/cgi-bin/appmsgpublish',
3103
+ params: {
3104
+ sub: "list",
3105
+ begin: begin,
3106
+ count: pageSize,
3107
+ token: token,
3108
+ lang: "zh_CN"
3109
+ }
3110
+ });
3111
+ }
3112
+ let size = pageSize > 20 ? 20 : pageSize;
3113
+ let rawArticlesInfo = await fetchArticles((pageNum - 1) * size, size, token);
3114
+ let articlesInfo = ParsePublishPage(rawArticlesInfo);
3115
+ if (!onlySuccess && pageSize > 20) {
3116
+ let totalFetched = articlesInfo.publish_list.length;
3117
+ let nextPage = pageNum + 1;
3118
+ while(totalFetched < pageSize){
3119
+ const remaining = pageSize - totalFetched;
3120
+ const currentPageSize = remaining > 20 ? 20 : remaining;
3121
+ let _rawArticlesInfo = await fetchArticles((nextPage - 1) * 20, currentPageSize, token);
3122
+ let parsed = ParsePublishPage(_rawArticlesInfo);
3123
+ articlesInfo.publish_list = articlesInfo.publish_list.concat(parsed.publish_list);
3124
+ totalFetched = articlesInfo.publish_list.length;
3125
+ if (parsed.publish_list.length < currentPageSize) break;
3126
+ nextPage++;
3127
+ }
3128
+ }
3129
+ const articleCell = articlesInfo?.publish_list.map((item)=>({
3130
+ title: item.publish_info.appmsg_info[0].title,
3131
+ imageUrl: item.publish_info.appmsg_info[0].cover,
3132
+ createTime: item.publish_info.appmsg_info[0].line_info.send_time,
3133
+ redirectUrl: item.publish_info.appmsg_info[0].content_url,
3134
+ readNum: item.publish_info.appmsg_info[0].read_num,
3135
+ likeNum: item.publish_info.appmsg_info[0].old_like_num,
3136
+ shareNum: item.publish_info.appmsg_info[0].share_num,
3137
+ recommendNum: item.publish_info.appmsg_info[0].like_num,
3138
+ ...showOriginalData ? {
3139
+ originalData: item
3140
+ } : {}
3141
+ }));
3142
+ return (0, share_namespaceObject.success)({
3143
+ articleCell,
3144
+ ...onlySuccess ? {
3145
+ pagination: {
3146
+ total: articlesInfo?.total_count,
3147
+ pageNum,
3148
+ pageSize
3149
+ }
3150
+ } : null
3151
+ }, "微信文章文章获取成功");
3152
+ } catch (error) {
3153
+ return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "微信文章数据获取失败");
3154
+ }
3155
+ }
3156
+ async function handleBaijiahaoData(params) {
3157
+ try {
3158
+ const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3159
+ if (!token) return {
3160
+ code: 200,
3161
+ message: "缺少token",
3162
+ data: null
3163
+ };
3164
+ const http = new Http({
3165
+ headers: {
3166
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3167
+ token: token
3168
+ }
3169
+ });
3170
+ async function fetchArticles(pageNum, pageSize, onlySuccess = false) {
3171
+ return await http.api({
3172
+ method: "get",
3173
+ url: "https://baijiahao.baidu.com/pcui/article/lists",
3174
+ params: {
3175
+ currentPage: pageNum,
3176
+ pageSize: pageSize,
3177
+ search: "",
3178
+ type: "",
3179
+ collection: onlySuccess ? "publish" : "",
3180
+ clearBeforeFetch: false,
3181
+ dynamic: 1
3182
+ }
3183
+ });
3184
+ }
3185
+ const articleInfo = await fetchArticles(pageNum, pageSize, onlySuccess);
3186
+ let filtered = articleInfo.data.list.filter((item)=>"draft" !== item.status);
3187
+ const totalPage = articleInfo.data.page?.totalPage || 1;
3188
+ let currentPage = pageNum + 1;
3189
+ const usedPages = new Set();
3190
+ while(filtered.length < pageSize && currentPage <= totalPage){
3191
+ if (usedPages.has(currentPage)) {
3192
+ currentPage++;
3193
+ continue;
3194
+ }
3195
+ const res = await fetchArticles(currentPage, pageSize, onlySuccess);
3196
+ usedPages.add(currentPage);
3197
+ const validItems = res.data.list.filter((item)=>"draft" !== item.status);
3198
+ filtered.push(...validItems);
3199
+ currentPage++;
3200
+ }
3201
+ const final = filtered.slice(0, pageSize);
3202
+ const articleCell = final.map((item)=>({
3203
+ title: item.title,
3204
+ imageUrl: JSON.parse(item.cover_images)[0].src,
3205
+ createTime: Math.floor(new Date(item.publish_at.replace(/-/g, "/")).getTime() / 1000),
3206
+ redirectUrl: item.url,
3207
+ recommendNum: item.rec_amount,
3208
+ collectNum: item.collection_amount,
3209
+ readNum: item.read_amount,
3210
+ likeNum: item.like_amount,
3211
+ commentNum: item.comment_amount,
3212
+ shareNum: item.share_amount,
3213
+ ...showOriginalData ? {
3214
+ originalData: item
3215
+ } : {}
3216
+ }));
3217
+ return (0, share_namespaceObject.success)({
3218
+ articleCell,
3219
+ ...onlySuccess ? {
3220
+ pagination: {
3221
+ total: articleInfo.data.page?.totalCount,
3222
+ pageNum,
3223
+ pageSize
3224
+ }
3225
+ } : null
3226
+ }, "百家号文章数据获取成功");
3227
+ } catch (error) {
3228
+ return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
3229
+ }
3230
+ }
3231
+ async function handleXiaohongshuData(params) {
3232
+ try {
3233
+ const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3234
+ const xsEncrypt = new XsEncrypt();
3235
+ const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
3236
+ if (!a1Cookie) return {
3237
+ code: 200,
3238
+ message: "账号数据异常",
3239
+ data: null
3240
+ };
3241
+ if (onlySuccess && 10 != pageSize) return {
3242
+ code: 200,
3243
+ message: "小红书pageSize不可修改",
3244
+ data: null
3245
+ };
3246
+ const http = new Http({
3247
+ headers: {
3248
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3249
+ referer: "https://creator.xiaohongshu.com",
3250
+ origin: "https://creator.xiaohongshu.com"
3251
+ }
3252
+ });
3253
+ async function fetchArticles(pageNum, a1Cookie, onlySuccess = false) {
3254
+ const xt = Date.now().toString();
3255
+ const serveUrl = `/web_api/sns/v5/creator/note/user/posted?tab=${onlySuccess ? 1 : 0}&page=${pageNum - 1}`;
3256
+ const xs = await xsEncrypt.encryptXs(serveUrl, a1Cookie, xt);
3257
+ return await http.api({
3258
+ method: "get",
3259
+ baseURL: "https://edith.xiaohongshu.com",
3260
+ url: serveUrl,
3261
+ headers: {
3262
+ "x-s": xs,
3263
+ "x-t": xt
3264
+ }
3265
+ });
3266
+ }
3267
+ const articleInfo = await fetchArticles(pageNum, a1Cookie, onlySuccess);
3268
+ let hasNextpage = -1 != articleInfo.data.page;
3269
+ let filtered = articleInfo.data.notes;
3270
+ let currentPage = pageNum + 1;
3271
+ const usedPages = new Set();
3272
+ while(filtered.length < pageSize && hasNextpage){
3273
+ if (usedPages.has(currentPage)) {
3274
+ currentPage++;
3275
+ continue;
3276
+ }
3277
+ const res = await fetchArticles(currentPage, a1Cookie, onlySuccess);
3278
+ usedPages.add(currentPage);
3279
+ const validItems = res.data.notes;
3280
+ filtered.push(...validItems);
3281
+ currentPage++;
3282
+ hasNextpage = -1 != res.data.page;
3283
+ }
3284
+ const final = filtered.slice(0, pageSize);
3285
+ const articleCell = final.map((item)=>({
3286
+ title: item.display_title,
3287
+ imageUrl: item.images_list[0].url,
3288
+ createTime: Math.floor(new Date(item.time.replace(/-/g, "/")).getTime() / 1000),
3289
+ redirectUrl: `https://www.xiaohongshu.com/explore/${item.id}?xsec_token=${item.xsec_token}&xsec_source=pc_creatormng`,
3290
+ readNum: item.view_count,
3291
+ likeNum: item.likes,
3292
+ commentNum: item.comments_count,
3293
+ collectNum: item.collected_count,
3294
+ shareNum: item.shared_count,
3295
+ ...showOriginalData ? {
3296
+ originalData: item
3297
+ } : {}
3298
+ }));
3299
+ return (0, share_namespaceObject.success)({
3300
+ articleCell,
3301
+ ...onlySuccess ? {
3302
+ pagination: {
3303
+ nextPage: hasNextpage,
3304
+ pageNum,
3305
+ pageSize
3306
+ }
3307
+ } : null
3308
+ }, "小红书文章数据获取成功");
3309
+ } catch (error) {
3310
+ return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "小红书文章数据获取失败");
3311
+ }
3312
+ }
3313
+ const FetchArticles = async (_task, params)=>{
3314
+ const { platform } = params;
3315
+ switch(platform){
3316
+ case "toutiao":
3317
+ return handleToutiaoData(params);
3318
+ case "weixin":
3319
+ return handleWeixinData(params);
3320
+ case "baijiahao":
3321
+ return handleBaijiahaoData(params);
3322
+ case "xiaohongshu":
3323
+ return handleXiaohongshuData(params);
3324
+ default:
3325
+ return (0, share_namespaceObject.success)(null, "暂不支持该平台");
3326
+ }
3327
+ };
3328
+ const getWeixinConfig = async (_task, params)=>{
3329
+ const http = new Http({
3330
+ headers: {
3331
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
3332
+ }
3333
+ });
3334
+ const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
3335
+ const res = await http.api({
3336
+ method: "get",
3337
+ url: "https://mp.weixin.qq.com/cgi-bin/masssendpage",
3338
+ params: {
3339
+ f: 'json',
3340
+ token: params.token,
3341
+ lang: 'zh_CN',
3342
+ ajax: 1,
3343
+ fingerprint: fingerprint,
3344
+ random: Math.random().toString()
3345
+ }
3346
+ });
3347
+ const filtered = {
3348
+ publishQuota: 0 === res.base_resp.ret ? res.quota_detail_list.filter((item)=>"kQuotaTypeMassSendNormal" === item.quota_type).map((item)=>item.quota_item_list) : []
3349
+ };
3350
+ return (0, share_namespaceObject.success)(filtered, 0 === res.base_resp.ret ? "微信配置信息获取成功!" : "微信配置信息获取失败!");
3351
+ };
2617
3352
  const weitoutiaoPublish_mock_mockAction = async (task, params)=>{
2618
3353
  const tmpCachePath = task.getTmpPath();
2619
3354
  const http = new Http({
@@ -4576,9 +5311,7 @@ var __webpack_exports__ = {};
4576
5311
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
4577
5312
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
4578
5313
  };
4579
- var package_namespaceObject = {
4580
- i8: "1.2.14"
4581
- };
5314
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.16-beta.0"}');
4582
5315
  class Action {
4583
5316
  constructor(task){
4584
5317
  this.task = task;
@@ -4599,6 +5332,24 @@ var __webpack_exports__ = {};
4599
5332
  } else this.task.logger.info(`${func.name} action success`);
4600
5333
  return responseData;
4601
5334
  }
5335
+ FetchArticles(params) {
5336
+ return this.bindTask(FetchArticles, params);
5337
+ }
5338
+ SearchAccountInfo(params) {
5339
+ return this.bindTask(SearchAccountInfo, params);
5340
+ }
5341
+ TTSessionCheck(params) {
5342
+ return this.bindTask(TTSessionCheck, params);
5343
+ }
5344
+ WxSessionCheck(params) {
5345
+ return this.bindTask(WxSessionCheck, params);
5346
+ }
5347
+ XhsSessionCheck(params) {
5348
+ return this.bindTask(XhsSessionCheck, params);
5349
+ }
5350
+ BjhSessionCheck(params) {
5351
+ return this.bindTask(BjhSessionCheck, params);
5352
+ }
4602
5353
  searchToutiaoTopicList(params) {
4603
5354
  return this.bindTask(searchToutiaoTopicList, params);
4604
5355
  }
@@ -4623,6 +5374,9 @@ var __webpack_exports__ = {};
4623
5374
  getToutiaoConfig(params) {
4624
5375
  return this.bindTask(getToutiaoConfig, params);
4625
5376
  }
5377
+ getWeixinConfig(params) {
5378
+ return this.bindTask(getWeixinConfig, params);
5379
+ }
4626
5380
  getBaijiahaoConfig(params) {
4627
5381
  return this.bindTask(getBaijiahaoConfig, params);
4628
5382
  }