1、在plugins目录下新建terminalToggle.js,写入以下代码
(function () {
let sUserAgent = navigator.userAgent.toLowerCase();
let isIpad = sUserAgent.match(/ipad/i) == "ipad";
let isIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
let isMidp = sUserAgent.match(/midp/i) == "midp";
let isUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
let isUc = sUserAgent.match(/ucweb/i) == "ucweb";
let isAndroid = sUserAgent.match(/android/i) == "android";
let isCE = sUserAgent.match(/windows ce/i) == "windows ce";
let isWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
let isMobile =isIpad || isIphoneOs || isMidp || isUc7 || isUc || isAndroid || isCE || isWM;
if (isMobile) {
let PC_URL = process.env.VUE_APP_WEBSITE_PC_URL;
let H5_URL = process.env.VUE_APP_WEBSITE_H5_URL;
if (PC_URL && H5_URL) {
let nowUrl = window.location.href;
if (nowUrl.includes(PC_URL)) {
window.location.href = nowUrl.replace(PC_URL, H5_URL);
}
}
}
if (!isMobile) {
let PC_URL = process.env.VUE_APP_WEBSITE_PC_URL;
let H5_URL = process.env.VUE_APP_WEBSITE_H5_URL;
if (PC_URL && H5_URL) {
let nowUrl = window.location.href;
if (nowUrl.includes(H5_URL)) {
window.location.href = nowUrl.replace(H5_URL, PC_URL);
}
}
}
})();
2、在nuxt.config.js的plugins配置项里引入

【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步