Application configuration
Configuration belongs to the application instance, not process-level global state. Create the app first, and then write the configuration before mounting:
import { createApp } from "@elfui/core";
import { App } from "./App";
const app = createApp(App);
app.config.globalProperties.appName = "Console";
app.config.warnHandler = (message, ...args) => {
console.warn("[Console]", message, ...args);
};
app.config.errorHandler = (error, info) => {
reportError(error, { info });
};
app.mount("#app");Configuration items
| Options | Function |
|---|---|
globalProperties | Application-level read-only convention value; component setup reads from ctx.config.globalProperties and template reads from $app |
warnHandler | Receive runtime warnings for this App component |
errorHandler | Receive setup/render error for this App |
When you need to read the configuration in TypeScript logic in the macro component, use useAppConfig():
import { useAppConfig } from "@elfui/core";
const appName = useAppConfig().globalProperties.appName;Template string expressions still respect TypeScript scoping; pure template expressions read $app:
defineHtml(`<p>{{ $app.appName }}</p>`);globalProperties itself is not a reactive container. When runtime updates are required, put the return value of useRef() or useReactive() into it.
boundary
tagPrefix does not belong to application configuration. The macro component tag is determined at compile time, and the unified prefix can only be set in @elfui/vite-plugin.
WARNING
@elfui/core also exports configure() and getConfig() for legacy process-wide configuration and low-level integrations. New applications should prefer isolated app.config; resetConfig() remains available only from @elfui/runtime, primarily for test cleanup.
