mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-22 16:23:50 +02:00
Organize bootstrap.js
This commit is contained in:
@@ -11,7 +11,7 @@ import SimpleSwitch from '../components/SimpleSwitch.vue';
|
||||
import Timer from '../components/Timer.vue';
|
||||
import DataTable from '../components/DataTable.vue';
|
||||
|
||||
export default function registerComponents(app) {
|
||||
export function initComponents(app) {
|
||||
app.component('SimpleSwitch', SimpleSwitch);
|
||||
app.component('Location', Location);
|
||||
app.component('Timer', Timer);
|
||||
|
||||
@@ -3,8 +3,14 @@ import duration from 'dayjs/plugin/duration';
|
||||
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
||||
import timezone from 'dayjs/plugin/timezone';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
||||
|
||||
dayjs.extend(duration);
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(isSameOrAfter);
|
||||
export function initDayjs() {
|
||||
dayjs.extend(duration);
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(isSameOrAfter);
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(customParseFormat);
|
||||
}
|
||||
|
||||
13
src/plugin/index.js
Normal file
13
src/plugin/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { initInteropApi } from './interopApi';
|
||||
import { initDayjs } from './dayjs';
|
||||
import { initNoty } from './noty';
|
||||
import { initUi } from './ui';
|
||||
|
||||
export async function initPlugins(isVrOverlay = false) {
|
||||
await initInteropApi(isVrOverlay);
|
||||
if (!isVrOverlay) {
|
||||
await initUi();
|
||||
}
|
||||
initDayjs();
|
||||
initNoty(isVrOverlay);
|
||||
}
|
||||
42
src/plugin/interopApi.js
Normal file
42
src/plugin/interopApi.js
Normal file
@@ -0,0 +1,42 @@
|
||||
// @ts-nocheck
|
||||
import InteropApi from '../ipc-electron/interopApi.js';
|
||||
import configRepository from '../service/config';
|
||||
import vrcxJsonStorage from '../service/jsonStorage';
|
||||
|
||||
export async function initInteropApi(isVrOverlay = false) {
|
||||
if (isVrOverlay) {
|
||||
if (WINDOWS) {
|
||||
await CefSharp.BindObjectAsync('AppApiVr');
|
||||
} else {
|
||||
// @ts-ignore
|
||||
window.AppApiVr = InteropApi.AppApiVrElectron;
|
||||
}
|
||||
} else {
|
||||
// #region | Init Cef C# bindings
|
||||
if (WINDOWS) {
|
||||
await CefSharp.BindObjectAsync(
|
||||
'AppApi',
|
||||
'WebApi',
|
||||
'VRCXStorage',
|
||||
'SQLite',
|
||||
'LogWatcher',
|
||||
'Discord',
|
||||
'AssetBundleManager'
|
||||
);
|
||||
} else {
|
||||
window.AppApi = InteropApi.AppApiElectron;
|
||||
window.WebApi = InteropApi.WebApi;
|
||||
window.VRCXStorage = InteropApi.VRCXStorage;
|
||||
window.SQLite = InteropApi.SQLite;
|
||||
window.LogWatcher = InteropApi.LogWatcher;
|
||||
window.Discord = InteropApi.Discord;
|
||||
window.AssetBundleManager = InteropApi.AssetBundleManager;
|
||||
window.AppApiVrElectron = InteropApi.AppApiVrElectron;
|
||||
}
|
||||
|
||||
configRepository.init();
|
||||
new vrcxJsonStorage(VRCXStorage);
|
||||
|
||||
AppApi.SetUserAgent();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// @ts-nocheck
|
||||
import InteropApi from '../ipc-electron/interopApi.js';
|
||||
|
||||
// #region | Init Cef C# bindings
|
||||
if (WINDOWS) {
|
||||
await CefSharp.BindObjectAsync(
|
||||
'AppApi',
|
||||
'WebApi',
|
||||
'VRCXStorage',
|
||||
'SQLite',
|
||||
'LogWatcher',
|
||||
'Discord',
|
||||
'AssetBundleManager'
|
||||
);
|
||||
} else {
|
||||
window.AppApi = InteropApi.AppApiElectron;
|
||||
window.WebApi = InteropApi.WebApi;
|
||||
window.VRCXStorage = InteropApi.VRCXStorage;
|
||||
window.SQLite = InteropApi.SQLite;
|
||||
window.LogWatcher = InteropApi.LogWatcher;
|
||||
window.Discord = InteropApi.Discord;
|
||||
window.AssetBundleManager = InteropApi.AssetBundleManager;
|
||||
window.AppApiVrElectron = InteropApi.AppApiVrElectron;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import Noty from 'noty';
|
||||
|
||||
function initNoty(isVrOverlay) {
|
||||
export function initNoty(isVrOverlay = false) {
|
||||
if (isVrOverlay) {
|
||||
Noty.overrideDefaults({
|
||||
animation: {
|
||||
@@ -23,5 +23,3 @@ function initNoty(isVrOverlay) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { initNoty };
|
||||
|
||||
32
src/plugin/ui.js
Normal file
32
src/plugin/ui.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import configRepository from '../service/config';
|
||||
import {
|
||||
changeAppDarkStyle,
|
||||
changeAppThemeStyle,
|
||||
refreshCustomCss,
|
||||
refreshCustomScript,
|
||||
setLoginContainerStyle,
|
||||
getThemeMode
|
||||
} from '../shared/utils/base/ui';
|
||||
import { i18n } from './i18n';
|
||||
|
||||
export async function initUi() {
|
||||
try {
|
||||
// @ts-ignore
|
||||
i18n.locale = await configRepository.getString(
|
||||
'VRCX_appLanguage',
|
||||
'en'
|
||||
);
|
||||
|
||||
const { initThemeMode, isDarkMode } =
|
||||
await getThemeMode(configRepository);
|
||||
|
||||
setLoginContainerStyle(isDarkMode);
|
||||
changeAppDarkStyle(isDarkMode);
|
||||
changeAppThemeStyle(initThemeMode);
|
||||
} catch (error) {
|
||||
console.error('Error initializing locale and theme:', error);
|
||||
}
|
||||
|
||||
refreshCustomCss();
|
||||
refreshCustomScript();
|
||||
}
|
||||
Reference in New Issue
Block a user