modified: fxmanifest.lua

deleted:    main.obf.lua
new file:   server/utils.lua
modified:   web/public/assets/bg.png
modified:   web/src/types/redux.type.ts
modified:   web/src/utils/fetchNui.ts
modified:   web/src/utils/misc.ts
This commit is contained in:
Lorraxs 2024-02-05 18:31:04 +07:00
parent 3a27609e37
commit 2b8448e1be
7 changed files with 48 additions and 8 deletions

View File

@ -34,10 +34,12 @@ shared_scripts {
client_scripts {
"client/utils.lua",
"client/classes/*",
"client/impl/*"
}
server_script {
"server/utils.lua",
'@oxmysql/lib/MySQL.lua',
"server/classes/*",
"server/impl/*"

File diff suppressed because one or more lines are too long

12
server/utils.lua Normal file
View File

@ -0,0 +1,12 @@
function Response(isSuccess, errorMessage, data)
if not isSuccess then
return {
status = "error",
data = errorMessage
}
end
return {
status = "ok",
data = data
}
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 MiB

After

Width:  |  Height:  |  Size: 4.5 MiB

View File

@ -17,3 +17,15 @@ export type AsyncThunkConfig = {
/** type to be passed into the second argument of `rejectWithValue` to finally be merged into `rejectedAction.meta` */
rejectedMeta?: unknown;
};
export type IResponseSuccess<T = unknown> = {
status: 'success';
data: T;
};
export type IResponseError = {
status: 'error';
data: string;
};
export type IResponse<T = unknown> = IResponseSuccess<T> | IResponseError;

View File

@ -1,4 +1,5 @@
import { isEnvBrowser } from "./misc";
/* eslint-disable @typescript-eslint/no-explicit-any */
import { isEnvBrowser } from './misc';
/**
* Simple wrapper around fetch API tailored for CEF/NUI use. This abstraction
@ -15,12 +16,12 @@ import { isEnvBrowser } from "./misc";
export async function fetchNui<T = unknown>(
eventName: string,
data?: unknown,
mockData?: T,
mockData?: T
): Promise<T> {
const options = {
method: "post",
method: 'post',
headers: {
"Content-Type": "application/json; charset=UTF-8",
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify(data),
};
@ -29,7 +30,7 @@ export async function fetchNui<T = unknown>(
const resourceName = (window as any).GetParentResourceName
? (window as any).GetParentResourceName()
: "nui-frame-app";
: 'nui-frame-app';
const resp = await fetch(`https://${resourceName}/${eventName}`, options);

View File

@ -1,6 +1,22 @@
// Will return whether the current environment is in a regular browser
import { IResponse, IResponseSuccess } from '../types';
// and not CEF
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const isEnvBrowser = (): boolean => !(window as any).invokeNative;
// Basic no operation function
export const noop = () => {};
export const Sleep = (ms: number) => {
return new Promise((resolve) => setTimeout(resolve, ms));
};
export const GuardResponse = (
response: IResponse
): response is IResponseSuccess => {
if (!response) return false;
if (response.status === 'error') throw new Error(response.data);
return response.status === 'success';
};