From 01e9c268214ddca9058b694155061daef2b17ab6 Mon Sep 17 00:00:00 2001 From: pengxiaolong <15716207+pengxiaolong711@user.noreply.gitee.com> Date: Tue, 1 Jul 2025 21:22:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/account.js | 13 +- src/router/index.js | 11 +- src/utils/axios.js | 13 +- src/utils/pythonBridge.js | 158 +++++---- src/views/HomeView.vue | 47 ++- src/views/hosts/hostsList.vue | 617 ++++++++++++++++++++++------------ src/views/nav.vue | 30 +- 7 files changed, 572 insertions(+), 317 deletions(-) diff --git a/src/api/account.js b/src/api/account.js index 1bf01cb..ea46092 100644 --- a/src/api/account.js +++ b/src/api/account.js @@ -1,13 +1,12 @@ import { getAxios, postAxios, downFile } from '@/utils/axios.js' - - -export function getIdByName(name) { - return getAxios({ url: `/api/tenant/get-id-by-name?name=${name}` }) +//租户获取登录id +export function rentgetloginID(data) { + return getAxios({ url: `/api/tenant/get-id-by-name?name=${data.name}`}) } - +//登录 export function login(data) { - return postAxios({ url: '/api/user/doLogin', data }) + return postAxios({ url: '/api/user/bigbrother-doLogin', data }) } //获取国家 export function getCountryinfo(data) { @@ -20,7 +19,7 @@ export function tkaccountuseinfo(accountName) { } export function tkhostdata(data) { - return postAxios({ url: '/api/save_data/hosts_info', data }) + return postAxios({ url: '/api/big-brother/page', data }) } diff --git a/src/router/index.js b/src/router/index.js index 15237ee..b039b77 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -19,11 +19,12 @@ const routes = [ name: 'hostsList', component: () => import(/* webpackChunkName: "hostsList" */ '../views/hosts/hostsList.vue') }, - { - path: 'workBenches', - name: 'workBenches', - component: () => import(/* webpackChunkName: "hostsList" */ '../views/hosts/workbenches.vue') - },] + // { + // path: 'workBenches', + // name: 'workBenches', + // component: () => import(/* webpackChunkName: "hostsList" */ '../views/hosts/workbenches.vue') + // }, + ] } ] const router = createRouter({ diff --git a/src/utils/axios.js b/src/utils/axios.js index c504cdf..ce34f94 100644 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -17,13 +17,14 @@ let baseURL = '' if (process.env.NODE_ENV === 'development') { // 生产环境 // baseURL = "https://api.tkpage.yolozs.com" - baseURL = "http://192.168.1.174:8101" + baseURL = "http://47.79.98.113:8101" // baseURL = "http://192.168.0.103:8085/" } else { // 测试环境 // baseURL = "http://120.26.251.180:8085/" // 开发环境 - baseURL = "https://api.tkpage.yolozs.com" + // baseURL = "https://api.tkpage.yolozs.com" + baseURL = "http://47.79.98.113:8101" // baseURL = "http://api.tkpage.vvtiktok.cn" } @@ -32,7 +33,7 @@ axios.interceptors.request.use((config) => { console.log("config", config) const url = sliceUrl(config.url) console.log("url", url) - if (!(config.url == 'doLogin' || config.url == 'get-id-by-name')) { + if (!(config.url == 'bigbrother-doLogin' || config.url == 'get-id-by-name')) { config.headers['vvtoken'] = getToken(); } @@ -52,10 +53,14 @@ axios.interceptors.response.use((response) => { if (response.data.code == 0) { console.log("response", response.data.data) return response.data.data - } else { + } else if (response.data.code == 40400) { router.push('/') ElMessage.error(response.data.code + '' + response.data.message); + }else{ + ElMessage.error(response.data.code + '' + response.data.message); } + + }, (error) => { // 可添加请求失败后的处理逻辑 diff --git a/src/utils/pythonBridge.js b/src/utils/pythonBridge.js index 33ef1ee..9d3ab3c 100644 --- a/src/utils/pythonBridge.js +++ b/src/utils/pythonBridge.js @@ -1,11 +1,12 @@ // pythonBridge.js import { ref, onMounted } from 'vue'; -const bridge = ref(null); +import { ElMessage } from 'element-plus'; +const pyBridge = ref(null); // 初始化 QWebChannel const initBridge = () => { if (/localhost/.test(window.location.href)) return new QWebChannel(qt.webChannelTransport, (channel) => { - bridge.value = channel.objects.bridge; + pyBridge.value = channel.objects.bridge; }); }; export function usePythonBridge() { @@ -13,95 +14,123 @@ export function usePythonBridge() { - // 调用 Python 方法 - const fetchDataConfig = (data) => { + // // 调用 Python 方法 + // const fetchDataConfig = (data) => { + // return new Promise((resolve, reject) => { + // if (bridge.value) { + // bridge.value.fetchDataConfig(data, function (result) { + // resolve(result); + // }); + // } + + + // }); + // }; + + // // 查询获取主播的数据 + // const fetchDataCount = () => { + // return new Promise((resolve, reject) => { + // if (bridge.value) { + // bridge.value.fetchDataCount(function (result) { + // resolve(result); + // }); + // } + // }); + // }; + + + // 查询获取大哥的数据 + const controlTask = (data) => { return new Promise((resolve, reject) => { - if (bridge.value) { - bridge.value.fetchDataConfig(data, function (result) { + if (pyBridge.value) { + pyBridge.value.control_task(data,function (result) { resolve(result); }); + }else{ + console.log("pyBridge is null未连接上") } - - }); }; - // 查询获取主播的数据 - const fetchDataCount = () => { + //总数有效数 + const getBrotherInfo = () => { return new Promise((resolve, reject) => { - if (bridge.value) { - bridge.value.fetchDataCount(function (result) { - resolve(result); + if (pyBridge.value) { + pyBridge.value.getBrotherInfo(function (result) { + resolve(JSON.parse(result)); + // ElMessage.success(result); }); + }else{ + console.log("pyBridge is null未连接上") } }); }; // 打开tk后台 const loginTikTok = () => { - if (bridge.value) { - bridge.value.loginTikTok(function (result) { - + if (pyBridge.value) { + pyBridge.value.loginTikTok(function (result) { }); - } - - }; - - // 登录tk后台 - const loginBackStage = (data) => { - if (bridge.value) { - if (data.index == 0) { - bridge.value.loginBackStage(JSON.stringify(data)); - } else if (data.index == 1) { - bridge.value.loginBackStageCopy(JSON.stringify(data)); - } - + }else{ + console.log("pyBridge is null未连接上") } }; + // // 登录tk后台 + // const loginBackStage = (data) => { + // if (bridge.value) { + // if (data.index == 0) { + // bridge.value.loginBackStage(JSON.stringify(data)); + // } else if (data.index == 1) { + // bridge.value.loginBackStageCopy(JSON.stringify(data)); + // } + + // } + // }; + //跳转到主播页面 const givePyAnchorId = (id) => { - - if (bridge.value) { - bridge.value.givePyAnchorId(id, function (result) { - + console.log("id",id); + if (pyBridge.value) { + ElMessage.success(id); + pyBridge.value.givePyAnchorId(id, function (result) { }); } }; - //查询登录状态 - const backStageloginStatus = () => { - return new Promise((resolve, reject) => { - if (bridge.value) { - bridge.value.backStageloginStatus(function (result) { - resolve(result); - }); - } - }); + // //查询登录状态 + // const backStageloginStatus = () => { + // return new Promise((resolve, reject) => { + // if (bridge.value) { + // bridge.value.backStageloginStatus(function (result) { + // resolve(result); + // }); + // } + // }); - }; - //查询登录状态 - const backStageloginStatusCopy = () => { - return new Promise((resolve, reject) => { - if (bridge.value) { - bridge.value.backStageloginStatusCopy(function (result) { - resolve(result); - }); - } - }); + // }; + // //查询登录状态 + // const backStageloginStatusCopy = () => { + // return new Promise((resolve, reject) => { + // if (bridge.value) { + // bridge.value.backStageloginStatusCopy(function (result) { + // resolve(result); + // }); + // } + // }); - }; + // }; //导出表格 const exportToExcel = (data) => { - if (bridge.value) { - bridge.value.exportToExcel(JSON.stringify(data)); + if (pyBridge .value) { + pyBridge .value.exportToExcel(JSON.stringify(data)); } }; const stopScript = () => { - if (bridge.value) { - bridge.value.stopScript(); + if (pyBridge .value) { + pyBridge .value.stopScript(); } }; @@ -109,8 +138,8 @@ export function usePythonBridge() { //获取版本号 const getVersion = () => { return new Promise((resolve, reject) => { - if (bridge.value) { - bridge.value.currentVersion(function (result) { + if (pyBridge.value) { + pyBridge.value.currentVersion(function (result) { resolve(result); }); } @@ -120,15 +149,12 @@ export function usePythonBridge() { onMounted(initBridge); return { - fetchDataConfig, - fetchDataCount, - loginBackStage, loginTikTok, - givePyAnchorId, - backStageloginStatus, - backStageloginStatusCopy, exportToExcel, stopScript, - getVersion + controlTask, + getBrotherInfo, + getVersion, + givePyAnchorId }; } \ No newline at end of file diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index c0d266f..d6503e0 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -24,10 +24,9 @@