update: 头部搜索能力补全

This commit is contained in:
@user8949
2025-03-19 20:47:53 +08:00
parent fc486e9488
commit 56edefdfa5
4 changed files with 20 additions and 15 deletions

View File

@@ -5,7 +5,7 @@
<d-row :gutter="16"> <d-row :gutter="16">
<d-col :span="8"> <d-col :span="8">
<d-form-item field="name" label="软件名称"> <d-form-item field="name" label="软件名称">
<d-input placeholder="请输入软件名称" v-model="formData.searchWord"/> <d-input placeholder="请输入软件名称" v-model="formData.softwareName"/>
</d-form-item> </d-form-item>
</d-col> </d-col>
<d-col :span="8"> <d-col :span="8">
@@ -71,7 +71,7 @@ const props = defineProps({
type: Object, type: Object,
default: () => ({ default: () => ({
licenseName: '', licenseName: '',
searchWord: '', softwareName: '',
softwareVersion: '', softwareVersion: '',
dependentSoftware: '', dependentSoftware: '',
programmingLanguage: '', programmingLanguage: '',
@@ -105,7 +105,7 @@ const submitForm = () => {
const cancel = () => { const cancel = () => {
formData.value = { formData.value = {
licenseName: '', licenseName: '',
searchWord: '', softwareName: '',
softwareVersion: '', softwareVersion: '',
dependentSoftware: '', dependentSoftware: '',
programmingLanguage: '', programmingLanguage: '',

View File

@@ -1,7 +1,7 @@
<template> <template>
<d-input <d-input
:key="$route.path + $route.query?.val" id="golbalSearch" class="g-header-search" :key="$route.path + $route.query?.val" id="golbalSearch" class="g-header-search"
v-model.trim="searchStr" placeholder="输入搜索内容..." @clear="handleClear" clearable > v-model.trim="softwareName" placeholder="输入软件名称搜索" @clear="handleClear" clearable >
<template #prepend> <template #prepend>
<d-dropdown> <d-dropdown>
<div class="flex items-center gap-1 cursor-pointer"> <div class="flex items-center gap-1 cursor-pointer">
@@ -46,7 +46,7 @@ const globalInfo = useGlobalInfoStore();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const searchStr = ref(globalInfo.headerSearch.searchWord); const softwareName = ref(globalInfo.headerSearch.softwareName);
const searchType = ref(globalInfo.headerSearch.searchType); const searchType = ref(globalInfo.headerSearch.searchType);
const position = ref(['right-start', 'right-end']); const position = ref(['right-start', 'right-end']);
@@ -56,14 +56,15 @@ const placeholder = ref('「开搜」一搜即达开发者的AI搜索');
const onCategoryChange = (event) => { const onCategoryChange = (event) => {
searchType.value = event; searchType.value = event;
globalInfo.updateHeaderSearch({ softwareName: softwareName.value, searchType: searchType.value });
} }
const search = () => { const search = () => {
globalInfo.updateHeaderSearch({ searchWord: searchStr.value, searchType: searchType.value }); window.open(`/repoList?softwareName=${softwareName.value}&searchType=${searchType.value}`, '_blank')
}; };
const handleClear = () => { const handleClear = () => {
globalInfo.updateHeaderSearch({ searchWord: ''.value, searchType: searchType.value }); globalInfo.updateHeaderSearch({ softwareName: ''.value, searchType: searchType.value });
}; };
watch(() => route.query?.val, (newVal) => { watch(() => route.query?.val, (newVal) => {
@@ -73,7 +74,7 @@ watch(() => route.query?.val, (newVal) => {
const handleDataChange = ({ name, type, data }) => { const handleDataChange = ({ name, type, data }) => {
if (name === 'micoro-app-homeweb-app') { if (name === 'micoro-app-homeweb-app') {
if (type === 'keyword-change') { if (type === 'keyword-change') {
searchStr.value = data; softwareName.value = data;
} }
if (type === 'route-change') { if (type === 'route-change') {
// //
@@ -82,7 +83,9 @@ const handleDataChange = ({ name, type, data }) => {
}; };
onMounted(() => { onMounted(() => {
globalInfo.updateHeaderSearch({ softwareName: route.query.softwareName ? route.query.softwareName : '', searchType: route.query.searchType || '软件' });
softwareName.value = route.query.softwareName;
searchType.value = route.query.searchType || '软件';
}); });
onUnmounted(() => { onUnmounted(() => {

View File

@@ -16,7 +16,7 @@ export const useGlobalInfoStore = defineStore('globalInfo', () => {
const globalTheme = ref('light'); // 网站主题 const globalTheme = ref('light'); // 网站主题
const headerSearch = ref({ const headerSearch = ref({
searchType: '软件', searchType: '软件',
searchWord: '' softwareName: ''
}) })
const menuInfo = computed(() => { const menuInfo = computed(() => {

View File

@@ -144,7 +144,7 @@ const headerSearch = ref(globalInfo.headerSearch)
const newFormData = ref({ const newFormData = ref({
licenseName: '', licenseName: '',
searchType: headerSearch.value.searchType ? headerSearch.value.searchType : 'software', searchType: headerSearch.value.searchType ? headerSearch.value.searchType : 'software',
searchWord: '', softwareName: '',
softwareVersion: '', softwareVersion: '',
dependentSoftware: '', dependentSoftware: '',
programmingLanguage: '', programmingLanguage: '',
@@ -155,7 +155,9 @@ const newFormData = ref({
watch(() => globalInfo.headerSearch, (newVal: any) => { watch(() => globalInfo.headerSearch, (newVal: any) => {
headerSearch.value = newVal; headerSearch.value = newVal;
console.log(newVal)
newFormData.value.searchType = newVal.searchType; newFormData.value.searchType = newVal.searchType;
newFormData.value.softwareName = newVal.softwareName;
getReleaseList(); getReleaseList();
}, { deep: true }) }, { deep: true })
@@ -211,7 +213,7 @@ const clear = () => {
newFormData.value = { newFormData.value = {
licenseName: '', licenseName: '',
searchType: headerSearch.value.searchType ? headerSearch.value.searchType : 'software', searchType: headerSearch.value.searchType ? headerSearch.value.searchType : 'software',
searchWord: '', softwareName: '',
softwareVersion: '', softwareVersion: '',
dependentSoftware: '', dependentSoftware: '',
programmingLanguage: '', programmingLanguage: '',
@@ -321,10 +323,8 @@ const signCla = (row: any) => {
}; };
const getReleaseList = async() => { const getReleaseList = async() => {
console.log(newFormData.value.searchWord, headerSearch.value.searchWord)
const { data, error } = await releasePage({ const { data, error } = await releasePage({
...newFormData.value, ...newFormData.value,
searchWord: newFormData.value.searchWord ? newFormData.value.searchWord : headerSearch.value.searchWord,
releaseDateStart: newFormData.value.dateRange&&newFormData.value.dateRange.length>0?newFormData.value.dateRange[0]:'', releaseDateStart: newFormData.value.dateRange&&newFormData.value.dateRange.length>0?newFormData.value.dateRange[0]:'',
releaseDateEnd: newFormData.value.dateRange&&newFormData.value.dateRange.length>0?newFormData.value.dateRange[1]:'', releaseDateEnd: newFormData.value.dateRange&&newFormData.value.dateRange.length>0?newFormData.value.dateRange[1]:'',
current: pager.value.pageIndex, current: pager.value.pageIndex,
@@ -333,11 +333,13 @@ const getReleaseList = async() => {
if (!error && data) { if (!error && data) {
tableData.value = data.data.records; tableData.value = data.data.records;
pager.value.total = data.data.total; pager.value.total = data.data.total;
console.log(tableData.value)
} }
}; };
onMounted(async() => { onMounted(async() => {
getReleaseList(); // getReleaseList();
}); });
onMounted(() => { onMounted(() => {