优化代码

This commit is contained in:
pengxiaolong
2025-08-21 21:36:08 +08:00
parent 5a39e461fe
commit 89014e306e
21 changed files with 370 additions and 151 deletions

View File

@@ -397,12 +397,32 @@ const chatList = ref({
//监听会话消息
function onConversationsUpdated(conversations) {
chatList.value = conversations;
if (chatList.value.unreadTotal != 0) {
initNotification();
}
}
//谷歌通知提醒
function initNotification() {
if (Notification.permission !== "granted") {
Notification.requestPermission().then(showNotification);
} else {
showNotification();
}
}
function showNotification() {
new Notification("新消息到达", {
body: "您有 "+ chatList.value.unreadTotal +" 封未读消息",
lang: "zh-CN", // 语言
// onClick: () => window.location.href = "/nav/Message",
});
}
//获取会话列表
function getChatList() {
goEasyGetConversations().then((res) => {
chatList.value = res.content;
});
}).catch((err) => {});
}
//重发邮箱验证
@@ -416,7 +436,7 @@ function ResendEmail() {
}).then(res => {
isResendEmail.value = 1;
setInterval(startCountdown, 1000);
});
}).catch((err) => {});
}
//修改新邮箱
@@ -442,7 +462,7 @@ function changeEmail() {
ElMessage.success("修改成功,请至新邮箱中验证邮箱");
emailVisible.value = false;
UserInfo();
});
}).catch((err) => {});
}
//获取验证码
@@ -456,7 +476,7 @@ function sendEmail() {
}).then(res => {
isSendEmail.value = 1;
setInterval(startCountdown, 1000);
});
}).catch((err) => {});
}
function startCountdown() {
@@ -516,7 +536,7 @@ function changePassword() {
}).then(res => {
passwordVisible.value = false;
ElMessage.success("修改成功");
});
}).catch((err) => {});
}
//修改昵称
function handleNickNameChange() {
@@ -527,7 +547,7 @@ function handleNickNameChange() {
setStorage("user", res);
ElMessage.success("修改成功");
UserInfo();
});
}).catch((err) => {});
}
// 上传头像
const headers = {
@@ -545,7 +565,7 @@ const handleAvatarSuccess = (
setStorage("user", res);
ElMessage.success("修改成功");
UserInfo();
});
}).catch((err) => {});
}
const beforeAvatarUpload = (rawFile) => {
@@ -671,7 +691,7 @@ function getAnchorLibrary() {
}
).then(res => {
anchorLibrary.value = res;
});
}).catch((err) => {});
}
//侧边导航
@@ -716,8 +736,8 @@ function popoverClick(id) {
clearStorage("user")
clearStorage("token")
clearStorage("activeId")
})
});
}).catch((err) => {});
}).catch((err) => {});
}
}
@@ -727,7 +747,7 @@ function setsignIn() {
userId: info.value.id,
}).then(res => {
ElMessage.success("签到成功");
});
}).catch((err) => {});
}
//获取用户数据
@@ -743,7 +763,7 @@ function UserInfo() {
if (info.value.mailVerification == 1) {
ElMessage.error("邮箱未验证,请至设置验证邮箱,如果已经验证请刷新页面");
}
});
}).catch((err) => {});
}
const refname = ref('');
@@ -754,13 +774,13 @@ watch(refname, async (newQuestion, oldQuestion) => {
onMounted(() => {
getPromiseStorage('activeId').then(res => {
activeId.value = res || 1;
});
}).catch((err) => {});
getPromiseStorage('user').then(res => {
info.value = res;
avatar.value = info.value.headerIcon;
getAnchorLibrary()
UserInfo();
});
}).catch((err) => {});
setTimeout(() => {
getChatList();

View File

@@ -209,7 +209,7 @@ function agreedialogConfirm(){
ElMessage.success("同意成功");
PkIDInfodata.value.pkStatus = 1;
agreedialog.value = false
});
}).catch((err) => {});
}
//确认拒绝
@@ -221,7 +221,7 @@ function refusedialogConfirm(){
ElMessage.success("拒绝成功");
PkIDInfodata.value.pkStatus = 2;
refusedialog.value = false
});
}).catch((err) => {});
}
//同意邀请
@@ -244,7 +244,7 @@ watch(
}).then((res) => {
PkIDInfodata.value = res;
console.log("PkIDInfodata", res);
});
}).catch((err) => {});
pkArticleDetail({
id: newVal.payload.customData.pkIdA,
userId: info.value.id,
@@ -252,7 +252,7 @@ watch(
}).then((res) => {
ArticleDetailsA.value = res;
console.log("ArticleDetailsA", res);
});
}).catch((err) => {});
pkArticleDetail({
id: newVal.payload.customData.pkIdB,
userId: info.value.id,
@@ -260,7 +260,7 @@ watch(
}).then((res) => {
ArticleDetailsB.value = res;
console.log("ArticleDetailsB", res);
});
}).catch((err) => {});
},
{ immediate: true }
);
@@ -268,7 +268,7 @@ watch(
onMounted(() => {
getPromiseStorage("user").then((res) => {
info.value = res;
});
}).catch((err) => {});
});
onUpdated(() => {
// 组件更新后执行

View File

@@ -192,7 +192,7 @@ function agreedialogConfirm() {
ElMessage.success("同意成功");
PkIDInfodata.value.pkStatus = 1;
agreedialog.value = false;
});
}).catch((err) => {});
}
//确认拒绝
@@ -204,7 +204,7 @@ function refusedialogConfirm() {
ElMessage.success("拒绝成功");
PkIDInfodata.value.pkStatus = 2;
refusedialog.value = false;
});
}).catch((err) => {});
}
//同意邀请
@@ -227,7 +227,7 @@ watch(
}).then((res) => {
PkIDInfodata.value = res;
console.log("PkIDInfodata", res);
});
}).catch((err) => {});
pkArticleDetail({
id: newVal.payload.customData.pkIdA,
userId: info.value.id,
@@ -235,7 +235,7 @@ watch(
}).then((res) => {
ArticleDetailsA.value = res;
console.log("ArticleDetailsA", res);
});
}).catch((err) => {});
pkArticleDetail({
id: newVal.payload.customData.pkIdB,
userId: info.value.id,
@@ -243,7 +243,7 @@ watch(
}).then((res) => {
ArticleDetailsB.value = res;
console.log("ArticleDetailsB", res);
});
}).catch((err) => {});
},
{ immediate: true }
);
@@ -251,7 +251,7 @@ watch(
onMounted(() => {
getPromiseStorage("user").then((res) => {
info.value = res;
});
}).catch((err) => {});
});
onUpdated(() => {
// 组件更新后执行

View File

@@ -9,6 +9,7 @@
class="anchor-library-list"
style="overflow: auto"
v-infinite-scroll="load"
v-if="list.length !== 0"
>
<div class="anchor-library-card" v-for="(item, index) in list" :key="index">
<div class="card-content">
@@ -46,6 +47,9 @@
</div>
</div>
</div>
<div class="chatNotDeta" v-if="list.length === 0">
<div class="chatNotDeta-text">您还没有主播快去添加吧</div>
</div>
</div>
</el-splitter-panel>
<el-splitter-panel size="25%" :collapsible="true" :resizable="false">
@@ -102,7 +106,8 @@
</el-splitter>
</div>
<!-- 确认删除弹窗 -->
<el-dialog center
<el-dialog
center
class="center-dialog"
v-model="centerDialogVisible"
title="提示"
@@ -147,7 +152,7 @@ const genderOptions = [
const gendervalue = ref(null); // 性别值
const countryvalue = ref(null); //国家
const anchorName = ref(null); // 主播名称
const list = ref([{}, {}, {}, {}, {}, {}]);
const list = ref([]);
const user = ref(null); // 用户信息
const AnchorProfilePicture = ref(null); // 主播头像
const centerDialogVisible = ref(false); // 确认删除弹窗
@@ -189,11 +194,13 @@ function cancel() {
// 删除主播
const deleteAnchorID = ref(null);
const deleteAnchor = () => {
delAnchor({ id: deleteAnchorID.value }).then((res) => {
centerDialogVisible.value = false;
ElMessage.success("删除成功");
AnchorList();
});
delAnchor({ id: deleteAnchorID.value })
.then((res) => {
centerDialogVisible.value = false;
ElMessage.success("删除成功");
AnchorList();
})
.catch((err) => {});
};
function anchordelete(id) {
deleteAnchorID.value = id;
@@ -320,6 +327,19 @@ onUnmounted(() => {
width: 100%;
height: 100%;
}
.chatNotDeta{
width: 100%;
height: 100%;
background-color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
}
.chatNotDeta-text{
font-size: 20px;
color: #03aba8;
font-weight: bold;
}
.anchor-library-card {
width: 100%;
height: 150px;

View File

@@ -28,7 +28,7 @@
</div>
</div>
<!-- list -->
<div class="list" style="overflow: auto" v-infinite-scroll="load">
<div class="list" style="overflow: auto" v-infinite-scroll="load" v-if="list.length !== 0">
<div v-for="(item, index) in list" :key="index" class="list-item">
<div
class="list-content"
@@ -93,6 +93,9 @@
</div>
</div>
</div>
<div class="chatNotDeta"v-if="list.length === 0">
<div class="chatNotDeta-text">您还没有PK记录</div>
</div>
</div>
</el-splitter-panel>
@@ -208,7 +211,7 @@ function detail(item) {
id: item.id,
}).then((res) => {
fetchDetailPkDataWithId.value = res;
});
}).catch((err) => {});
}
//切换选项卡
function optionsclick(value) {
@@ -243,7 +246,7 @@ function PkRecord(type) {
list.value = InvitationData.value;
}
}
});
}).catch((err) => {});
}
// 加载更多
@@ -404,6 +407,19 @@ onUnmounted(() => {
width: 100%;
height: calc(100% -150px);
}
.chatNotDeta{
width: 100%;
height: calc(100% -150px);
background-color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
}
.chatNotDeta-text{
font-size: 20px;
color: #03aba8;
font-weight: bold;
}
.list-item {
width: 100%;
height: 150px;

View File

@@ -8,6 +8,7 @@
class="anchor-library-list"
style="overflow: auto"
v-infinite-scroll="load"
v-if="list.length !== 0"
>
<div class="anchor-library-card" v-for="(item, index) in list" :key="index">
<div class="card-content">
@@ -85,6 +86,9 @@
</div>
</div>
</div>
<div class="chatNotDeta" v-if="list.length === 0">
<div class="chatNotDeta-text">您还没有PK信息快去添加吧</div>
</div>
</div>
</el-splitter-panel>
<el-splitter-panel size="25%" :resizable="false" collapsible>
@@ -342,7 +346,7 @@ function getMyAnchorLibrary() {
getAnchorList({ id: user.value.id }).then((res) => {
console.log("anchorLibrary", res);
anchorLibrary.value = res;
});
}).catch((err) => {});
}
// 置顶or取消置顶
function topPosition(item) {
@@ -371,7 +375,7 @@ function topPositionstateConfirm() {
list.value = [];
page.value = 0;
PKInfo();
});
}).catch((err) => {});
}
// 确认取消置顶
@@ -382,7 +386,7 @@ function cancelTopPositionstateConfirm() {
list.value = [];
page.value = 0;
PKInfo();
});
}).catch((err) => {});
}
//计算置顶时长
@@ -449,7 +453,7 @@ function deleteAnchor() {
list.value = [];
page.value = 0;
PKInfo();
});
}).catch((err) => {});
}
// 确认发布
@@ -508,7 +512,7 @@ function Confirm() {
page.value = 0;
PKInfo();
cancel();
});
}).catch((err) => {});
} else {
releasePkInfo({
anchorId: anchorName.value,
@@ -585,7 +589,7 @@ function PKInfo() {
}).then((res) => {
console.log("list", res);
list.value.push(...res);
});
}).catch((err) => {});
}
// 组件挂载完成后执行
@@ -629,6 +633,19 @@ watch(refname, async (newQuestion, oldQuestion) => {
width: 100%;
height: 100%;
}
.chatNotDeta{
width: 100%;
height: 100%;
background-color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
}
.chatNotDeta-text{
font-size: 20px;
color: #03aba8;
font-weight: bold;
}
.anchor-library-card {
width: 100%;
height: 150px;

View File

@@ -1,36 +1,35 @@
<template>
<!-- 积分列表 -->
<!-- 积分列表 -->
<div class="points-list-container">
<div class="points-list-title">
<img
class="points-icon"
src="@/assets/Points.png"
mode="scaleToFill"
/>
<div class="points-text">
我的积分:{{ user.points }}
<div class="points-alwaysnum">
<img class="points-icon" src="@/assets/Points.png" mode="scaleToFill" />
<div class="points-text">
我的积分:{{ user.points }}
<div class="points-alwaysnum"></div>
</div>
</div>
</div>
<div class="points-list" style="overflow: auto;">
<div class="points-list-item" v-for="(item, index) in pointsList" :key="index">
<div class="points-list-content" :style="{background: item.status == 1 ? '#DFFEFC':'#FBECE9'}">
<div class="Event">
{{ item.info }}
</div>
<div class="points-num">
{{ item.number }}
</div>
<div class="time">
{{TimestamptolocalTime(item.time*1000) }}
<div class="points-list" style="overflow: auto" v-if="pointsList.length !== 0">
<div class="points-list-item" v-for="(item, index) in pointsList" :key="index">
<div
class="points-list-content"
:style="{ background: item.status == 1 ? '#DFFEFC' : '#FBECE9' }"
>
<div class="Event">
{{ item.info }}
</div>
<div class="points-num">
{{ item.number }}
</div>
<div class="time">
{{ TimestamptolocalTime(item.time * 1000) }}
</div>
</div>
</div>
<div class="chatNotDeta" v-if="pointsList.length === 0">
<div class="chatNotDeta-text">您还没有积分记录</div>
</div>
</div>
</div>
</div>
</template>
<script setup>
@@ -41,24 +40,26 @@ import {
onUpdated, // 组件更新后执行
onUnmounted, // 组件销毁前执行
} from "vue";
import {getIntegralDetail} from "@/api/account";
import { getIntegralDetail } from "@/api/account";
import { ElMessage } from "element-plus";
import {getPromiseStorage } from "@/utils/storage.js";
import { getPromiseStorage } from "@/utils/storage.js";
import { TimestamptolocalTime } from "../../utils/timeConversion";
const pointsList = ref([]);
const user = ref({});//用户信息
const user = ref({}); //用户信息
const page = ref(0);
//获取积分数据
function getPointsList () {
function getPointsList() {
getIntegralDetail({
page: page.value,
size: 30,
userId: user.value.id,
}).then((res) => {
console.log(res);
pointsList.value.push(...res);
})
.then((res) => {
console.log(res);
pointsList.value.push(...res);
})
.catch((err) => {});
}
// 组件挂载完成后执行
@@ -66,7 +67,7 @@ onMounted(() => {
getPromiseStorage("user")
.then((res) => {
user.value = res;
getPointsList()
getPointsList();
})
.catch((err) => {
console.log(err);
@@ -79,14 +80,14 @@ onUpdated(() => {
onUnmounted(() => {
// 组件销毁前执行
});
const refname = ref('');
const refname = ref("");
watch(refname, async (newQuestion, oldQuestion) => {
// 变化后执行
});
</script>
<style scoped lang="less">
.points-list-container{
.points-list-container {
width: 100%;
height: 100%;
-webkit-user-select: none;
@@ -94,44 +95,57 @@ watch(refname, async (newQuestion, oldQuestion) => {
-ms-user-select: none;
user-select: none;
}
.points-list{
.points-list {
width: 100%;
height: calc(100% - 70px);
}
.points-list-title{
.chatNotDeta {
width: 100%;
height: calc(100% - 70px);
background-color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
}
.chatNotDeta-text {
font-size: 20px;
color: #03aba8;
font-weight: bold;
}
.points-list-title {
width: 100%;
height: 70px;
display: flex;
justify-content: center;
align-items: center;
}
.points-text{
.points-text {
margin-top: 10px;
color: #666666;
font-size: 24px;
display: flex;
align-items: center;
}
.points-alwaysnum{
.points-alwaysnum {
color: #333333;
font-size: 24px;
font-weight: bold;
}
.points-icon{
.points-icon {
width: 52px;
height: 52px;
margin-right: 18px;
}
.points-list-item{
.points-list-item {
width: 100%;
height: 60px;
margin-top: 10px;
margin-bottom: 10px;
display: flex;
justify-content:center;
justify-content: center;
align-items: center;
}
.points-list-content{
.points-list-content {
width: 90%;
height: 100%;
border-radius: 10px;
@@ -139,17 +153,17 @@ watch(refname, async (newQuestion, oldQuestion) => {
justify-content: space-around;
align-items: center;
}
.Event{
.Event {
color: @Supplementary-text-color;
font-size: 16px;
}
.points-num{
.points-num {
color: @font-color;
font-size: 18px;
font-weight: bold;
}
.time{
color:@Prompt-text-color;
.time {
color: @Prompt-text-color;
font-size: 16px;
}
</style>
}
</style>