5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-09 00:42:16 +08:00

Support setting app state at startup

This commit is contained in:
Lea Anthony 2020-10-04 12:07:10 +11:00
parent f4943bc26c
commit 6aae2eb1df
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405

View File

@ -838,6 +838,14 @@ void createMainWindow(struct Application *app) {
app->mainWindow = mainWindow;
}
const char* getInitialState(struct Application *app) {
if( isDarkMode(app) ) {
return "window.wails.System.IsDarkMode.set(true);";
} else {
return "window.wails.System.IsDarkMode.set(false);";
}
}
void Run(struct Application *app, int argc, char **argv) {
processDecorations(app);
@ -944,6 +952,11 @@ void Run(struct Application *app, int argc, char **argv) {
const char *internalCode = concat(temp, (const char*)&runtime);
free((void*)temp);
// Add code that sets up the initial state, EG: State Stores.
temp = concat(internalCode, getInitialState(app));
free((void*)internalCode);
internalCode = temp;
// Loop over assets and build up one giant Mother Of All Evals
int index = 1;
while(1) {