Add new hotkey functionalitys
This commit is contained in:
29
src/lib/Others/QuickSettingsGUI.svelte
Normal file
29
src/lib/Others/QuickSettingsGUI.svelte
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { BotIcon, PackageIcon, Sailboat, UserIcon } from "lucide-svelte";
|
||||||
|
import { QuickSettings } from "src/ts/stores.svelte";
|
||||||
|
import BotSettings from "../Setting/Pages/BotSettings.svelte";
|
||||||
|
import OtherBotSettings from "../Setting/Pages/OtherBotSettings.svelte";
|
||||||
|
import ModuleSettings from "../Setting/Pages/Module/ModuleSettings.svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex mb-2 gap-2">
|
||||||
|
<button class={QuickSettings.index === 0 ? 'text-textcolor ' : 'text-textcolor2'} onclick={() => {QuickSettings.index = 0}}>
|
||||||
|
<BotIcon />
|
||||||
|
</button>
|
||||||
|
<button class={QuickSettings.index === 1 ? 'text-textcolor ' : 'text-textcolor2'} onclick={() => {QuickSettings.index = 1}}>
|
||||||
|
<Sailboat />
|
||||||
|
</button>
|
||||||
|
<button class={QuickSettings.index === 2 ? 'text-textcolor ' : 'text-textcolor2'} onclick={() => {QuickSettings.index = 2}}>
|
||||||
|
<PackageIcon />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="py-6 px-4 flex flex-col text-textcolor overflow-y-auto relative rs-setting-cont-5">
|
||||||
|
{#if QuickSettings.index === 0}
|
||||||
|
<BotSettings />
|
||||||
|
{:else if QuickSettings.index === 1}
|
||||||
|
<OtherBotSettings />
|
||||||
|
{:else if QuickSettings.index === 2}
|
||||||
|
<ModuleSettings />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
@@ -8,7 +8,10 @@
|
|||||||
sideBarClosing,
|
sideBarClosing,
|
||||||
sideBarStore,
|
sideBarStore,
|
||||||
OpenRealmStore,
|
OpenRealmStore,
|
||||||
PlaygroundStore
|
PlaygroundStore,
|
||||||
|
|
||||||
|
QuickSettings
|
||||||
|
|
||||||
} from "../../ts/stores.svelte";
|
} from "../../ts/stores.svelte";
|
||||||
import { setDatabase, type folder } from "../../ts/storage/database.svelte";
|
import { setDatabase, type folder } from "../../ts/storage/database.svelte";
|
||||||
import { DBState } from 'src/ts/stores.svelte';
|
import { DBState } from 'src/ts/stores.svelte';
|
||||||
@@ -45,6 +48,7 @@
|
|||||||
import { ConnectionIsHost, ConnectionOpenStore, RoomIdStore } from "src/ts/sync/multiuser";
|
import { ConnectionIsHost, ConnectionOpenStore, RoomIdStore } from "src/ts/sync/multiuser";
|
||||||
import { sideBarSize } from "src/ts/gui/guisize";
|
import { sideBarSize } from "src/ts/gui/guisize";
|
||||||
import DevTool from "./DevTool.svelte";
|
import DevTool from "./DevTool.svelte";
|
||||||
|
import QuickSettingsGui from "../Others/QuickSettingsGUI.svelte";
|
||||||
let sideBarMode = $state(0);
|
let sideBarMode = $state(0);
|
||||||
let editMode = $state(false);
|
let editMode = $state(false);
|
||||||
let menuMode = $state(0);
|
let menuMode = $state(0);
|
||||||
@@ -751,7 +755,9 @@
|
|||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if devTool}
|
{#if QuickSettings.open}
|
||||||
|
<QuickSettingsGui />
|
||||||
|
{:else if devTool}
|
||||||
<DevTool />
|
<DevTool />
|
||||||
{:else if $botMakerMode}
|
{:else if $botMakerMode}
|
||||||
<CharConfig />
|
<CharConfig />
|
||||||
|
|||||||
@@ -119,16 +119,6 @@ export const defaultHotkeys: Hotkey[] = [
|
|||||||
ctrl: true,
|
ctrl: true,
|
||||||
action: 'previewRequest'
|
action: 'previewRequest'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'i',
|
|
||||||
ctrl: true,
|
|
||||||
action: 'import'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'x',
|
|
||||||
ctrl: true,
|
|
||||||
action: 'export'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'w',
|
key: 'w',
|
||||||
ctrl: true,
|
ctrl: true,
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { alertSelect, alertToast, doingAlert } from "./alert"
|
import { alertMd, alertSelect, alertToast, alertWait, doingAlert } from "./alert"
|
||||||
import { changeToPreset as changeToPreset2, getDatabase } from "./storage/database.svelte"
|
import { changeToPreset as changeToPreset2, getDatabase } from "./storage/database.svelte"
|
||||||
import { alertStore, MobileGUIStack, MobileSideBar, openPersonaList, openPresetList, SafeModeStore, selectedCharID, settingsOpen } from "./stores.svelte"
|
import { alertStore, MobileGUIStack, MobileSideBar, openPersonaList, openPresetList, OpenRealmStore, PlaygroundStore, QuickSettings, SafeModeStore, selectedCharID, settingsOpen } from "./stores.svelte"
|
||||||
import { language } from "src/lang"
|
import { language } from "src/lang"
|
||||||
import { updateTextThemeAndCSS } from "./gui/colorscheme"
|
import { updateTextThemeAndCSS } from "./gui/colorscheme"
|
||||||
import { defaultHotkeys } from "./defaulthotkeys"
|
import { defaultHotkeys } from "./defaulthotkeys"
|
||||||
|
import { doingChat, previewBody, sendChat } from "./process/index.svelte"
|
||||||
|
import { getRequestLog } from "./globalApi.svelte"
|
||||||
|
|
||||||
export function initHotkey(){
|
export function initHotkey(){
|
||||||
document.addEventListener('keydown', (ev) => {
|
document.addEventListener('keydown', (ev) => {
|
||||||
@@ -111,6 +113,67 @@ export function initHotkey(){
|
|||||||
updateTextThemeAndCSS()
|
updateTextThemeAndCSS()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
case 'prevChar':{
|
||||||
|
const sorted = database.characters.map((v, i) => {
|
||||||
|
return {name: v.name, i}
|
||||||
|
}).sort((a, b) => a.name.localeCompare(b.name))
|
||||||
|
const currentIndex = sorted.findIndex(v => v.i === get(selectedCharID))
|
||||||
|
if(currentIndex === 0){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if(currentIndex >= sorted.length - 1){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
selectedCharID.set(sorted[currentIndex - 1].i)
|
||||||
|
PlaygroundStore.set(0)
|
||||||
|
OpenRealmStore.set(false)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'nextChar':{
|
||||||
|
const sorted = database.characters.map((v, i) => {
|
||||||
|
return {name: v.name, i}
|
||||||
|
}).sort((a, b) => a.name.localeCompare(b.name))
|
||||||
|
const currentIndex = sorted.findIndex(v => v.i === get(selectedCharID))
|
||||||
|
if(currentIndex === 0){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if(currentIndex >= sorted.length - 1){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
selectedCharID.set(sorted[currentIndex + 1].i)
|
||||||
|
PlaygroundStore.set(0)
|
||||||
|
OpenRealmStore.set(false)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'quickMenu':{
|
||||||
|
quickMenu()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'previewRequest':{
|
||||||
|
if(get(doingChat) && get(selectedCharID) !== -1){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
alertWait("Loading...")
|
||||||
|
sendChat(-1, {
|
||||||
|
previewPrompt: true
|
||||||
|
})
|
||||||
|
|
||||||
|
let md = ''
|
||||||
|
md += '### Prompt\n'
|
||||||
|
md += '```json\n' + JSON.stringify(JSON.parse(previewBody), null, 2).replaceAll('```', '\\`\\`\\`') + '\n```\n'
|
||||||
|
doingChat.set(false)
|
||||||
|
alertMd(md)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'toggleLog':{
|
||||||
|
alertMd(getRequestLog())
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'quickSettings':{
|
||||||
|
QuickSettings.open = !QuickSettings.open
|
||||||
|
QuickSettings.index = 0
|
||||||
|
break
|
||||||
|
}
|
||||||
default:{
|
default:{
|
||||||
hotKeyRanThisTime = false
|
hotKeyRanThisTime = false
|
||||||
}
|
}
|
||||||
@@ -221,6 +284,18 @@ export function initHotkey(){
|
|||||||
if(doingAlert()){
|
if(doingAlert()){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
quickMenu()
|
||||||
|
}
|
||||||
|
if(touchs === 1){
|
||||||
|
touchStartTime = Date.now()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
document.addEventListener('touchend', (ev) => {
|
||||||
|
touchs = 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function quickMenu(){
|
||||||
const selStr = await alertSelect([
|
const selStr = await alertSelect([
|
||||||
language.presets,
|
language.presets,
|
||||||
language.persona,
|
language.persona,
|
||||||
@@ -234,14 +309,6 @@ export function initHotkey(){
|
|||||||
openPersonaList.set(!get(openPersonaList))
|
openPersonaList.set(!get(openPersonaList))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(touchs === 1){
|
|
||||||
touchStartTime = Date.now()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
document.addEventListener('touchend', (ev) => {
|
|
||||||
touchs = 0
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function clickQuery(query:string){
|
function clickQuery(query:string){
|
||||||
let ele = document.querySelector(query) as HTMLElement
|
let ele = document.querySelector(query) as HTMLElement
|
||||||
|
|||||||
@@ -98,6 +98,11 @@ export const LoadingStatusState = $state({
|
|||||||
text: '',
|
text: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const QuickSettings = $state({
|
||||||
|
open: false,
|
||||||
|
index: 0
|
||||||
|
})
|
||||||
|
|
||||||
export const disableHighlight = writable(true)
|
export const disableHighlight = writable(true)
|
||||||
|
|
||||||
ReloadGUIPointer.subscribe(() => {
|
ReloadGUIPointer.subscribe(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user