refactor editor and panel.

This commit is contained in:
2023-01-31 22:16:41 +08:00
parent 7b0163885a
commit 17aa4afc04
8 changed files with 115 additions and 74 deletions

View File

@@ -16,12 +16,20 @@ const props = defineProps<{
}>()
const submission = ref<Submission>()
const [copied, toggle] = useToggle()
const { start } = useTimeoutFn(() => toggle(false), 1000, { immediate: false })
async function init() {
const res = await getSubmission(props.submissionID)
submission.value = res.data
}
function handleCopy(v: string) {
copy(v)
toggle(true)
start()
}
const columns: DataTableColumn<Submission["info"]["data"][number]>[] = [
{ title: "测试用例", key: "test_case" },
{
@@ -59,7 +67,9 @@ onMounted(init)
</n-alert>
<n-card embedded>
<n-space justify="end">
<n-button @click="copy(submission!.code)">复制代码</n-button>
<n-button @click="handleCopy(submission!.code)">
{{ copied ? "已复制" : "复制代码" }}
</n-button>
</n-space>
<n-code
class="code"