优化代码

This commit is contained in:
pengxiaolong
2025-09-25 19:40:54 +08:00
parent 8cabf98bd9
commit ea50c14175
17 changed files with 1462 additions and 271 deletions

View File

@@ -3,66 +3,78 @@
<div>
<!-- -->
<div style="display: flex">
<div></div>
<el-checkbox
class="isFilter"
v-model="queryFormData.isFilter"
label="过滤隐私用户"
size="large"
border
/>
<el-input
v-model="queryFormData.coinMin"
placeholder="最小金币"
size="large"
style="width: 180px"
type="number"
:disabled = "streamdialogVisibletext || isRunnings"
/>
<el-input
v-model="queryFormData.coinMax"
placeholder="最大金币"
size="large"
style="width: 180px;"
style="width: 180px"
class="right-input"
type="number"
:disabled = "streamdialogVisibletext || isRunnings"
/>
<el-input
v-model="queryFormData.levelMin"
placeholder="最小等级"
size="large"
style="width: 180px;"
style="width: 180px"
class="right-input"
type="number"
:disabled = "streamdialogVisibletext || isRunnings"
/>
<el-input
v-model="queryFormData.levelMax"
placeholder="最大等级"
size="large"
style="width: 180px;"
style="width: 180px"
class="right-input"
type="number"
:disabled = "streamdialogVisibletext || isRunnings"
/>
<div class="right-input right-text" style="width: 250px; height: 50px; line-height: 50px">
当前网络{{ countryData }}
</div>
<div class="right-input right-text" style="width: 160px; height: 50px; line-height: 50px">
<el-button
@click="streamdialogVisible = true"
:disabled="isRunnings"
class="put-button buttoMore-filters Specify"
type="primary"
>
<div>{{ streamdialogVisibletext ? '已指定直播间' : '指定直播间' }}</div></el-button
>
<div
class="right-input right-text"
style="width: 160px; height: 50px; line-height: 50px"
>
总数{{ getBrotherInfodata.total }}
</div>
<div class="right-input right-text" style="width: 160px;height: 50px; line-height: 50px">
<div
class="right-input right-text"
style="width: 160px; height: 50px; line-height: 50px"
>
有效数{{ getBrotherInfodata.valid }}
</div>
<el-button
class="serch-button right-input"
type="primary"
@click="Resetss"
<el-button class="serch-button right-input" type="primary" @click="Resetss"
>重置</el-button
>
<el-button
class="serch-button right-input"
style="width: 150px"
type="primary"
@click="openTikTok"
>打开 TikTok 登录</el-button
>
<el-button
v-show="queryFormData.isRunning"
class="serch-button right-input"
@@ -101,15 +113,12 @@
v-model="searchForm.displayId"
placeholder="大哥id"
size="large"
style="width: 160px;"
style="width: 160px"
class="right-input"
clearable
/>
<el-button
class="serch-button right-input"
type="primary"
@click="serch"
<el-button class="serch-button right-input" type="primary" @click="serch"
>查询</el-button
>
@@ -126,12 +135,26 @@
@click="filterdialogVisible = true"
class="put-button buttoMore-filters"
type="primary"
><img class="filters-img" src="@/assets/filter.png"
/><div style="margin-left: 10px">
更多筛选
</div></el-button>
<!-- <el-button @click="filterdialogVisible = true" style="width: 50px;" class="put-button" type="primary"><img
style="height: 30px;" src="@/assets/filter.png"></el-button> -->
><img class="filters-img" src="@/assets/filter.png" />
<div style="margin-left: 10px">更多筛选</div></el-button
>
<el-button
class="serch-button right-input"
style="width: 150px"
type="primary"
@click="openTikTok"
>打开 TikTok 登录</el-button
>
<div
class="right-input right-text"
style="width: auto; height: 50px; line-height: 50px"
>
当前网络{{ countryData }}
</div>
<div class="right-input right-text" style="width: auto; height: 50px; line-height: 50px">
运行时间{{ String(hourstuo).padStart(2, '0') }}:{{ String(minutestuo).padStart(2, '0') }}:{{ String(secondstuo).padStart(2, '0') }}
</div>
</div>
<!-- ····················································································································· -->
<div class="hostTable center-justify">
@@ -145,7 +168,7 @@
>
<!-- <el-table-column type="selection" width="35" /> -->
<el-table-column fixed prop="displayId" label="Id" width="170">
<el-table-column fixed prop="displayId" label="Id" :width="screenWidth">
<template #default="scope">
<div class="hostIdText" @click="openHTML(scope.row.displayId)">
{{ scope.row.displayId }}
@@ -158,7 +181,7 @@
:key="label.paramCode"
:prop="label.paramCode"
:label="label.paramCodeMeaning"
width="170"
:width="screenWidth"
>
<template v-if="label.paramCode != 'createDt'" #default="scope"> </template>
</el-table-column>
@@ -283,6 +306,24 @@
</span>
</template>
</el-dialog>
<el-dialog v-model="streamdialogVisible" width="800px" :before-close="handleClose">
<div class="specify-dialog">
<el-input
v-model="textarea"
style="width: 100%"
:rows="15"
type="textarea"
placeholder="请输入直播间id多个id用回车键隔开"
@input="handleInput"
/>
<div class="specify-footer">
<el-button class="specify-button" @click="specifyCancel">取消指定直播间</el-button>
<el-button class="specify-button" type="primary" @click="specifyreset"> 重置 </el-button>
<el-button class="specify-button" type="primary" @click="specifyClick"> 确认 </el-button>
</div>
</div>
</el-dialog>
</div>
</div>
</template>
@@ -302,7 +343,10 @@ import {
} from "@/api/account";
import { usePythonBridge } from "@/utils/pythonBridge";
import { getUser, setSerch, getSerch } from "@/utils/storage";
import { ref, reactive, onMounted } from "vue";
import { ref, reactive, onMounted, onBeforeUnmount } from "vue";
const hourstuo = ref(0);
const minutestuo = ref(0);
const secondstuo = ref(0);
import EChartsComponent from "@/components/EChartsComponent.vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { color } from "echarts";
@@ -310,6 +354,8 @@ import { getCountryName } from "@/utils/countryUtil";
import { ElLoading } from "element-plus";
//ip国家
let countryData = ref("");
//获取屏幕宽度
const screenWidth = ref(window.innerWidth / 11);
//获取国家
const getIpInfo = async () => {
try {
@@ -354,7 +400,9 @@ const queryFormData = ref({
coinMax: "",
levelMin: "",
levelMax: "",
isFilter: false,
isRunning: true,
anchor_ids: [],
});
//时间
const timerId = ref(null);
@@ -363,15 +411,64 @@ const getBrotherInfodata = ref({
valid: 0,
});
//结束爬取
function BigBrotherstop() {
const loading = ElLoading.service({
lock: true,
text: "正在停止...",
background: "rgba(0, 0, 0, 0.7)",
});
stopTimerfun();
isRunnings.value = false;
queryFormData.value.tenantId = userInfo.value.tenantId;
queryFormData.value.region = countryData.value;
controlTask(JSON.stringify(queryFormData.value)).then((res) => {
queryFormData.value.isRunning = true;
clearInterval(timerId.value);
timerId.value = null;
loading.close();
});
Specifystreaming(JSON.stringify(queryFormData.value)).then((res) => {
queryFormData.value.isRunning = true;
clearInterval(timerId.value);
timerId.value = null;
loading.close();
});
}
//指定直播间
function specifyClick() {
if (textarea.value == "") {
ElMessage({
type: "error",
message: "请输入直播间id",
});
return;
}
setStorageStreamId(textarea.value).then((res) => {
});
queryFormData.value.anchor_ids = textarea.value.split("\n");
streamdialogVisible.value = false;
streamdialogVisibletext.value = true;
}
//指定直播间重置
function specifyreset() {
textarea.value = "";
streamdialogVisibletext.value = false;
queryFormData.value.anchor_ids = []
}
//指定直播间取消
function specifyCancel() {
streamdialogVisible.value = false;
streamdialogVisibletext.value = false;
queryFormData.value.anchor_ids = []
}
//输入框input
function handleInput() {
streamdialogVisibletext.value = false;
}
//获取主播列表
//开始爬取
function getBigBrother() {
const loading = ElLoading.service({
lock: true,
@@ -380,15 +477,29 @@ function getBigBrother() {
});
queryFormData.value.tenantId = userInfo.value.tenantId;
queryFormData.value.region = countryData.value;
controlTask(JSON.stringify(queryFormData.value)).then((res) => {
queryFormData.value.isRunning = false;
timerId.value = setInterval(() => {
getBrotherInfo().then((res) => {
loading.close();
getBrotherInfodata.value = res;
});
}, 1000);
});
startTimerfun();
isRunnings.value = true;
if (queryFormData.value.anchor_ids == [] || queryFormData.value.anchor_ids == null || queryFormData.value.anchor_ids == undefined || queryFormData.value.anchor_ids.length == "") {
controlTask(JSON.stringify(queryFormData.value)).then((res) => {
queryFormData.value.isRunning = false;
timerId.value = setInterval(() => {
getBrotherInfo().then((res) => {
loading.close();
getBrotherInfodata.value = res;
});
}, 1000);
});
} else {
Specifystreaming(JSON.stringify(queryFormData.value)).then((res) => {
queryFormData.value.isRunning = false;
timerId.value = setInterval(() => {
getBrotherInfo().then((res) => {
loading.close();
getBrotherInfodata.value = res;
});
}, 1000);
});
}
}
const loading = ref(false);
@@ -399,6 +510,9 @@ const {
loginTikTok,
controlTask,
getBrotherInfo,
Specifystreaming,
setStorageStreamId,
getStorageStreamId
} = usePythonBridge();
let num = ref(0);
@@ -409,8 +523,8 @@ const multipleTableRef = ref(null);
let labelList = ref([
{ paramCode: "userIdStr", paramCodeMeaning: "用户id" },
{ paramCode: "level", paramCodeMeaning: "等级" },
{ paramCode: "fansLevel", paramCodeMeaning: "粉丝团等级" },
{ paramCode: "hostcoins", paramCodeMeaning: "打赏的金币" },
{ paramCode: "totalGiftCoins", paramCodeMeaning: "最低打赏金币数" },
{ paramCode: "hostDisplayId", paramCodeMeaning: "所在直播间主播id" },
{ paramCode: "region", paramCodeMeaning: "地区" },
{ paramCode: "followerCount", paramCodeMeaning: "粉丝数" },
@@ -426,8 +540,7 @@ const createTimes = ref([]);
const page = ref(1);
const pageSize = ref(10);
const fields = [
{ label: "打赏的金币", minModel: "hostcoinsMin", maxModel: "hostcoinsMax" },
{ label: "打赏金币总和", minModel: "totalGiftCoinsMin", maxModel: "totalGiftCoinsMax" },
// { label: "打赏的金币", minModel: "hostcoinsMin", maxModel: "hostcoinsMax" },
{ label: "等级", minModel: "levelMin", maxModel: "levelMax" },
];
//排序
@@ -440,23 +553,14 @@ let sortNameOptions = ref([
{ label: "打赏金币总和", type: "totalGiftCoins" },
{ label: "等级", type: "level" },
]);
//员工选择列表
let staffOptions = ref([]);
//筛选条件选择列表
//选择的员工
let staffValue = ref("");
//选择的主播列表
let selectHostList = ref([]);
//分配弹窗是否弹出
let dialogFormVisible = ref(false);
//分配情况弹窗是否弹出
let hostNameVisible = ref(false);
//备注弹窗是否弹出
let commentVisible = ref(false);
//筛选弹窗是否弹出
let filterdialogVisible = ref(false);
//是否在运行
let isRunnings = ref(false);
//是否指定直播间
let streamdialogVisibletext = ref(false);
//指定直播间弹窗
let streamdialogVisible = ref(false);
//指定直播间id
let textarea = ref("");
//分配的员工
let staffId = ref({});
//备注信息
@@ -473,10 +577,38 @@ let options = ref([]);
let version = ref("0.0.0");
onMounted(() => {
window.addEventListener("resize", handleResize);
setTimeout(() => {
getUserdata();
getStorageStreamId(1).then((res) => {
textarea.value = res == "" ? "" : JSON.parse(res);
});
}, 500);
});
// 启动计时器
function startTimerfun() {
startTime.value = setInterval(() => {
secondstuo.value++;
if (secondstuo.value >= 60) {
secondstuo.value = 0;
minutestuo.value++;
if (minutestuo.value >= 60) {
minutestuo.value = 0;
hourstuo.value++;
}
}
}, 1000);
}
// 停止计时器
function stopTimerfun() {
clearInterval(startTime.value);
}
//表格单元格长度判断
function handleResize() {
screenWidth.value = window.innerWidth / 11;
}
async function getUserdata() {
const User = await getUser();
@@ -492,21 +624,7 @@ function serch() {
}
function exportList() {
// if (searchForm.value.dataType == "InvitationType") {
// searchForm.value.dataEnd = searchForm.value.dataStart;
// }
exportToExcel(requestParams.value);
// //浏览器导出方法
// downList('export/hostsinfo',
// {
// searchTime: searchForm.value.time,
// region: searchForm.value.country,
// pageSize: pageSize.value,
// page: page.value,
// userId: userInfo.value.userId,
// }
// );
}
//分页每页条数
function handleSizeChange(val) {
@@ -562,6 +680,7 @@ const getlist = () => {
total.value = Number(res.total);
tableData.value = res.records.map((item) => ({
level: item.level, // 等级
fansLevel: item.fansLevel, // 粉丝团等级
createTime: formatDate(new Date(item.createTime)), // 创建时间
followerCount: item.followerCount, // 粉丝数
followingCount: item.followingCount, // 关注数
@@ -578,45 +697,18 @@ const getlist = () => {
function handelClick() {
filterdialogVisible.value = false;
}
function reset() {
searchForm.value = {};
sortData.value = { sortName: "createTime", sort: "desc" };
createTimes.value = [];
}
function handleClose(done) {
console.log("关闭");
done();
}
//修改主播维护状态
// function handleSelectChange(event, data) {
// upholdinfo({
// "hostId": data.hostId,
// "userId": userInfo.value.userId,
// "tenantId": userInfo.value.tenantId,
// // "comment": "我已经尽力维护,但是失败了",
// "useable": event.target.value
// }).then(res => {
// console.log(res)
// })
// }
//更改主播维护备注
// function uphostcomment() {
// upholdinfo({
// "hostId": commentHost.value,
// "userId": userInfo.value.userId,
// "tenantId": userInfo.value.tenantId,
// "comment": commentInfo.value,
// }).then(res => {
// console.log(res)
// serch()
// commentVisible.value = false
// })
// }
function filterTag(value, row) {
console.log(row.useable, value);
return row.useable === value;
@@ -626,7 +718,6 @@ function filterTag(value, row) {
function getCountry() {
getCountryinfo({})
.then((res) => {
console.log("````````国家`````````", res);
res.forEach((item) => {
if (item.countryGroupName) {
options.value.push({
@@ -635,60 +726,12 @@ function getCountry() {
});
}
});
console.log("````````国家2`````````", options.value);
})
.catch((err) => {
console.log("getCountry", err);
});
}
//获取下级员工
// const getStaff = () => {
// getStaffList({
// userId: userInfo.value.userId,
// activeYn: userInfo.value.activeYn,
// tenantId: userInfo.value.tenantId,
// }).then(res => {
// console.log(res)
// res.forEach(item => {
// staffOptions.value.push({
// value: item.userId,
// label: item.userName
// })
// })
// })
// }
// //分配主播给员工
// function allocation() {
// managerhosts({
// "manaId": userInfo.value.userId,
// "userId": staffValue.value,
// "tenantId": userInfo.value.tenantId,
// "hostIds": selectHostList.value
// }).then(res => {
// if (res) {
// dialogFormVisible.value = false
// }
// })
// }
//获取主播信息
// const getTkhostdetail = (id) => {
// tkhostdetail({
// hostId: id,
// // page: 1,
// searchTimeStart: '20250401',
// searchTimeEnd: '20250403'
// }).then(res => {
// console.log(labelList.value)
// })
// }
function openPopover(hostId, paramCode) {
isPopoverVisible[`${hostId}-${paramCode}`] = true;
}
@@ -701,30 +744,7 @@ function openHTML(id) {
console.log(id);
givePyAnchorId(id);
// upholdinfo({
// "hostId": id,
// "userId": userInfo.value.userId,
// "tenantId": userInfo.value.tenantId,
// // "comment": "我已经尽力维护,但是失败了",
// "useable": "Y"
// }).then(res => {
// getlist();
// })
}
// function openAccountName(idStr) {
// if (idStr) {
// hostNameVisible.value = true
// accountName(idStr).then(res => {
// staffId.value = JSON.stringify(res).replace(/[{}"]/g, '') // 移除所有 {} 和 "
// .split(',') // 按逗号分割成数组
// console.log(res)
// })
// }
// }
</script>
<style lang="less">
@@ -734,10 +754,10 @@ function openHTML(id) {
padding: 40px;
/* 页面无法选中 */
// -webkit-user-select: none;
// -moz-user-select: none;
// -ms-user-select: none;
// user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
.hostTable {
width: 100%;
@@ -764,11 +784,14 @@ function openHTML(id) {
border-radius: 10px;
border: none;
}
.Specify {
margin-left: 20px;
}
}
.buttoMore-filters{
.buttoMore-filters {
width: 150px;
}
.filters-img{
.filters-img {
width: 30px;
}
.el-dialog {
@@ -823,8 +846,25 @@ function openHTML(id) {
.right-input {
margin-left: 20px;
}
.right-text{
.isFilter {
margin-right: 20px;
height: 47px;
}
.right-text {
color: #666;
font-size: 16px;
}
.specify-dialog {
height: 400px;
}
.specify-footer{
width: 100%;
display: flex;
justify-content:space-around;
margin-top: 20px;
}
.specify-button{
width: 200px;
height: 50px;
}
</style>