| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import { App } from '@capacitor/app'
- import { Capacitor } from '@capacitor/core'
- import { Device } from '@capacitor/device'
- let initialized = false
- let loading = false
- async function init() {
- // eruda.init({
- // useShadowDom: false,
- // defaults: {
- // theme: 'Material Oceanic'
- // }
- // })
- // eruda.add(erudaCode)
- // eruda.add(erudaFeatures)
- // eruda.add(erudaFps)
- // eruda.add(erudaTiming)
- // eruda.add(erudaMemory)
- if (loading || initialized) return
- loading = true
- import('eruda')
- .then(res => {
- loading = false
- let eruda = res.default
- eruda.init({
- useShadowDom: true,
- defaults: {
- theme: 'Material Oceanic',
- displaySize: '90'
- }
- })
- initialized = true
- import('eruda-code').then(res => {
- eruda.add(res.default)
- })
- // import('eruda-features').then(res => {
- // eruda.add(res.default)
- // })
- // import('eruda-fps').then(res => {
- // eruda.add(res.default)
- // })
- // import('eruda-timing').then(res => {
- // eruda.add(res.default)
- // })
- // import('eruda-memory').then(res => {
- // eruda.add(res.default)
- // })
- eruda.remove('sources')
- let snippets = eruda.get('snippets')
- let info = eruda.get('info')
- info.remove('Backers')
- info.remove('About')
- if (Capacitor.isNativePlatform()) {
- App.getInfo().then(appInfo => {
- info.add(
- 'AppInfo',
- `<table><tbody>
- <tr><td class="eruda-device-key">name</td><td>${appInfo.name}</td></tr>
- <tr><td>id</td><td>${appInfo.id}</td></tr>
- <tr><td>build</td><td>${appInfo.build}</td></tr>
- <tr><td>version</td><td>${appInfo.version}</td></tr>
- </tbody></table>`
- )
- })
- Device.getInfo().then(deviceInfo => {
- info.add(
- 'DeviceInfo',
- `<table><tbody>
- <tr><td class="eruda-device-key">name</td><td>${deviceInfo.name}</td></tr>
- <tr><td>model</td><td>${deviceInfo.model}</td></tr>
- <tr><td>platform</td><td>${deviceInfo.platform}</td></tr>
- <tr><td>operatingSystem</td><td>${deviceInfo.operatingSystem}</td></tr>
- <tr><td>osVersion</td><td>${deviceInfo.operatingSystem}</td></tr>
- <tr><td>manufacturer</td><td>${deviceInfo.manufacturer}</td></tr>
- <tr><td>isVirtual</td><td>${deviceInfo.isVirtual}</td></tr>
- <tr><td>memUsed</td><td>${deviceInfo.memUsed}</td></tr>
- <tr><td>diskFree</td><td>${deviceInfo.diskFree}</td></tr>
- <tr><td>diskTotal</td><td>${deviceInfo.diskTotal}</td></tr>
- <tr><td>realDiskFree</td><td>${deviceInfo.realDiskFree}</td></tr>
- <tr><td>realDiskTotal</td><td>${deviceInfo.realDiskTotal}</td></tr>
- <tr><td>webViewVersion</td><td>${deviceInfo.webViewVersion}</td></tr>
- </tbody></table>`
- )
- })
- }
- })
- .catch(e => {
- loading = false
- console.log(e)
- })
- }
- export { init }
|