diff --git a/gpt-vue/packages/utils/index.ts b/gpt-vue/packages/utils/index.ts index 937cdd0d..698da4d8 100644 --- a/gpt-vue/packages/utils/index.ts +++ b/gpt-vue/packages/utils/index.ts @@ -2,4 +2,56 @@ import { v4 as uuidV4 } from "uuid"; export const getUUID = () => { return uuidV4(); -}; \ No newline at end of file +}; + +// 格式化日期 +export function dateFormat(timestamp: number, format?: string) { + if (!timestamp) { + return ''; + } else if (timestamp < 9680917502) { + timestamp = timestamp * 1000; + } + let year, month, day, HH, mm, ss; + let time = new Date(timestamp); + let timeDate; + year = time.getFullYear(); // 年 + month = time.getMonth() + 1; // 月 + day = time.getDate(); // 日 + HH = time.getHours(); // 时 + mm = time.getMinutes(); // 分 + ss = time.getSeconds(); // 秒 + + month = month < 10 ? '0' + month : month; + day = day < 10 ? '0' + day : day; + HH = HH < 10 ? '0' + HH : HH; // 时 + mm = mm < 10 ? '0' + mm : mm; // 分 + ss = ss < 10 ? '0' + ss : ss; // 秒 + + switch (format) { + case 'yyyy': + timeDate = String(year); + break; + case 'yyyy-MM': + timeDate = year + '-' + month; + break; + case 'yyyy-MM-dd': + timeDate = year + '-' + month + '-' + day; + break; + case 'yyyy/MM/dd': + timeDate = year + '/' + month + '/' + day; + break; + case 'yyyy-MM-dd HH:mm:ss': + timeDate = year + '-' + month + '-' + day + ' ' + HH + ':' + mm + ':' + ss; + break; + case 'HH:mm:ss': + timeDate = HH + ':' + mm + ':' + ss; + break; + case 'MM': + timeDate = String(month); + break; + default: + timeDate = year + '-' + month + '-' + day + ' ' + HH + ':' + mm + ':' + ss; + break; + } + return timeDate; +} \ No newline at end of file diff --git a/gpt-vue/projects/vue-admin/src/components/SearchTable/useAsyncTable.ts b/gpt-vue/projects/vue-admin/src/components/SearchTable/useAsyncTable.ts index 8c13a461..0e0ebbd3 100644 --- a/gpt-vue/projects/vue-admin/src/components/SearchTable/useAsyncTable.ts +++ b/gpt-vue/projects/vue-admin/src/components/SearchTable/useAsyncTable.ts @@ -46,7 +46,7 @@ function useAsyncTable>( const { data } = await request({ ...unref(params ?? {}), page: paginationState.current, - pageSize: paginationState.pageSize, + page_size: paginationState.pageSize, }); tableState.data = (data as any)?.items; paginationState.total = (data as any)?.total; diff --git a/gpt-vue/projects/vue-admin/src/components/SimpleTable/SimpleTable.vue b/gpt-vue/projects/vue-admin/src/components/SimpleTable/SimpleTable.vue index e235a986..de0821b8 100644 --- a/gpt-vue/projects/vue-admin/src/components/SimpleTable/SimpleTable.vue +++ b/gpt-vue/projects/vue-admin/src/components/SimpleTable/SimpleTable.vue @@ -5,9 +5,9 @@ import { useTableScroll } from "@/components/SearchTable/utils"; import { Message } from "@arco-design/web-vue"; import type { TableRequest, TableOriginalProps } from "./useAsyncTable"; -export interface SimpleTable extends TableOriginalProps { +export interface SimpleTable extends /* @vue-ignore */ TableOriginalProps { request: TableRequest>; - params: Record; + params?: Record; } const props = defineProps(); diff --git a/gpt-vue/projects/vue-admin/src/composables/usePopup.ts b/gpt-vue/projects/vue-admin/src/composables/usePopup.ts new file mode 100644 index 00000000..282e1d3c --- /dev/null +++ b/gpt-vue/projects/vue-admin/src/composables/usePopup.ts @@ -0,0 +1,37 @@ +import { h } from "vue"; +import type { Component, ComponentInternalInstance } from "vue"; +import { Modal, Drawer } from "@arco-design/web-vue"; +import type { ModalConfig, DrawerConfig } from "@arco-design/web-vue"; +import app from "@/main"; + +interface Config { + nodeProps?: (...arg: any) => Record; + popupProps?: ( + arg: any[], + exposed: () => ComponentInternalInstance["exposed"] + ) => Omit & { + [key: string]: any; + }; + type?: "drawer" | "modal"; +} + +const component = { + modal: Modal, + drawer: Drawer, +}; +function usePopup(node: Component, config: Config) { + const { nodeProps, popupProps, type = "modal" } = config; + + return (...arg: any[]) => { + const content = h(node, nodeProps ? nodeProps(arg) : {}); + const popupNode = component[type]; + // 获取全局组件的上下文 + popupNode._context = app._context; + popupNode.open({ + content: () => content, + ...popupProps?.(arg, () => content?.component?.exposed as any), + }); + }; +} + +export default usePopup; diff --git a/gpt-vue/projects/vue-admin/src/http/login.ts b/gpt-vue/projects/vue-admin/src/http/login.ts index 8032866c..71e2e1bc 100644 --- a/gpt-vue/projects/vue-admin/src/http/login.ts +++ b/gpt-vue/projects/vue-admin/src/http/login.ts @@ -25,3 +25,11 @@ export const getSession = () => { }); }; + +export const loginLog = (params?: Record) => { + return http({ + url: "/api/admin/user/loginLog", + method: "get", + params + }) +} \ No newline at end of file diff --git a/gpt-vue/projects/vue-admin/src/router/menu.ts b/gpt-vue/projects/vue-admin/src/router/menu.ts index 3a70696c..429e6c19 100644 --- a/gpt-vue/projects/vue-admin/src/router/menu.ts +++ b/gpt-vue/projects/vue-admin/src/router/menu.ts @@ -2,6 +2,7 @@ import { IconUser, IconDashboard, IconOrderedList, + IconCalendar, } from "@arco-design/web-vue/es/icon"; const menu = [ @@ -32,6 +33,24 @@ const menu = [ }, component: () => import('@/views/Order/OrderContainer.vue') }, + { + path: '/reward', + name: 'Reward', + meta: { + title: "众筹管理", + icon: IconCalendar, + }, + component: () => import('@/views/Reward/RewardContainer.vue') + }, + { + path: '/loginLog', + name: 'LoginLog', + meta: { + title: "登录日志", + icon: IconCalendar, + }, + component: () => import('@/views/LoginLog.vue') + }, ]; export default menu; diff --git a/gpt-vue/projects/vue-admin/src/views/Chats/ChatsContainer.vue b/gpt-vue/projects/vue-admin/src/views/Chats/ChatsContainer.vue new file mode 100644 index 00000000..e69de29b diff --git a/gpt-vue/projects/vue-admin/src/views/Functions/FunctionsContainer.vue b/gpt-vue/projects/vue-admin/src/views/Functions/FunctionsContainer.vue new file mode 100644 index 00000000..e69de29b diff --git a/gpt-vue/projects/vue-admin/src/views/LoginLog.vue b/gpt-vue/projects/vue-admin/src/views/LoginLog.vue new file mode 100644 index 00000000..c2cbfc69 --- /dev/null +++ b/gpt-vue/projects/vue-admin/src/views/LoginLog.vue @@ -0,0 +1,29 @@ + + diff --git a/gpt-vue/projects/vue-admin/src/views/Reward/RewardContainer.vue b/gpt-vue/projects/vue-admin/src/views/Reward/RewardContainer.vue new file mode 100644 index 00000000..3b93763a --- /dev/null +++ b/gpt-vue/projects/vue-admin/src/views/Reward/RewardContainer.vue @@ -0,0 +1,59 @@ + + diff --git a/gpt-vue/projects/vue-admin/src/views/Reward/api.ts b/gpt-vue/projects/vue-admin/src/views/Reward/api.ts new file mode 100644 index 00000000..ed68ff00 --- /dev/null +++ b/gpt-vue/projects/vue-admin/src/views/Reward/api.ts @@ -0,0 +1,9 @@ +import http from "@/http/config"; + +export const getList = (params?: Record) => { + return http({ + url: "/api/admin/reward/list", + method: "get", + params + }) +} \ No newline at end of file