|
|
@@ -1,17 +1,36 @@
|
|
|
<template>
|
|
|
- <div class="p-8">
|
|
|
- <NSpace class="mb-4">
|
|
|
- <NButton type="primary" @click="onCreate">创建</NButton>
|
|
|
- </NSpace>
|
|
|
- <n-data-table
|
|
|
- remote
|
|
|
- :columns="columns"
|
|
|
- :data="tableData"
|
|
|
- :pagination="paginationReactive"
|
|
|
- :bordered="false"
|
|
|
- @update:page="getData"
|
|
|
- />
|
|
|
- </div>
|
|
|
+ <NLayout class="h-full">
|
|
|
+ <NLayoutHeader class="flex items-center px-8" style="height: 64px">
|
|
|
+ <span class="text-lg flex-1">论文助手</span>
|
|
|
+ <template v-if="isLogin">
|
|
|
+ <n-popover placement="bottom" trigger="click">
|
|
|
+ <template #trigger>
|
|
|
+ <n-button text>
|
|
|
+ <user-avatar avatarType="medium" onlyAvatar />
|
|
|
+ </n-button>
|
|
|
+ </template>
|
|
|
+ <n-button size="small" @click="logout" text>退出登录</n-button>
|
|
|
+ </n-popover>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template v-else>
|
|
|
+ <n-button round @click="showLogin = true" type="primary" size="small">登录</n-button>
|
|
|
+ </template>
|
|
|
+ </NLayoutHeader>
|
|
|
+ <NLayoutContent position="absolute" style="top: 64px; bottom: 0" class="px-8 py-4">
|
|
|
+ <NSpace class="pb-8">
|
|
|
+ <NButton type="primary" @click="onCreate">创建</NButton>
|
|
|
+ </NSpace>
|
|
|
+ <n-data-table
|
|
|
+ remote
|
|
|
+ :columns="columns"
|
|
|
+ :data="tableData"
|
|
|
+ :pagination="paginationReactive"
|
|
|
+ :bordered="false"
|
|
|
+ @update:page="getData"
|
|
|
+ />
|
|
|
+ </NLayoutContent>
|
|
|
+ </NLayout>
|
|
|
<n-modal v-model:show="showModal">
|
|
|
<n-card style="width: 600px" title="生成结果" :bordered="false" size="huge" role="dialog" aria-modal="true">
|
|
|
<n-data-table
|
|
|
@@ -51,9 +70,17 @@
|
|
|
</NSpace>
|
|
|
</n-card>
|
|
|
</n-modal>
|
|
|
+ <n-modal v-model:show="showLogin" transform-origin="center">
|
|
|
+ <n-card class="!max-w-xl !rounded-xl">
|
|
|
+ <div class="text-white text-2xl text-center font-bold py-8">登录</div>
|
|
|
+ <div class="max-w-sm my-5 mx-auto pb-16">
|
|
|
+ <login-form @success="onLogin" theme="dark"></login-form>
|
|
|
+ </div>
|
|
|
+ </n-card>
|
|
|
+ </n-modal>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
-import { h, defineComponent, ref, reactive, onMounted, Ref } from 'vue'
|
|
|
+import { h, defineComponent, ref, reactive, onMounted, Ref, computed } from 'vue'
|
|
|
import {
|
|
|
NButton,
|
|
|
NDataTable,
|
|
|
@@ -67,12 +94,54 @@ import {
|
|
|
NForm,
|
|
|
FormInst,
|
|
|
NFormItem,
|
|
|
- NInput
|
|
|
+ NInput,
|
|
|
+ NPageHeader,
|
|
|
+ NLayout,
|
|
|
+ NLayoutHeader,
|
|
|
+ NLayoutContent,
|
|
|
+ NAvatar,
|
|
|
+ NPopover
|
|
|
} from 'naive-ui'
|
|
|
import { fetchPaperOrders, fetchGenPaper, fetchPaperResults, fetchCreatePaperOrder, fetchUpdatePaperOrder } from '@/api'
|
|
|
import { format, parseISO } from 'date-fns'
|
|
|
+import { UserAvatar } from '@/components/common'
|
|
|
+import { LoginForm } from '@/components/common'
|
|
|
+import { useUserStore } from '@/store'
|
|
|
+import { storeToRefs } from 'pinia'
|
|
|
|
|
|
const message = useMessage()
|
|
|
+const showLogin = ref(false)
|
|
|
+const userStore = useUserStore()
|
|
|
+const { userInfo } = storeToRefs(userStore)
|
|
|
+const dialog = useDialog()
|
|
|
+const isLogin = computed(() => {
|
|
|
+ return !!userInfo.value.id
|
|
|
+})
|
|
|
+onMounted(() => {
|
|
|
+ getData()
|
|
|
+ if (!isLogin.value) {
|
|
|
+ showLogin.value = true
|
|
|
+ }
|
|
|
+})
|
|
|
+function logout() {
|
|
|
+ dialog.create({
|
|
|
+ title: '提示',
|
|
|
+ content: '确认要退出登录吗?',
|
|
|
+ positiveText: '退出登录',
|
|
|
+ negativeText: '取消',
|
|
|
+ maskClosable: false,
|
|
|
+ onPositiveClick: () => {
|
|
|
+ userStore.logout()
|
|
|
+ message.success('退出登录成功')
|
|
|
+ tableData.value = []
|
|
|
+ resultData.value = []
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+function onLogin() {
|
|
|
+ showLogin.value = false
|
|
|
+ getData()
|
|
|
+}
|
|
|
const tableData = ref([])
|
|
|
function timeFormatter(rowData: any, rowIndex: number) {
|
|
|
return format(parseISO(rowData.createdAt), 'yyyy-MM-dd HH:mm:ss')
|
|
|
@@ -191,11 +260,6 @@ async function getData() {
|
|
|
paginationReactive.pageCount = res.meta.totalPages
|
|
|
}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
- getData()
|
|
|
- getResults()
|
|
|
-})
|
|
|
-const dialog = useDialog()
|
|
|
async function gen(row: any) {
|
|
|
const d = dialog.success({
|
|
|
title: '生成',
|