mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-17 16:56:38 +08:00
auto jump to mobile page when use mobile device access the page
This commit is contained in:
parent
4861dd75be
commit
471017657f
@ -12,7 +12,7 @@ import {isChrome, isMobile} from "@/utils/libs";
|
|||||||
import {showMessageInfo} from "@/utils/dialog";
|
import {showMessageInfo} from "@/utils/dialog";
|
||||||
import {useSharedStore} from "@/store/sharedata";
|
import {useSharedStore} from "@/store/sharedata";
|
||||||
import {getUserToken} from "@/store/session";
|
import {getUserToken} from "@/store/session";
|
||||||
import {clear} from "core-js/internals/task";
|
import {router} from "@/router";
|
||||||
|
|
||||||
const debounce = (fn, delay) => {
|
const debounce = (fn, delay) => {
|
||||||
let timer
|
let timer
|
||||||
@ -51,6 +51,11 @@ onMounted(() => {
|
|||||||
store.setIsLogin(true)
|
store.setIsLogin(true)
|
||||||
connect()
|
connect()
|
||||||
}).catch(()=>{})
|
}).catch(()=>{})
|
||||||
|
|
||||||
|
// 自动跳转到手机端
|
||||||
|
if (isMobile() && !router.currentRoute.value.path.startsWith("/mobile")) {
|
||||||
|
router.push("/mobile/index")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(() => store.isLogin, (val) => {
|
watch(() => store.isLogin, (val) => {
|
||||||
|
@ -249,6 +249,18 @@ const routes = [
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'mobile-login',
|
||||||
|
path: '/mobile/login',
|
||||||
|
meta: {title: '用户登录'},
|
||||||
|
component: () => import('@/views/Login.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'mobile-register',
|
||||||
|
path: '/mobile/register',
|
||||||
|
meta: {title: '用户注册'},
|
||||||
|
component: () => import('@/views/Register.vue'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'mobile',
|
name: 'mobile',
|
||||||
path: '/mobile',
|
path: '/mobile',
|
||||||
|
@ -218,7 +218,7 @@ export function showLoginDialog(router) {
|
|||||||
message:
|
message:
|
||||||
'此操作需要登录才能进行,前往登录?',
|
'此操作需要登录才能进行,前往登录?',
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
router.push("/login")
|
router.push("/mobile/login")
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// on cancel
|
// on cancel
|
||||||
});
|
});
|
||||||
|
@ -219,7 +219,6 @@ import ChatReply from "@/components/ChatReply.vue";
|
|||||||
import {Delete, Edit, InfoFilled, More, Plus, Promotion, Search, Share, VideoPause} from '@element-plus/icons-vue'
|
import {Delete, Edit, InfoFilled, More, Plus, Promotion, Search, Share, VideoPause} from '@element-plus/icons-vue'
|
||||||
import 'highlight.js/styles/a11y-dark.css'
|
import 'highlight.js/styles/a11y-dark.css'
|
||||||
import {
|
import {
|
||||||
isMobile,
|
|
||||||
randString,
|
randString,
|
||||||
removeArrayItem,
|
removeArrayItem,
|
||||||
UUID
|
UUID
|
||||||
@ -294,10 +293,6 @@ if (!chatId.value) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMobile()) {
|
|
||||||
router.replace("/mobile/chat")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取系统配置
|
// 获取系统配置
|
||||||
getSystemInfo().then(res => {
|
getSystemInfo().then(res => {
|
||||||
title.value = res.data.title
|
title.value = res.data.title
|
||||||
|
@ -61,15 +61,10 @@ import {useRouter} from "vue-router";
|
|||||||
import FooterBar from "@/components/FooterBar.vue";
|
import FooterBar from "@/components/FooterBar.vue";
|
||||||
import {httpGet} from "@/utils/http";
|
import {httpGet} from "@/utils/http";
|
||||||
import {ElMessage} from "element-plus";
|
import {ElMessage} from "element-plus";
|
||||||
import {isMobile} from "@/utils/libs";
|
|
||||||
import {checkSession, getLicenseInfo, getSystemInfo} from "@/store/cache";
|
import {checkSession, getLicenseInfo, getSystemInfo} from "@/store/cache";
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
if (isMobile()) {
|
|
||||||
router.push("/mobile")
|
|
||||||
}
|
|
||||||
|
|
||||||
const title = ref("")
|
const title = ref("")
|
||||||
const logo = ref("")
|
const logo = ref("")
|
||||||
const slogan = ref("")
|
const slogan = ref("")
|
||||||
|
@ -183,7 +183,7 @@ import {ElMessage} from "element-plus";
|
|||||||
import {useRouter} from "vue-router";
|
import {useRouter} from "vue-router";
|
||||||
import FooterBar from "@/components/FooterBar.vue";
|
import FooterBar from "@/components/FooterBar.vue";
|
||||||
import SendMsg from "@/components/SendMsg.vue";
|
import SendMsg from "@/components/SendMsg.vue";
|
||||||
import {arrayContains} from "@/utils/libs";
|
import {arrayContains, isMobile} from "@/utils/libs";
|
||||||
import {setUserToken} from "@/store/session";
|
import {setUserToken} from "@/store/session";
|
||||||
import {validateEmail, validateMobile} from "@/utils/validate";
|
import {validateEmail, validateMobile} from "@/utils/validate";
|
||||||
import {showMessageError, showMessageOK} from "@/utils/dialog";
|
import {showMessageError, showMessageOK} from "@/utils/dialog";
|
||||||
@ -294,11 +294,12 @@ const doSubmitRegister = (verifyData) => {
|
|||||||
data.value.reg_way = activeName.value
|
data.value.reg_way = activeName.value
|
||||||
httpPost('/api/user/register', data.value).then((res) => {
|
httpPost('/api/user/register', data.value).then((res) => {
|
||||||
setUserToken(res.data.token)
|
setUserToken(res.data.token)
|
||||||
showMessageOK({
|
showMessageOK("注册成功,即将跳转到对话主界面...")
|
||||||
"message": "注册成功,即将跳转到对话主界面...",
|
if (isMobile()) {
|
||||||
onClose: () => router.push("/chat"),
|
router.push('/mobile/index')
|
||||||
duration: 1000
|
} else {
|
||||||
})
|
router.push('/chat')
|
||||||
|
}
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
showMessageError('注册失败,' + e.message)
|
showMessageError('注册失败,' + e.message)
|
||||||
})
|
})
|
||||||
|
@ -182,7 +182,7 @@ const onLoad = () => {
|
|||||||
error.value = true
|
error.value = true
|
||||||
showFailToast("加载会话列表失败")
|
showFailToast("加载会话列表失败")
|
||||||
})
|
})
|
||||||
})
|
}).catch(() => {})
|
||||||
};
|
};
|
||||||
|
|
||||||
const search = () => {
|
const search = () => {
|
||||||
|
@ -18,15 +18,8 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {ref, watch} from "vue";
|
import {ref, watch} from "vue";
|
||||||
import {useRouter} from "vue-router";
|
|
||||||
import {isMobile} from "@/utils/libs";
|
|
||||||
import {useSharedStore} from "@/store/sharedata";
|
import {useSharedStore} from "@/store/sharedata";
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
if (!isMobile()) {
|
|
||||||
router.replace('/')
|
|
||||||
}
|
|
||||||
|
|
||||||
const active = ref('home')
|
const active = ref('home')
|
||||||
const store = useSharedStore()
|
const store = useSharedStore()
|
||||||
const theme = ref(store.mobileTheme)
|
const theme = ref(store.mobileTheme)
|
||||||
|
Loading…
Reference in New Issue
Block a user