头部搜索对接开源软件列表
This commit is contained in:
@@ -53,7 +53,13 @@
|
||||
</d-col>
|
||||
<d-col :span="8">
|
||||
<d-form-item field="industry" label="行业">
|
||||
<d-input v-model="formData.industry" placeholder="请输入行业" />
|
||||
<d-select
|
||||
:options="industryList"
|
||||
:allow-clear="true"
|
||||
v-model="formData.industry"
|
||||
placeholder="请选择行业"
|
||||
></d-select>
|
||||
<!-- <d-input v-model="formData.industry" placeholder="请输入行业" />-->
|
||||
</d-form-item>
|
||||
</d-col>
|
||||
</d-row>
|
||||
@@ -70,6 +76,9 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, defineEmits, defineProps, watch, onMounted } from 'vue';
|
||||
import { searchLanguageList } from '@/api/jyh';
|
||||
import { useGlobalInfoStore } from '@/stores/Global';
|
||||
const globalInfo = useGlobalInfoStore();
|
||||
const industryList = globalInfo.industryList;
|
||||
const props = defineProps({
|
||||
layout: {
|
||||
type: String,
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
</li>
|
||||
<template #menu>
|
||||
<ul class="list-menu">
|
||||
<li class="menu-item" v-for="option in industryOptions" @click="onCategoryChange(option)">
|
||||
{{ option }}
|
||||
<li class="menu-item" v-for="option in industryList" @click="onCategoryChange(option)">
|
||||
{{ option.name }}
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
@@ -46,30 +46,32 @@ const globalInfo = useGlobalInfoStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const softwareName = ref(globalInfo.headerSearch.softwareName);
|
||||
const searchType = ref(globalInfo.headerSearch.searchType);
|
||||
const softwareName = ref('');
|
||||
const searchType = ref('软件');
|
||||
|
||||
const position = ref(['right-start', 'right-end']);
|
||||
const industryOptions = ref(['通信', '军工', '金融', '能源']);
|
||||
// const industryOptions = ref(['通信', '军工', '金融', '能源']);
|
||||
|
||||
const placeholder = ref('「开搜」:一搜即达,开发者的AI搜索');
|
||||
|
||||
const industryList = globalInfo.industryList;
|
||||
const onCategoryChange = (event) => {
|
||||
searchType.value = event;
|
||||
globalInfo.updateHeaderSearch({ softwareName: softwareName.value, searchType: searchType.value });
|
||||
searchType.value = event?.name || '软件';
|
||||
globalInfo.updateHeaderSearch({ softwareName: softwareName.value, searchType: event.value });
|
||||
}
|
||||
|
||||
const search = () => {
|
||||
window.open(`${import.meta.env.VITE_BASE_URL}repoList?softwareName=${softwareName.value ? softwareName.value : ''}&searchType=${searchType.value}`, '_blank')
|
||||
window.open(`${import.meta.env.VITE_BASE_URL}repoList?softwareName=${softwareName.value ? softwareName.value : ''}&searchType=${getIndustryValue(searchType.value)}`, '_blank')
|
||||
};
|
||||
|
||||
const handleClear = () => {
|
||||
globalInfo.updateHeaderSearch({ softwareName: ''.value, searchType: searchType.value });
|
||||
};
|
||||
|
||||
watch(() => route.query?.val, (newVal) => {
|
||||
microApp.setData('micoro-app-homeweb-app', { type: 'search', data: newVal || '' });
|
||||
});
|
||||
|
||||
const getIndustryValue = (name) => {
|
||||
const industry = industryList.find(item => item.name === name);
|
||||
return industry ? industry.value : ''; // 如果找不到,返回默认值
|
||||
};
|
||||
|
||||
const handleDataChange = ({ name, type, data }) => {
|
||||
if (name === 'micoro-app-homeweb-app') {
|
||||
@@ -84,8 +86,8 @@ const handleDataChange = ({ name, type, data }) => {
|
||||
|
||||
onMounted(() => {
|
||||
globalInfo.updateHeaderSearch({ softwareName: route.query.softwareName ? route.query.softwareName : '', searchType: route.query.searchType || '软件' });
|
||||
softwareName.value = route.query.softwareName;
|
||||
searchType.value = route.query.searchType || '软件';
|
||||
// softwareName.value = route.query.softwareName;
|
||||
// searchType.value = route.query.searchType || '软件';
|
||||
});
|
||||
onUnmounted(() => {
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div v-if="showColumnList" ref="columnListRef" class="column-list">
|
||||
<div class="column-list-header">
|
||||
<span class="title1">展示列设置</span>
|
||||
<a class="title2">恢复默认</a>
|
||||
<a @click="emits('setDefult')" class="title2">恢复默认</a>
|
||||
</div>
|
||||
<div class="column-list-body">
|
||||
<d-checkbox
|
||||
@@ -35,7 +35,7 @@ const props = defineProps({
|
||||
});
|
||||
|
||||
// 定义 emit,用于更新 showColumnList
|
||||
const emits = defineEmits(['update:show-column-list']);
|
||||
const emits = defineEmits(['update:show-column-list','setDefult']);
|
||||
|
||||
// 切换多选列表的显示
|
||||
const toggleColumnList = () => {
|
||||
@@ -101,6 +101,7 @@ onUnmounted(() => {
|
||||
text-align: left;
|
||||
}
|
||||
.title2 {
|
||||
cursor: pointer;
|
||||
color: #5E7CE0;
|
||||
font-family: 苹方-简;
|
||||
font-weight: regular;
|
||||
|
||||
Reference in New Issue
Block a user