Refactor API requests and update component imports

This commit is contained in:
wangqiao
2025-08-18 14:28:10 +08:00
parent 07b4d3de99
commit 9ae3abeded
91 changed files with 669 additions and 884 deletions

View File

@ -11,7 +11,7 @@
<script lang="ts" setup>
import KlFooter from './kl-footer/index.vue'
import KlQuickMenu from '@/components/kl-quick-menu/index.vue'
import KlQuickMenu from '~/components/kl-quick-menu/index.vue'
</script>
<style lang="scss" scoped>

View File

@ -4,7 +4,7 @@
<div class="mb-[40px] flex flex-col items-start justify-between gap-[30px] lg:flex-row">
<!-- 左侧 Logo -->
<div class="mx-auto w-[200px] shrink-0 lg:mx0">
<img src="@/assets/images/logo5.png" class="h-auto w-full" />
<img src="~/assets/images/logo5.png" class="h-auto w-full" />
</div>
<!-- 中间部分 -->
@ -52,8 +52,8 @@
<script setup lang="ts">
import { reactive, ref } from 'vue'
import { getSettingPage } from '@/api/home/index'
import { PageResultIndexSettingRespVO } from '@/api/home/type'
import { getSettingPage } from '~/api/home/index'
import type { PageResultIndexSettingRespVO } from '~/api/home/type'
// 导航数据
// const columns = [
@ -70,11 +70,11 @@
// 二维码数据(需要替换真实图片路径)
// const qrcodes = [
// {
// img: new URL('@/assets/images/logo2.png', import.meta.url).href,
// img: new URL('~/assets/images/logo2.png', import.meta.url).href,
// text: '抖音电商关注官方号',
// },
// {
// img: new URL('@/assets/images/logo2.png', import.meta.url).href,
// img: new URL('~/assets/images/logo2.png', import.meta.url).href,
// text: '微信扫码关注官方助手',
// },
// ]
@ -122,7 +122,7 @@
if (item.content && (item.innerType === 3 || item.innerType === 2)) {
window.open(item.content, '_blank')
} else if (item.content && (item.innerType === 4 || item.innerType === 0)) {
window.open(`/editor-view?content=${encodeURIComponent(item.content)}`, '_blank')
navigateTo(`/editor-view?content=${encodeURIComponent(item.content)}`)
} else if (item.innerType === 1 && item.content) {
showViewer.value = true
previewImgList.value = [item.content]

View File

@ -3,11 +3,11 @@
<div class="flex items-center">
<div class="flex items-center">
<div class="box-border h-100% h-55px w-221px flex items-center rounded-lg bg-[#1A65FF] pl-24px text-white">
<img src="@/assets/images/1.png" alt="" srcset="" />
<img src="~/assets/images/1.png" alt="" srcset="" />
<span class="ml-12px text-16px">全部资源分类</span>
</div>
<div class="item-center ml-45px w-660px flex justify-between">
<router-link
<nuxt-link
v-for="(item, index) in menuItems"
:key="index"
target="_blank"
@ -15,13 +15,13 @@
class="parent-links relative rounded-lg px3 py2 text-[#1A65FF]"
>
{{ item.name }}
<img v-if="item.path === '/communication/channel'" src="@/assets/images/hot.png" alt="火" class="absolute right--15px top--2px" />
</router-link>
<img v-if="item.path === '/communication/channel'" src="~/assets/images/hot.png" alt="火" class="absolute right--15px top--2px" />
</nuxt-link>
</div>
</div>
<div v-if="isLogin" class="flex flex-1 items-center justify-end">
<div class="h-36px w-36px cursor-pointer border-rd-[50%] bg-[#F5F5F5] text-center line-height-44px" @click="handleUserCenter">
<img src="@/assets/images/user.png" alt="" srcset="" class="h-19px w-17px" />
<img src="~/assets/images/user.png" alt="" srcset="" class="h-19px w-17px" />
</div>
<div class="ml-8px h-36px w-36px cursor-pointer border-rd-[50%] text-center line-height-44px" @click="handleMessageCenter">
<el-icon size="20px" color="#999999"><BellFilled /></el-icon>
@ -31,12 +31,10 @@
</div>
</template>
<script setup lang="ts">
import useUserStore from '@/store/user'
import useUserStore from '~/store/user'
const userStore = useUserStore()
import { BellFilled } from '@element-plus/icons-vue'
import { ref, computed } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const menuItems = ref([
{ name: '首页', path: '/index' },
{ name: '图纸', path: '/drawe' },
@ -55,12 +53,12 @@
// 用户中心
const handleUserCenter = () => {
router.push('/personal/center/info')
navigateTo('/personal/center/info')
}
// 消息中心
const handleMessageCenter = () => {
router.push('/personal/center/message')
navigateTo('/personal/center/message')
}
</script>
<style scoped>

View File

@ -1,66 +0,0 @@
<template>
<div class="kl-menu">
<el-scrollbar height="100%">
<el-menu class="el-menu-vertical" :default-active="activeRouteComputed" router>
<KlMenuItem
v-for="menu in childRoutes"
:key="menu?.component?.toString()"
:title="menu?.meta?.title + ''"
:children="menu.children"
:index="menu.path"
/>
</el-menu>
</el-scrollbar>
</div>
</template>
<script lang="ts" setup>
import KlMenuItem from './kl-menu-item.vue'
import { RouteRecordRaw, useRoute } from 'vue-router'
import { computed } from 'vue'
const modulesFiles = import.meta.globEager('@/router/modules/*.ts')
const childRoutes: RouteRecordRaw[] = []
Object.keys(modulesFiles).forEach((path: string) => {
const module = modulesFiles[path] as any
if (module?.default) {
childRoutes.push(...module.default)
}
}, {})
const route = useRoute()
const activeRouteComputed = computed(() => {
return route.path
})
</script>
<style lang="scss" scoped>
.kl-menu {
height: 100%;
::v-deep(.el-scrollbar) {
.el-scrollbar__bar.is-vertical {
display: block !important;
.el-scrollbar__thumb {
width: 0px;
float: right;
}
}
}
}
.el-menu-vertical {
border: none;
.el-sub-menu__title,
.el-menu-item {
font-size: 15px;
}
.el-menu-item.is-active {
background-color: #ebf1ff;
border-right: 4px solid $color-primary;
}
.el-sub-menu {
.el-menu-item {
text-indent: 10px;
}
}
}
</style>

View File

@ -1,58 +0,0 @@
<template>
<el-menu-item v-if="!props.children?.length" :index="props.index">
<template #title>
<span>{{ props.title }}</span>
</template>
</el-menu-item>
<el-sub-menu v-else-if="props.children.length" :index="props.index + props.title">
<template #title>
<span>{{ props.title }}</span>
</template>
<KlMenuItem v-for="menu in props.children" :key="menu.path" :title="menu.meta?.title || ''" :children="menu.children" :index="menu.path"></KlMenuItem>
</el-sub-menu>
</template>
<script lang="ts" setup>
import { PropType } from 'vue'
import { RouteRecordRaw } from 'vue-router'
const props = defineProps({
title: {
type: String as PropType<string>,
default: '',
},
children: {
type: Array as PropType<RouteRecordRaw[]>,
default: () => [],
},
index: {
type: String as PropType<string>,
default: '',
},
})
</script>
<style lang="scss" scoped>
::v-deep(.el-sub-menu) {
.el-menu-item {
display: flex;
span {
text-indent: 6px;
flex: 1;
position: relative;
z-index: 1;
}
&::before {
content: '';
display: inline-block;
width: 4px;
height: 4px;
background-color: #bcbfc5;
border-radius: 10px;
margin-left: -4px;
position: relative;
z-index: 2;
}
}
}
</style>

View File

@ -4,7 +4,7 @@
<div class="mx-a ml--250px h-full flex items-center justify-center">
<!-- Logo区域 -->
<div class="h-100% flex cursor-pointer items-center" @click="router.push('/index')">
<img src="@/assets/images/logo5.png" alt="图夕夕" class="h-51px w-182px" />
<img src="~/assets/images/logo5.png" alt="图夕夕" class="h-51px w-182px" />
</div>
<!-- 搜索区域 -->
<div class="relative ml-49px w-647px px4 p-r-0px!">
@ -61,13 +61,12 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { Search } from '@element-plus/icons-vue'
import useUserStore from '@/store/user'
import router from '@/router'
import useUserStore from '~/store/user'
const userStore = useUserStore()
import { top } from '@/api/home/index'
import type { ProjectDrawStatisticAppRespVO } from '@/api/home/type'
import { page } from '@/api/upnew/index'
import { top } from '~/api/home/index'
import type { ProjectDrawStatisticAppRespVO } from '~/api/home/type'
import { page } from '~/api/upnew/index'
const searchQuery = ref('')
const showHotList = ref(false)
@ -77,7 +76,7 @@
// 是否登录
if (!userStore.token) return ElMessage.error('请先登录')
// 新开窗口 用router跳转 新窗口打开
window.open('/upnew/drawe', '_blank')
navigateTo('/upnew/drawe')
}
const loading = ref(false)
@ -121,11 +120,11 @@
const level = item.pairs?.filter(Boolean).map((item) => ({ id: item?.id, name: item?.name, isChildren: false })) || []
level.unshift(normal)
if (item.type === 1) {
window.open(`/drawe?level=${JSON.stringify(level)}&keywords=${item.title || ''}`, '_blank')
navigateTo(`/drawe?level=${JSON.stringify(level)}&keywords=${item.title || ''}`,)
} else if (item.type === 2) {
window.open(`/text?level=${JSON.stringify(level)}&keywords=${item.title || ''}`, '_blank')
navigateTo(`/text?level=${JSON.stringify(level)}&keywords=${item.title || ''}`,)
} else if (item.type === 3) {
window.open(`/model?level=${JSON.stringify(level)}&keywords=${item.title || ''}`, '_blank')
navigateTo(`/model?level=${JSON.stringify(level)}&keywords=${item.title || ''}`,)
}
}