2022-09-07 10:37:01 +00:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="hot-search">
|
|
|
|
|
|
<el-card class="!border-none" shadow="never">
|
|
|
|
|
|
<el-form ref="formRef" :model="formData" label-width="100px">
|
2022-09-15 01:25:46 +00:00
|
|
|
|
<el-form-item label="功能状态" style="margin-bottom: 0">
|
2022-09-07 10:37:01 +00:00
|
|
|
|
<div>
|
|
|
|
|
|
<el-radio-group v-model="formData.isHotSearch">
|
|
|
|
|
|
<el-radio :label="1">开启</el-radio>
|
|
|
|
|
|
<el-radio :label="0">关闭</el-radio>
|
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-tips">默认开始,关闭则前端不显示该功能</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
|
|
<el-card class="!border-none mt-4" shadow="never">
|
2022-09-21 06:11:23 +00:00
|
|
|
|
<div class="lg:flex">
|
|
|
|
|
|
<div class="flex-1 min-w-0">
|
2022-09-21 08:42:53 +00:00
|
|
|
|
<el-button type="primary" class="mb-4" @click="handleAdd">
|
|
|
|
|
|
<template #icon>
|
|
|
|
|
|
<icon name="el-icon-Plus" />
|
|
|
|
|
|
</template>
|
|
|
|
|
|
添加
|
|
|
|
|
|
</el-button>
|
2022-09-07 10:37:01 +00:00
|
|
|
|
<el-table size="large" :data="formData.list">
|
2022-09-21 06:11:23 +00:00
|
|
|
|
<el-table-column label="关键词" prop="describe" min-width="200">
|
2022-09-07 10:37:01 +00:00
|
|
|
|
<template #default="{ row }">
|
2022-09-29 07:18:41 +00:00
|
|
|
|
<el-input
|
|
|
|
|
|
v-model.trim="row.name"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
placeholder="请输入关键字"
|
|
|
|
|
|
show-word-limit
|
|
|
|
|
|
maxlength="30"
|
|
|
|
|
|
/>
|
2022-09-07 10:37:01 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2022-09-21 06:11:23 +00:00
|
|
|
|
<el-table-column label="排序" prop="describe" min-width="80">
|
2022-09-07 10:37:01 +00:00
|
|
|
|
<template #default="{ row }">
|
2022-09-21 08:44:00 +00:00
|
|
|
|
<el-input v-model="row.sort" type="number" clearable />
|
2022-09-07 10:37:01 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="操作" min-width="80" fixed="right">
|
2022-09-15 09:43:03 +00:00
|
|
|
|
<template #default="{ $index }">
|
2022-09-15 01:25:46 +00:00
|
|
|
|
<el-button
|
|
|
|
|
|
v-perms="['setting:storage:edit']"
|
|
|
|
|
|
type="danger"
|
|
|
|
|
|
link
|
|
|
|
|
|
@click="handleDel($index)"
|
|
|
|
|
|
>
|
2022-09-07 10:37:01 +00:00
|
|
|
|
删除
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2022-09-21 06:11:23 +00:00
|
|
|
|
<div class="flex-none hot-search-phone mt-4 lg:mt-0 lg:ml-4">
|
|
|
|
|
|
<div class="mb-4 text-center">- 热搜预览图 -</div>
|
2022-09-07 10:37:01 +00:00
|
|
|
|
<div class="hot-search-phone-content">
|
|
|
|
|
|
<!-- 搜索框 -->
|
|
|
|
|
|
<div class="search-com">
|
|
|
|
|
|
<div class="search-con flex items-center px-[15px]">
|
|
|
|
|
|
<icon name="el-icon-Search" :size="17" />
|
|
|
|
|
|
<span class="ml-[5px]">请输入关键词搜索</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- 热门搜索 -->
|
|
|
|
|
|
<div class="hot-search-title">热门搜索</div>
|
|
|
|
|
|
<div class="hot-search-text">
|
2022-09-21 08:44:00 +00:00
|
|
|
|
<span
|
|
|
|
|
|
class="truncate max-w-full"
|
|
|
|
|
|
v-for="(text, index) in list"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
>{{ text.name }}</span
|
|
|
|
|
|
>
|
2022-09-07 10:37:01 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
2022-09-16 07:35:38 +00:00
|
|
|
|
<footer-btns v-perms="['setting:search:save']">
|
2022-09-07 10:37:01 +00:00
|
|
|
|
<el-button type="primary" @click="handleSave">保存</el-button>
|
|
|
|
|
|
</footer-btns>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
2022-09-20 02:58:38 +00:00
|
|
|
|
<script setup lang="ts" name="search">
|
2022-09-15 01:25:46 +00:00
|
|
|
|
import { getSearch, setSearch } from '@/api/setting/search'
|
|
|
|
|
|
import type { Search } from '@/api/setting/search'
|
|
|
|
|
|
import feedback from '@/utils/feedback'
|
2022-09-07 10:37:01 +00:00
|
|
|
|
|
|
|
|
|
|
const formData = reactive<Search>({
|
|
|
|
|
|
isHotSearch: 1,
|
2022-09-15 01:25:46 +00:00
|
|
|
|
list: []
|
2022-09-07 10:37:01 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const list = computed(() => {
|
2022-09-29 07:18:41 +00:00
|
|
|
|
return formData.list.filter((item) => item.name).sort((v1, v2) => v2.sort - v1.sort)
|
2022-09-07 10:37:01 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 获取登录注册数据
|
|
|
|
|
|
const getData = async () => {
|
|
|
|
|
|
try {
|
2022-09-15 01:25:46 +00:00
|
|
|
|
const data = await getSearch()
|
2022-09-07 10:37:01 +00:00
|
|
|
|
for (const key in formData) {
|
|
|
|
|
|
//@ts-ignore
|
2022-09-15 01:25:46 +00:00
|
|
|
|
formData[key] = data[key]
|
2022-09-07 10:37:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.log('获取=>', error)
|
|
|
|
|
|
}
|
2022-09-15 01:25:46 +00:00
|
|
|
|
}
|
2022-09-07 10:37:01 +00:00
|
|
|
|
|
|
|
|
|
|
const handleAdd = () => {
|
|
|
|
|
|
formData.list.push({
|
2022-09-29 07:18:41 +00:00
|
|
|
|
name: '',
|
2022-09-07 10:37:01 +00:00
|
|
|
|
sort: 0
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleDel = (index: number) => {
|
|
|
|
|
|
formData.list.splice(index, 1)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleSave = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await setSearch(formData)
|
2022-09-15 01:25:46 +00:00
|
|
|
|
feedback.msgSuccess('操作成功')
|
2022-09-07 10:37:01 +00:00
|
|
|
|
getData()
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.log('保存=>', error)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getData()
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.hot-search {
|
|
|
|
|
|
.hot-search-phone {
|
2022-09-21 06:11:23 +00:00
|
|
|
|
width: 300px;
|
2022-09-07 10:37:01 +00:00
|
|
|
|
&-content {
|
2022-09-21 06:11:23 +00:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 530px;
|
2022-09-07 10:37:01 +00:00
|
|
|
|
padding: 12px 12px;
|
|
|
|
|
|
border-radius: 10px;
|
2022-09-15 01:25:46 +00:00
|
|
|
|
border: 1px solid #e6e6e6;
|
2022-09-07 10:37:01 +00:00
|
|
|
|
|
|
|
|
|
|
.search-com {
|
|
|
|
|
|
.search-con {
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
height: 36px;
|
|
|
|
|
|
border-radius: 36px;
|
|
|
|
|
|
background: #f4f4f4;
|
|
|
|
|
|
color: #999999;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.hot-search-title {
|
|
|
|
|
|
padding: 10px 0;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.hot-search-text {
|
|
|
|
|
|
span {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
border-radius: 100px;
|
|
|
|
|
|
padding: 5px 10px;
|
|
|
|
|
|
margin: 0 6px 6px 0;
|
|
|
|
|
|
display: inline-block;
|
2022-09-15 01:25:46 +00:00
|
|
|
|
background-color: #f4f4f4;
|
2022-09-07 10:37:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-09-15 01:25:46 +00:00
|
|
|
|
</style>
|