42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
"use strict";
|
|
|
|
const {
|
|
newLoginPage,
|
|
detachLoginBrowser,
|
|
LOGIN_URLS,
|
|
} = require("./publish_browser.js");
|
|
|
|
const OPEN_URLS = {
|
|
douyin: "https://creator.douyin.com/creator-micro/content/upload",
|
|
kuaishou: "https://cp.kuaishou.com/article/publish/video",
|
|
shipin: "https://channels.weixin.qq.com/post/list",
|
|
xiaohongshu: "https://creator.xiaohongshu.com/publish/publish",
|
|
};
|
|
|
|
globalThis.__nodejsMain = async function main(params) {
|
|
const p = params || {};
|
|
const platform = String(p.platform || "").trim();
|
|
const accountId = p.accountId || null;
|
|
const cookies = Array.isArray(p.cookies) ? p.cookies : [];
|
|
const targetUrl = OPEN_URLS[platform] || LOGIN_URLS[platform];
|
|
|
|
if (!targetUrl) {
|
|
return { success: false, message: `不支持的平台: ${platform}` };
|
|
}
|
|
|
|
globalThis.__native?.emitProgress?.("正在打开浏览器…");
|
|
const page = await newLoginPage(platform, accountId, cookies, targetUrl);
|
|
const cur = page.url();
|
|
if (!cur || cur === "about:blank" || !cur.includes("://")) {
|
|
await page.goto(targetUrl, { waitUntil: "domcontentloaded", timeout: 60000 });
|
|
}
|
|
await detachLoginBrowser(platform, accountId);
|
|
|
|
return {
|
|
success: true,
|
|
message: "已打开平台页面",
|
|
url: page.url(),
|
|
};
|
|
};
|
|
|