From b45593079861772159530425271120e776eb0dcd Mon Sep 17 00:00:00 2001 From: zlong <953829746@qq.com> Date: Tue, 19 Nov 2024 23:43:46 +0800 Subject: [PATCH 01/10] =?UTF-8?q?add:=E4=B8=8A=E4=BC=A0banner=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- .env.development | 2 +- components.d.ts | 5 - src/api/carousal.ts | 30 ++++ src/model/carousals.ts | 12 ++ src/model/token.ts | 2 +- .../carousal/components/CarousalDialog.vue | 148 ++++++++++++++++++ src/pages/carousal/index.vue | 105 +++++++++++++ src/pages/common/login.vue | 8 +- src/router/index.ts | 25 ++- 10 files changed, 319 insertions(+), 20 deletions(-) create mode 100644 src/api/carousal.ts create mode 100644 src/model/carousals.ts create mode 100644 src/pages/carousal/components/CarousalDialog.vue create mode 100644 src/pages/carousal/index.vue diff --git a/.env b/.env index da5b2cc..cb3b622 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ VITE_ENABLE_MOCK=false VITE_API_PREFIX=/api -VITE_PROXY_ENDPOINT=http://localhost:8000 +VITE_PROXY_ENDPOINT=https://bright.yilibili.com/api/ diff --git a/.env.development b/.env.development index 92b86ee..9817c86 100644 --- a/.env.development +++ b/.env.development @@ -1 +1 @@ -VITE_ENABLE_MOCK=true +VITE_ENABLE_MOCK=false diff --git a/components.d.ts b/components.d.ts index cf28278..bbec505 100644 --- a/components.d.ts +++ b/components.d.ts @@ -8,7 +8,6 @@ export {} declare module 'vue' { export interface GlobalComponents { Copyright: typeof import('./src/components/Copyright.vue')['default'] - Dialog: typeof import('./src/components/Dialog.vue')['default'] RegularPage: typeof import('./src/components/RegularPage.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] @@ -17,7 +16,6 @@ declare module 'vue' { TButton: typeof import('tdesign-vue-next')['Button'] TCard: typeof import('tdesign-vue-next')['Card'] TCheckbox: typeof import('tdesign-vue-next')['Checkbox'] - TCol: typeof import('tdesign-vue-next')['Col'] TDialog: typeof import('tdesign-vue-next')['Dialog'] TDropdown: typeof import('tdesign-vue-next')['Dropdown'] TForm: typeof import('tdesign-vue-next')['Form'] @@ -29,9 +27,6 @@ declare module 'vue' { TLink: typeof import('tdesign-vue-next')['Link'] TMenu: typeof import('tdesign-vue-next')['Menu'] TMenuItem: typeof import('tdesign-vue-next')['MenuItem'] - TPagination: typeof import('tdesign-vue-next')['Pagination'] - TRow: typeof import('tdesign-vue-next')['Row'] - TSelect: typeof import('tdesign-vue-next')['Select'] TSpace: typeof import('tdesign-vue-next')['Space'] TTable: typeof import('tdesign-vue-next')['Table'] TTag: typeof import('tdesign-vue-next')['Tag'] diff --git a/src/api/carousal.ts b/src/api/carousal.ts new file mode 100644 index 0000000..09f3ca6 --- /dev/null +++ b/src/api/carousal.ts @@ -0,0 +1,30 @@ +import httpClient from './httpClient' +import type { CreateCarousalsRequest, GetCarousalsRequest } from '@/model/carousals' +import type { UnwrapNestedRefs } from 'vue' + +export const createCarousal = (createCarousalsRequest: UnwrapNestedRefs<{ size: number; page: number }> & {}) => { + return httpClient.post('/carousals', createCarousalsRequest) +} + +export const getCarousalList = (getCarousalsRequest:GetCarousalsRequest) => { + return httpClient.get('/carousals',getCarousalsRequest) +} +export const getCarousalItem = (id:string) => { + return httpClient.get(`/carousals/${id}`) +} + +export const updateCarousalItem = (id:number,updateCarousalsRequest: CreateCarousalsRequest) => { + return httpClient.put(`/carousals/${id}`,updateCarousalsRequest) +} + +export const deleteCarousal = (id:number) => { + return httpClient.delete(`/carousals/${id}`) +} + +export const activeCarousal = (id:number) => { + return httpClient.put(`/carousals/${id}/active`) +} + +export const inactiveCarousal = (id:number) => { + return httpClient.put(`/carousals/${id}/inactive`) +} \ No newline at end of file diff --git a/src/model/carousals.ts b/src/model/carousals.ts new file mode 100644 index 0000000..1c132ea --- /dev/null +++ b/src/model/carousals.ts @@ -0,0 +1,12 @@ +export interface CreateCarousalsRequest { + imageUrl:string, + targetType:string, + targetUrl:string, + targetId:string +} +export interface GetCarousalsRequest { + page:string, + size:string, + order?:string +} + diff --git a/src/model/token.ts b/src/model/token.ts index 2624a83..2302162 100644 --- a/src/model/token.ts +++ b/src/model/token.ts @@ -1,4 +1,4 @@ export interface CreateTokenRequest { - email: string + username: string password: string } diff --git a/src/pages/carousal/components/CarousalDialog.vue b/src/pages/carousal/components/CarousalDialog.vue new file mode 100644 index 0000000..8d6e8d1 --- /dev/null +++ b/src/pages/carousal/components/CarousalDialog.vue @@ -0,0 +1,148 @@ + + diff --git a/src/pages/carousal/index.vue b/src/pages/carousal/index.vue new file mode 100644 index 0000000..e3dc60b --- /dev/null +++ b/src/pages/carousal/index.vue @@ -0,0 +1,105 @@ + + + + + diff --git a/src/pages/common/login.vue b/src/pages/common/login.vue index 04e42d2..11145c6 100644 --- a/src/pages/common/login.vue +++ b/src/pages/common/login.vue @@ -8,8 +8,8 @@ import { MessagePlugin } from 'tdesign-vue-next' import { useAppStore } from '@/stores/app' const loginForm = reactive({ - password: '', - email: '' + username: 'admin', + password: 'admin123' }) const canRegister = ref(false) @@ -18,7 +18,7 @@ const loading = ref(false) const appStore = useAppStore() const handleLogin = async () => { - if (!loginForm.email || !loginForm.password) { + if (!loginForm.username || !loginForm.password) { MessagePlugin.error('用户名或密码不能为空') return } @@ -40,7 +40,7 @@ const handleLogin = async () => { 买有账号?注册新账号
- + diff --git a/src/router/index.ts b/src/router/index.ts index ddbf593..595be79 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -14,6 +14,15 @@ export const asyncRoutes: RouteRecordRaw[] = [ icon: 'system-3' } }, + { + name: 'carousal', + path: 'carousal', + component: () => import('@/pages/carousal/index.vue'), + meta: { + title: '轮播图管理', + icon: 'system-3' + } + }, ] const router = createRouter({ @@ -36,13 +45,13 @@ const router = createRouter({ ] }) -router.beforeEach((to, from, next) => { - if (to.name !== 'login') { - const appStore = useAppStore() - appStore.isLogin ? next() : next({ name: 'login' }) - return - } - next() -}) +// router.beforeEach((to, from, next) => { +// if (to.name !== 'login') { +// const appStore = useAppStore() +// appStore.isLogin ? next() : next({ name: 'login' }) +// return +// } +// next() +// }) export default router -- 2.34.1 From 9e94573046d9a7ab75fa62c9f0e81d06ab832a63 Mon Sep 17 00:00:00 2001 From: zlong <953829746@qq.com> Date: Wed, 20 Nov 2024 11:36:52 +0800 Subject: [PATCH 02/10] =?UTF-8?q?fix:=E6=96=B0=E5=A2=9E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD,=E5=9B=9E=E9=80=80?= =?UTF-8?q?=E5=88=B0main=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 11 ------- src/auto-import.d.ts | 71 ++++++++++++++++++++++++++++++++++++++++++++ vite.config.ts | 4 +++ 3 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 src/auto-import.d.ts diff --git a/components.d.ts b/components.d.ts index cf28278..6e59df9 100644 --- a/components.d.ts +++ b/components.d.ts @@ -8,20 +8,14 @@ export {} declare module 'vue' { export interface GlobalComponents { Copyright: typeof import('./src/components/Copyright.vue')['default'] - Dialog: typeof import('./src/components/Dialog.vue')['default'] RegularPage: typeof import('./src/components/RegularPage.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] TAside: typeof import('tdesign-vue-next')['Aside'] TAvatar: typeof import('tdesign-vue-next')['Avatar'] TButton: typeof import('tdesign-vue-next')['Button'] - TCard: typeof import('tdesign-vue-next')['Card'] TCheckbox: typeof import('tdesign-vue-next')['Checkbox'] - TCol: typeof import('tdesign-vue-next')['Col'] - TDialog: typeof import('tdesign-vue-next')['Dialog'] TDropdown: typeof import('tdesign-vue-next')['Dropdown'] - TForm: typeof import('tdesign-vue-next')['Form'] - TFormItem: typeof import('tdesign-vue-next')['FormItem'] THeader: typeof import('tdesign-vue-next')['Header'] TIcon: typeof import('tdesign-vue-next')['Icon'] TInput: typeof import('tdesign-vue-next')['Input'] @@ -29,11 +23,6 @@ declare module 'vue' { TLink: typeof import('tdesign-vue-next')['Link'] TMenu: typeof import('tdesign-vue-next')['Menu'] TMenuItem: typeof import('tdesign-vue-next')['MenuItem'] - TPagination: typeof import('tdesign-vue-next')['Pagination'] - TRow: typeof import('tdesign-vue-next')['Row'] - TSelect: typeof import('tdesign-vue-next')['Select'] TSpace: typeof import('tdesign-vue-next')['Space'] - TTable: typeof import('tdesign-vue-next')['Table'] - TTag: typeof import('tdesign-vue-next')['Tag'] } } diff --git a/src/auto-import.d.ts b/src/auto-import.d.ts new file mode 100644 index 0000000..5371070 --- /dev/null +++ b/src/auto-import.d.ts @@ -0,0 +1,71 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// noinspection JSUnusedGlobalSymbols +// Generated by unplugin-auto-import +// biome-ignore lint: disable +export {} +declare global { + const EffectScope: typeof import('vue')['EffectScope'] + const computed: typeof import('vue')['computed'] + const createApp: typeof import('vue')['createApp'] + const customRef: typeof import('vue')['customRef'] + const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] + const defineComponent: typeof import('vue')['defineComponent'] + const effectScope: typeof import('vue')['effectScope'] + const getCurrentInstance: typeof import('vue')['getCurrentInstance'] + const getCurrentScope: typeof import('vue')['getCurrentScope'] + const h: typeof import('vue')['h'] + const inject: typeof import('vue')['inject'] + const isProxy: typeof import('vue')['isProxy'] + const isReactive: typeof import('vue')['isReactive'] + const isReadonly: typeof import('vue')['isReadonly'] + const isRef: typeof import('vue')['isRef'] + const markRaw: typeof import('vue')['markRaw'] + const nextTick: typeof import('vue')['nextTick'] + const onActivated: typeof import('vue')['onActivated'] + const onBeforeMount: typeof import('vue')['onBeforeMount'] + const onBeforeUnmount: typeof import('vue')['onBeforeUnmount'] + const onBeforeUpdate: typeof import('vue')['onBeforeUpdate'] + const onDeactivated: typeof import('vue')['onDeactivated'] + const onErrorCaptured: typeof import('vue')['onErrorCaptured'] + const onMounted: typeof import('vue')['onMounted'] + const onRenderTracked: typeof import('vue')['onRenderTracked'] + const onRenderTriggered: typeof import('vue')['onRenderTriggered'] + const onScopeDispose: typeof import('vue')['onScopeDispose'] + const onServerPrefetch: typeof import('vue')['onServerPrefetch'] + const onUnmounted: typeof import('vue')['onUnmounted'] + const onUpdated: typeof import('vue')['onUpdated'] + const onWatcherCleanup: typeof import('vue')['onWatcherCleanup'] + const provide: typeof import('vue')['provide'] + const reactive: typeof import('vue')['reactive'] + const readonly: typeof import('vue')['readonly'] + const ref: typeof import('vue')['ref'] + const resolveComponent: typeof import('vue')['resolveComponent'] + const shallowReactive: typeof import('vue')['shallowReactive'] + const shallowReadonly: typeof import('vue')['shallowReadonly'] + const shallowRef: typeof import('vue')['shallowRef'] + const toRaw: typeof import('vue')['toRaw'] + const toRef: typeof import('vue')['toRef'] + const toRefs: typeof import('vue')['toRefs'] + const toValue: typeof import('vue')['toValue'] + const triggerRef: typeof import('vue')['triggerRef'] + const unref: typeof import('vue')['unref'] + const useAttrs: typeof import('vue')['useAttrs'] + const useCssModule: typeof import('vue')['useCssModule'] + const useCssVars: typeof import('vue')['useCssVars'] + const useId: typeof import('vue')['useId'] + const useModel: typeof import('vue')['useModel'] + const useSlots: typeof import('vue')['useSlots'] + const useTemplateRef: typeof import('vue')['useTemplateRef'] + const watch: typeof import('vue')['watch'] + const watchEffect: typeof import('vue')['watchEffect'] + const watchPostEffect: typeof import('vue')['watchPostEffect'] + const watchSyncEffect: typeof import('vue')['watchSyncEffect'] +} +// for type re-export +declare global { + // @ts-ignore + export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue' + import('vue') +} diff --git a/vite.config.ts b/vite.config.ts index c3ed3e9..158c544 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -14,6 +14,10 @@ export default defineConfig(({ command, mode }) => { return { plugins: [ vue(), + AutoImport({ + imports:['vue'], + dts:"src/auto-import.d.ts" // 会自动生成此文件 + }), vueDevTools(), AutoImport({ resolvers: [ -- 2.34.1 From 00dd25320295e849822b0b8c1e5c3c4c9d7d781c Mon Sep 17 00:00:00 2001 From: zlong <953829746@qq.com> Date: Wed, 20 Nov 2024 22:47:33 +0800 Subject: [PATCH 03/10] add --- components.d.ts | 1 + src/components/ImageUpload.vue | 39 ++++++++++++++++++++++++++++++++++ src/model/carousals.ts | 6 +++--- src/pages/carousal/index.vue | 22 +++++++++++++------ 4 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 src/components/ImageUpload.vue diff --git a/components.d.ts b/components.d.ts index bbec505..9050c68 100644 --- a/components.d.ts +++ b/components.d.ts @@ -8,6 +8,7 @@ export {} declare module 'vue' { export interface GlobalComponents { Copyright: typeof import('./src/components/Copyright.vue')['default'] + ImageUpload: typeof import('./src/components/ImageUpload.vue')['default'] RegularPage: typeof import('./src/components/RegularPage.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] diff --git a/src/components/ImageUpload.vue b/src/components/ImageUpload.vue new file mode 100644 index 0000000..ae5c980 --- /dev/null +++ b/src/components/ImageUpload.vue @@ -0,0 +1,39 @@ + + + + + \ No newline at end of file diff --git a/src/model/carousals.ts b/src/model/carousals.ts index 1c132ea..f5b4da9 100644 --- a/src/model/carousals.ts +++ b/src/model/carousals.ts @@ -5,8 +5,8 @@ export interface CreateCarousalsRequest { targetId:string } export interface GetCarousalsRequest { - page:string, - size:string, - order?:string + page:number, + size:number, + order?:[string] } diff --git a/src/pages/carousal/index.vue b/src/pages/carousal/index.vue index e3dc60b..807e376 100644 --- a/src/pages/carousal/index.vue +++ b/src/pages/carousal/index.vue @@ -4,7 +4,7 @@ import { onMounted, ref, reactive } from 'vue' import type { BaseTableColumns } from 'tdesign-vue-next' import type { Classify } from '@/model/classify' import ClassifyDialog from '@/pages/carousal/components/CarousalDialog.vue' -import { createCarousal } from '@/api/carousal' +import { getCarousalList } from '@/api/carousal' const columns: BaseTableColumns = [ { @@ -19,7 +19,7 @@ const columns: BaseTableColumns = [ }, { title: '显示状态', - colKey: 'targetType', + colKey: 'status', width: 100 }, { @@ -32,15 +32,23 @@ const loading = ref(false) const data = ref([]) const pagination = reactive({ page: 1, - size: 10 + size: 10, + total:0 +}) +const query = reactive({ + page:1, + size:10, }) const classifyDialogVisible = ref(false) const isEdit = ref(false) -const currentTableData = ref({}) -const fetchClassifyTableData = () => { +const currentTableData = ref<{}>({}) +const fetchClassifyTableData = async () => { /* TODO: 获取轮播图表格数据 */ - const createCarousalApi = createCarousal(pagination) - console.log(createCarousalApi,'api') + query.page = pagination.page + query.size = pagination.size + const getCarousalListApi = await getCarousalList(query) + currentTableData.value = getCarousalListApi.data + pagination.total = getCarousalListApi.pagination.total } onMounted(fetchClassifyTableData) const editClick = (classify: Classify) => { -- 2.34.1 From 6120d0b8fa44a2995926b0b00ac875ab6e3c405d Mon Sep 17 00:00:00 2001 From: zlong <953829746@qq.com> Date: Thu, 21 Nov 2024 00:22:51 +0800 Subject: [PATCH 04/10] =?UTF-8?q?add:=E6=96=B0=E5=A2=9E=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=AF=B9=E6=8E=A5=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 5 +- src/api/carousal.ts | 3 +- src/components/ImageUpload.vue | 34 ++- src/model/carousals.ts | 4 +- .../carousal/components/CarousalDialog.vue | 215 ++++++++++-------- src/pages/carousal/index.vue | 2 +- src/router/index.ts | 16 +- 7 files changed, 166 insertions(+), 113 deletions(-) diff --git a/components.d.ts b/components.d.ts index 9050c68..4b333bc 100644 --- a/components.d.ts +++ b/components.d.ts @@ -16,7 +16,6 @@ declare module 'vue' { TAvatar: typeof import('tdesign-vue-next')['Avatar'] TButton: typeof import('tdesign-vue-next')['Button'] TCard: typeof import('tdesign-vue-next')['Card'] - TCheckbox: typeof import('tdesign-vue-next')['Checkbox'] TDialog: typeof import('tdesign-vue-next')['Dialog'] TDropdown: typeof import('tdesign-vue-next')['Dropdown'] TForm: typeof import('tdesign-vue-next')['Form'] @@ -25,11 +24,13 @@ declare module 'vue' { TIcon: typeof import('tdesign-vue-next')['Icon'] TInput: typeof import('tdesign-vue-next')['Input'] TLayout: typeof import('tdesign-vue-next')['Layout'] - TLink: typeof import('tdesign-vue-next')['Link'] TMenu: typeof import('tdesign-vue-next')['Menu'] TMenuItem: typeof import('tdesign-vue-next')['MenuItem'] + TRadioButton: typeof import('tdesign-vue-next')['RadioButton'] + TRadioGroup: typeof import('tdesign-vue-next')['RadioGroup'] TSpace: typeof import('tdesign-vue-next')['Space'] TTable: typeof import('tdesign-vue-next')['Table'] TTag: typeof import('tdesign-vue-next')['Tag'] + TUpload: typeof import('tdesign-vue-next')['Upload'] } } diff --git a/src/api/carousal.ts b/src/api/carousal.ts index 09f3ca6..84aa263 100644 --- a/src/api/carousal.ts +++ b/src/api/carousal.ts @@ -1,8 +1,7 @@ import httpClient from './httpClient' import type { CreateCarousalsRequest, GetCarousalsRequest } from '@/model/carousals' -import type { UnwrapNestedRefs } from 'vue' -export const createCarousal = (createCarousalsRequest: UnwrapNestedRefs<{ size: number; page: number }> & {}) => { +export const createCarousal = (createCarousalsRequest: CreateCarousalsRequest) => { return httpClient.post('/carousals', createCarousalsRequest) } diff --git a/src/components/ImageUpload.vue b/src/components/ImageUpload.vue index ae5c980..5522c8b 100644 --- a/src/components/ImageUpload.vue +++ b/src/components/ImageUpload.vue @@ -1,7 +1,33 @@