修改标签的出现逻辑
This commit is contained in:
3
src/components.d.ts
vendored
3
src/components.d.ts
vendored
@@ -7,7 +7,10 @@ export {}
|
|||||||
|
|
||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
|
IEpArrowD: typeof import('~icons/ep/arrow-d')['default']
|
||||||
|
IEpArrowDown: typeof import('~icons/ep/arrow-down')['default']
|
||||||
IEpArrowRightBold: typeof import('~icons/ep/arrow-right-bold')['default']
|
IEpArrowRightBold: typeof import('~icons/ep/arrow-right-bold')['default']
|
||||||
|
IEpArrowUp: typeof import('~icons/ep/arrow-up')['default']
|
||||||
IEpBell: typeof import('~icons/ep/bell')['default']
|
IEpBell: typeof import('~icons/ep/bell')['default']
|
||||||
IEpCaretRight: typeof import('~icons/ep/caret-right')['default']
|
IEpCaretRight: typeof import('~icons/ep/caret-right')['default']
|
||||||
IEpLoading: typeof import('~icons/ep/loading')['default']
|
IEpLoading: typeof import('~icons/ep/loading')['default']
|
||||||
|
|||||||
@@ -27,6 +27,18 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
|
|
||||||
const errMsg = ref("无数据")
|
const errMsg = ref("无数据")
|
||||||
|
|
||||||
|
const onlyDetail = computed(
|
||||||
|
() =>
|
||||||
|
screenMode.value === ScreenMode.both ||
|
||||||
|
screenMode.value === ScreenMode.problem,
|
||||||
|
)
|
||||||
|
|
||||||
|
const onlyCode = computed(
|
||||||
|
() =>
|
||||||
|
screenMode.value === ScreenMode.both ||
|
||||||
|
screenMode.value === ScreenMode.code,
|
||||||
|
)
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
try {
|
try {
|
||||||
const res = await getProblem(props.problemID, props.contestID)
|
const res = await getProblem(props.problemID, props.contestID)
|
||||||
@@ -51,12 +63,7 @@ onBeforeUnmount(() => {
|
|||||||
x-gap="16"
|
x-gap="16"
|
||||||
:cols="screenMode === ScreenMode.both ? 2 : 1"
|
:cols="screenMode === ScreenMode.both ? 2 : 1"
|
||||||
>
|
>
|
||||||
<n-gi
|
<n-gi :span="isDesktop ? 1 : 2" v-show="onlyDetail">
|
||||||
:span="isDesktop ? 1 : 2"
|
|
||||||
v-show="
|
|
||||||
screenMode === ScreenMode.both || screenMode === ScreenMode.problem
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<n-scrollbar v-if="isDesktop" style="max-height: calc(100vh - 92px)">
|
<n-scrollbar v-if="isDesktop" style="max-height: calc(100vh - 92px)">
|
||||||
<n-tabs default-value="content" type="segment">
|
<n-tabs default-value="content" type="segment">
|
||||||
<n-tab-pane name="content" tab="题目描述">
|
<n-tab-pane name="content" tab="题目描述">
|
||||||
@@ -85,14 +92,9 @@ onBeforeUnmount(() => {
|
|||||||
</n-tab-pane>
|
</n-tab-pane>
|
||||||
</n-tabs>
|
</n-tabs>
|
||||||
</n-gi>
|
</n-gi>
|
||||||
<n-gi
|
<n-gi v-if="isDesktop" v-show="onlyCode">
|
||||||
v-if="isDesktop"
|
|
||||||
v-show="screenMode === ScreenMode.both || screenMode === ScreenMode.code"
|
|
||||||
>
|
|
||||||
<Editor />
|
<Editor />
|
||||||
</n-gi>
|
</n-gi>
|
||||||
</n-grid>
|
</n-grid>
|
||||||
<n-empty v-else :description="errMsg"></n-empty>
|
<n-empty v-else :description="errMsg"></n-empty>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useUserStore } from "~/shared/store/user"
|
import { NSpace, NTag } from "naive-ui"
|
||||||
import { filterEmptyValue, getTagColor } from "utils/functions"
|
import { filterEmptyValue, getTagColor } from "utils/functions"
|
||||||
import { ProblemFiltered } from "utils/types"
|
import { ProblemFiltered } from "utils/types"
|
||||||
import { getProblemList, getRandomProblemID } from "oj/api"
|
import { getProblemList, getRandomProblemID } from "oj/api"
|
||||||
import Pagination from "~/shared/Pagination.vue"
|
|
||||||
import { NSpace, NTag } from "naive-ui"
|
|
||||||
import ProblemStatus from "./components/ProblemStatus.vue"
|
import ProblemStatus from "./components/ProblemStatus.vue"
|
||||||
|
import { useUserStore } from "~/shared/store/user"
|
||||||
import { getProblemTagList } from "~/shared/api"
|
import { getProblemTagList } from "~/shared/api"
|
||||||
|
import Pagination from "~/shared/Pagination.vue"
|
||||||
import { isDesktop } from "~/shared/composables/breakpoints"
|
import { isDesktop } from "~/shared/composables/breakpoints"
|
||||||
|
|
||||||
interface Tag {
|
interface Tag {
|
||||||
@@ -69,7 +69,7 @@ async function listTags() {
|
|||||||
const res = await getProblemTagList()
|
const res = await getProblemTagList()
|
||||||
tags.value = res.data.map((r: Omit<Tag, "checked">) => ({
|
tags.value = res.data.map((r: Omit<Tag, "checked">) => ({
|
||||||
...r,
|
...r,
|
||||||
checked: false,
|
checked: query.tag === r.name,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +117,16 @@ watch(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => query.tag,
|
||||||
|
() => {
|
||||||
|
tags.value = tags.value.map((r: Omit<Tag, "checked">) => ({
|
||||||
|
...r,
|
||||||
|
checked: query.tag === r.name,
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => route.path === "/" && route.query,
|
() => route.path === "/" && route.query,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
@@ -186,8 +196,8 @@ function rowProps(row: ProblemFiltered) {
|
|||||||
:options="difficultyOptions"
|
:options="difficultyOptions"
|
||||||
/>
|
/>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="搜索">
|
<n-form-item>
|
||||||
<n-input clearable @change="search" />
|
<n-input clearable @change="search" placeholder="标题或序号" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-form>
|
</n-form>
|
||||||
<n-form :show-feedback="false" inline label-placement="left">
|
<n-form :show-feedback="false" inline label-placement="left">
|
||||||
@@ -199,20 +209,28 @@ function rowProps(row: ProblemFiltered) {
|
|||||||
</n-space>
|
</n-space>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-form>
|
</n-form>
|
||||||
<n-button @click="toggleShowTag()" quaternary>标签</n-button>
|
<n-button @click="toggleShowTag()" quaternary icon-placement="right">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon>
|
||||||
|
<i-ep-arrow-down v-if="showTag" />
|
||||||
|
<i-ep-arrow-up v-else />
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
标签
|
||||||
|
</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-collapse-transition :show="showTag">
|
<n-collapse-transition :show="showTag">
|
||||||
<n-space>
|
<n-space>
|
||||||
<n-button
|
<n-tag
|
||||||
@click="chooseTag(tag)"
|
|
||||||
v-for="tag in tags"
|
v-for="tag in tags"
|
||||||
|
:closable="tag.checked"
|
||||||
|
@close="chooseTag(tag)"
|
||||||
|
@click="chooseTag(tag)"
|
||||||
:key="tag.id"
|
:key="tag.id"
|
||||||
size="small"
|
|
||||||
secondary
|
|
||||||
:type="tag.checked ? 'success' : 'default'"
|
:type="tag.checked ? 'success' : 'default'"
|
||||||
>
|
>
|
||||||
{{ tag.name }}
|
{{ tag.name }}
|
||||||
</n-button>
|
</n-tag>
|
||||||
</n-space>
|
</n-space>
|
||||||
</n-collapse-transition>
|
</n-collapse-transition>
|
||||||
<n-data-table
|
<n-data-table
|
||||||
|
|||||||
Reference in New Issue
Block a user