组件按需加载
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -51,7 +51,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
|
import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { ElLoading } from 'element-plus'
|
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -84,11 +83,11 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
loading = ElLoading.service({
|
// loading = ElLoading.service({
|
||||||
lock: true,
|
// lock: true,
|
||||||
text: 'Loading',
|
// text: 'Loading',
|
||||||
background: 'rgba(0, 0, 0, 0.7)',
|
// background: 'rgba(0, 0, 0, 0.7)',
|
||||||
})
|
// })
|
||||||
|
|
||||||
// if (identityList.value > 0) return
|
// if (identityList.value > 0) return
|
||||||
proxy.$post("/tenement/pc/api/publish/checkidentity").then(res => {
|
proxy.$post("/tenement/pc/api/publish/checkidentity").then(res => {
|
||||||
@@ -99,7 +98,7 @@ async function init() {
|
|||||||
isintermediary.value = data.isintermediary
|
isintermediary.value = data.isintermediary
|
||||||
if (data['ispopup'] == 0) overallJump()
|
if (data['ispopup'] == 0) overallJump()
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
loading.close()
|
// loading.close()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +123,7 @@ let choiceItem = (key) => {
|
|||||||
|
|
||||||
let overallJump = () => {
|
let overallJump = () => {
|
||||||
choicePopState.value = false
|
choicePopState.value = false
|
||||||
console.log("11",identityKey.value);
|
console.log("11", identityKey.value);
|
||||||
router.push(`/edit?intermediary=${identityKey.value}`)
|
router.push(`/edit?intermediary=${identityKey.value}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<header class="container-header flexflex">
|
<header class="container-header flexflex">
|
||||||
<nav class="header-nav flexacenter">
|
<nav class="header-nav flexacenter">
|
||||||
<div class="header-nav-item" :class="{ pitch: index == 3 }" v-for="(item, index) in navList" :key="index">{{ item }}</div>
|
<a class="header-nav-item" :class="{ pitch: item['key'] == 'fang' }" v-for="(item, index) in nav" :key="index"
|
||||||
|
:href="item.url" target="_blank">{{ item.name }}</a>
|
||||||
<img class="header-nav-item header-user-img" :src="user.avatar">
|
<img class="header-nav-item header-user-img" :src="user.avatar">
|
||||||
</nav>
|
</nav>
|
||||||
<div class="logo-box flexacenter">
|
<div class="logo-box flexacenter">
|
||||||
@@ -10,13 +11,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="header-bj-box"></div>
|
<div class="header-bj-box"></div>
|
||||||
|
|
||||||
|
|
||||||
<nav class="nav-box flexflex" v-if="!isNoTabList">
|
<nav class="nav-box flexflex" v-if="!isNoTabList">
|
||||||
<div class="nav-list wid1200 flexflex">
|
<div class="nav-list wid1200 flexflex">
|
||||||
<!-- <<<<<<< HEAD
|
|
||||||
<div class="nav-item flexcenter" :class="{ pitch: item['name'] == '我的' }" v-for="item in tabList"
|
|
||||||
:key="item">{{ item.name }}</div>
|
|
||||||
======= -->
|
|
||||||
<div class="tab-btn dis-f al-item jus-x" :class="{ 'tab-btn-click': i === 0 }" v-for="(item, i) in tabList"
|
<div class="tab-btn dis-f al-item jus-x" :class="{ 'tab-btn-click': i === 0 }" v-for="(item, i) in tabList"
|
||||||
:key="i">
|
:key="i">
|
||||||
<el-badge :value="12">
|
<el-badge :value="12">
|
||||||
@@ -26,24 +22,27 @@
|
|||||||
</el-badge>
|
</el-badge>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- >>>>>>> origin/main -->
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { useStore } from 'vuex'
|
||||||
|
import { toRefs } from 'vue';
|
||||||
// 是否不需要导航栏
|
// 是否不需要导航栏
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
isNoTabList: {
|
isNoTabList: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
user: Object,
|
// user: Object,
|
||||||
});
|
});
|
||||||
|
|
||||||
const navList = ["寄托首页", "论坛", "Offer榜", "港校租房", "院校库", "兑换店", "搜索", "招生官", "中外合办院校"]
|
const store = useStore();
|
||||||
|
const { user, nav } = toRefs(store.state);
|
||||||
|
|
||||||
|
// const navList = ["寄托首页", "论坛", "Offer榜", "港校租房", "院校库", "兑换店", "搜索", "招生官", "中外合办院校"]
|
||||||
|
|
||||||
const tabList = [{
|
const tabList = [{
|
||||||
name: '首页',
|
name: '首页',
|
||||||
|
|||||||
68
src/main.js
68
src/main.js
@@ -2,25 +2,67 @@ import { createApp } from 'vue'
|
|||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
import store from './store'
|
import store from './store'
|
||||||
import ElementPlus from 'element-plus'
|
// import ElementPlus from 'element-plus'
|
||||||
|
// import { ElButton, ElInput } from 'element-plus'
|
||||||
|
|
||||||
|
import {
|
||||||
|
ElButton,
|
||||||
|
ElInput,
|
||||||
|
ElSelect,
|
||||||
|
ElOption,
|
||||||
|
ElLoading,
|
||||||
|
ElCheckbox,
|
||||||
|
ElCheckboxGroup,
|
||||||
|
ElCarousel,
|
||||||
|
ElCarouselItem,
|
||||||
|
ElBadge,
|
||||||
|
ElDropdown,
|
||||||
|
ElPopover,
|
||||||
|
// 其他需要的组件
|
||||||
|
} from 'element-plus'
|
||||||
|
|
||||||
|
import 'element-plus/theme-chalk/index.css'
|
||||||
import 'element-plus/dist/index.css'
|
import 'element-plus/dist/index.css'
|
||||||
import 'element-plus/lib/locale/lang/zh-cn'
|
import 'element-plus/lib/locale/lang/zh-cn'
|
||||||
|
import 'element-plus/theme-chalk/index.css'
|
||||||
|
|
||||||
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
||||||
import api from "./utils/api";
|
import api from "./utils/api";
|
||||||
|
|
||||||
//引入封装Axios请求
|
//引入封装Axios请求
|
||||||
import Axios from '@/utils/axios';
|
import Axios from '@/utils/axios';
|
||||||
|
|
||||||
const app = createApp(App)
|
|
||||||
api.index().then(res => {
|
api.index().then(res => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
store.state.seachTypeData = res.data.combination
|
store.state.seachTypeData = res.data.combination
|
||||||
store.state.indexData = res.data
|
store.state.indexData = res.data
|
||||||
store.state.ListSelectBtn = res.data.recommendedTab
|
store.state.ListSelectBtn = res.data.recommendedTab
|
||||||
console.log(store.state.seachTypeData)
|
store.state.user = res.data.user
|
||||||
}
|
store.state.nav = res.data.nav
|
||||||
})
|
console.log(store.state.seachTypeData)
|
||||||
app.use(store).use(router).use(Axios).use(ElementPlus, {
|
}
|
||||||
locale: zhCn
|
})
|
||||||
}).mount('#app')
|
|
||||||
|
|
||||||
|
const app = createApp(App)
|
||||||
|
|
||||||
|
app.use(ElButton)
|
||||||
|
app.use(ElInput)
|
||||||
|
app.use(ElSelect)
|
||||||
|
app.use(ElOption)
|
||||||
|
app.use(ElLoading)
|
||||||
|
app.use(ElCheckbox)
|
||||||
|
app.use(ElCheckboxGroup)
|
||||||
|
app.use(ElCarousel)
|
||||||
|
app.use(ElCarouselItem)
|
||||||
|
app.use(ElBadge)
|
||||||
|
app.use(ElDropdown)
|
||||||
|
app.use(ElPopover)
|
||||||
|
|
||||||
|
|
||||||
|
app.use(store).use(router).use(Axios).mount('#app')
|
||||||
|
// app.use(store).use(router).use(Axios).use(ElementPlus, {
|
||||||
|
// locale: zhCn
|
||||||
|
// }).mount('#app')
|
||||||
|
|
||||||
|
|||||||
@@ -51,14 +51,10 @@ const router = createRouter({
|
|||||||
|
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
console.log(to);
|
|
||||||
next()
|
next()
|
||||||
|
|
||||||
let meta = to['meta'] || {}
|
let meta = to['meta'] || {}
|
||||||
let title = meta['title']
|
let title = meta['title']
|
||||||
console.log("title", title);
|
|
||||||
if (title) setSeoTitle(title)
|
if (title) setSeoTitle(title)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ export default createStore({
|
|||||||
seachTypeData:[],
|
seachTypeData:[],
|
||||||
indexData:[],
|
indexData:[],
|
||||||
ListSelectBtn:[],
|
ListSelectBtn:[],
|
||||||
|
user:{},
|
||||||
|
nav:[],
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import QS from 'qs';
|
import QS from 'qs';
|
||||||
import router from '../router/index'
|
import { goTologin } from '@/utils/util.js'
|
||||||
import { redirectToExternalWebsite } from '@/utils/util.js'
|
|
||||||
//qs.stringify()是将对象 序列化成URL的形式,以&进行拼接
|
//qs.stringify()是将对象 序列化成URL的形式,以&进行拼接
|
||||||
// let protocol = window.location.protocol; //协议
|
// let protocol = window.location.protocol; //协议
|
||||||
// let host = window.location.host; //主机
|
// let host = window.location.host; //主机
|
||||||
// axios.defaults.baseURL = protocol + "//" + host;
|
// axios.defaults.baseURL = protocol + "//" + host;
|
||||||
axios.defaults.baseURL = 'https://app.gter.net'
|
axios.defaults.baseURL = 'https://app.gter.net'
|
||||||
// axios.defaults.baseURL = '/index'
|
// axios.defaults.baseURL = '/index'
|
||||||
// axios.defaults.emulateJSON = true
|
axios.defaults.emulateJSON = true
|
||||||
// axios.defaults.withCredentials = true
|
axios.defaults.withCredentials = true
|
||||||
|
|
||||||
axios.interceptors.request.use( //响应拦截
|
axios.interceptors.request.use( //响应拦截
|
||||||
async config => {
|
async config => {
|
||||||
@@ -39,13 +38,13 @@ axios.interceptors.response.use(
|
|||||||
switch (error.response.status) {
|
switch (error.response.status) {
|
||||||
// 401: 未登录
|
// 401: 未登录
|
||||||
case 401:
|
case 401:
|
||||||
|
console.log("401");
|
||||||
|
goTologin()
|
||||||
|
console.log("401");
|
||||||
|
|
||||||
break
|
break
|
||||||
// 403 token过期
|
|
||||||
// 清除本地token和清空vuex中token对象
|
|
||||||
// 跳转登录页面
|
|
||||||
case 403:
|
case 403:
|
||||||
// router.push('/login')
|
// router.push('/login')
|
||||||
redirectToExternalWebsite()
|
|
||||||
break
|
break
|
||||||
// 404请求不存在
|
// 404请求不存在
|
||||||
case 404:
|
case 404:
|
||||||
@@ -90,8 +89,8 @@ const $post = (url, params) => {
|
|||||||
}
|
}
|
||||||
//下面是vue3必须加的,vue2不需要,只需要暴露出去get,post方法就可以
|
//下面是vue3必须加的,vue2不需要,只需要暴露出去get,post方法就可以
|
||||||
export default {
|
export default {
|
||||||
get:$get,
|
get: $get,
|
||||||
post:$post,
|
post: $post,
|
||||||
install: (app) => {
|
install: (app) => {
|
||||||
app.config.globalProperties['$get'] = $get;
|
app.config.globalProperties['$get'] = $get;
|
||||||
app.config.globalProperties['$post'] = $post;
|
app.config.globalProperties['$post'] = $post;
|
||||||
|
|||||||
@@ -3,13 +3,21 @@ function setSeoTitle(title) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function redirectToExternalWebsite(url) {
|
function redirectToExternalWebsite(url) {
|
||||||
|
console.log(url, "url");
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.target = '_blank';
|
// link.target = '_blank';
|
||||||
link.click();
|
link.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 跳转登录
|
||||||
|
function goTologin() {
|
||||||
|
let url = encodeURIComponent(location.href);
|
||||||
|
redirectToExternalWebsite(`https://passport.gter.net/?referer=${url}`);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
setSeoTitle,
|
setSeoTitle,
|
||||||
redirectToExternalWebsite,
|
redirectToExternalWebsite,
|
||||||
|
goTologin,
|
||||||
}
|
}
|
||||||
@@ -673,23 +673,6 @@ import { setSeoTitle } from '@/utils/util.js'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ZufangEdit',
|
name: 'ZufangEdit',
|
||||||
metaInfo() {
|
|
||||||
return {
|
|
||||||
title: 'My Page Title',
|
|
||||||
meta: [
|
|
||||||
{
|
|
||||||
name: 'description',
|
|
||||||
content: 'This is a description of my page'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
link: [
|
|
||||||
{
|
|
||||||
rel: 'canonical',
|
|
||||||
href: 'https://example.com/my-page'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
value: '',
|
value: '',
|
||||||
@@ -773,36 +756,6 @@ export default {
|
|||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
// 判断类型的类名
|
|
||||||
judgeClassNameType() {
|
|
||||||
return function (item) {
|
|
||||||
let isPitch = ''
|
|
||||||
let typeData = this.typeData
|
|
||||||
let type = this.info.type
|
|
||||||
for (const key in typeData) {
|
|
||||||
typeData[key]['data'].forEach(element => {
|
|
||||||
if (element['key'] == type) isPitch = 'pitch'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return isPitch
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// // 判断 求房源的 同住人性别要求应不应该显示
|
|
||||||
// judgeGenderCohabitantsShow() {
|
|
||||||
// /
|
|
||||||
// / return function (field) {
|
|
||||||
// console.log("info", this, this.info);
|
|
||||||
// // let type = this.info['type']
|
|
||||||
// // let intermediary = this.intermediary
|
|
||||||
// // if (intermediary != 6 || field != 'gender') return true
|
|
||||||
// // if (type >>> 0 == 1 && field == 'gender') return true
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
// 访问URL中的查询参数
|
// 访问URL中的查询参数
|
||||||
const queryString = window.location.search;
|
const queryString = window.location.search;
|
||||||
@@ -824,9 +777,6 @@ export default {
|
|||||||
userBox,
|
userBox,
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateMap(evtModel) {
|
|
||||||
console.log("evtModel", evtModel);
|
|
||||||
},
|
|
||||||
|
|
||||||
require(url) {
|
require(url) {
|
||||||
return require(url)
|
return require(url)
|
||||||
@@ -970,7 +920,7 @@ export default {
|
|||||||
setSeoTitle(title)
|
setSeoTitle(title)
|
||||||
|
|
||||||
console.log();
|
console.log();
|
||||||
}).finally(() => {
|
}).catch(err => { }).finally(err => {
|
||||||
this.loading.close()
|
this.loading.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const { defineConfig } = require('@vue/cli-service')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
module.exports = defineConfig({
|
module.exports = defineConfig({
|
||||||
|
productionSourceMap: false,
|
||||||
// publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
|
// publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
|
||||||
publicPath: '/',
|
publicPath: '/',
|
||||||
configureWebpack: {
|
configureWebpack: {
|
||||||
@@ -50,7 +51,9 @@ module.exports = defineConfig({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user