mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
d2974a9ff6
* refactor(adapters): convert adapter layer from TypeScript to JavaScript Core framework stays TypeScript; adapter layer moves to JS-first. Adapters are essentially "executable config + browser scripts" that barely use TS features — this simplifies the build/distribution pipeline by removing the dist/clis/ intermediate compilation step. Changes: - Convert all 753 adapter files in clis/ from .ts to .js - Update tsconfig to exclude clis/ from compilation - Simplify build-manifest to scan clis/*.js directly (no dist/clis/) - Update discovery, main, fetch-adapters to load JS adapters from clis/ - Update generate-verified to output .js artifacts - Update package.json files field: dist/clis/ → clis/ - Fix all test files for the .ts → .js transition * fix(main): use findPackageRoot for BUILTIN_CLIS path The previous relative path (../../clis from __dirname) only worked for dist/src/main.js but broke dev mode (tsx src/main.ts) where __dirname is <repo>/src — resolving to /clis instead of <repo>/clis. Use findPackageRoot() which works for both dev and prod paths.
46 lines
1.8 KiB
JavaScript
46 lines
1.8 KiB
JavaScript
/**
|
||
* BOSS直聘 exchange — request phone/wechat exchange with a candidate.
|
||
*/
|
||
import { cli, Strategy } from '@jackwener/opencli/registry';
|
||
import { requirePage, navigateToChat, bossFetch, findFriendByUid, verbose } from './utils.js';
|
||
cli({
|
||
site: 'boss',
|
||
name: 'exchange',
|
||
description: 'BOSS直聘交换联系方式(请求手机/微信)',
|
||
domain: 'www.zhipin.com',
|
||
strategy: Strategy.COOKIE,
|
||
navigateBefore: false,
|
||
browser: true,
|
||
args: [
|
||
{ name: 'uid', required: true, positional: true, help: 'Encrypted UID of the candidate' },
|
||
{ name: 'type', default: 'phone', choices: ['phone', 'wechat'], help: 'Exchange type: phone or wechat' },
|
||
],
|
||
columns: ['status', 'detail'],
|
||
func: async (page, kwargs) => {
|
||
requirePage(page);
|
||
const exchangeType = kwargs.type || 'phone';
|
||
verbose(`Requesting ${exchangeType} exchange for ${kwargs.uid}...`);
|
||
await navigateToChat(page);
|
||
const friend = await findFriendByUid(page, kwargs.uid, { checkGreetList: true });
|
||
if (!friend)
|
||
throw new Error('未找到该候选人');
|
||
const friendName = friend.name || '候选人';
|
||
const typeId = exchangeType === 'wechat' ? 2 : 1;
|
||
const params = new URLSearchParams({
|
||
type: String(typeId),
|
||
securityId: friend.securityId || '',
|
||
uniqueId: String(friend.uid),
|
||
name: friendName,
|
||
});
|
||
await bossFetch(page, 'https://www.zhipin.com/wapi/zpchat/exchange/request', {
|
||
method: 'POST',
|
||
body: params.toString(),
|
||
});
|
||
const typeLabel = exchangeType === 'wechat' ? '微信' : '手机号';
|
||
return [{
|
||
status: '✅ 交换请求已发送',
|
||
detail: `已向 ${friendName} 发送${typeLabel}交换请求`,
|
||
}];
|
||
},
|
||
});
|