Cef Template - is a Vue application template that has everything you need to create your CEF.
Can be used in RageMp, SAMP or CRMP
- To install the project, download the application here and unzip it to a convenient location.
Next, in the project folder, runyarn install
ornpm install
Now, you are ready to write the code. 💪 - To build the project run:
yarn build
ornpm run build
- To start the dev server use the command:
yarn dev
ornpm run build
- To run the previously built project just open file
dist/index.html
- Create a file/folder of interface
- Go to the App.vue file and import the component
- Add a component to the
components
field - Add your component to
interfaces
// 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>
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
I will describe only complex control functions, getInterface
, interfaceStatus
and hideInterface
are self-explanatory.
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.
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.
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