diff --git a/package.json b/package.json index 86991a7a..5cfeb38e 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "conventional-changelog-cli": "^2.1.1", "cross-env": "^7.0.2", "dayjs": "^1.9.4", - "electron": "^10.1.3", + "electron": "^10.1.5", "electron-devtools-installer": "^3.1.0", "electron-icon-builder": "^1.0.2", "eslint": "^6.7.2", @@ -89,7 +89,7 @@ "typescript": "^4.0.3", "url-loader": "^4.1.1", "v-easy-components": "2.0.0-beta.12", - "vue-cli-plugin-electron-builder": "~2.0.0-rc.4" + "vue-cli-plugin-electron-builder": "^2.0.0-rc.5" }, "gitHooks": { "pre-commit": "lint-staged" diff --git a/src/app/app.tsx b/src/app/app.tsx index 7c32683c..664160a8 100644 --- a/src/app/app.tsx +++ b/src/app/app.tsx @@ -1,4 +1,4 @@ -import { defineComponent } from 'vue' +import { defineComponent, toRefs } from 'vue' import { ErrorBoundary } from '@/components/error-boundary/index' import { Container } from '@/layout/container' import { FullScreen } from '@/components/full-screen' @@ -11,10 +11,10 @@ import './app.less' export default defineComponent({ name: 'APP', setup() { - const { meta } = useRoute() + const { meta } = toRefs(useRoute()) return () => ( - {meta.full ? : } + {meta.value.full ? : } ) } diff --git a/src/background.ts b/src/background.ts index a3229ba6..285cee8d 100644 --- a/src/background.ts +++ b/src/background.ts @@ -20,6 +20,7 @@ function createWindow() { win = new BrowserWindow({ width: width / 1.5, height: height / 1.5, + useContentSize: true, frame: false, titleBarStyle: 'hidden', show: false, @@ -54,6 +55,10 @@ function createWindow() { win = null }) + win.on('unresponsive', (e: any) => { + console.log(e) + }) + eventInit(win) } diff --git a/src/components/process-bar/index.tsx b/src/components/process-bar/index.tsx index 042199fb..391db939 100644 --- a/src/components/process-bar/index.tsx +++ b/src/components/process-bar/index.tsx @@ -67,9 +67,11 @@ export const ProgressBar = defineComponent({ const setIndicatorX = (x: number, w: number) => { const width = toFixed((x / w) * 100, 6) - const format = width > 100 ? 100 : width < 0 ? 0 : width - if (onCurrent?.value) { - onCurrent.value(format) + if (width) { + const format = width > 100 ? 100 : width < 0 ? 0 : width + if (onCurrent?.value) { + onCurrent.value(format) + } } } diff --git a/src/electron/event/action-types.ts b/src/electron/event/action-types.ts index 7239efba..10ef7a3a 100644 --- a/src/electron/event/action-types.ts +++ b/src/electron/event/action-types.ts @@ -5,3 +5,8 @@ export const enum Action { CLOSE_WINDOW = 'CLOSE_WINDOW', CREATE_WINDOW = 'CREATE_WINDOW' } + +export const enum Lyrice { + LYRICE_UPDATE = 'LYRICE_UPDATE', + LYRICE_UPDATE_RENDER = 'LYRICE_UPDATE_RENDER' +} diff --git a/src/electron/event/ipc-browser.ts b/src/electron/event/ipc-browser.ts new file mode 100644 index 00000000..605e4ef5 --- /dev/null +++ b/src/electron/event/ipc-browser.ts @@ -0,0 +1,10 @@ +import { IpcRenderer } from '@/electron/event/ipc-renderer' + +export const importIpc = () => { + return import('@/electron/event/ipc-renderer').then((v: IpcRenderer) => { + return { + sendAsyncIpcRendererEvent: v.sendAsyncIpcRendererEvent, + sendSyncIpcRendererEvent: v.sendSyncIpcRendererEvent + } + }) +} diff --git a/src/electron/event/ipc-main/index.ts b/src/electron/event/ipc-main/index.ts index 8fb6466c..83df22ad 100644 --- a/src/electron/event/ipc-main/index.ts +++ b/src/electron/event/ipc-main/index.ts @@ -1,5 +1,5 @@ -import { ipcMain, IpcMainEvent, BrowserWindow } from 'electron' -import { Action } from '../action-types' +import { ipcMain, IpcMainEvent, BrowserWindow, screen } from 'electron' +import { Action, Lyrice } from '../action-types' export const onIpcMainEvent = (win: BrowserWindow) => { let bounds = win.getBounds() @@ -17,4 +17,33 @@ export const onIpcMainEvent = (win: BrowserWindow) => { ipcMain.on(Action.CLOSE_WINDOW, (event: IpcMainEvent, arg) => { win.close() }) + ipcMain.on(Action.CREATE_WINDOW, (event: IpcMainEvent, arg) => { + const { width, height } = screen.getPrimaryDisplay().workAreaSize + const syrice = new BrowserWindow({ + width: 724, + height: 100, + x: width / 2 - 724 / 2, + y: height - 100 * 2, + show: false, + // frame: false, + titleBarStyle: 'hidden', + webPreferences: { + nodeIntegration: true + } + }) + if (process.env.WEBPACK_DEV_SERVER_URL) { + console.log(process.env.WEBPACK_DEV_SERVER_URL) + syrice.loadURL( + process.env.WEBPACK_DEV_SERVER_URL + 'electron-lyrice-flash' + ) + } + syrice.once('ready-to-show', () => { + syrice && syrice.show() + }) + }) + // ipcMain.on(Lyrice.LYRICE_UPDATE, (event: IpcMainEvent, arg) => { + // console.log('主窗口接受到数据') + // console.log('主窗口发送数据到子窗口') + // event.reply(Lyrice.LYRICE_UPDATE_RENDER, arg) + // }) } diff --git a/src/electron/event/ipc-renderer/index.ts b/src/electron/event/ipc-renderer/index.ts index bca9891c..b6bc6c29 100644 --- a/src/electron/event/ipc-renderer/index.ts +++ b/src/electron/event/ipc-renderer/index.ts @@ -6,19 +6,28 @@ and then process some things that the main process can handle (for example, chan */ import { ipcRenderer } from 'electron' -import { Action } from '../action-types' +import { Action, Lyrice } from '../action-types' -type Message = string | string[] +type Message = any -export function sendAsyncIpcRendererEvent(action: Action, message?: Message) { +export function sendAsyncIpcRendererEvent( + action: Action | Lyrice, + message?: Message +) { ipcRenderer.send(action, message) } -export function sendSyncIpcRendererEvent(action: Action, message?: Message) { - ipcRenderer.send(action, message) +export function sendSyncIpcRendererEvent( + action: Action | Lyrice, + message?: Message +) { + return ipcRenderer.sendSync(action, message) } export interface IpcRenderer { - sendAsyncIpcRendererEvent: (action: Action, message?: Message) => void - sendSyncIpcRendererEvent: (action: Action, message?: Message) => void + sendAsyncIpcRendererEvent: ( + action: Action | Lyrice, + message?: Message + ) => void + sendSyncIpcRendererEvent: (action: Action | Lyrice, message?: Message) => T } diff --git a/src/pages/footer/component/lyrice-flash/browser-lyrice.tsx b/src/pages/footer/component/lyrice-flash/browser-lyrice.tsx new file mode 100644 index 00000000..0c80b68c --- /dev/null +++ b/src/pages/footer/component/lyrice-flash/browser-lyrice.tsx @@ -0,0 +1,100 @@ +import { defineComponent, computed, toRefs, watch, watchEffect } from 'vue' +import { uesModuleStore } from '@/hooks/index' +import { toFixed } from '@/utils/index' +import { ENV } from '@/interface/app' +import { + NAMESPACED as LayoutNamespace, + State as LayoutState, + Size +} from '@/layout/module' +import { NAMESPACED, State, Getter, Mutations } from '../../module' +import { Platform } from '@/config/build' +import LyriceFlash from './index' +import './index.less' + +const { VUE_APP_PLATFORM } = window as ENV + +export const BrowserLyriceFlash = defineComponent({ + name: 'BrowserLyriceFlash', + setup() { + const { useState, useGetter, useMutations } = uesModuleStore( + NAMESPACED + ) + const LayoutModule = uesModuleStore(LayoutNamespace) + + const { currentTime, playing, visibleFlash, musicUrl } = toRefs(useState()) + const { screenSize } = toRefs(LayoutModule.useState()) + + if (VUE_APP_PLATFORM === Platform.ELECTRON) { + useMutations(Mutations.VISIBLE_FLASH, true) + } + + const lyrice = computed(() => + useGetter('musicLyrics').filter(value => value.lyric) + ) + + watch(screenSize, v => { + if (musicUrl.value) { + useMutations(Mutations.VISIBLE_FLASH, v === Size.SM) + } + }) + + const index = computed(() => { + if (visibleFlash.value) { + const len = lyrice.value.length + return ( + lyrice.value.findIndex((value, index) => { + return currentTime.value >= value.time && len - 1 === index + ? true + : currentTime.value < lyrice.value[index + 1]?.time + }) || 0 + ) + } + return 0 + }) + + const flashMagic = computed(() => { + if (visibleFlash.value) { + const cur = lyrice.value[index.value] + // const schedule = cur.duration - (currentTime.value - cur.time) + const d = toFixed(cur?.duration, 2) + if (d) { + return { + animationDuration: `${d}s` + } + } else { + return { + animationDuration: '' + } + } + } + return { + animationDuration: '' + } + }) + + watchEffect(() => { + useMutations(Mutations.UPDATE_ELECTRON_LYRICE, { + flashMagic: flashMagic.value, + index: index.value, + playing: playing.value, + lyrice: lyrice.value + }) + }) + + return () => ( + <> + {VUE_APP_PLATFORM === Platform.BROWSER && ( + + )} + + ) + } +}) diff --git a/src/pages/footer/component/lyrice-flash/electron-lyrice.tsx b/src/pages/footer/component/lyrice-flash/electron-lyrice.tsx new file mode 100644 index 00000000..83e36eee --- /dev/null +++ b/src/pages/footer/component/lyrice-flash/electron-lyrice.tsx @@ -0,0 +1,49 @@ +import { defineComponent, reactive } from 'vue' +import LyriceFlash from './index' +import { Size } from '@/layout/module' +import { Lyrics } from '@/pages/footer/module' +import { ipcRenderer } from 'electron' +import { Lyrice } from '@/electron/event/action-types' + +export interface PostData { + screenSize: Size + visibleFlash: boolean + lyrice: Lyrics[] + index: number + playing: boolean + flashMagic: { + animationDuration: string + } +} + +export default defineComponent({ + name: 'Lyrice', + setup() { + const postData: PostData = reactive({ + screenSize: Size.SM, + visibleFlash: true, + lyrice: [], + index: 0, + playing: true, + flashMagic: { + animationDuration: '' + } + }) + + ipcRenderer.on(Lyrice.LYRICE_UPDATE_RENDER, (event, any) => { + console.log('子窗口接受到主窗口的数据') + console.log(any) + }) + + return () => ( + + ) + } +}) diff --git a/src/pages/footer/component/lyrice-flash/index.less b/src/pages/footer/component/lyrice-flash/index.less index 4f763395..717eb33a 100644 --- a/src/pages/footer/component/lyrice-flash/index.less +++ b/src/pages/footer/component/lyrice-flash/index.less @@ -5,6 +5,8 @@ overflow: hidden; transform: matrix(1, 0, 0, 1, 0, 0); user-select: none; + -webkit-user-select: none; + -webkit-app-region: drag; > div { position: absolute; left: 100%; @@ -47,4 +49,10 @@ width: 784px; font-size: 56px; } + &-electron { + left: 0; + top: 0; + width: 100%; + height: 100%; + } } diff --git a/src/pages/footer/component/lyrice-flash/index.tsx b/src/pages/footer/component/lyrice-flash/index.tsx index 9cdcef63..744cd821 100644 --- a/src/pages/footer/component/lyrice-flash/index.tsx +++ b/src/pages/footer/component/lyrice-flash/index.tsx @@ -1,82 +1,81 @@ -import { defineComponent, computed, toRefs, ref, onMounted, watch } from 'vue' -import { uesModuleStore, useDrag } from '@/hooks/index' -import { toFixed } from '@/utils/index' +import { defineComponent, toRefs, ref, onMounted, PropType } from 'vue' +import { useDrag } from '@/hooks/index' import { TeleportToAny } from '@/components/teleport-layout/index' -import { - NAMESPACED as LayoutNamespace, - State as LayoutState, - Size -} from '@/layout/module' +import { ENV } from '@/interface/app' +import { Size } from '@/layout/module' +import { Getter } from '@/pages/footer/module' import classnames from 'classnames' -import { NAMESPACED, State, Getter, Mutations } from '../../module' import './index.less' +import { Platform } from '@/config/build' + +const { VUE_APP_PLATFORM } = window as ENV export const LyriceFlash = defineComponent({ name: 'LyriceFlash', - setup() { + props: { + screenSize: { + type: String as PropType, + required: true + }, + visibleFlash: { + type: Boolean as PropType, + required: true + }, + lyrice: { + type: Array as PropType, + required: true + }, + index: { + type: Number as PropType, + required: true + }, + playing: { + type: Boolean as PropType, + required: true + }, + flashMagic: { + type: Object as PropType<{ + animationDuration: string + }>, + required: true + } + }, + setup(props) { const lyriceEl = ref() - const { useState, useGetter, useMutations } = uesModuleStore( - NAMESPACED - ) - const LayoutModule = uesModuleStore(LayoutNamespace) - - const { currentTime, playing, visibleFlash, musicUrl } = toRefs(useState()) - const { screenSize } = toRefs(LayoutModule.useState()) - - const lyrice = computed(() => - useGetter('musicLyrics').filter(value => value.lyric) - ) - - watch(screenSize, v => { - if (musicUrl.value) { - useMutations(Mutations.VISIBLE_FLASH, v === Size.SM) - } - }) - - const index = computed(() => { - if (visibleFlash.value) { - const len = lyrice.value.length - return ( - lyrice.value.findIndex((value, index) => { - return currentTime.value >= value.time && len - 1 === index - ? true - : currentTime.value < lyrice.value[index + 1]?.time - }) || 0 - ) - } - return 0 - }) - - const flashMagic = computed(() => { - if (visibleFlash.value) { - const cur = lyrice.value[index.value] - // const schedule = cur.duration - (currentTime.value - cur.time) - return { - animationDuration: `${toFixed(cur.duration, 2)}s` - } - } - }) + const { + screenSize, + visibleFlash, + lyrice, + index, + playing, + flashMagic + } = toRefs(props) onMounted(() => { - const { start } = useDrag( - lyriceEl.value as HTMLElement, - lyriceEl.value as HTMLElement, - { - moveCB(x, y) { - requestAnimationFrame(() => { - lyriceEl.value.style.transform = `matrix(1, 0, 0, 1, ${x}, ${y}) translateZ(0)` - }) + if (VUE_APP_PLATFORM === Platform.BROWSER) { + const { start } = useDrag( + lyriceEl.value as HTMLElement, + lyriceEl.value as HTMLElement, + { + moveCB(x, y) { + requestAnimationFrame(() => { + lyriceEl.value.style.transform = `matrix(1, 0, 0, 1, ${x}, ${y}) translateZ(0)` + }) + } } - } - ) - start() + ) + start() + } }) return () => (
@@ -99,3 +98,5 @@ export const LyriceFlash = defineComponent({ ) } }) + +export default LyriceFlash diff --git a/src/pages/footer/component/music-controller/index.tsx b/src/pages/footer/component/music-controller/index.tsx index 6ef64e98..501dced2 100644 --- a/src/pages/footer/component/music-controller/index.tsx +++ b/src/pages/footer/component/music-controller/index.tsx @@ -1,11 +1,4 @@ -import { - defineComponent, - ref, - toRefs, - onMounted, - watchEffect, - computed -} from 'vue' +import { defineComponent, ref, toRefs, onMounted, computed } from 'vue' import { uesModuleStore } from '@/hooks/index' import { toFixed, formatTime } from '@/utils/index' import { Block } from '@/components/process-bar/block' @@ -17,8 +10,13 @@ import { Size } from '@/layout/module' import './index.less' +import { Platform } from '@/config/build' +import { importIpc } from '@/electron/event/ipc-browser' +import { Action } from '@/electron/event/action-types' +import { ENV } from '@/interface/app' const prefix = 'music' +const { VUE_APP_PLATFORM } = window as ENV export const MusicControl = defineComponent({ name: 'MusicControl', @@ -65,8 +63,19 @@ export const MusicControl = defineComponent({ } const handleVisibleFlash = () => { - if (screenSize.value === Size.SM) { - useMutations(Mutations.VISIBLE_FLASH, !visibleFlash.value) + if (VUE_APP_PLATFORM === Platform.BROWSER) { + if (screenSize.value === Size.SM) { + useMutations(Mutations.VISIBLE_FLASH, !visibleFlash.value) + } + } + if (VUE_APP_PLATFORM === Platform.ELECTRON) { + importIpc() + .then(event => { + event.sendSyncIpcRendererEvent(Action.CREATE_WINDOW) + }) + .catch(e => { + console.log(e) + }) } } @@ -93,7 +102,9 @@ export const MusicControl = defineComponent({ if (audioElement.value && musicDetail.dt && !draging.value) { const time = audioElement.value.currentTime const width = toFixed((time / musicDetail.dt) * 100 * 1000, 6) - currentIndicator.value = width > 100 ? 100 : width + if (width) { + currentIndicator.value = width > 100 ? 100 : width + } useMutations(Mutations.UPDATE_CURRENT_TIME, time) } } diff --git a/src/pages/footer/component/volume-history/index.tsx b/src/pages/footer/component/volume-history/index.tsx index e8cd8fa9..0de2f71a 100644 --- a/src/pages/footer/component/volume-history/index.tsx +++ b/src/pages/footer/component/volume-history/index.tsx @@ -28,7 +28,9 @@ export const VolumeAndHistory = defineComponent({ const updateCurrent = (v: number) => { current.value = v const volume = toFixed(v / 100, 2) - useMutations(Mutations.SET_VOLUME, volume < 0 ? 0 : volume) + if (volume) { + useMutations(Mutations.SET_VOLUME, volume < 0 ? 0 : volume) + } } return () => ( diff --git a/src/pages/footer/sage.ts b/src/pages/footer/sage.ts index 409b5d23..8ae8d124 100644 --- a/src/pages/footer/sage.ts +++ b/src/pages/footer/sage.ts @@ -3,6 +3,9 @@ import { isNumber, timeTos, toFixed } from '@/utils/index' import { getSongUrl, getSongDetail, getLyric } from './api/index' import { State, Getter } from './state' import { RootState } from '@/store/index' +import { PostData } from './component/lyrice-flash/electron-lyrice' +import { importIpc } from '@/electron/event/ipc-browser' +import { Lyrice } from '@/electron/event/action-types' export const enum Actions { SET_MUSIC = 'SET_MUSIC_URL', @@ -18,7 +21,8 @@ export const enum Mutations { UPDATE_CURRENT_TIME = 'UPDATE_CURRENT_TIME', CAN_PLAY = 'CAN_PLAY', SET_VOLUME = 'SET_VOLUME', - VISIBLE_FLASH = 'VISIBLE_FLASH' + VISIBLE_FLASH = 'VISIBLE_FLASH', + UPDATE_ELECTRON_LYRICE = 'UPDATE_electron_Lyrice' } const dominateMediaSession = ( title: string, @@ -183,5 +187,18 @@ export const mutations: MutationTree = { }, [Mutations.VISIBLE_FLASH](state, visible: boolean) { state.visibleFlash = visible + }, + [Mutations.UPDATE_ELECTRON_LYRICE](state, playond: PostData) { + state.electronLyrice = { + ...state.electronLyrice, + ...playond + } + importIpc().then(event => { + console.log('主窗口发送数据') + event.sendAsyncIpcRendererEvent( + Lyrice.LYRICE_UPDATE, + state.electronLyrice + ) + }) } } diff --git a/src/pages/footer/state.ts b/src/pages/footer/state.ts index 7e317658..a792f9c4 100644 --- a/src/pages/footer/state.ts +++ b/src/pages/footer/state.ts @@ -1,5 +1,7 @@ import { Artists, Albums, SongsDetail } from '@/interface/index' import { AudioType, BackgroundAudio } from './component/music-controller/audio' +import { PostData } from './component/lyrice-flash/electron-lyrice' +import { Size } from '@/layout/module' export interface Music { id: number @@ -29,6 +31,7 @@ export interface State { audioElement: HTMLAudioElement | null sourceElement: HTMLSourceElement | null visibleFlash: boolean + electronLyrice: PostData } export const state: State = { @@ -42,7 +45,17 @@ export const state: State = { canplay: false, audioElement: new Audio(), sourceElement: null, - visibleFlash: false + visibleFlash: false, + electronLyrice: { + screenSize: Size.SM, + visibleFlash: true, + lyrice: [], + index: 0, + playing: true, + flashMagic: { + animationDuration: '' + } + } } export interface Getter { diff --git a/src/pages/footer/view/index.less b/src/pages/footer/view/index.less index ca504787..02481186 100644 --- a/src/pages/footer/view/index.less +++ b/src/pages/footer/view/index.less @@ -30,6 +30,7 @@ .music-pic { width: 62px; height: 62px; + min-width: 62px; margin-right: 10px; border-radius: 4px; background-size: contain; @@ -39,6 +40,9 @@ } } &-des { + > div { + white-space: nowrap; + } &--title { font-size: 16px; } diff --git a/src/pages/footer/view/index.tsx b/src/pages/footer/view/index.tsx index b27e55d7..0d363da6 100644 --- a/src/pages/footer/view/index.tsx +++ b/src/pages/footer/view/index.tsx @@ -1,4 +1,4 @@ -import { defineComponent, ref, toRefs, computed } from 'vue' +import { defineComponent, ref, toRefs, computed, onMounted } from 'vue' import { NAMESPACED, State, LayoutActions } from '@/layout/module' import { uesModuleStore } from '@/hooks/index' import { MusicControl } from '../component/music-controller' @@ -19,12 +19,15 @@ import { Size } from '@/layout/module' import { AsyncComponent } from '../component/lyrice/index' -import { LyriceFlash } from '../component/lyrice-flash/index' +import { BrowserLyriceFlash } from '../component/lyrice-flash/browser-lyrice' +import { ENV } from '@/interface/app' import classnames from 'classnames' +import { Platform } from '@/config/build' import './index.less' // Fix JSX element type "AsyncComponent" does not have any construction signature or call signature. const Com = AsyncComponent as any +const { VUE_APP_PLATFORM } = window as ENV export const Footer = defineComponent({ name: 'Footer', @@ -79,8 +82,8 @@ export const Footer = defineComponent({
- - + + {/* Failed to locate Teleport target with selector "#cover-container" */} {/* {} */} diff --git a/src/pages/header/view/index.tsx b/src/pages/header/view/index.tsx index 8eae2aec..e33dfdfb 100644 --- a/src/pages/header/view/index.tsx +++ b/src/pages/header/view/index.tsx @@ -1,7 +1,7 @@ import { defineComponent, ref } from 'vue' import { Action } from '@/electron/event/action-types' import { ENV } from '@/interface/app' -import { IpcRenderer } from '@/electron/event/ipc-renderer' +import { importIpc } from '@/electron/event/ipc-browser' import { Logo } from '../component/logo' import { PushShift } from '../component/push-shift' import { Setting } from '../component/setting' @@ -14,20 +14,12 @@ import './index.less' const { VUE_APP_PLATFORM } = window as ENV const actionToClass = { [Action.CLOSE_WINDOW]: '', + [Action.CREATE_WINDOW]: '', [Action.MAXIMIZE_WINDOW]: 'lg', [Action.MINIMIZE_WINDOW]: 'sm', [Action.RESTORE_WINDOW]: 'md' } -const importIpc = () => { - return import('@/electron/event/ipc-renderer').then((v: IpcRenderer) => { - return { - sendAsyncIpcRendererEvent: v.sendAsyncIpcRendererEvent, - sendSyncIpcRendererEvent: v.sendSyncIpcRendererEvent - } - }) -} - export const Header = defineComponent({ name: 'Header', setup() { diff --git a/src/router/index.ts b/src/router/index.ts index 82d7ab89..0a72cdf9 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -16,6 +16,8 @@ export interface RouterChildren { meta?: Meta } +export const LYRICE_PATH = '/electron-lyrice-flash' + // Internationalization is not currently supported const baseRouter: RouteRecordRaw[] = [ { @@ -23,8 +25,11 @@ const baseRouter: RouteRecordRaw[] = [ redirect: '/music' }, { - path: '/test', - component: TestFull, + path: LYRICE_PATH, + component: () => + import( + /* webpackChunkName: "layrice" */ '@/pages/footer/component/lyrice-flash/electron-lyrice' + ), meta: { full: true } diff --git a/src/utils/index.ts b/src/utils/index.ts index 5a176855..df05c0a1 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -72,7 +72,10 @@ export const isNumber = (n: unknown) => { } export const toFixed = (n: number, m: number) => { - return Number(n.toFixed(m)) + if (typeof n === 'number') { + return Number(n.toFixed(m)) + } + return null } export const sleep = (n: number) => { diff --git a/yarn.lock b/yarn.lock index ff0eb1b5..9142741a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7155,7 +7155,7 @@ electron-to-chromium@^1.3.378, electron-to-chromium@^1.3.585: resolved "https://registry.npm.taobao.org/electron-to-chromium/download/electron-to-chromium-1.3.588.tgz?cache=0&sync_timestamp=1604514816392&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Felectron-to-chromium%2Fdownload%2Felectron-to-chromium-1.3.588.tgz#c6515571737bfb42678115a5eaa818384593a9a5" integrity sha1-xlFVcXN7+0JngRWl6qgYOEWTqaU= -electron@^10.1.3: +electron@^10.1.5: version "10.1.5" resolved "https://registry.npm.taobao.org/electron/download/electron-10.1.5.tgz#f2b161310f627063e73fbac44efcb35dece83a90" integrity sha1-8rFhMQ9icGPnP7rETvyzXezoOpA= @@ -16887,7 +16887,7 @@ void-elements@^3.1.0: resolved "https://registry.npm.taobao.org/void-elements/download/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09" integrity sha1-YU9/v42AHwu18GYfWy9XhXUOTwk= -vue-cli-plugin-electron-builder@~2.0.0-rc.4: +vue-cli-plugin-electron-builder@^2.0.0-rc.5: version "2.0.0-rc.5" resolved "https://registry.npm.taobao.org/vue-cli-plugin-electron-builder/download/vue-cli-plugin-electron-builder-2.0.0-rc.5.tgz#87cd8d09877f5f3ae339abc0bedc47d7d2b733ac" integrity sha1-h82NCYd/XzrjOavAvtxH19K3M6w=