提交 c4e7d5f8 authored 作者: lidongxu's avatar lidongxu

feat(mobile_views): 移动端页面新增一个

同上
上级 c6f338ce
<template>
<div>这里只是针对移动设备开放的页面</div>
</template>
<script setup>
</script>
<style scoped>
</style>
\ No newline at end of file
<template>
<div>
<p>{{ url }}</p>
<button @click="copy">复制 URL</button>
</div>
</template>
<script setup>
import { isMobile } from '@/utils/device'
const url = ref('')
if (isMobile()) {
url.value = window.location.href
}
// 点击复制按钮复制字符串到剪切板
const copy = () => {
const input = document.createElement('input');
input.value = url.value;
document.body.appendChild(input);
input.select();
document.execCommand('Copy');
document.body.removeChild(input);
alert('复制成功');
}
</script>
<style scoped></style>
\ No newline at end of file
import { createWebHashHistory, createRouter } from 'vue-router' import { createWebHashHistory, createRouter } from 'vue-router'
/* Layout */ /* Layout */
import Layout from '@/layout' import Layout from '@/layout'
import { isMobile } from '@/utils/device'
/** /**
* Note: 路由配置项 * Note: 路由配置项
...@@ -81,6 +82,15 @@ export const constantRoutes = [ ...@@ -81,6 +82,15 @@ export const constantRoutes = [
} }
] ]
// 移动端 路由
export const mobileRoutes = [
{
path: '/promotion',
component: () => import('@/mobile_views/promotion/index'),
hidden: true
}
]
// 动态路由,基于用户权限动态去加载 // 动态路由,基于用户权限动态去加载
export const dynamicRoutes = [ export const dynamicRoutes = [
{ {
...@@ -155,6 +165,11 @@ export const dynamicRoutes = [ ...@@ -155,6 +165,11 @@ export const dynamicRoutes = [
} }
] ]
// 判断移动端添加路由
if (isMobile()) {
constantRoutes.push(...mobileRoutes)
}
const router = createRouter({ const router = createRouter({
history: createWebHashHistory(), history: createWebHashHistory(),
routes: constantRoutes, routes: constantRoutes,
......
export const isMobile = () => {
const userAgent = navigator.userAgent;
const mobileKeywords = ['Android', 'iPhone', 'iPad', 'iPod', 'Mobile'];
for (let i = 0; i < mobileKeywords.length; i++) {
if (userAgent.indexOf(mobileKeywords[i]) !== -1) {
return true;
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论