add top for announcement
This commit is contained in:
@@ -19,6 +19,7 @@ const announcement = reactive<AnnouncementEdit>({
|
|||||||
tag: "公告",
|
tag: "公告",
|
||||||
content: "",
|
content: "",
|
||||||
visible: false,
|
visible: false,
|
||||||
|
top: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
const tags: SelectOption[] = [
|
const tags: SelectOption[] = [
|
||||||
@@ -38,6 +39,7 @@ async function init() {
|
|||||||
announcement.title = res.data.title
|
announcement.title = res.data.title
|
||||||
announcement.content = res.data.content
|
announcement.content = res.data.content
|
||||||
announcement.visible = res.data.visible
|
announcement.visible = res.data.visible
|
||||||
|
announcement.top = res.data.top
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
@@ -85,6 +87,9 @@ onMounted(init)
|
|||||||
<n-form-item label="可见">
|
<n-form-item label="可见">
|
||||||
<n-switch v-model:value="announcement.visible" />
|
<n-switch v-model:value="announcement.visible" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
<n-form-item label="置顶">
|
||||||
|
<n-switch v-model:value="announcement.top" />
|
||||||
|
</n-form-item>
|
||||||
</n-form>
|
</n-form>
|
||||||
<TextEditor
|
<TextEditor
|
||||||
v-if="ready"
|
v-if="ready"
|
||||||
|
|||||||
14
src/oj/announcement/components/TitleWithTag.vue
Normal file
14
src/oj/announcement/components/TitleWithTag.vue
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<template>
|
||||||
|
<n-flex align="center">
|
||||||
|
<n-tag type="error" v-if="top">置顶</n-tag>
|
||||||
|
<span>{{ title }}</span>
|
||||||
|
</n-flex>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
interface Props {
|
||||||
|
top: boolean
|
||||||
|
title: string
|
||||||
|
}
|
||||||
|
|
||||||
|
defineProps<Props>()
|
||||||
|
</script>
|
||||||
@@ -5,6 +5,7 @@ import { parseTime } from "~/utils/functions"
|
|||||||
import { Announcement } from "~/utils/types"
|
import { Announcement } from "~/utils/types"
|
||||||
import { isDesktop } from "~/shared/composables/breakpoints"
|
import { isDesktop } from "~/shared/composables/breakpoints"
|
||||||
import { NTag } from "naive-ui"
|
import { NTag } from "naive-ui"
|
||||||
|
import TitleWithTag from "./components/TitleWithTag.vue"
|
||||||
|
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const content = ref("")
|
const content = ref("")
|
||||||
@@ -15,7 +16,12 @@ const query = reactive({
|
|||||||
page: 1,
|
page: 1,
|
||||||
})
|
})
|
||||||
const columns: DataTableColumn<Announcement>[] = [
|
const columns: DataTableColumn<Announcement>[] = [
|
||||||
{ key: "title", title: "公告标题", minWidth: 300 },
|
{
|
||||||
|
key: "title",
|
||||||
|
title: "公告标题",
|
||||||
|
render: (row) => h(TitleWithTag, { title: row.title, top: row.top }),
|
||||||
|
minWidth: 300,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "tag",
|
key: "tag",
|
||||||
title: "标签",
|
title: "标签",
|
||||||
|
|||||||
@@ -337,6 +337,7 @@ export interface AnnouncementEdit {
|
|||||||
tag: string
|
tag: string
|
||||||
content: string
|
content: string
|
||||||
visible: boolean
|
visible: boolean
|
||||||
|
top: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Announcement extends AnnouncementEdit {
|
export interface Announcement extends AnnouncementEdit {
|
||||||
|
|||||||
Reference in New Issue
Block a user