mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
Clean up keyboard bindings and reload locale
Co-Authored-By: kubectl <me@kube.moe>
This commit is contained in:
@@ -20,4 +20,11 @@ const i18n = createI18n({
|
|||||||
fallbackWarn: false
|
fallbackWarn: false
|
||||||
});
|
});
|
||||||
|
|
||||||
export { i18n };
|
async function updateLocalizedStrings() {
|
||||||
|
const newStrings = await getLocalizationStrings();
|
||||||
|
Object.entries(newStrings).forEach(([key, value]) => {
|
||||||
|
i18n.global.setLocaleMessage(key.replaceAll('_', '-'), value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export { i18n, updateLocalizedStrings };
|
||||||
|
|||||||
106
src/stores/ui.js
106
src/stores/ui.js
@@ -1,44 +1,88 @@
|
|||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
|
import { useMagicKeys } from '@vueuse/core';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
import { AppDebug } from '../service/appConfig';
|
||||||
|
import { refreshCustomCss } from '../shared/utils/base/ui';
|
||||||
|
import { updateLocalizedStrings } from '../plugin/i18n';
|
||||||
import { useNotificationStore } from './notification';
|
import { useNotificationStore } from './notification';
|
||||||
import { useSearchStore } from './search';
|
import { useSearchStore } from './search';
|
||||||
|
|
||||||
export const useUiStore = defineStore('Ui', () => {
|
export const useUiStore = defineStore('Ui', () => {
|
||||||
const notificationStore = useNotificationStore();
|
const notificationStore = useNotificationStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const search = useSearchStore();
|
const keys = useMagicKeys();
|
||||||
|
const { directAccessPaste } = useSearchStore();
|
||||||
|
|
||||||
document.addEventListener('keydown', function (e) {
|
const ctrlR = keys['Ctrl+R'];
|
||||||
if (e.shiftKey) {
|
const ctrlD = keys['Ctrl+D'];
|
||||||
shiftHeld.value = true;
|
const shift = keys['Shift'];
|
||||||
}
|
const ctrlShiftI = keys['Ctrl+Shift+I'];
|
||||||
if (e.ctrlKey && e.key === 'd') {
|
const altShiftR = keys['Alt+Shift+R'];
|
||||||
e.preventDefault();
|
|
||||||
search.directAccessPaste();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('keyup', function (e) {
|
|
||||||
if (!e.shiftKey) {
|
|
||||||
shiftHeld.value = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const notifiedMenus = ref([]);
|
const notifiedMenus = ref([]);
|
||||||
const shiftHeld = ref(false);
|
const shiftHeld = ref(false);
|
||||||
const trayIconNotify = ref(false);
|
const trayIconNotify = ref(false);
|
||||||
|
|
||||||
function notifyMenu(index) {
|
watch(ctrlR, (isPressed) => {
|
||||||
const currentRouteName = router.currentRoute.value?.name;
|
if (isPressed) {
|
||||||
if (
|
location.reload();
|
||||||
index !== currentRouteName &&
|
|
||||||
!notifiedMenus.value.includes(index)
|
|
||||||
) {
|
|
||||||
notifiedMenus.value.push(index);
|
|
||||||
updateTrayIconNotify();
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(ctrlD, (isPressed) => {
|
||||||
|
if (isPressed) {
|
||||||
|
directAccessPaste();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(shift, (isHeld) => {
|
||||||
|
shiftHeld.value = isHeld;
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(ctrlShiftI, (isPressed) => {
|
||||||
|
if (isPressed) {
|
||||||
|
showConsole();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(altShiftR, (isPressed) => {
|
||||||
|
if (isPressed) {
|
||||||
|
refreshCustomCss();
|
||||||
|
updateLocalizedStrings();
|
||||||
|
ElMessage({
|
||||||
|
message: 'Custom CSS and localization strings refreshed',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Make sure file drops outside of the screenshot manager don't navigate to the file path dropped.
|
||||||
|
// This issue persists on prompts created with prompt(), unfortunately. Not sure how to fix that.
|
||||||
|
document.body.addEventListener('drop', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
function showConsole() {
|
||||||
|
AppApi.ShowDevTools();
|
||||||
|
if (
|
||||||
|
AppDebug.debug ||
|
||||||
|
AppDebug.debugWebRequests ||
|
||||||
|
AppDebug.debugWebSocket ||
|
||||||
|
AppDebug.debugUserDiff
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
'%cCareful! This might not do what you think.',
|
||||||
|
'background-color: red; color: yellow; font-size: 32px; font-weight: bold'
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
'%cIf someone told you to copy-paste something here, it can give them access to your account.',
|
||||||
|
'font-size: 20px;'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@@ -54,6 +98,17 @@ export const useUiStore = defineStore('Ui', () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function notifyMenu(index) {
|
||||||
|
const currentRouteName = router.currentRoute.value?.name;
|
||||||
|
if (
|
||||||
|
index !== currentRouteName &&
|
||||||
|
!notifiedMenus.value.includes(index)
|
||||||
|
) {
|
||||||
|
notifiedMenus.value.push(index);
|
||||||
|
updateTrayIconNotify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function removeNotify(index) {
|
function removeNotify(index) {
|
||||||
notifiedMenus.value = notifiedMenus.value.filter((i) => i !== index);
|
notifiedMenus.value = notifiedMenus.value.filter((i) => i !== index);
|
||||||
updateTrayIconNotify();
|
updateTrayIconNotify();
|
||||||
@@ -80,6 +135,7 @@ export const useUiStore = defineStore('Ui', () => {
|
|||||||
shiftHeld,
|
shiftHeld,
|
||||||
|
|
||||||
notifyMenu,
|
notifyMenu,
|
||||||
removeNotify
|
removeNotify,
|
||||||
|
showConsole
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { debounce, parseLocation } from '../shared/utils';
|
|||||||
import { AppDebug } from '../service/appConfig';
|
import { AppDebug } from '../service/appConfig';
|
||||||
import { database } from '../service/database';
|
import { database } from '../service/database';
|
||||||
import { failedGetRequests } from '../service/request';
|
import { failedGetRequests } from '../service/request';
|
||||||
import { refreshCustomCss } from '../shared/utils/base/ui';
|
|
||||||
import { useAdvancedSettingsStore } from './settings/advanced';
|
import { useAdvancedSettingsStore } from './settings/advanced';
|
||||||
import { useAvatarProviderStore } from './avatarProvider';
|
import { useAvatarProviderStore } from './avatarProvider';
|
||||||
import { useAvatarStore } from './avatar';
|
import { useAvatarStore } from './avatar';
|
||||||
@@ -150,48 +149,6 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
// Make sure file drops outside of the screenshot manager don't navigate to the file path dropped.
|
|
||||||
// This issue persists on prompts created with prompt(), unfortunately. Not sure how to fix that.
|
|
||||||
document.body.addEventListener('drop', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('keyup', function (e) {
|
|
||||||
if (e.ctrlKey) {
|
|
||||||
if (e.key === 'I') {
|
|
||||||
showConsole();
|
|
||||||
} else if (e.key === 'r') {
|
|
||||||
location.reload();
|
|
||||||
}
|
|
||||||
} else if (e.altKey && e.key === 'R') {
|
|
||||||
refreshCustomCss();
|
|
||||||
ElMessage({
|
|
||||||
message: 'Custom CSS refreshed',
|
|
||||||
type: 'success'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function showConsole() {
|
|
||||||
AppApi.ShowDevTools();
|
|
||||||
if (
|
|
||||||
AppDebug.debug ||
|
|
||||||
AppDebug.debugWebRequests ||
|
|
||||||
AppDebug.debugWebSocket ||
|
|
||||||
AppDebug.debugUserDiff
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log(
|
|
||||||
'%cCareful! This might not do what you think.',
|
|
||||||
'background-color: red; color: yellow; font-size: 32px; font-weight: bold'
|
|
||||||
);
|
|
||||||
console.log(
|
|
||||||
'%cIf someone told you to copy-paste something here, it can give them access to your account.',
|
|
||||||
'font-size: 20px;'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updateDatabaseVersion() {
|
async function updateDatabaseVersion() {
|
||||||
// requires dbVars.userPrefix to be already set
|
// requires dbVars.userPrefix to be already set
|
||||||
const databaseVersion = 13;
|
const databaseVersion = 13;
|
||||||
@@ -775,7 +732,6 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
ipcEnabled,
|
ipcEnabled,
|
||||||
clearVRCXCacheFrequency,
|
clearVRCXCacheFrequency,
|
||||||
maxTableSize,
|
maxTableSize,
|
||||||
showConsole,
|
|
||||||
clearVRCXCache,
|
clearVRCXCache,
|
||||||
eventVrcxMessage,
|
eventVrcxMessage,
|
||||||
eventLaunchCommand,
|
eventLaunchCommand,
|
||||||
|
|||||||
@@ -405,6 +405,7 @@
|
|||||||
useLaunchStore,
|
useLaunchStore,
|
||||||
useNotificationsSettingsStore,
|
useNotificationsSettingsStore,
|
||||||
usePhotonStore,
|
usePhotonStore,
|
||||||
|
useUiStore,
|
||||||
useUserStore,
|
useUserStore,
|
||||||
useVRCXUpdaterStore,
|
useVRCXUpdaterStore,
|
||||||
useVrStore,
|
useVrStore,
|
||||||
@@ -430,7 +431,8 @@
|
|||||||
const { showLaunchOptions } = useLaunchStore();
|
const { showLaunchOptions } = useLaunchStore();
|
||||||
const { enablePrimaryPasswordChange } = useAuthStore();
|
const { enablePrimaryPasswordChange } = useAuthStore();
|
||||||
const { cachedConfig } = storeToRefs(useAuthStore());
|
const { cachedConfig } = storeToRefs(useAuthStore());
|
||||||
const { showConsole, clearVRCXCache, showRegistryBackupDialog } = useVrcxStore();
|
const { clearVRCXCache, showRegistryBackupDialog } = useVrcxStore();
|
||||||
|
const { showConsole } = useUiStore();
|
||||||
const { disableGameLogDialog } = useGameLogStore();
|
const { disableGameLogDialog } = useGameLogStore();
|
||||||
|
|
||||||
const { cachedUsers } = useUserStore();
|
const { cachedUsers } = useUserStore();
|
||||||
|
|||||||
@@ -361,7 +361,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ArrowDown, ArrowRight, DocumentCopy, Notebook } from '@element-plus/icons-vue';
|
import { ArrowDown, ArrowRight, DocumentCopy, Notebook } from '@element-plus/icons-vue';
|
||||||
import { computed, ref } from 'vue';
|
import { computed, onBeforeUnmount, ref } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
@@ -425,15 +425,26 @@
|
|||||||
|
|
||||||
const zoomLevel = ref(100);
|
const zoomLevel = ref(100);
|
||||||
const isLinux = computed(() => LINUX);
|
const isLinux = computed(() => LINUX);
|
||||||
|
let cleanupWheel = null;
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
if (cleanupWheel) {
|
||||||
|
cleanupWheel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
initGetZoomLevel();
|
initGetZoomLevel();
|
||||||
|
|
||||||
async function initGetZoomLevel() {
|
async function initGetZoomLevel() {
|
||||||
addEventListener('wheel', (event) => {
|
const handleWheel = (event) => {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
getZoomLevel();
|
getZoomLevel();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
window.addEventListener('wheel', handleWheel);
|
||||||
|
cleanupWheel = () => {
|
||||||
|
window.removeEventListener('wheel', handleWheel);
|
||||||
|
};
|
||||||
getZoomLevel();
|
getZoomLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user