Skip to content

Vue application template that has everything you need to create your CEF.

Notifications You must be signed in to change notification settings

electronjsc/cef-template

 
 

Repository files navigation

Cef Template

Cef Template - is a Vue application template that has everything you need to create your CEF.

Can be used in RageMp, SAMP or CRMP

📦 How to install and build a project?

  • To install the project, download the application here and unzip it to a convenient location.
    Next, in the project folder, run yarn install or npm install Now, you are ready to write the code. 💪
  • To build the project run: yarn build or npm run build
  • To start the dev server use the command: yarn dev or npm run build
  • To run the previously built project just open file dist/index.html

💻 How to create your own interface?

  1. Create a file/folder of interface
  2. Go to the App.vue file and import the component
  3. Add a component to the components field
  4. Add your component to interfaces

Example

// App.vue
<script lang="ts">
import { ref } from 'vue';
import CompositionAPIExample from '@/interfaces/CompositionAPIExample.vue';

export default {
  components: { CompositionAPIExample },
    setup() {
      const interfaces = ref({
      CompositionAPIExample: { display: false, }
    });

    return { interfaces };
  },
};
</script>

⌨️ How to manage the interface?

To control the interface, we have 5 functions added to the window object.

window.getInterface = function(name: string) // Returns an interface object
window.interfaceStatus= function(name: string) // Returns the state of the interface (open/closed)
window.openInterface= function(name: string, args: string) // Opens the interface
window.hideInterface= function(name: string) // Closes the interface
window.interface= function(name: string) // Returns an interface

More details

I will describe only complex control functions, getInterface, interfaceStatus and hideInterface are self-explanatory.

openInterface

Opens an interface, has an additional args argument. args is a JSON string that contains the so-called openParams. Let's say your interface has a name field that you want to specify when you open the interface. You can, of course, just specify a value in the data field, but suppose you want to specify it when opening the interface, then the code will look like this:

window.openInterface('InterfaceName', "[{'name': 'test'}]");

The function will parse the arguments and apply them by key to the fields in data.

interface

Will return an object for which you can directly change the fields, if we consider the previous example, then we could change the name field like this:

window.interface('InterfaceName').name = 'Test';

As a result, the interface will be re-rendered and its name field will change.

📑 Notes

In vue3, when using the Composition API, be sure to expose any fields you want to access from outside in defineExpose. Below I have left examples of the interface using Options and Composition API.

Author: Hold404

About

Vue application template that has everything you need to create your CEF.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Vue 33.8%
  • TypeScript 21.6%
  • JavaScript 17.7%
  • SCSS 15.3%
  • HTML 11.6%