2025-03-12 18:41:20 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<d-input
|
2025-03-27 17:04:06 +08:00
|
|
|
|
@keyup.enter="search"
|
2025-03-12 18:41:20 +08:00
|
|
|
|
:key="$route.path + $route.query?.val" id="golbalSearch" class="g-header-search"
|
2025-03-19 20:47:53 +08:00
|
|
|
|
v-model.trim="softwareName" placeholder="请输入软件名称搜索" @clear="handleClear" clearable >
|
2025-03-12 18:41:20 +08:00
|
|
|
|
<template #prepend>
|
2025-03-19 19:38:32 +08:00
|
|
|
|
<d-dropdown>
|
2025-03-18 20:20:37 +08:00
|
|
|
|
<div class="flex items-center gap-1 cursor-pointer">
|
|
|
|
|
|
{{ searchType }}
|
|
|
|
|
|
<d-icon :rotate="cateRotate" name="icon-chevron-down-2"></d-icon>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<template #menu>
|
|
|
|
|
|
<ul class="list-menu">
|
2025-03-18 20:29:01 +08:00
|
|
|
|
<li class="menu-item" @click="onCategoryChange('软件')">软件</li>
|
2025-03-18 20:20:37 +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">
|
2025-03-20 20:51:16 +08:00
|
|
|
|
<li class="menu-item" v-for="option in industryList" @click="onCategoryChange(option)">
|
|
|
|
|
|
{{ option.name }}
|
2025-03-18 20:20:37 +08:00
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</d-dropdown>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</d-dropdown>
|
2025-03-12 18:41:20 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template #append>
|
2025-03-13 19:45:34 +08:00
|
|
|
|
<d-icon @click="search" name="search" style="font-size: inherit;" />
|
2025-03-12 18:41:20 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</d-input>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { ref, onMounted, watch, onUnmounted, reactive } from 'vue';
|
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
2025-03-19 19:38:32 +08:00
|
|
|
|
import { useGlobalInfoStore } from '@/stores/Global';
|
2025-03-12 18:41:20 +08:00
|
|
|
|
import microApp from '@micro-zoe/micro-app';
|
|
|
|
|
|
|
2025-03-19 19:38:32 +08:00
|
|
|
|
const emit = defineEmits('updateSearch');
|
|
|
|
|
|
const globalInfo = useGlobalInfoStore();
|
|
|
|
|
|
|
2025-03-12 18:41:20 +08:00
|
|
|
|
const route = useRoute();
|
|
|
|
|
|
const router = useRouter();
|
2025-03-19 19:38:32 +08:00
|
|
|
|
|
2025-03-20 20:51:16 +08:00
|
|
|
|
const softwareName = ref('');
|
|
|
|
|
|
const searchType = ref('软件');
|
2025-03-19 19:38:32 +08:00
|
|
|
|
|
2025-03-18 20:20:37 +08:00
|
|
|
|
const position = ref(['right-start', 'right-end']);
|
2025-03-20 20:51:16 +08:00
|
|
|
|
// const industryOptions = ref(['通信', '军工', '金融', '能源']);
|
2025-03-12 18:41:20 +08:00
|
|
|
|
|
|
|
|
|
|
const placeholder = ref('「开搜」:一搜即达,开发者的AI搜索');
|
2025-03-20 20:51:16 +08:00
|
|
|
|
const industryList = globalInfo.industryList;
|
2025-03-18 20:20:37 +08:00
|
|
|
|
const onCategoryChange = (event) => {
|
2025-03-20 20:51:16 +08:00
|
|
|
|
searchType.value = event?.name || '软件';
|
|
|
|
|
|
globalInfo.updateHeaderSearch({ softwareName: softwareName.value, searchType: event.value });
|
2025-03-18 20:20:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-12 18:41:20 +08:00
|
|
|
|
const search = () => {
|
2025-03-20 20:51:16 +08:00
|
|
|
|
window.open(`${import.meta.env.VITE_BASE_URL}repoList?softwareName=${softwareName.value ? softwareName.value : ''}&searchType=${getIndustryValue(searchType.value)}`, '_blank')
|
2025-03-12 18:41:20 +08:00
|
|
|
|
};
|
2025-03-19 19:38:32 +08:00
|
|
|
|
|
2025-03-12 18:41:20 +08:00
|
|
|
|
const handleClear = () => {
|
2025-03-19 20:47:53 +08:00
|
|
|
|
globalInfo.updateHeaderSearch({ softwareName: ''.value, searchType: searchType.value });
|
2025-03-12 18:41:20 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-03-20 20:51:16 +08:00
|
|
|
|
|
|
|
|
|
|
const getIndustryValue = (name) => {
|
|
|
|
|
|
const industry = industryList.find(item => item.name === name);
|
|
|
|
|
|
return industry ? industry.value : ''; // 如果找不到,返回默认值
|
|
|
|
|
|
};
|
2025-03-12 18:41:20 +08:00
|
|
|
|
|
|
|
|
|
|
const handleDataChange = ({ name, type, data }) => {
|
|
|
|
|
|
if (name === 'micoro-app-homeweb-app') {
|
|
|
|
|
|
if (type === 'keyword-change') {
|
2025-03-19 20:47:53 +08:00
|
|
|
|
softwareName.value = data;
|
2025-03-12 18:41:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (type === 'route-change') {
|
|
|
|
|
|
//
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
2025-03-19 20:47:53 +08:00
|
|
|
|
globalInfo.updateHeaderSearch({ softwareName: route.query.softwareName ? route.query.softwareName : '', searchType: route.query.searchType || '软件' });
|
2025-03-20 20:51:16 +08:00
|
|
|
|
// softwareName.value = route.query.softwareName;
|
|
|
|
|
|
// searchType.value = route.query.searchType || '软件';
|
2025-03-12 18:41:20 +08:00
|
|
|
|
});
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
@import 'devui-theme/styles-var/devui-var.scss';
|
|
|
|
|
|
|
|
|
|
|
|
.g-header-search {
|
|
|
|
|
|
border: 1px solid #5E7CE0;
|
|
|
|
|
|
background: #FFF;
|
|
|
|
|
|
//box-shadow: 0px 2px 5px 1px rgba(0, 0, 0, 0.05) inset;
|
|
|
|
|
|
&-icon {
|
|
|
|
|
|
opacity: .5;
|
|
|
|
|
|
transition: opacity .5s ease;
|
|
|
|
|
|
}
|
|
|
|
|
|
.devui-input--focus {
|
|
|
|
|
|
.g-header-search-icon {
|
|
|
|
|
|
opacity: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
::v-deep .devui-input-slot__prepend{
|
|
|
|
|
|
width: 140px;
|
|
|
|
|
|
}
|
|
|
|
|
|
::v-deep .devui-input-slot__append{
|
|
|
|
|
|
width: 40px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-18 20:20:37 +08:00
|
|
|
|
|
|
|
|
|
|
.menu-item {
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.list-menu {
|
|
|
|
|
|
padding: 8px;
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
width: 100px;
|
|
|
|
|
|
}
|
2025-03-12 18:41:20 +08:00
|
|
|
|
</style>
|