11
This commit is contained in:
@@ -21,6 +21,7 @@ const scheduleDate = ref(null);
|
||||
const accountDialogVisible = ref(false);
|
||||
const activePlatformKey = ref("douyin");
|
||||
const checkingAccountId = ref(null);
|
||||
const openingAccountId = ref(null);
|
||||
|
||||
const hasVideo = computed(
|
||||
() => Boolean(processedVideoPath.value || generatedVideoPath.value),
|
||||
@@ -133,6 +134,13 @@ async function onTestAccount(platform, account) {
|
||||
showFeedback(result);
|
||||
}
|
||||
|
||||
async function onOpenAccount(platform, account) {
|
||||
openingAccountId.value = account.id;
|
||||
const result = await workflow.openPublishAccount(platform.key, account.id);
|
||||
openingAccountId.value = null;
|
||||
showFeedback(result);
|
||||
}
|
||||
|
||||
function onDeleteAccount(platform, account) {
|
||||
platform.accounts = (platform.accounts || []).filter((a) => a.id !== account.id);
|
||||
if (platform.accountId === account.id) {
|
||||
@@ -337,6 +345,14 @@ function formatUpdateTime(account) {
|
||||
:loading="checkingAccountId === account.id"
|
||||
@click="onTestAccount(activePlatform, account)"
|
||||
/>
|
||||
<Button
|
||||
label="打开"
|
||||
size="small"
|
||||
severity="secondary"
|
||||
outlined
|
||||
:loading="openingAccountId === account.id"
|
||||
@click="onOpenAccount(activePlatform, account)"
|
||||
/>
|
||||
<Button
|
||||
label="删除"
|
||||
size="small"
|
||||
|
||||
@@ -126,6 +126,40 @@ export async function checkPublishLoginStatus(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ReturnType<typeof import('../stores/workflow.js').useWorkflowStore>} store
|
||||
* @param {string} platformKey
|
||||
* @param {number | null} accountId
|
||||
*/
|
||||
export async function openPublishAccount(store, platformKey, accountId = null) {
|
||||
try {
|
||||
if (accountId != null) {
|
||||
const check = await invoke("publish_check_login", {
|
||||
params: {
|
||||
platform: platformKey,
|
||||
accountId,
|
||||
checkBrowser: false,
|
||||
},
|
||||
});
|
||||
if (!check?.isLoggedIn) {
|
||||
return { ok: false, message: "该账号未登录,请先扫码登录" };
|
||||
}
|
||||
}
|
||||
await invoke("run_nodejs_script", {
|
||||
scriptName: "publish_open.js",
|
||||
params: {
|
||||
platform: platformKey,
|
||||
accountId,
|
||||
cookies: [],
|
||||
},
|
||||
});
|
||||
return { ok: true, message: "已打开平台页面" };
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
return { ok: false, message: `打开失败:${msg}` };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ReturnType<typeof import('../stores/workflow.js').useWorkflowStore>} store
|
||||
*/
|
||||
|
||||
@@ -50,6 +50,7 @@ import {
|
||||
createDefaultPublishPlatforms,
|
||||
executePublishVideo,
|
||||
checkPublishLoginStatus,
|
||||
openPublishAccount,
|
||||
loginPublishPlatform,
|
||||
refreshPublishAccounts,
|
||||
} from "../services/videoPublish.js";
|
||||
@@ -694,6 +695,10 @@ export const useWorkflowStore = defineStore("workflow", {
|
||||
return checkPublishLoginStatus(this, platformKey, accountId, checkBrowser);
|
||||
},
|
||||
|
||||
async openPublishAccount(platformKey, accountId = null) {
|
||||
return openPublishAccount(this, platformKey, accountId);
|
||||
},
|
||||
|
||||
async publishVideo(options) {
|
||||
return executePublishVideo(this, options);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user