feat: add module apply
This commit is contained in:
@@ -6,7 +6,7 @@ import { Capacitor } from "@capacitor/core"
|
||||
import { DataBase, type MessageGenerationInfo } from "./storage/database"
|
||||
|
||||
interface alertData{
|
||||
type: 'error'| 'normal'|'none'|'ask'|'wait'|'selectChar'|'input'|'toast'|'wait2'|'markdown'|'select'|'login'|'tos'|'cardexport'|'requestdata'|'addchar'|'hypaV2',
|
||||
type: 'error'| 'normal'|'none'|'ask'|'wait'|'selectChar'|'input'|'toast'|'wait2'|'markdown'|'select'|'login'|'tos'|'cardexport'|'requestdata'|'addchar'|'hypaV2'|'selectModule',
|
||||
msg: string,
|
||||
submsg?: string
|
||||
}
|
||||
@@ -269,6 +269,23 @@ export async function alertInput(msg:string){
|
||||
return get(alertStore).msg
|
||||
}
|
||||
|
||||
export async function alertModuleSelect(){
|
||||
|
||||
alertStore.set({
|
||||
'type': 'selectModule',
|
||||
'msg': ''
|
||||
})
|
||||
|
||||
while(true){
|
||||
if (get(alertStore).type === 'none'){
|
||||
break
|
||||
}
|
||||
await sleep(10)
|
||||
}
|
||||
|
||||
return get(alertStore).msg
|
||||
}
|
||||
|
||||
export function alertRequestData(info:AlertGenerationInfoStoreData){
|
||||
alertGenerationInfoStore.set(info)
|
||||
alertStore.set({
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { language } from "src/lang"
|
||||
import { alertConfirm, alertError, alertNormal } from "../alert"
|
||||
import { alertConfirm, alertError, alertModuleSelect, alertNormal } from "../alert"
|
||||
import { DataBase, setDatabase, type customscript, type loreBook, type triggerscript } from "../storage/database"
|
||||
import { downloadFile } from "../storage/globalApi"
|
||||
import { get } from "svelte/store"
|
||||
import { CurrentChat } from "../stores"
|
||||
import { CurrentCharacter, CurrentChat } from "../stores"
|
||||
import { selectSingleFile } from "../util"
|
||||
import { v4 } from "uuid"
|
||||
import { convertExternalLorebook } from "./lorebook"
|
||||
@@ -186,4 +186,42 @@ export function getModuleRegexScripts() {
|
||||
}
|
||||
}
|
||||
return customscripts
|
||||
}
|
||||
|
||||
export async function applyModule() {
|
||||
const sel = await alertModuleSelect()
|
||||
if (!sel) {
|
||||
return
|
||||
}
|
||||
|
||||
const module = structuredClone(getModuleById(sel))
|
||||
if (!module) {
|
||||
return
|
||||
}
|
||||
|
||||
const currentChar = get(CurrentCharacter)
|
||||
if (!currentChar) {
|
||||
return
|
||||
}
|
||||
if(currentChar.type === 'group'){
|
||||
return
|
||||
}
|
||||
|
||||
if (module.lorebook) {
|
||||
for (const lore of module.lorebook) {
|
||||
currentChar.globalLore.push(lore)
|
||||
}
|
||||
}
|
||||
if (module.regex) {
|
||||
for (const regex of module.regex) {
|
||||
currentChar.customscript.push(regex)
|
||||
}
|
||||
}
|
||||
if (module.trigger) {
|
||||
for (const trigger of module.trigger) {
|
||||
currentChar.triggerscript.push(trigger)
|
||||
}
|
||||
}
|
||||
|
||||
alertNormal(language.successApplyModule)
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import type { OobaChatCompletionRequestParams } from '../model/ooba';
|
||||
|
||||
export const DataBase = writable({} as any as Database)
|
||||
export const loadedStore = writable(false)
|
||||
export let appVer = "1.111.6"
|
||||
export let appVer = "1.111.7"
|
||||
export let webAppSubVer = ''
|
||||
|
||||
export function setDatabase(data:Database){
|
||||
|
||||
Reference in New Issue
Block a user