This commit is contained in:
oneao committed 2025-12-11 17:31:05 +08:00
1 parent 68e0785ec6
commit 57c0d98f11
189 files changed
+34329

No files matched your search

@@ -0,0 +1,29 @@
<script lang="ts" setup>
import { onMounted } from 'vue'
import { getAreaListApi } from './request/api/area'
import { getPropertyListApi } from './request/api/peoperty'
import { useCommonOptions } from './store/commonOptions'
const commonOptions = useCommonOptions()
onMounted(() => {
handleInitData()
})
function handleInitData() {
getAreaListApi().then((res) => {
commonOptions.areaOptions.splice(0, commonOptions.areaOptions.length, ...res.data)
})
getPropertyListApi().then((res) => {
commonOptions.propertyOptions.splice(0, commonOptions.propertyOptions.length, ...res.data)
})
}
</script>
<template>
<RouterView />
</template>
<style lang="scss" scoped>
//
</style>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

After

Width:  |  Height:  |  Size: 496 B

@@ -0,0 +1,133 @@
<script lang="ts" setup>
import type { PropType } from 'vue'
import type { Area, CompanyQuery, Property } from '@/types/company/index'
const props = defineProps({
properties: {
type: Object as PropType<Property[]>,
required: false,
},
areas: {
type: Object as PropType<Area[]>,
required: false,
},
})
const query: CompanyQuery = {
areas: [],
properties: [],
name: '',
}
</script>
<template>
<div class="query">
<div class="query-item">
<el-select
v-model="query.properties"
filterable
placeholder="请选择行业"
multiple
collapse-tags
collapse-tags-tooltip
:max-collapse-tags="2"
>
<el-option
v-for="item in props.properties"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
<div class="query-item">
<el-tree-select
v-model="query.areas"
placeholder="请选择地域"
:data="areas"
filterable
multiple
check-strictly
collapse-tags
collapse-tags-tooltip
:max-collapse-tags="2"
:render-after-expand="false"
/>
</div>
<div class="query-item">
<el-input
v-model="query.name"
placeholder="请输入公司名称"
/>
</div>
<div class="search">
<i-tdesign:search />
</div>
</div>
</template>
<style lang="scss" scoped>
.query {
width: 100%;
display: flex;
align-items: center;
height: 60px;
border-radius: 4px;
border: 0;
color: #000;
.query-item {
flex: 1;
:deep(.el-select__wrapper) {
height: 60px;
border-radius: 0px;
box-shadow: none;
padding-top: 0px;
padding-bottom: 0px;
}
:deep(.el-select__placeholder) {
font-size: 18px;
}
:deep(.el-select__input) {
font-size: 18px;
}
:deep(.el-input__wrapper) {
border-radius: 0px;
box-shadow: none;
padding: 0px;
}
:deep(.el-input__inner) {
height: 60px;
font-size: 18px;
}
&:first-child {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
}
.search {
height: 60px;
width: 60px;
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
background-color: #333;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
color: #fff;
cursor: pointer;
transition: background-color 0.2s ease;
&:hover {
background-color: #555;
}
&:active {
background-color: #111;
}
}
}
</style>
@@ -0,0 +1,172 @@
<script lang="ts" setup>
import { useRoute } from 'vue-router'
const props = defineProps({
isLogined: {
type: Boolean,
default: false,
},
})
const route = useRoute()
const menuList = [
{ name: '首页', path: '/' },
{ name: '企业名录', path: '/companies' },
{ name: '论坛中心', path: '/forum' },
{ name: '关于我们', path: '/companies' },
{ name: '联系我们', path: '/forum' },
]
</script>
<template>
<header class="header">
<nav class="container">
<img src="/logo.png" class="logo">
<div class="menu">
<span
v-for="item in menuList"
:key="item.path"
:class="{ active: route.path.startsWith(item.path) }"
class="menu-item"
>
<span class="menu-item-name">
{{ item.name }}
</span>
</span>
</div>
<div class="action">
<i-tdesign:search class="action-item" />
<i-tdesign:notification v-if="props.isLogined" class="action-item" />
<template v-if="props.isLogined">
<el-divider direction="vertical" />
<el-dropdown>
<div class="user">
<el-avatar :size="32" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png" />
<span class="name">
远通G3
</span>
</div>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item>个人中心</el-dropdown-item>
<el-dropdown-item>退出登录</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template>
<template v-else>
<el-button type="primary" round>
登录
</el-button>
</template>
</div>
</nav>
</header>
</template>
<style lang="scss" scoped>
.header {
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: 99;
background-color: #fff;
.container {
width: 100%;
padding: 0rem 3rem;
display: flex;
justify-content: space-between;
align-items: center;
height: 60px;
box-shadow: 0 5px 16px rgba(0, 0, 0, 0.1);
.logo {
width: 160px;
height: 50px;
}
.menu {
display: flex;
align-items: center;
.menu-item {
display: flex;
align-items: center;
cursor: pointer;
color: #000;
outline: none;
margin-left: 36px;
transition: color 0.3s ease;
position: relative;
&:hover {
color: #0f6fec !important;
}
&:first-child {
margin-left: 0px;
}
&.active {
color: #0f6fec !important;
}
&::after {
content: '';
position: absolute;
bottom: -4px;
left: 50%;
width: 0;
height: 2px;
background-color: #0f6fec;
transition: all 0.3s ease;
transform: translateX(-50%);
}
&:hover::after {
width: 100%;
}
&.active::after {
width: 100%;
}
.menu-item-name {
font-size: 18px;
font-weight: 400;
}
}
}
.action {
display: flex;
align-items: center;
.action-item {
font-size: 20px;
margin-right: 24px;
color: #000;
cursor: pointer;
&:last-child {
margin-right: 0px;
}
}
.user {
margin-left: 24px;
display: flex;
align-items: center;
cursor: pointer;
outline: 0;
.name {
margin-left: 8px;
font-size: 18px;
}
}
}
}
}
</style>
@@ -0,0 +1,35 @@
<script lang="ts" setup>
import Header from './components/header.vue'
</script>
<template>
<div class="app">
<Header />
<div class="content">
<RouterView />
</div>
<footer class="footer">
footer
</footer>
</div>
</template>
<style lang="scss" scoped>
.app {
position: relative;
background-color: #eff2f6;
}
.content {
padding-top: 60px;
height: 1800px;
}
.footer {
height: 100px;
background-color: #ccc;
display: flex;
align-items: center;
justify-content: center;
}
</style>
@@ -0,0 +1,18 @@
import ElementPlus from 'element-plus'
import { createApp } from 'vue'
import App from './App.vue'
import { setupRouter } from './router/index'
import { setupPinia } from './store'
import 'element-plus/dist/index.css'
import '@/styles/css/global.css'
async function setupApp() {
const app = createApp(App)
setupPinia(app)
setupRouter(app)
app.use(ElementPlus)
app.mount('#app')
}
setupApp()
@@ -0,0 +1,6 @@
import type { AreaResult } from '@/types/company/index'
import { httpGet } from '../utils'
export function getAreaListApi() {
return httpGet<AreaResult>(`/webArea/list`)
}
@@ -0,0 +1,6 @@
import type { PropertyResult } from '@/types/company/index'
import { httpGet } from '../utils'
export function getPropertyListApi() {
return httpGet<PropertyResult>(`/webProperty/list`)
}
@@ -0,0 +1,122 @@
import type { AxiosError, AxiosInstance, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
import axios from 'axios'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/store/user'
function buildBaseUrl() {
const isProxy = import.meta.env.VITE_APP_PROXY === 'Y'
const mode = import.meta.env.MODE
const proxyPrefix = import.meta.env.VITE_APP_PROXY_PREFIX
const baseURL = import.meta.env.VITE_SERVER_BASEURL
if (mode === 'prod') {
if (isProxy) {
return baseURL + proxyPrefix
}
else {
return baseURL
}
}
else {
if (isProxy) {
return proxyPrefix
}
else {
return baseURL
}
}
}
const axiosInstance: AxiosInstance = axios.create({
baseURL: buildBaseUrl(),
timeout: 0,
})
const NoFreePaths = [
'/imMessage/**',
'/file/**',
'/company/getPrivateDetail',
]
// 请求拦截器
axiosInstance.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
const router = useRouter()
const userStore = useUserStore()
const path = config.url || ''
const needAuth = matchPaths(path, NoFreePaths)
if (needAuth) {
if (!userStore.isLogined) {
userStore.clearUserInfo()
router.push('/login')
return Promise.reject(new Error('尚未登录,请先登录!'))
}
}
config.headers.Authorization = `Bearer ${userStore.userInfo.token}`
config.headers.id = userStore.userInfo.id
return config
},
(error: AxiosError) => {
return Promise.reject(error)
},
)
axiosInstance.interceptors.response.use(
(response: AxiosResponse) => {
// 判断响应是否为文件下载类型
const isDownload = isDownloadResponse(response.headers)
if (isDownload) {
return response
}
if (response.status !== 200) {
return Promise.reject(new Error('系统异常'))
}
const resData = response.data as ResponseData<any>
response.data.data = parseJsonOrReturnString(response.data.data)
if (resData.code === 200) {
return Promise.resolve(response.data)
}
else {
return Promise.reject(resData)
}
},
(error: AxiosError) => {
console.log(error)
},
)
function matchPaths(path: string, patterns: string[]): boolean {
return patterns.some((pattern) => {
const regex = new RegExp(
`${pattern
.replace(/\/\*\*/g, '(/.*)?')
.replace(/\/\*/g, '(/[^/]*)?')
.replace(/\./g, '\\.')}$`,
)
return regex.test(path)
})
}
function isDownloadResponse(headers: any): boolean {
const contentType = headers['content-type']
return /application\/(?:octet-stream|force-download|pdf|vnd.ms-excel|msexcel|OCTET-STREAM)/.test(contentType || '')
}
function parseJsonOrReturnString(input: any) {
try {
return JSON.parse(input)
}
catch {
return input
}
}
export default axiosInstance
@@ -0,0 +1,21 @@
import axiosInstance from './index'
export function httpGet<T>(url: string, params?: Record<string, any>): Promise<ResponseData<T>> {
return axiosInstance.get(url, { params })
}
export function httpPostJson<T>(url: string, data?: Record<string, any>): Promise<ResponseData<T>> {
return axiosInstance.post(url, data, {
headers: {
'Content-Type': 'application/json',
},
})
}
export function httpPostForm<T>(url: string, data?: any): Promise<ResponseData<T>> {
return axiosInstance.post(url, data, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}
@@ -0,0 +1,25 @@
import type { App } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layout/index.vue'
const router = createRouter({
history: createWebHashHistory(),
strict: true,
routes: [
{
path: '/',
component: Layout,
children: [
{
path: '/',
component: () => import('@/views/home/index.vue'),
},
],
},
],
scrollBehavior: () => ({ left: 0, top: 0 }),
})
export function setupRouter(app: App) {
app.use(router)
}
@@ -0,0 +1,13 @@
import type { Area } from '@/types/company/area'
import type { Property } from '@/types/company/peoperty'
import { reactive } from 'vue'
const areaOptions = reactive<Area[]>([])
const propertyOptions = reactive<Property[]>([])
export function useCommonOptions() {
return {
areaOptions,
propertyOptions,
}
}
@@ -0,0 +1,9 @@
import type { App } from 'vue'
import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-plugin-persistedstate'
export function setupPinia(app: App) {
const store = createPinia()
store.use(createPersistedState())
app.use(store)
}
@@ -0,0 +1,48 @@
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
interface IUserInfo {
id: number
account?: string
email?: string
name?: string
token?: string
avatar?: string
}
export const useUserStore = defineStore(
'user',
() => {
const userInfo = ref<IUserInfo>({
id: 0,
})
const setUserInfo = (val: IUserInfo) => {
userInfo.value = val
}
const clearUserInfo = () => {
}
// ✅ 如果需要同时验证多个字段
const isLogined = computed(() => {
return !!(
(
userInfo.value.token
&& userInfo.value.id !== 0
&& userInfo.value.account
)
)
})
return {
userInfo,
setUserInfo,
clearUserInfo,
isLogined,
}
},
{
persist: true,
},
)
@@ -0,0 +1,27 @@
body::-webkit-scrollbar {
display: none;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 10px;
border: 2px solid #f1f1f1;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
Whitespace-only changes.
@@ -0,0 +1,23 @@
/* eslint-disable */
// @ts-nocheck
// biome-ignore lint: disable
// oxlint-disable
// ------
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}
/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
HelloWorld: typeof import('./../components/HelloWorld.vue')['default']
ICarbonAccessibility: typeof import('~icons/carbon/accessibility')['default']
IMdiAccountBox: typeof import('~icons/mdi/account-box')['default']
'ITdesign:notification': typeof import('~icons/tdesign/notification')['default']
'ITdesign:search': typeof import('~icons/tdesign/search')['default']
QueryCompany: typeof import('./../components/QueryCompany.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}
}
@@ -0,0 +1,19 @@
export interface Area {
label: string
value: number
children?: AreaResult[]
}
export type AreaResult = Area[]
export interface Property {
label: string
value: string
}
export type PropertyResult = Property[]
export interface CompanyQuery {
properties: string[]
areas: string[]
name: string
}
+14
View File
@@ -0,0 +1,14 @@
// src/env.d.ts
declare namespace Env {
interface ImportMeta extends ImportMetaEnv {
readonly VITE_BASE_URL: string
readonly VITE_APP_TITLE: string
readonly VITE_SERVER_BASEURL: string
readonly VITE_UPLOAD_BASEURL: string
readonly VITE_WEBSOCKET_BASEURL: string
readonly VITE_APP_PROXY: string
readonly VITE_APP_PROXY_PREFIX: string
readonly VITE_APP_SERVER_PREFIX: string
}
}
+9
View File
@@ -0,0 +1,9 @@
export {}
declare global {
interface ResponseData<T> {
code: number
message: string
data: T
}
}
@@ -0,0 +1,110 @@
<script lang="ts" setup>
const tableData = [
{
date: '2016-05-03',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
},
{
date: '2016-05-02',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
},
{
date: '2016-05-04',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
},
{
date: '2016-05-01',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles',
},
]
</script>
<template>
<div class="recommend">
<div class="left">
<div class="recommend-title">
企业名录
</div>
<el-table :data="tableData" border stripe style="width: 100%">
<el-table-column prop="date" label="地区" width="180" />
<el-table-column prop="name" label="公司" />
</el-table>
</div>
<div class="right">
<div class="hot-card">
<div class="hot-card-title">
热门推荐
</div>
<div class="hot-card-list">
<div v-for="i in 10" :key="i" class="hot-card-item">
<span class="number">{{ i }}</span>
<span class="name">xxxxxxxxxx公司公司</span>
</div>
</div>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.recommend {
width: 100%;
padding: 0 128px;
margin-top: 24px;
display: flex;
.left {
flex: 1;
}
.right {
width: 20%;
margin-left: 32px;
.hot-card {
width: 100%;
.hot-card-list {
display: flex;
flex-direction: column;
background-color: #fff;
.hot-card-item {
display: flex;
align-items: center;
padding: 8px 12px;
border-bottom: 1px solid #eee;
cursor: pointer;
.number {
font-weight: bold;
color: #666666;
font-size: 22px;
}
.name {
margin-left: 12px;
font-size: 18px;
color: #333;
}
&:last-child {
border-bottom: none;
}
}
}
}
}
.recommend-title,
.hot-card-title {
font-size: 22px;
font-weight: 600;
color: #333;
position: relative;
margin-bottom: 12px;
}
}
</style>
@@ -0,0 +1,98 @@
<script lang="ts" setup>
import QueryCompany from '@/components/QueryCompany.vue'
import { useCommonOptions } from '@/store/commonOptions'
import Recommend from './components/recommend.vue'
const commonOptions = useCommonOptions()
const carouselList = [
{ img: '/ship-8263464_1920.jpg', href: '' },
{ img: '/ship-8263464_1920.jpg', href: '' },
{ img: '/ship-8263464_1920.jpg', href: '' },
]
</script>
<template>
<div class="wrapper">
<!-- 轮播图 -->
<el-carousel class="carousel">
<el-carousel-item v-for="item in carouselList" :key="item.href">
<img :src="item.img">
</el-carousel-item>
</el-carousel>
<!-- 内容浮在轮播图上 -->
<div class="content">
<div class="intro">
<span class="intro-heading">连接优质企业伙伴</span>
</div>
<div class="query">
<QueryCompany :properties="commonOptions.propertyOptions" :areas="commonOptions.areaOptions" />
</div>
</div>
<Recommend />
</div>
</template>
<style lang="scss" scoped>
.wrapper {
width: 100%;
}
/* 轮播图 */
.carousel {
width: 100%;
height: 600px;
position: relative;
:deep(.el-carousel__container) {
height: 100%;
}
:deep(.el-carousel__item) {
cursor: pointer;
}
img {
width: 100%;
height: 100%;
object-fit: cover;
cursor: pointer;
}
}
/* 内容浮在轮播图上 */
.content {
position: absolute;
top: 260px;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 2;
color: #fff;
.intro {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 28px;
.intro-heading {
font-size: 28px;
font-weight: 600;
}
.intro-detail {
font-size: 18px;
margin-top: 8px;
}
}
.query {
width: 1240px;
}
}
</style>