Modify some parts of PR

This commit is contained in:
Kwaroran
2025-01-06 00:30:33 +09:00
parent c0e1311568
commit 2ec13a4550
7 changed files with 43 additions and 17 deletions

View File

@@ -98,6 +98,7 @@
"@tsconfig/svelte": "^3.0.0",
"@types/blueimp-md5": "^2.18.2",
"@types/codemirror": "^5.60.15",
"@types/diff": "^6.0.0",
"@types/dompurify": "^3.0.5",
"@types/libsodium-wrappers-sumo": "^0.7.8",
"@types/lodash": "^4.14.202",

8
pnpm-lock.yaml generated
View File

@@ -249,6 +249,9 @@ importers:
'@types/codemirror':
specifier: ^5.60.15
version: 5.60.15
'@types/diff':
specifier: ^6.0.0
version: 6.0.0
'@types/dompurify':
specifier: ^3.0.5
version: 3.0.5
@@ -1211,6 +1214,9 @@ packages:
'@types/codemirror@5.60.15':
resolution: {integrity: sha512-dTOvwEQ+ouKJ/rE9LT1Ue2hmP6H1mZv5+CCnNWu2qtiOe2LQa9lCprEY20HxiDmV/Bxh+dXjywmy5aKvoGjULA==}
'@types/diff@6.0.0':
resolution: {integrity: sha512-dhVCYGv3ZSbzmQaBSagrv1WJ6rXCdkyTcDyoNu1MD8JohI7pR7k8wdZEm+mvdxRKXyHVwckFzWU1vJc+Z29MlA==}
'@types/dompurify@3.0.5':
resolution: {integrity: sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==}
@@ -4865,6 +4871,8 @@ snapshots:
dependencies:
'@types/tern': 0.23.9
'@types/diff@6.0.0': {}
'@types/dompurify@3.0.5':
dependencies:
'@types/trusted-types': 2.0.7

View File

@@ -838,5 +838,7 @@ export const languageEnglish = {
showSavingIcon: "Show Saving Icon",
pluginVersionWarn: "This is {{plugin_version}} version of the plugin. which is not compatible with this version of RisuAI. please update the plugin to {{required_version}} version.",
imageTranslation: "Image Translation",
banCharacterset: 'Auto Regenerate On Characterset'
banCharacterset: 'Auto Regenerate On Characterset',
checkCorruption: "Check Corruption",
showPromptComparison: "Show Prompt Comparison",
}

View File

@@ -192,6 +192,10 @@
<Help key="dynamicAssets"/>
</Check>
</div>
<div class="flex items-center mt-4">
<Check bind:check={DBState.db.checkCorruption} name={language.checkCorruption}>
</Check>
</div>
{#if DBState.db?.account?.useSync}
<div class="flex items-center mt-4">
<Check bind:check={DBState.db.lightningRealmImport} name={"Lightning Realm Import"}>

View File

@@ -304,6 +304,10 @@
<Check bind:check={DBState.db.showSavingIcon} name={language.showSavingIcon}/>
</div>
<div class="flex items-center mt-2">
<Check bind:check={DBState.db.showPromptComparison} name={language.showPromptComparison}/>
</div>
{#if DBState.db.textScreenBorder}
<div class="flex items-center mt-2">
<Check check={true} onChange={() => {

View File

@@ -8,7 +8,6 @@
import { prebuiltPresets } from "src/ts/process/templates/templates";
import { ShowRealmFrameStore } from "src/ts/stores.svelte";
import type { PromptItem, PromptItemPlain, PromptItemChatML, PromptItemTyped, PromptItemAuthorNote, PromptItemChat } from "src/ts/process/prompt.ts";
import { diffWordsWithSpace, diffLines } from 'diff';
let editMode = $state(false)
interface Props {
@@ -112,7 +111,8 @@
return prompt
}
function checkDiff(prompt1: string, prompt2: string): string {
async function checkDiff(prompt1: string, prompt2: string): Promise<string> {
const { diffLines } = await import('diff')
const lineDiffs = diffLines(prompt1, prompt2)
let resultHtml = '';
@@ -123,7 +123,7 @@
if(linePart.removed){
const nextPart = lineDiffs[i + 1]
if(nextPart?.added){
resultHtml += `<div style="border-left: 4px solid blue; padding-left: 8px;">${highlightChanges(linePart.value, nextPart.value)}</div>`
resultHtml += `<div style="border-left: 4px solid blue; padding-left: 8px;">${await highlightChanges(linePart.value, nextPart.value)}</div>`
i++;
}
else{
@@ -148,7 +148,8 @@
return resultHtml
}
function highlightChanges(string1: string, string2: string) {
async function highlightChanges(string1: string, string2: string) {
const { diffWordsWithSpace } = await import('diff')
const charDiffs = diffWordsWithSpace(string1, string2)
return charDiffs
@@ -169,7 +170,7 @@
}
function handleDiffMode(id: number) {
async function handleDiffMode(id: number) {
if (selectedDiffPreset === id) {
selectedDiffPreset = -1
selectedPrompts = []
@@ -193,7 +194,7 @@
}
else{
alertWait("Loading...")
const result = checkDiff(selectedPrompts[0], prompt)
const result = await checkDiff(selectedPrompts[0], prompt)
alertMd(result)
selectedDiffPreset = -1
selectedPrompts = []
@@ -234,6 +235,7 @@
<span>{preset.name}</span>
{/if}
<div class="flex-grow flex justify-end">
{#if DBState.db.showPromptComparison}
<div class="{selectedDiffPreset === i ? 'text-green-500' : 'text-textcolor2 hover:text-green-500'} cursor-pointer mr-2" role="button" tabindex="0" onclick={(e) => {
e.stopPropagation()
handleDiffMode(i)
@@ -244,6 +246,7 @@
}}>
<GitCompare size={18}/>
</div>
{/if}
<div class="text-textcolor2 hover:text-green-500 cursor-pointer mr-2" role="button" tabindex="0" onclick={(e) => {
e.stopPropagation()
copyPreset(i)

View File

@@ -468,6 +468,8 @@ export function setDatabase(data:Database){
data.assetMaxDifference ??= 4
data.showSavingIcon ??= false
data.banCharacterset ??= []
data.showPromptComparison ??= false
data.checkCorruption ??= true
changeLanguage(data.language)
setDatabaseLite(data)
}
@@ -868,6 +870,8 @@ export interface Database{
showSavingIcon:boolean
presetRegex: customscript[]
banCharacterset:string[]
showPromptComparison:boolean
checkCorruption:boolean
}
interface SeparateParameters{