Files
Situation-Awareness-Platfor…/src/views/Jyh/Home/index.vue

448 lines
11 KiB
Vue
Raw Normal View History

2025-03-13 19:18:53 +08:00
<template>
<div class="home-container">
<div class="home-content">
<div class="home-title">
2025-03-19 12:27:37 +08:00
<img src="@/assets/imgs/logo.png" alt="logo" />
2025-03-13 19:18:53 +08:00
<h1>可信开源代码库</h1>
</div>
2025-03-14 20:03:14 +08:00
<div class="home-search" ref="homeSearch" :class="{ 'glow-border': inputGlow }">
2025-03-19 13:26:18 +08:00
<d-input
ref="searchInput"
placeholder="请输入搜索关键字"
@focus="inputFocus"
@blur="inputBlur"
:autocomplete="'off'"
v-model="searchStr"
>
2025-03-13 19:18:53 +08:00
<template #prepend>
2025-03-15 17:02:06 +08:00
<d-dropdown @toggle="onCateToggle($event)">
<div class="flex items-center gap-1 cursor-pointer">
{{ selectedCate }}
2025-03-15 17:02:06 +08:00
<d-icon :rotate="cateRotate" name="icon-chevron-down-2"></d-icon>
</div>
<template #menu>
<ul class="list-menu">
<li class="menu-item" @click="onCategoryChange('软件')">软件</li>
2025-03-15 17:02:06 +08:00
<d-dropdown :position="position" :offset="0">
<li class="menu-item">
行业
<i class="icon icon-chevron-right"></i>
</li>
<template #menu>
<ul class="list-menu">
<li class="menu-item" v-for="option in industryOptions" @click="onCategoryChange(option)">
2025-03-19 13:26:18 +08:00
{{ option }}
2025-03-15 17:02:06 +08:00
</li>
</ul>
</template>
</d-dropdown>
</ul>
</template>
</d-dropdown>
2025-03-13 19:18:53 +08:00
</template>
<template #append>
2025-03-14 20:03:14 +08:00
<div class="advanced-search" @click="openAdvancedSearch">
2025-03-19 13:26:18 +08:00
<span>高级筛选</span>
<d-badge :count="6" :bg-color="'#f0f0f0'"></d-badge>
<d-icon :rotate="rotate" name="icon-chevron-down-2"></d-icon>
</div>
2025-03-13 19:18:53 +08:00
</template>
</d-input>
2025-03-19 13:26:18 +08:00
<d-dropdown-menu
v-model="isOpen"
:origin="searchInput?.$el"
close-scope="'blank'"
:offset="offset"
:clickOutside="closeOutside"
>
<div class="advanced-search-menu" :style="{ width: dropdownWidth + 'px' }">
2025-03-15 17:15:39 +08:00
<AdvanceSearch @submit="submit($event)" @cancel="isOpen = false" class="p-20" :layout="'vertical'">
2025-03-15 17:02:06 +08:00
<template #title>
<span class="title">高级筛选</span>
</template>
</AdvanceSearch>
2025-03-14 20:03:14 +08:00
</div>
</d-dropdown-menu>
<d-button color="primary" variant="solid" @click="search">搜索</d-button>
2025-03-13 19:18:53 +08:00
</div>
<d-button @click="check" ref="origin" icon="share" class="batch-btn">批量校验</d-button>
2025-03-13 19:18:53 +08:00
<div class="home-information">
<div class="info-title">
<div class="sub-title">
2025-03-19 13:26:18 +08:00
<img src="@/assets/imgs/home/informIcon@2x.png" />
2025-03-19 11:55:21 +08:00
<span>预警公告</span>
2025-03-13 19:18:53 +08:00
</div>
2025-03-15 17:02:06 +08:00
<a class="devui-link" @click="checkMore">更多 ></a>
2025-03-13 19:18:53 +08:00
</div>
<div class="info-content">
<d-timeline :direction="'vertical'" :time-position="'right'" :position="'right'">
2025-03-19 13:26:18 +08:00
<d-timeline-item
v-for="(item, index) in infoList"
:key="index"
:dot-color="item.dotColor"
:line-color="'var(--devui-form-control-line-hover)'"
>
2025-03-13 19:18:53 +08:00
<template #default>
2025-03-18 20:20:37 +08:00
<div class="flex items-center justify-between w-full">
2025-03-19 13:26:18 +08:00
<div
class="cursor-pointer notice-content flex gap-2 items-center"
@click="openWarningDetail(item, index)"
>
2025-03-18 20:20:37 +08:00
<span>{{ item.subject }}</span>
<d-tag :color="tagMap[item.importance]" size="sm">{{ item.importance }}</d-tag>
</div>
<div class="time-container">
2025-03-13 19:18:53 +08:00
<d-icon name="icon-time"></d-icon>
2025-03-18 20:20:37 +08:00
{{ item.pulishTime }}
2025-03-13 19:18:53 +08:00
</div>
</div>
</template>
<template #time>
<span></span>
</template>
</d-timeline-item>
</d-timeline>
</div>
</div>
</div>
</div>
2025-03-18 20:20:37 +08:00
2025-03-19 13:26:18 +08:00
<d-modal class="warning-modal" v-model="warningModalVisable" title="" style="width: 600px">
2025-03-18 20:20:37 +08:00
<EarlyWarningDetail :warningData="currentWarning" :type="'user'"></EarlyWarningDetail>
</d-modal>
2025-03-13 19:18:53 +08:00
</template>
<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount } from 'vue';
2025-03-14 20:03:14 +08:00
import { useRoute, useRouter } from 'vue-router';
2025-03-14 20:35:13 +08:00
import AdvanceSearch from '@/components/AdvanceSearch/index.vue';
2025-03-19 13:26:18 +08:00
import { getHomeNoticeList } from '@/api/jyh';
2025-03-18 20:20:37 +08:00
import EarlyWarningDetail from '@/views/Jyh/PersonalCenter/Detail/EarlyWarningDetail.vue';
2025-03-13 19:18:53 +08:00
2025-03-14 20:03:14 +08:00
const route = useRoute();
const router = useRouter();
const inputGlow = ref(false);
const searchStr = ref('');
2025-03-15 17:02:06 +08:00
const position = ref(['right-start', 'right-end']);
2025-03-19 13:26:18 +08:00
const industryOptions = ref(['通信', '军工', '金融', '能源']);
const searchType = ref('软件');
const searchOptions = ref(['软件']);
2025-03-19 13:26:18 +08:00
const offset = ref({ mainAxis: 7, crossAxis: -10 });
2025-03-14 20:03:14 +08:00
const isOpen = ref(false);
const rotate = ref(0);
2025-03-15 17:02:06 +08:00
const cateRotate = ref(0);
2025-03-19 13:26:18 +08:00
const infoList = ref([]);
2025-03-18 20:20:37 +08:00
const warningModalVisable = ref(false);
const currentWarning = ref();
2025-03-13 19:18:53 +08:00
2025-03-14 20:03:14 +08:00
const homeSearch = ref(null);
2025-03-13 19:18:53 +08:00
const dropdownWidth = ref(0);
const selectedCate = ref('软件');
2025-03-18 20:20:37 +08:00
const tagMap = {
2025-03-19 13:26:18 +08:00
: '#f66f6a',
: '#fac20a',
: '#5e7ce0'
};
2025-03-14 20:03:14 +08:00
const searchInput = ref(null);
const openAdvancedSearch = () => {
isOpen.value = !isOpen.value;
rotate.value = isOpen.value ? 180 : 0;
inputGlow.value = isOpen.value;
};
const check = () => {
router.push({
name: 'Search',
2025-03-19 13:26:18 +08:00
query: { tab: 'BatchVerify' } // 通过查询参数指定 Tab
});
2025-03-19 13:26:18 +08:00
};
2025-03-15 17:02:06 +08:00
const closeOutside = () => {
2025-03-19 13:26:18 +08:00
return false;
};
2025-03-15 17:02:06 +08:00
2025-03-14 20:35:13 +08:00
const submit = (formData) => {
isOpen.value = false;
2025-03-19 13:26:18 +08:00
router.push({ name: 'Search', query: { searchWord: searchStr, ...formData, searchType: selectedCate.value } });
2025-03-14 20:35:13 +08:00
};
2025-03-14 20:03:14 +08:00
const inputFocus = () => {
inputGlow.value = true;
};
const inputBlur = () => {
inputGlow.value = false;
2025-03-19 13:26:18 +08:00
};
2025-03-13 19:18:53 +08:00
const updateDropdownWidth = () => {
if (homeSearch.value) {
2025-03-14 20:03:14 +08:00
dropdownWidth.value = homeSearch.value.offsetWidth * 0.85;
2025-03-13 19:18:53 +08:00
}
};
2025-03-14 20:03:14 +08:00
const search = () => {
2025-03-19 13:26:18 +08:00
router.push({ name: 'Search', query: { searchWord: searchStr.value, searchType: selectedCate.value } });
2025-03-14 20:03:14 +08:00
};
2025-03-15 17:02:06 +08:00
const onCategoryChange = (cate) => {
selectedCate.value = cate;
2025-03-19 13:26:18 +08:00
};
2025-03-15 17:02:06 +08:00
const onCateToggle = (event) => {
cateRotate.value = event ? 180 : 0;
2025-03-19 13:26:18 +08:00
};
2025-03-15 17:02:06 +08:00
const checkMore = () => {
router.push({ name: 'PersonalCenter' });
2025-03-19 13:26:18 +08:00
};
2025-03-15 17:02:06 +08:00
2025-03-15 17:27:47 +08:00
const openWarningDetail = (event, index) => {
infoList.value.forEach((item, i) => {
if (i <= index) {
item.dotColor = 'var(--devui-info)';
} else {
item.dotColor = '';
}
2025-03-19 13:26:18 +08:00
});
2025-03-19 12:27:37 +08:00
2025-03-18 20:20:37 +08:00
warningModalVisable.value = true;
currentWarning.value = event;
2025-03-19 13:26:18 +08:00
};
2025-03-15 17:02:06 +08:00
2025-03-13 19:18:53 +08:00
let resizeObserver: ResizeObserver | null = null;
onMounted(() => {
resizeObserver = new ResizeObserver(updateDropdownWidth);
if (homeSearch.value) {
resizeObserver.observe(homeSearch.value);
}
2025-03-13 19:18:53 +08:00
updateDropdownWidth();
});
onBeforeUnmount(() => {
if (resizeObserver && homeSearch.value) {
resizeObserver.unobserve(homeSearch.value);
}
});
2025-03-19 13:26:18 +08:00
const getNoticeList = async () => {
const res: any = await getHomeNoticeList();
2025-03-18 20:20:37 +08:00
if (!res.error) {
infoList.value = res.data.data;
}
2025-03-19 13:26:18 +08:00
};
2025-03-18 20:20:37 +08:00
getNoticeList();
2025-03-13 19:18:53 +08:00
</script>
<style scoped lang="scss">
@import 'devui-theme/styles-var/devui-var.scss';
.home-container {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
position: relative;
overflow: hidden;
.home-content {
font-size: 14px;
2025-03-19 13:26:18 +08:00
height: 80%;
2025-03-13 19:18:53 +08:00
width: 50%;
display: flex;
flex-direction: column;
justify-self: center;
align-items: center;
gap: 20px;
.home-title {
display: flex;
2025-03-19 13:26:18 +08:00
flex-shrink: 0;
2025-03-13 19:18:53 +08:00
justify-content: center;
align-items: center;
gap: 20px;
h1 {
font-size: xx-large;
font-weight: bold;
}
img {
width: 50px;
2025-03-19 12:27:37 +08:00
//filter: brightness(0);
2025-03-13 19:18:53 +08:00
}
}
.home-search {
width: 100%;
height: 40px;
2025-03-19 13:26:18 +08:00
flex-shrink: 0;
2025-03-13 19:18:53 +08:00
background-color: white;
border-radius: 10px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px;
2025-03-14 20:03:14 +08:00
box-shadow: var(--devui-shadow, 0 2px 12px 0);
2025-03-13 19:18:53 +08:00
input {
border: none;
outline: none;
padding: 5px;
font-size: 14px;
}
.advanced-search {
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
gap: 8px;
2025-03-14 20:03:14 +08:00
&::before {
content: '';
position: absolute;
left: -10px;
top: 50%;
transform: translateY(-50%);
width: 1px;
height: 20px;
background-color: var(--devui-form-control-line, #d7d8da);
}
2025-03-13 19:18:53 +08:00
}
.advanced-search-menu {
height: 300px;
padding: 12px;
background-color: white;
}
.form-operation {
display: flex;
justify-content: center;
align-items: center;
gap: 8px;
}
}
.batch-btn {
color: $devui-aide-text;
width: 150px;
2025-03-19 13:26:18 +08:00
flex-shrink: 0;
2025-03-13 19:18:53 +08:00
background-color: #f0f0f0;
border-color: $devui-aide-text;
}
.home-information {
width: 100%;
background-color: #f0f0f0;
2025-03-19 13:26:18 +08:00
overflow: auto;
margin-bottom: 20px;
2025-03-13 19:18:53 +08:00
border-radius: 10px;
padding: 12px;
.info-title {
img {
width: 20px;
}
display: flex;
justify-content: space-between;
.sub-title {
display: flex;
gap: 8px;
}
margin-bottom: 20px;
margin-left: 10px;
}
:deep(.devui-timeline-item-data-left) {
display: none;
}
:deep(.devui-timeline-item-dot) {
scale: 0.7;
}
}
}
}
.home-search {
:deep(.devui-input-slot__prepend),
:deep(.devui-input-slot__append),
:deep(.devui-input__wrapper) {
border: none;
}
:deep(.devui-select__selection--glow-style),
:deep(.devui-input--glow-style) {
box-shadow: none !important;
}
}
2025-03-14 20:03:14 +08:00
.glow-border {
border: 1px solid var(--devui-form-control-line, #d7d8da);
border-color: var(--devui-form-control-line-active, #5e7ce0) !important;
2025-03-19 13:26:18 +08:00
box-shadow: 0 0 0 4px var(--devui-form-control-interactive-outline, rgba(94, 124, 224, 0.08));
2025-03-14 20:03:14 +08:00
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
2025-03-15 17:02:06 +08:00
.menu-item {
2025-03-19 13:26:18 +08:00
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
padding: 4px;
cursor: pointer;
&:hover {
background-color: var(--devui-list-item-hover-bg, #f2f5fc);
color: var(--devui-list-item-hover-text, #526ecc);
}
2025-03-15 17:02:06 +08:00
}
.list-menu {
2025-03-19 13:26:18 +08:00
padding: 8px;
margin: 0;
width: 100px;
2025-03-15 17:02:06 +08:00
}
2025-03-13 19:18:53 +08:00
2025-03-15 17:02:06 +08:00
.title {
font-size: 14px;
font-weight: 500;
}
2025-03-18 20:20:37 +08:00
.notice-content {
flex: 1;
overflow: hidden;
margin-right: 8px;
2025-03-19 12:27:37 +08:00
2025-03-18 20:20:37 +08:00
span {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: block;
}
}
.time-container {
display: flex;
align-items: center;
gap: 8px;
width: 120px;
flex-shrink: 0;
}
:deep(.devui-timeline-item-data-right) {
width: 80%;
}
</style>
2025-03-18 20:20:37 +08:00
<style>
.warning-modal {
.devui-modal__body {
padding: 0px !important;
}
}
2025-03-19 12:27:37 +08:00
</style>