11
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { defineStore, acceptHMRUpdate } from "pinia";
|
||||
|
||||
const defaultPublishPlatforms = () => [
|
||||
{ label: "*音", checked: false, account: null },
|
||||
@@ -11,6 +11,15 @@ export const useWorkflowStore = defineStore("workflow", {
|
||||
state: () => ({
|
||||
// 01 IP 深度学习
|
||||
ipMode: "ipBrain",
|
||||
ipBrainModalVisible: false,
|
||||
ipBrainProfileUrl: "",
|
||||
ipBrainCollecting: false,
|
||||
ipBenchmarks: [],
|
||||
ipTopics: [],
|
||||
ipBrainSelectedBenchmarkId: null,
|
||||
videoLinkModalVisible: false,
|
||||
videoShareText: "",
|
||||
videoRewriting: false,
|
||||
recognizedContent: "",
|
||||
videoType: "口播文案",
|
||||
copyType: "人设型",
|
||||
@@ -71,9 +80,69 @@ export const useWorkflowStore = defineStore("workflow", {
|
||||
keywordCountDescribe: (state) => countLines(state.keywordsDescribe),
|
||||
keywordCountAction: (state) => countLines(state.keywordsAction),
|
||||
keywordCountEmotion: (state) => countLines(state.keywordsEmotion),
|
||||
ipBenchmarkCount: (state) => state.ipBenchmarks.length,
|
||||
selectedBenchmark: (state) =>
|
||||
state.ipBenchmarks.find((b) => b.id === state.ipBrainSelectedBenchmarkId) ?? null,
|
||||
},
|
||||
|
||||
actions: {
|
||||
openIpBrainDialog() {
|
||||
this.ipBrainModalVisible = true;
|
||||
},
|
||||
|
||||
closeIpBrainDialog() {
|
||||
this.ipBrainModalVisible = false;
|
||||
},
|
||||
|
||||
async startIpBrainCollect() {
|
||||
const url = this.ipBrainProfileUrl?.trim();
|
||||
if (!url) {
|
||||
return { ok: false, message: "请输入账号主页或分享链接" };
|
||||
}
|
||||
if (this.ipBenchmarks.length >= 5) {
|
||||
return { ok: false, message: "最多添加 5 个对标账号" };
|
||||
}
|
||||
|
||||
this.ipBrainCollecting = true;
|
||||
try {
|
||||
// TODO: 对接后端采集 API / Tauri 浏览器自动化
|
||||
await new Promise((r) => setTimeout(r, 800));
|
||||
|
||||
const benchmark = {
|
||||
id: `bm_${Date.now()}`,
|
||||
url,
|
||||
label: truncateUrl(url),
|
||||
};
|
||||
this.ipBenchmarks.push(benchmark);
|
||||
this.ipBrainSelectedBenchmarkId = benchmark.id;
|
||||
this.ipTopics = Array.from({ length: 5 }, (_, i) => ({
|
||||
id: `topic_${Date.now()}_${i}`,
|
||||
title: `示例视频标题 ${i + 1}(待对接真实采集)`,
|
||||
}));
|
||||
this.ipBrainProfileUrl = "";
|
||||
this.ipBrainModalVisible = false;
|
||||
return { ok: true, message: "采集完成" };
|
||||
} finally {
|
||||
this.ipBrainCollecting = false;
|
||||
}
|
||||
},
|
||||
|
||||
selectBenchmark(id) {
|
||||
this.ipBrainSelectedBenchmarkId = id;
|
||||
this.ipTopics = [];
|
||||
},
|
||||
|
||||
openVideoLinkDialog() {
|
||||
this.videoLinkModalVisible = true;
|
||||
},
|
||||
|
||||
closeVideoLinkDialog() {
|
||||
this.videoLinkModalVisible = false;
|
||||
},
|
||||
|
||||
async startVideoRewrite() {
|
||||
return executeVideoRewrite(this);
|
||||
},
|
||||
resetAll() {
|
||||
this.$reset();
|
||||
this.publishPlatforms = defaultPublishPlatforms();
|
||||
@@ -85,7 +154,59 @@ export const useWorkflowStore = defineStore("workflow", {
|
||||
},
|
||||
});
|
||||
|
||||
export async function executeVideoRewrite(store) {
|
||||
const text = store.videoShareText?.trim();
|
||||
if (!text) {
|
||||
return { ok: false, message: "请粘贴视频分享文本或视频链接" };
|
||||
}
|
||||
|
||||
const unsupported = detectUnsupportedPlatform(text);
|
||||
if (unsupported) {
|
||||
return { ok: false, message: unsupported };
|
||||
}
|
||||
|
||||
store.videoRewriting = true;
|
||||
try {
|
||||
// TODO: 对接 FUNASR 语音识别与仿写 API
|
||||
await new Promise((r) => setTimeout(r, 1000));
|
||||
|
||||
store.recognizedContent =
|
||||
"【示例识别结果】这里是 FUNASR 语音识别后的原始文案内容,待对接后端后将显示真实结果。\n\n" +
|
||||
`来源:${truncateUrl(text, 48)}`;
|
||||
store.videoShareText = "";
|
||||
store.videoLinkModalVisible = false;
|
||||
return { ok: true, message: "仿写完成" };
|
||||
} finally {
|
||||
store.videoRewriting = false;
|
||||
}
|
||||
}
|
||||
|
||||
const UNSUPPORTED_PLATFORM_RULES = [
|
||||
{ pattern: /kuaishou\.com|ksurl\.cn|gifshow\.com/i, name: "快手" },
|
||||
{ pattern: /xiaohongshu\.com|xhslink\.com/i, name: "小红书" },
|
||||
{ pattern: /bilibili\.com|b23\.tv/i, name: "B站" },
|
||||
{ pattern: /channels\.weixin\.qq\.com|finder\.video\.qq\.com/i, name: "视频号" },
|
||||
];
|
||||
|
||||
function detectUnsupportedPlatform(text) {
|
||||
for (const { pattern, name } of UNSUPPORTED_PLATFORM_RULES) {
|
||||
if (pattern.test(text)) {
|
||||
return `${name}分享链接暂不支持,请使用抖音分享文本或视频链接`;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function truncateUrl(url, max = 36) {
|
||||
if (url.length <= max) return url;
|
||||
return `${url.slice(0, max)}…`;
|
||||
}
|
||||
|
||||
function countLines(text) {
|
||||
if (!text?.trim()) return 0;
|
||||
return text.split("\n").filter((line) => line.trim()).length;
|
||||
}
|
||||
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useWorkflowStore, import.meta.hot));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user