Improve beta mobile accessibility
This commit is contained in:
@@ -66,6 +66,8 @@ async function importCharacterProcess(f:{
|
||||
}
|
||||
}
|
||||
|
||||
let db = get(DataBase)
|
||||
db.statics.imports += 1
|
||||
|
||||
if(f.name.endsWith('charx')){
|
||||
console.log('reading charx')
|
||||
@@ -235,7 +237,6 @@ async function importCharacterProcess(f:{
|
||||
const charaData:OldTavernChar = JSON.parse(Buffer.from(readedChara, 'base64').toString('utf-8'))
|
||||
console.log(charaData)
|
||||
const imgp = await saveAsset(await reencodeImage(img))
|
||||
let db = get(DataBase)
|
||||
db.characters.push(convertOffSpecCards(charaData, imgp))
|
||||
DataBase.set(db)
|
||||
alertNormal(language.importedCharacter)
|
||||
|
||||
@@ -412,7 +412,9 @@ function formatTavernChat(chat:string, charName:string){
|
||||
return chat.replace(/<([Uu]ser)>|\{\{([Uu]ser)\}\}/g, getUserName()).replace(/((\{\{)|<)([Cc]har)(=.+)?((\}\})|>)/g, charName)
|
||||
}
|
||||
|
||||
export function characterFormatUpdate(index:number|character){
|
||||
export function characterFormatUpdate(index:number|character, arg:{
|
||||
updateInteraction?:boolean,
|
||||
} = {}){
|
||||
let db = get(DataBase)
|
||||
let cha = typeof(index) === 'number' ? db.characters[index] : index
|
||||
if(cha.chats.length === 0){
|
||||
@@ -504,6 +506,7 @@ export function characterFormatUpdate(index:number|character){
|
||||
if(checkNullish(cha.customscript)){
|
||||
cha.customscript = []
|
||||
}
|
||||
cha.lastInteraction = Date.now()
|
||||
if(typeof(index) === 'number'){
|
||||
db.characters[index] = cha
|
||||
setDatabase(db)
|
||||
|
||||
@@ -36,8 +36,8 @@ export const defaultColorScheme: ColorScheme = {
|
||||
const colorShemes = {
|
||||
"default": defaultColorScheme,
|
||||
"light": {
|
||||
bgcolor: "#f0f0f0",
|
||||
darkbg: "#ffffff",
|
||||
bgcolor: "#ffffff",
|
||||
darkbg: "#f0f0f0",
|
||||
borderc: "#0f172a",
|
||||
selected: "#e0e0e0",
|
||||
draculared: "#ff5555",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { get } from "svelte/store"
|
||||
import { alertSelect, alertToast, doingAlert } from "./alert"
|
||||
import { DataBase, changeToPreset as changeToPreset2 } from "./storage/database"
|
||||
import { openPersonaList, openPresetList, SafeModeStore, selectedCharID, settingsOpen } from "./stores"
|
||||
import { MobileGUIStack, MobileSideBar, openPersonaList, openPresetList, SafeModeStore, selectedCharID, settingsOpen } from "./stores"
|
||||
import { language } from "src/lang"
|
||||
import { updateTextThemeAndCSS } from "./gui/colorscheme"
|
||||
|
||||
@@ -143,6 +143,50 @@ export function initHotkey(){
|
||||
})
|
||||
}
|
||||
|
||||
export function initMobileGesture(){
|
||||
|
||||
let pressingPointers = new Map<number, {x:number, y:number}>()
|
||||
|
||||
document.addEventListener('pointerdown', (ev) => {
|
||||
pressingPointers.set(ev.pointerId, {x: ev.clientX, y: ev.clientY})
|
||||
}, {
|
||||
passive: true
|
||||
})
|
||||
document.addEventListener('pointerup', (ev) => {
|
||||
const d = pressingPointers.get(ev.pointerId)
|
||||
const moveX = ev.clientX - d.x
|
||||
const moveY = ev.clientY - d.y
|
||||
pressingPointers.delete(ev.pointerId)
|
||||
|
||||
if(moveX > 50 && Math.abs(moveY) < Math.abs(moveX)){
|
||||
if(get(selectedCharID) === -1){
|
||||
if(get(MobileGUIStack) > 0){
|
||||
MobileGUIStack.update(v => v - 1)
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(get(MobileSideBar) > 0){
|
||||
MobileSideBar.update(v => v - 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(moveX < -50 && Math.abs(moveY) < Math.abs(moveX)){
|
||||
if(get(selectedCharID) === -1){
|
||||
if(get(MobileGUIStack) < 2){
|
||||
MobileGUIStack.update(v => v + 1)
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(get(MobileSideBar) < 3){
|
||||
MobileSideBar.update(v => v + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
passive: true
|
||||
})
|
||||
}
|
||||
|
||||
function changeToPreset(num:number){
|
||||
if(!doingAlert()){
|
||||
let db = get(DataBase)
|
||||
|
||||
@@ -122,8 +122,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
}
|
||||
|
||||
let db = get(DataBase)
|
||||
db.statics.messages += 1
|
||||
let selectedChar = get(selectedCharID)
|
||||
const nowChatroom = db.characters[selectedChar]
|
||||
nowChatroom.lastInteraction = Date.now()
|
||||
let selectedChat = nowChatroom.chatPage
|
||||
nowChatroom.chats[nowChatroom.chatPage].message = nowChatroom.chats[nowChatroom.chatPage].message.map((v) => {
|
||||
v.chatId = v.chatId ?? v4()
|
||||
|
||||
@@ -436,6 +436,10 @@ export function setDatabase(data:Database){
|
||||
data.falLoraScale ??= 1
|
||||
data.customCSS ??= ''
|
||||
data.strictJsonSchema ??= true
|
||||
data.statics ??= {
|
||||
messages: 0,
|
||||
imports: 0
|
||||
}
|
||||
changeLanguage(data.language)
|
||||
DataBase.set(data)
|
||||
}
|
||||
@@ -734,6 +738,10 @@ export interface Database{
|
||||
jsonSchema:string
|
||||
strictJsonSchema:boolean
|
||||
extractJson:string
|
||||
statics: {
|
||||
messages: number
|
||||
imports: number
|
||||
}
|
||||
}
|
||||
|
||||
export interface customscript{
|
||||
@@ -887,6 +895,7 @@ export interface character{
|
||||
defaultVariables?:string
|
||||
lowLevelAccess?:boolean
|
||||
hideChatIcon?:boolean
|
||||
lastInteraction?:number
|
||||
}
|
||||
|
||||
|
||||
@@ -935,6 +944,7 @@ export interface groupChat{
|
||||
defaultVariables?:string
|
||||
lowLevelAccess?:boolean
|
||||
hideChatIcon?:boolean
|
||||
lastInteraction?:number
|
||||
}
|
||||
|
||||
export interface botPreset{
|
||||
|
||||
@@ -35,6 +35,7 @@ import { removeDefaultHandler } from "src/main";
|
||||
import { updateGuisize } from "../gui/guisize";
|
||||
import { encodeCapKeySafe } from "./mobileStorage";
|
||||
import { updateLorebooks } from "../characters";
|
||||
import { initMobileGesture } from "../hotkey";
|
||||
|
||||
//@ts-ignore
|
||||
export const isTauri = !!window.__TAURI__
|
||||
@@ -542,7 +543,8 @@ export async function loadData() {
|
||||
if(db.botSettingAtStart){
|
||||
botMakerMode.set(true)
|
||||
}
|
||||
if(db.betaMobileGUI && window.innerWidth <= 800){
|
||||
if((db.betaMobileGUI && window.innerWidth <= 800) || import.meta.env.VITE_RISU_LITE){
|
||||
initMobileGesture()
|
||||
MobileGUI.set(true)
|
||||
}
|
||||
loadedStore.set(true)
|
||||
|
||||
@@ -30,7 +30,7 @@ export const openPresetList = writable(false)
|
||||
export const openPersonaList = writable(false)
|
||||
export const MobileGUI = writable(false)
|
||||
export const MobileGUIStack = writable(0)
|
||||
export const MobileSideBar = writable(false)
|
||||
export const MobileSideBar = writable(0)
|
||||
//optimization
|
||||
export const CurrentCharacter = writable(null) as Writable<character | groupChat>
|
||||
export const CurrentSimpleCharacter = writable(null) as Writable<simpleCharacterArgument>
|
||||
@@ -50,6 +50,7 @@ export const UserIconProtrait = writable(false)
|
||||
export const CustomCSSStore = writable('')
|
||||
export const SafeModeStore = writable(false)
|
||||
export const MobileSearch = writable('')
|
||||
export const CharConfigSubMenu = writable(0)
|
||||
|
||||
let lastGlobalEnabledModules: string[] = []
|
||||
let lastChatEnabledModules: string[] = []
|
||||
|
||||
Reference in New Issue
Block a user