Skip to content

Let's use AI to Earn!

feat: 快手位置和好友前端搜索添加

gaoSircb6e4e893ebb
diff --git a/electron/main/plat/plat.type.ts b/electron/main/plat/plat.type.ts
index e806efa2..4050705c 100644
--- a/electron/main/plat/plat.type.ts
+++ b/electron/main/plat/plat.type.ts
@@ -131,6 +131,7 @@ export interface IGetLocationDataParams {
keywords: string;
latitude: number;
longitude: number;
+ cityName: string;
cookie?: Electron.Cookie[];
account?: AccountModel;
}
diff --git a/electron/main/plat/platforms/Kwai/index.ts b/electron/main/plat/platforms/Kwai/index.ts
index bd8bb79a..fcc28aba 100644
--- a/electron/main/plat/platforms/Kwai/index.ts
+++ b/electron/main/plat/platforms/Kwai/index.ts
@@ -139,16 +139,42 @@ export class Kwai extends PlatformBase {
}
async getUsers(params: IGetUsersParams) {
+ const res = await kwaiPub.getUsers({
+ page: params.page,
+ cookies: JSON.parse(params.account.loginCookie),
+ });
+
return {
- status: 400,
- data: [],
+ status: res.status,
+ data: res.data?.data?.list?.map((v) => {
+ return {
+ image: v.headUrl,
+ id: `${v.userId}`,
+ name: v.userName,
+ follower_count: v.fansCount,
+ };
+ }),
};
}
async getLocationData(params: IGetLocationDataParams) {
+ const res = await kwaiPub.getLocations({
+ cookies: params.cookie!,
+ cityName: params.cityName,
+ keyword: params.keywords,
+ });
return {
- status: 400,
- data: [],
+ status: res.status,
+ data: res.data?.locations?.map((v) => {
+ return {
+ name: v.title,
+ simpleAddress: v.address,
+ id: `${v.id}`,
+ latitude: v.latitude,
+ longitude: v.longitude,
+ city: v.city,
+ };
+ }),
};
}
}
diff --git a/electron/main/views.ts b/electron/main/views.ts
index b4400184..fcd01f52 100644
--- a/electron/main/views.ts
+++ b/electron/main/views.ts
@@ -28,17 +28,17 @@ export function views(win: Electron.BrowserWindow) {
const res = await requestNet({
url: `https://map.baidu.com/?qt=ipLocation&t=${Date.now()}`,
headers: {
- cookie: `BAIDUID=C6DFA184EA0E181B507D36D4E39DE552:FG=1; BAIDUID_BFESS=C6DFA184EA0E181B507D36D4E39DE552:FG=1; BAIDU_WISE_UID=wapp_1740893445646_358; ZFY=gFmlsByYQo2uV:A8KgAXQ5Ou6usNB8S4rufvkkSZ9WfE:C; arialoadData=false; RT="z=1&dm=baidu.com&si=6acd8df5-273b-4d7b-a273-72762d6a27a7&ss=m7snsitx&sl=0&tt=0&bcn=https%3A%2F%2Ffclog.baidu.com%2Flog%2Fweirwood%3Ftype%3Dperf&r=32ngg0aq&ul=3pfv&hd=3pg5"; PSTM=1740990133; H_PS_PSSID=61027_61680_62126_62169_62200_62278_62325_62344_62345_62328_62367_62369_62372_62246_62391; BA_HECTOR=24a02la1al052hag8g01a0a1bclj991jsaplo1v; BIDUPSID=256707C2A28F613DE9EA4FC5C7347285`
+ cookie: `BAIDUID=C6DFA184EA0E181B507D36D4E39DE552:FG=1; BAIDUID_BFESS=C6DFA184EA0E181B507D36D4E39DE552:FG=1; BAIDU_WISE_UID=wapp_1740893445646_358; ZFY=gFmlsByYQo2uV:A8KgAXQ5Ou6usNB8S4rufvkkSZ9WfE:C; arialoadData=false; RT="z=1&dm=baidu.com&si=6acd8df5-273b-4d7b-a273-72762d6a27a7&ss=m7snsitx&sl=0&tt=0&bcn=https%3A%2F%2Ffclog.baidu.com%2Flog%2Fweirwood%3Ftype%3Dperf&r=32ngg0aq&ul=3pfv&hd=3pg5"; PSTM=1740990133; H_PS_PSSID=61027_61680_62126_62169_62200_62278_62325_62344_62345_62328_62367_62369_62372_62246_62391; BA_HECTOR=24a02la1al052hag8g01a0a1bclj991jsaplo1v; BIDUPSID=256707C2A28F613DE9EA4FC5C7347285`,
},
method: 'GET',
});
- console.log(res);
const { lat, lng } = res.data.rgc.result.location;
const gcj02 = coordtransform.bd09togcj02(lng, lat);
return {
bd09: [lng, lat],
wgs84: coordtransform.gcj02towgs84(gcj02[0], gcj02[1]),
gcj02,
+ city: res.data.rgc.result.addressComponent.city,
};
});
diff --git a/electron/plat/Kwai/index.ts b/electron/plat/Kwai/index.ts
index 3c5ae2a1..1c36d5a5 100644
--- a/electron/plat/Kwai/index.ts
+++ b/electron/plat/Kwai/index.ts
@@ -1,11 +1,13 @@
import { Browser, chromium, webkit } from 'playwright';
import requestNet from '../requestNet';
import {
+ IKwaiGetLocationsResponse,
IKwaiGetTopicsResponse,
+ IKwaiGetUsersResponse,
IKwaiPubVideoParams,
IKwaiUserInfoResponse,
- ILoginResponse,
-} from './kwai.type';
+ ILoginResponse
+} from "./kwai.type";
import { cookieToPlaywright, CookieToString } from '../utils';
import { BrowserWindow } from 'electron';
import { KwaiVisibleTypeEnum } from '../plat.common.type';
@@ -260,6 +262,55 @@ class KwaiPub {
},
});
}
+
+ // 获取关注用户
+ async getUsers({
+ page,
+ cookies,
+ }: {
+ page: number;
+ cookies: Electron.Cookie[];
+ }) {
+ return await requestNet<IKwaiGetUsersResponse>({
+ url: `https://cp.kuaishou.com/rest/cp/works/v2/video/pc/at/list`,
+ method: 'POST',
+ headers: {
+ cookie: CookieToString(cookies),
+ },
+ body: {
+ atType: 3,
+ pageCount: page,
+ pageSize: 10,
+ 'kuaishou.web.cp.api_ph': 'fe283c2f058ddb7a3098f89511fbd536dd82',
+ },
+ });
+ }
+
+ // 获取快手位置
+ async getLocations({
+ cookies,
+ cityName,
+ keyword,
+ }: {
+ cookies: Electron.Cookie[];
+ cityName: string;
+ keyword: string;
+ }) {
+ return await requestNet<IKwaiGetLocationsResponse>({
+ url: `https://cp.kuaishou.com/rest/zt/location/wi/poi/search?kpn=kuaishou_cp&subBiz=CP%2FCREATOR_PLATFORM&kuaishou.web.cp.api_ph=fe283c2f058ddb7a3098f89511fbd536dd82`,
+ method: 'POST',
+ headers: {
+ cookie: CookieToString(cookies),
+ },
+ body: {
+ cityName,
+ count: 50,
+ keyword,
+ pcursor: '',
+ 'kuaishou.web.cp.api_ph': 'fe283c2f058ddb7a3098f89511fbd536dd82',
+ },
+ });
+ }
}
export const kwaiPub = new KwaiPub();
diff --git a/electron/plat/Kwai/kwai.type.ts b/electron/plat/Kwai/kwai.type.ts
index fe15bdb3..1b7daebd 100644
--- a/electron/plat/Kwai/kwai.type.ts
+++ b/electron/plat/Kwai/kwai.type.ts
@@ -55,6 +55,34 @@ export type IKwaiGetTopicsResponse = IKwaiUserCommonResponse<{
}[];
}>;
+// 获取快手关注用户返回的数据
+export type IKwaiGetUsersResponse = IKwaiUserCommonResponse<{
+ list: {
+ userName: string;
+ userId: number;
+ fansCount: number;
+ headUrl: string;
+ }[];
+ name: string;
+ type: number;
+}>;
+
+// 获取快手位置数据
+export type IKwaiGetLocationsResponse = {
+ locations: {
+ id: number;
+ title: string;
+ address: string;
+ city: string;
+ category: number;
+ latitude: number;
+ longitude: number;
+ idString: string;
+ }[];
+ pcursor: string;
+ result: number;
+};
+
// 快手视频发布入参
export interface IKwaiPubVideoParams {
// cookies
diff --git a/src/icp/view.ts b/src/icp/view.ts
index 86d43099..4372de83 100644
--- a/src/icp/view.ts
+++ b/src/icp/view.ts
@@ -24,6 +24,7 @@ export async function icpGetLocation() {
bd09: number[];
wgs84: number[];
gcj02: number[];
+ city: string;
} = await window.ipcRenderer.invoke('GET_LOCATION');
return res;
}
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
index 4ef0bac4..345e7bef 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
@@ -351,7 +351,8 @@ const VideoPubSetModal_KWAI = memo(
<UserSelect
currChooseAccount={currChooseAccount}
maxCount={10}
- tips="您可以@10个视频号"
+ tips="您可以添加100个好友"
+ title="@好友"
/>
<ActivitySelect currChooseAccount={currChooseAccount} />
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx
index bb65d871..4de858ab 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx
@@ -8,6 +8,8 @@ import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPa
import { useShallow } from 'zustand/react/shallow';
import { VisibleTypeEnum } from '@@/publish/PublishEnum';
import TopicSelect from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/TopicSelect';
+import LocationSelect from '../components/LocationSelect';
+import UserSelect from "../components/UserSelect";
const { TextArea } = Input;
@@ -50,6 +52,16 @@ const VideoPubSetModal_KWAI = memo(
tips="您可以添加3个话题"
/>
+ <UserSelect
+ currChooseAccount={currChooseAccount}
+ maxCount={3}
+ title="@好友"
+ tips="您可以添加3个好友"
+ isSearch={false}
+ />
+
+ <LocationSelect currChooseAccount={currChooseAccount} />
+
<h1>查看权限</h1>
<Radio.Group
options={[
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx
index c471ff75..23dd679e 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx
@@ -178,8 +178,9 @@ const VideoPubSetModal_KWAI = memo(
<UserSelect
currChooseAccount={currChooseAccount}
- maxCount={100}
- tips="您可以添加100个好友"
+ maxCount={10}
+ tips="您可以添加10个视频号"
+ title="@视频号"
/>
<LocationSelect currChooseAccount={currChooseAccount} />
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx
index 5fdcc6e4..29497c4b 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx
@@ -69,7 +69,7 @@ const VideoPubSetModal_KWAI = memo(
tips="您可以添加20个话题"
/>
- <UserSelect currChooseAccount={currChooseAccount} />
+ <UserSelect currChooseAccount={currChooseAccount} title="@用户" />
<LocationSelect currChooseAccount={currChooseAccount} />
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx
index bb24f85c..000e11a9 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx
@@ -31,12 +31,13 @@ export default function LocationSelect({
);
const { fetching, options, debounceFetcher } =
useDebounceFetcher<ILocationDataItem>(async (keywords) => {
- if (location.current.length === 0) await getLocation();
+ if (location.current.loca.length === 0) await getLocation();
const locationData = await icpGetLocationData({
account: currChooseAccount.account!,
keywords,
- latitude: location.current[1],
- longitude: location.current[0],
+ latitude: location.current.loca[1],
+ longitude: location.current.loca[0],
+ cityName: location.current.city,
});
if (locationData.status !== 200 && locationData.status !== 201) {
if (locationData.status === 401 || locationData.data === undefined) {
@@ -52,7 +53,13 @@ export default function LocationSelect({
return locationData.data || [];
});
// 位置 0=经度 1=纬度
- const location = useRef<number[]>([]);
+ const location = useRef<{
+ loca: number[];
+ city: string;
+ }>({
+ loca: [],
+ city: '',
+ });
useEffect(() => {
getLocation();
@@ -60,7 +67,8 @@ export default function LocationSelect({
const getLocation = async () => {
const res = await icpGetLocation();
- location.current = res.gcj02;
+ location.current.loca = res.gcj02;
+ location.current.city = res.city;
};
return (
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx
index e61efe94..5e165b10 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx
@@ -12,11 +12,15 @@ import { icpGetUsers } from '../../../../../../../icp/publish';
import { AccountStatus } from '../../../../../../../../commont/AccountEnum';
import { ipcUpdateAccountStatus } from '../../../../../../../icp/account';
import { describeNumber } from '../../../../../../../utils';
+import { onAccountLoginFinish } from '../../../../../../../icp/receiveMsg';
interface DebounceSelectProps<ValueType = any>
extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
currChooseAccount: IVideoChooseItem;
tips?: string;
+ title: string;
+ // 是否需要搜索,默认需要
+ isSearch?: boolean;
}
// 话题选择器
@@ -30,36 +34,50 @@ export default function UserSelect({
updateAccounts: state.updateAccounts,
})),
);
- const { fetching, options, debounceFetcher } = useDebounceFetcher<IUsersItem>(
- async (keywords) => {
- const res = await icpGetUsers({
- page: 1,
- keyword: keywords,
- account: currChooseAccount.account!,
- });
- if (res.status !== 200 && res.status !== 201) {
- if (res.status === 401) {
- currChooseAccount.account!.status = AccountStatus.DISABLE;
- updateAccounts({ accounts: [currChooseAccount.account!] });
- await ipcUpdateAccountStatus(
- currChooseAccount.account!.id,
- AccountStatus.DISABLE,
- );
- }
- return [];
+ const { fetching, options, debounceFetcher, setOptions } =
+ useDebounceFetcher<IUsersItem>(async (keywords) => {
+ return await getList(keywords);
+ });
+
+ const getList = async (keywords?: string) => {
+ const res = await icpGetUsers({
+ page: 1,
+ keyword: keywords || '',
+ account: currChooseAccount.account!,
+ });
+ if (res.status !== 200 && res.status !== 201) {
+ if (res.status === 401) {
+ currChooseAccount.account!.status = AccountStatus.DISABLE;
+ updateAccounts({ accounts: [currChooseAccount.account!] });
+ await ipcUpdateAccountStatus(
+ currChooseAccount.account!.id,
+ AccountStatus.DISABLE,
+ );
}
- console.log(res);
- return res.data || [];
- },
- );
+ return [];
+ }
+ return res.data || [];
+ };
+
+ useEffect(() => {
+ if (props.isSearch === false) {
+ getList().then((res) => {
+ setOptions(res);
+ });
- useEffect(() => {}, []);
+ onAccountLoginFinish(() => {
+ getList().then((res) => {
+ setOptions(res);
+ });
+ });
+ }
+ }, []);
return (
<>
- <h1>@好友</h1>
+ <h1>{props.title}</h1>
<Select
- showSearch
+ showSearch={props.hasOwnProperty('isSearch') ? props.isSearch : true}
allowClear
style={{ width: '100%' }}
mode="multiple"
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher.ts b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher.ts
index 9e44fc69..c7a5f02e 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher.ts
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher.ts
@@ -33,5 +33,6 @@ export default function useDebounceFetcher<T>(
options,
fetching,
debounceFetcher,
+ setOptions,
};
}