ci010 / electron-vue-next

A starter template for using vue-next with the electron.
https://ci010.github.io/electron-vue-next/
191 stars 27 forks source link

service:call multiple parameters #39

Closed carlosyan1807 closed 3 years ago

carlosyan1807 commented 3 years ago

https://github.com/ci010/electron-vue-next/blob/d85735fb9a64a3dbbf36232b3280a4efff69f197/src/renderer/hooks/service.ts#L9-L10

      return (...payload: any) => {
        return invoke('service:call', service, functionName as string, ...payload)

https://github.com/ci010/electron-vue-next/blob/d85735fb9a64a3dbbf36232b3280a4efff69f197/src/main/services/index.ts#L77

        return service[method](...args)

when service:call passes multiple parameters, I think it can be changed like this.

const { fetchConfig } = useService('RedisService')
const dbCount= ref(0)

onMounted(async ()=> {
  const result = await fetchConfig(client, 'get', 'databases')
  dbCount.value = result[1]
}
[console] [ 'e4a95375-7555-4e53-9eac-c2ceb3e066d4', 'get', 'databases' ]
ci010 commented 3 years ago

Yes, I think it will be good to support the multi-params. Since in my old project, the services are used to be the vuex actions, it keeps the vuex design that only pass one param. This will fix in next patch. Thanks the feedback!

ci010 commented 3 years ago

This should be supported in https://github.com/ci010/electron-vue-next/commit/98d0d44da04fa2d9702994f7f1904684b3bb40c7