// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@nuxtjs/device'],
// 기본 device 설정
device: {
refreshOnResize: true, // 창 크기 변경시 디바이스 감지 새로고침
defaultUserAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36', // 기본 User Agent
detectOnInitialize: true // 초기화시 디바이스 감지
}
})
플러그인 생성
plugins 폴더에 device.ts 파일을 생성합니다.
export default defineNuxtPlugin((nuxtApp) => {
const device = useDevice()
// 디바이스 정보를 전역 상태로 관리하고 싶을 때
const deviceStore = useState('device', () => ({
isMobile: device.isMobile,
isTablet: device.isTablet,
isDesktop: device.isDesktop,
userAgent: device.userAgent
}))
return {
provide: {
deviceInfo: deviceStore
}
}
})
사용 방법
device 정보를 가져올 Vue 소스에서 deviceInfo를 선언합니다.
const { $deviceInfo } = useNuxtApp();
$deviceInfo.isMobile 을 사용하여 mobile 여부를 체크할 수 있습니다.
Nestjs에서 e2e 테스트 수행에는 성공했지만 다음과 같은 메시지가 나오면서 테스트가 종료되지 않는 문제가 발생했습니다.
Jest did not exit one second after the test run has completed.
'This usually means that there are asynchronous operations
that weren't stopped in your tests.
Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
오류 메시지에 친절하게도 --detectOpenHandles를 사용하라고 나옵니다.
이 옵션을 추가해서 실행해 보았습니다.
에러 메시지는 사라졌지만 여전히 커서가 깜빡이면서 종료가 되지 않습니다.
이때 추가적으로 --forceExit 옵션을 사용하면 테스트 완료 후 정상적으로 종료가 됩니다.
xcode-select: note: Command line tools are already installed.
Use "Software Update" in System Settings or the softwareupdate
command line interface to install updates
이때는 software update를 download 하여 설치하면 해결 할 수 있습니다.
software update는 운영 체제와 관련된 모든 소프트웨어 업데이트를 자동으로 설치하는 기능을 수행합니다.
따라서 다운로드 및 설치 시간이 좀 많이 소요됩니다.
softwareupdate --install -a
다운로드가 완료되면 "시스템 설정"에 업데이트가 표시되고, 업데이트를 클릭 하시면됩니다.
업데이트가 완료되면 다시 CocoaPods를 설치합니다.
sudo gem install cocoapods
설치가 완료되면 다음과 같이 메시지가 표시됩니다.
Text Editor Settings
Text editor는 Visual Studio Code, Android Studio, IntelliJ IDEA등을 사용할 수 있습니다.