11import type { ValaxyAddon } from 'valaxy'
22import type { Live2DCollection , Live2dOptions , Live2dTips } from '../types'
3+ import defu from 'defu'
34import { useRuntimeConfig } from 'valaxy'
45import { computed } from 'vue'
56import { live2DCollection } from '../constants/live2dCollection'
@@ -10,19 +11,19 @@ import { filterLive2DCollection, mergeConfigs } from '../utils/config'
1011export function useAddonLive2dConfig ( ) {
1112 const runtimeConfig = useRuntimeConfig ( )
1213 return computed < Live2dOptions > ( ( ) => {
13- const { options } = runtimeConfig . value . addons [ 'valaxy-addon-live2d' ] as ValaxyAddon < Live2dOptions >
14+ const { options : userOptions } = runtimeConfig . value . addons [ 'valaxy-addon-live2d' ] as ValaxyAddon < Live2dOptions >
1415
15- const enableLive2D = options ?. enableLive2D ?? 'all'
16- const mergedLive2DCollection : Live2DCollection = { ...live2DCollection , ...options ?. live2DCollection }
16+ const enableLive2D = userOptions ?. enableLive2D ?? 'all'
17+ const mergedLive2DCollection : Live2DCollection = { ...live2DCollection , ...userOptions ?. live2DCollection }
1718
1819 const filteredAndSortedLive2DCollection : Live2DCollection = ( enableLive2D === 'all' )
1920 ? mergedLive2DCollection
2021 : filterLive2DCollection ( enableLive2D , mergedLive2DCollection )
2122
22- const mergedLive2dTips = mergeConfigs ( live2dTips , options ?. live2dTips || { } ) as Live2dTips
23+ const mergedLive2dTips = mergeConfigs ( live2dTips , userOptions ?. live2dTips || { } ) as Live2dTips
24+ const options = defu ( userOptions , defaultLive2DOptions )
2325
2426 return {
25- ...defaultLive2DOptions ,
2627 ...options ,
2728
2829 live2DCollection : filteredAndSortedLive2DCollection ,
0 commit comments