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