[feat] added asset width option
This commit is contained in:
@@ -344,5 +344,6 @@ export const languageEnglish = {
|
|||||||
noweb: "This feature cannot be used on web version.",
|
noweb: "This feature cannot be used on web version.",
|
||||||
createBotInternet: "Create Bot from Internet with AI",
|
createBotInternet: "Create Bot from Internet with AI",
|
||||||
createBotInternetAlert: "Please provide the character's name and the corresponding series/game.",
|
createBotInternetAlert: "Please provide the character's name and the corresponding series/game.",
|
||||||
able:"Able"
|
able:"Able",
|
||||||
|
assetWidth: "Asset Max Width",
|
||||||
}
|
}
|
||||||
@@ -63,6 +63,13 @@
|
|||||||
<SliderInput min={50} max={200} bind:value={$DataBase.iconsize} />
|
<SliderInput min={50} max={200} bind:value={$DataBase.iconsize} />
|
||||||
<span class="text-gray-400 mb-6 text-sm">{($DataBase.iconsize)}%</span>
|
<span class="text-gray-400 mb-6 text-sm">{($DataBase.iconsize)}%</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class="text-neutral-200">{language.assetWidth}</span>
|
||||||
|
<SliderInput min={-1} max={40} step={1} bind:value={$DataBase.assetWidth} />
|
||||||
|
<span class="text-gray-400 mb-6 text-sm">{
|
||||||
|
($DataBase.assetWidth === -1) ? "Unlimited" :
|
||||||
|
($DataBase.assetWidth === 0) ? "Hidden" : (`${($DataBase.assetWidth).toFixed(1)} rem`)}</span>
|
||||||
|
|
||||||
<div class="flex items-center mt-2">
|
<div class="flex items-center mt-2">
|
||||||
<Check bind:check={$DataBase.fullScreen} onChange={changeFullscreen} name={language.fullscreen}/>
|
<Check bind:check={$DataBase.fullScreen} onChange={changeFullscreen} name={language.fullscreen}/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -56,11 +56,14 @@ DOMPurify.addHook("uponSanitizeAttribute", (node, data) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function parseAdditionalAssets(data:string, char:character, mode:'normal'|'back'){
|
async function parseAdditionalAssets(data:string, char:character, mode:'normal'|'back'){
|
||||||
|
const db = get(DataBase)
|
||||||
|
const assetWidthString = (db.assetWidth && db.assetWidth !== -1 || db.assetWidth === 0) ? `max-width:${db.assetWidth}rem;` : ''
|
||||||
|
|
||||||
if(char.additionalAssets){
|
if(char.additionalAssets){
|
||||||
for(const asset of char.additionalAssets){
|
for(const asset of char.additionalAssets){
|
||||||
const assetPath = await getFileSrc(asset[1])
|
const assetPath = await getFileSrc(asset[1])
|
||||||
data = data.replaceAll(`{{raw::${asset[0]}}}`, assetPath).
|
data = data.replaceAll(`{{raw::${asset[0]}}}`, assetPath).
|
||||||
replaceAll(`{{img::${asset[0]}}}`,`<img src="${assetPath}" alt="${asset[0]}"/>`)
|
replaceAll(`{{img::${asset[0]}}}`,`<img src="${assetPath}" alt="${asset[0]}" style="${assetWidthString} "/>`)
|
||||||
.replaceAll(`{{video::${asset[0]}}}`,`<video controls autoplay loop><source src="${assetPath}" type="video/mp4"></video>`)
|
.replaceAll(`{{video::${asset[0]}}}`,`<video controls autoplay loop><source src="${assetPath}" type="video/mp4"></video>`)
|
||||||
.replaceAll(`{{audio::${asset[0]}}}`,`<audio controls autoplay loop><source src="${assetPath}" type="audio/mpeg"></audio>`)
|
.replaceAll(`{{audio::${asset[0]}}}`,`<audio controls autoplay loop><source src="${assetPath}" type="audio/mpeg"></audio>`)
|
||||||
if(mode === 'back'){
|
if(mode === 'back'){
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ export function setDatabase(data:Database){
|
|||||||
data.openrouterRequestModel ??= 'openai/gpt-3.5-turbo'
|
data.openrouterRequestModel ??= 'openai/gpt-3.5-turbo'
|
||||||
data.toggleConfirmRecommendedPreset ??= true
|
data.toggleConfirmRecommendedPreset ??= true
|
||||||
data.officialplugins ??= {}
|
data.officialplugins ??= {}
|
||||||
|
data.assetWidth ??= -1
|
||||||
changeLanguage(data.language)
|
changeLanguage(data.language)
|
||||||
DataBase.set(data)
|
DataBase.set(data)
|
||||||
}
|
}
|
||||||
@@ -574,6 +575,7 @@ export interface Database{
|
|||||||
name:string
|
name:string
|
||||||
icon:string
|
icon:string
|
||||||
}[]
|
}[]
|
||||||
|
assetWidth:number
|
||||||
}
|
}
|
||||||
|
|
||||||
interface hordeConfig{
|
interface hordeConfig{
|
||||||
|
|||||||
Reference in New Issue
Block a user