Files
workspace/code/link56/link56-frontend/src/App.vue
T
2026-04-24 17:28:11 +08:00

69 lines
1.6 KiB
Vue

<script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { onBeforeUnmount, onMounted } from 'vue'
import { useCommonStore } from '@/store/common'
import { listAreasApi, listIndustriesApi } from './request/api/company'
import { listPostTagApi } from './request/api/post'
import { useWebSocket } from './store/websocket'
const websocket = useWebSocket()
const commonOptions = useCommonStore()
onMounted(() => {
websocket.connect()
handleInitData()
})
onBeforeUnmount(() => {
websocket.logout()
websocket.close()
})
async function handleInitData(): Promise<void> {
try {
const [areaRes, industryRes, postTagRes] = await Promise.all([
listAreasApi(),
listIndustriesApi(),
listPostTagApi(),
])
// 处理区域数据
if (areaRes.isSuccess) {
commonOptions.setAreaOptions(areaRes.data)
}
else {
ElMessage.error(areaRes.message || '初始化失败,请刷新页面后重试')
}
// 处理行业数据
if (industryRes.isSuccess) {
commonOptions.setIndustryOptions(industryRes.data)
}
else {
ElMessage.error(industryRes.message || '初始化失败,请刷新页面后重试')
}
// 处理岗位标签数据
if (postTagRes.isSuccess) {
commonOptions.setPostTagOptions(postTagRes.data)
}
else {
ElMessage.error(postTagRes.message || '初始化失败,请刷新页面后重试')
}
}
catch (err) {
console.error(err)
ElMessage.error('初始化失败,请刷新页面后重试')
}
}
</script>
<template>
<RouterView />
</template>
<style lang="scss" scoped>
//
</style>