mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-24 08:07:23 +08:00
🦄 refactor: 适配 web移动端 改造
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
import { computed } from 'vue';
|
||||
|
||||
import store from '@/store';
|
||||
|
||||
// 设置歌手背景图片
|
||||
export const setBackgroundImg = (url: String) => {
|
||||
return `background-image:url(${url})`;
|
||||
@@ -59,3 +63,15 @@ export const getImgUrl = computed(() => (url: string | undefined, size: string =
|
||||
const imgUrl = encodeURIComponent(`${url}?param=${size}`);
|
||||
return `${bdUrl}${imgUrl}`;
|
||||
});
|
||||
|
||||
export const isMobile = computed(() => {
|
||||
const flag = navigator.userAgent.match(
|
||||
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i,
|
||||
);
|
||||
|
||||
store.state.isMobile = !!flag;
|
||||
|
||||
// 给html标签 添加mobile
|
||||
if (flag) document.documentElement.classList.add('mobile');
|
||||
return !!flag;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user