星球加入标签

master
shenhan000 2025-05-14 17:56:04 +08:00
parent 13eea2f2d9
commit 73baf0a166
6 changed files with 117 additions and 18 deletions

2
app/components.d.ts vendored
View File

@ -10,10 +10,12 @@ declare module 'vue' {
NAffix: typeof import('naive-ui')['NAffix']
NAvatar: typeof import('naive-ui')['NAvatar']
NButton: typeof import('naive-ui')['NButton']
NButtonGroup: typeof import('naive-ui')['NButtonGroup']
NCard: typeof import('naive-ui')['NCard']
NCarousel: typeof import('naive-ui')['NCarousel']
NCascader: typeof import('naive-ui')['NCascader']
NCheckbox: typeof import('naive-ui')['NCheckbox']
NCheckboxGroup: typeof import('naive-ui')['NCheckboxGroup']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDatePicker: typeof import('naive-ui')['NDatePicker']
NDivider: typeof import('naive-ui')['NDivider']

View File

@ -413,11 +413,12 @@ function handleDownload(index: number, item: any) {
v-for="(subItem, subIndex) in item.fileName.split(',')"
:key="subIndex"
title="点击下载"
class="text-[#4a5563] text-sm cursor-pointer flex items-center hover:text-[#4a5563]/80 my-1"
@click="handleDownload(subIndex, item)"
class="text-[#4a5563] text-sm flex items-center hover:text-[#4a5563]/80 my-1"
>
<FileChartColumn size="16" class="mr-1" />
{{ subItem }}
<span class="truncate cursor-pointer" @click="handleDownload(subIndex, item)">
{{ subItem }}
</span>
</div>
</div>
<div v-if="item.imageUrl" class="flex items-center my-1 gap-2">

View File

@ -171,7 +171,7 @@ function handleShowMessage() {
</div>
<div class="text-sm text-[#4a5563] flex justify-center items-center my-4 cursor-pointer" @click="handleLogout">
出登录
退出登录
</div>
</div>
</div>

View File

@ -24,6 +24,8 @@ const formData = ref({
fileUrl: '',
fileName: '',
imageUrl: '',
labelName: null,
isElite: 0,
})
//
@ -59,6 +61,8 @@ async function handlePublish() {
fileUrl: '',
fileName: '',
imageUrl: '',
labelName: '',
isElite: 0,
}
fileUrl.value = []
fileName.value = []
@ -125,6 +129,25 @@ async function handlePictureChange(event: Event) {
message.error(currentUploadType.value === 'img' ? '图片上传失败' : '文件上传失败')
}
}
const tagList = ref([])
async function getTagList() {
const params = {
communityId: props.communityId,
tenantId: props.tenantId,
}
const res = await request.post('/publishLabel/list', params)
for (let i = 0; i < res.data.length; i++) {
tagList.value.push({
label: res.data[i],
value: res.data[i],
})
}
}
onMounted(() => {
getTagList()
})
</script>
<template>
@ -136,7 +159,7 @@ async function handlePictureChange(event: Event) {
label-width="auto"
require-mark-placement="right-hanging"
>
<n-form-item path="content" :show-label="false">
<!-- <n-form-item path="content" :show-label="false">
<n-input
v-model:value="formData.content"
type="textarea"
@ -144,6 +167,25 @@ async function handlePictureChange(event: Event) {
:autosize="{ minRows: 5, maxRows: 10 }"
class="rounded-lg"
/>
</n-form-item> -->
<n-form-item label="标签" path="labelName">
<n-select
v-model:value="formData.labelName"
placeholder="选择标签"
:options="tagList"
/>
</n-form-item>
<n-form-item label="内容" path="content">
<n-input
v-model:value="formData.content"
placeholder="点击发表主题"
type="textarea"
:autosize="{
minRows: 3,
maxRows: 5,
}"
/>
</n-form-item>
<div v-if="fileName.length > 0" class="mt-4 flex flex-wrap gap-3 mb-2">
@ -185,6 +227,11 @@ async function handlePictureChange(event: Event) {
<div class="border border-gray-300 rounded p-1 cursor-pointer hover:bg-gray-50 transition-colors" @click="handlePictureInput('file')">
<FolderPlus class="w-5 h-5" />
</div>
<div v-if="userStore.userInfo.userId === props.tenantId" class="ml-6 flex items-center gap-2">
<n-checkbox v-model:checked="formData.isElite" checked-value="1" unchecked-value="0">
是否为精选
</n-checkbox>
</div>
</div>
<div class="flex items-center gap-8">

View File

@ -1,15 +1,17 @@
<script setup lang="ts">
import request from '@/utils/request'
import { FolderPlus, ImagePlus, MessageCircle, Star, ThumbsUp } from 'lucide-vue-next'
import { FolderPlus, ImagePlus, MessageCircle, Plus, Star, ThumbsUp } from 'lucide-vue-next'
import { NConfigProvider, NImage, NMessageProvider } from 'naive-ui'
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
const userStore = useUserStore()
const message = useMessage()
definePageMeta({
layout: 'planet',
})
const route = useRoute()
const isShowInputLabel = ref(false)
const typeList = ref([
{
label: '最新',
@ -53,15 +55,6 @@ async function handleTypeChange(type: number | null) {
questionParams.value.pageNum = 1
if (type === 999) { //
isShow.value = 'question'
// try {
// const res = await request.post('/question/list', questionParams.value)
// if (res.code === 200) {
// questionList.value = res.rows
// }
// }
// catch (error) {
// console.error(error)
// }
}
else {
publishListParams.value.pageNum = 1
@ -76,6 +69,42 @@ function closePublishModal() {
})
}
//
//
const tagList = ref([])
async function getTagList() {
const params = {
communityId: questionParams.value.communityId,
tenantId: questionParams.value.tenantId,
}
const res = await request.post('/publishLabel/list', params)
tagList.value = res.data
}
//
const inputLabel = ref('')
async function handleAddLabel() {
const params = {
communityId: questionParams.value.communityId,
tenantId: questionParams.value.tenantId,
labelName: inputLabel.value,
}
const res = await request.post('/publishLabel/add', params)
if (res.code === 200) {
message.success('添加成功')
isShowInputLabel.value = false
inputLabel.value = ''
getTagList()
}
}
//
function handleTagClick(tag: string) {
if (publishListParams.value.type === 999)
return
publishListParams.value.labelName = tag
publishListParams.value.pageNum = 1
isShow.value = 'publish'
}
onMounted(() => {
const state = history.state
if (state && state.communityId && state.tenantId) {
@ -107,6 +136,7 @@ onMounted(() => {
pageSize: 10,
}
}
getTagList()
})
</script>
@ -149,6 +179,25 @@ onMounted(() => {
>
{{ item.label }}
</div>
<div
v-for="tag in tagList" :key="tag.id" class="flex items-center px-4 py-1 rounded cursor-pointer mr-2" :style="{
backgroundColor: publishListParams.type === tag.id ? '#000000' : '#ffffff',
color: publishListParams.type === tag.id ? '#ffffff' : '#878d95',
}" @click="handleTagClick(tag)"
>
{{ tag }}
</div>
<div v-if="tagList.length < 3 && questionParams.tenantId === userStore.userInfo.userId" class="flex items-center justify-center bg-white w-10 h-8 cursor-pointer" title="添加标签" @click="isShowInputLabel = true">
<Plus class="w-4 h-4" />
</div>
<n-input-group v-if="isShowInputLabel" class="ml-4 w-64">
<n-input v-model:value="inputLabel" :style="{ width: '200px' }" placeholder="请输入标签名" />
<n-button type="primary" @click="handleAddLabel">
确定
</n-button>
</n-input-group>
</div>
</div>
<div v-if="isShow === 'publish'">

View File

@ -85,9 +85,9 @@ export default defineNuxtConfig({
preset: 'node-server',
devProxy: {
'/api': {
target: 'http://113.45.190.154:8080', // 线上
// target: 'http://113.45.190.154:8080', // 线上
// target: 'http://192.168.2.29:8080', // 代
// target: 'http://192.168.2.21:8080', // 嗨
target: 'http://192.168.2.21:8080', // 嗨
// target: 'https://2d1a399f.r27.cpolar.top', // 嗨
changeOrigin: true,
prependPath: true,