Basic Lite version

This commit is contained in:
kwaroran
2024-08-12 23:48:14 +09:00
parent 952ee5fb54
commit 2ab318188e
9 changed files with 128 additions and 19 deletions

3
.gitignore vendored
View File

@@ -41,4 +41,5 @@ recc.md
__pycache__/ __pycache__/
.tauri/ .tauri/
dist.zip dist.zip
scripts/ scripts/
.env

View File

@@ -13,6 +13,8 @@
import RealmFrame from './lib/UI/Realm/RealmFrame.svelte'; import RealmFrame from './lib/UI/Realm/RealmFrame.svelte';
import { AccountWarning } from './ts/storage/accountStorage'; import { AccountWarning } from './ts/storage/accountStorage';
import AccountWarningComp from './lib/Others/AccountWarningComp.svelte'; import AccountWarningComp from './lib/Others/AccountWarningComp.svelte';
import { isLite } from './ts/lite';
import LiteMain from './LiteMain.svelte';
let didFirstSetup: boolean = false let didFirstSetup: boolean = false
let gridOpen = false let gridOpen = false
@@ -36,8 +38,11 @@
</div> </div>
{:else if !didFirstSetup} {:else if !didFirstSetup}
<WelcomeRisu /> <WelcomeRisu />
{:else if $isLite}
<LiteMain />
{:else if $settingsOpen} {:else if $settingsOpen}
<Settings /> <Settings />
{:else} {:else}
{#if gridOpen} {#if gridOpen}
<GridChars endGrid={() => {gridOpen = false}} /> <GridChars endGrid={() => {gridOpen = false}} />

51
src/LiteMain.svelte Normal file
View File

@@ -0,0 +1,51 @@
<script lang="ts">
import { downloadRisuHub, getRisuHub } from "src/ts/characterCards";
import LiteCardIcon from "./lib/LiteUI/LiteCardIcon.svelte";
import { selectedCharID } from "./ts/stores";
import DefaultChatScreen from "./lib/ChatScreens/DefaultChatScreen.svelte";
</script>
<div class="w-full h-full bg-white text-black flex flex-col overflow-y-auto">
<div class="bg-blue-500 py-4">
<div class="container mx-auto flex items-center justify-between">
<h1 class="text-white text-2xl font-bold flex justify-center ml-4 sm:ml-0">
<a href="/">Lite Test</a>
</h1>
<nav class="mr-4 sm:mr-0">
<ul class="flex space-x-4">
<li><a class="text-white" href="/account">계정</a></li>
<!-- <li><a class="text-white">About</a></li>
<li><a class="text-white">Contact</a></li> -->
</ul>
</nav>
</div>
</div>
{#if $selectedCharID === -1}
<div class="flex w-full mt-2">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 ml-2 mr-2 flex-1">
{#await getRisuHub({
search: '',
page: 0,
nsfw: false,
sort: ''
})}
로딩중...
{:then cards}
{#each cards as card}
<LiteCardIcon card={card} on:click={async () => {
await downloadRisuHub(card.id, {
forceRedirect: true
})
}} />
{/each}
{/await}
</div>
</div>
{:else}
<div class="w-full flex justify-center flex-1">
<div class="h-full max-w-full" style:width="42rem">
<DefaultChatScreen customStyle={`backdrop-filter: blur(4px);`}/>
</div>
</div>
{/if}
</div>

View File

@@ -180,7 +180,7 @@
}}><ArrowLeftRightIcon size="18" /></button> }}><ArrowLeftRightIcon size="18" /></button>
</span> </span>
{:else if !blankMessage && !$HideIconStore} {:else if !blankMessage && !$HideIconStore}
<span class="chat text-xl unmargin">{name}</span> <span class="chat text-xl unmargin text-textcolor">{name}</span>
{/if} {/if}
<div class="flex-grow flex items-center justify-end text-textcolor2"> <div class="flex-grow flex items-center justify-end text-textcolor2">
<span class="text-xs">{statusMessage}</span> <span class="text-xs">{statusMessage}</span>

View File

@@ -0,0 +1,28 @@
<script lang="ts">
import type { hubType } from "src/ts/characterCards";
export let card: hubType
</script>
<button class="border p-4 flex hover:ring-2 rounded-md transition items-start justify-start" on:click>
<div class="bg-white rounded-md shadow-md p-4 relative w-32 h-48 min-w-32 min-h-48">
{#key card.img}
<img src={"https://sv.risuai.xyz/resource/" + card.img} alt={card.name} class="absolute inset-0 w-full h-full object-cover rounded-md">
{/key}
</div>
<div class="ml-4 mt-4 flex flex-col items-start text-start">
<h2 class="text-lg font-semibold break-all line-clamp-1">{card.name}</h2>
{#if card.hidden}
<span class="text-sm text-red-500 line-clamp-1 text-wrap max-w-full break-all whitespace-pre-wrap">Private</span>
{:else if card.authorname}
<span class="text-sm text-gray-500 line-clamp-1 text-wrap max-w-full break-all whitespace-pre-wrap">By {card.authorname}</span>
{/if}
<p class="text-xs text-gray-500 line-clamp-2 text-wrap max-w-full break-words whitespace-pre-wrap mt-2">{card.desc}</p>
<div class="mt-2 w-full flex flex-wrap">
{#each card.tags as tag}
{#if tag}
<button class="bg-gray-200 text-gray-800 text-xs font-semibold rounded-full p-2 mt-2 ml-2">{tag}</button>
{/if}
{/each}
</div>
</div>
</button>

View File

@@ -246,9 +246,9 @@ export async function alertCardExport(type:string = ''){
export async function alertTOS(){ export async function alertTOS(){
// if(localStorage.getItem('tos') === 'true'){ if(localStorage.getItem('tos') === 'true'){
// return true return true
// } }
alertStore.set({ alertStore.set({
'type': 'tos', 'type': 'tos',

View File

@@ -1264,6 +1264,7 @@ export type hubType = {
authorname?:string authorname?:string
original?:string original?:string
type:string type:string
hidden?:boolean
} }
export let hubAdditionalHTML = '' export let hubAdditionalHTML = ''
@@ -1293,15 +1294,19 @@ export async function getRisuHub(arg:{
} }
} }
export async function downloadRisuHub(id:string) { export async function downloadRisuHub(id:string, arg:{
forceRedirect?: boolean
} = {}) {
try { try {
if(!(await alertTOS())){ if(!arg.forceRedirect){
return if(!(await alertTOS())){
return
}
alertStore.set({
type: "wait",
msg: "Downloading..."
})
} }
alertStore.set({
type: "wait",
msg: "Downloading..."
})
const res = await fetch("https://realm.risuai.net/api/v1/download/png-v3/" + id + '?cors=true', { const res = await fetch("https://realm.risuai.net/api/v1/download/png-v3/" + id + '?cors=true', {
headers: { headers: {
"x-risu-api-version": "4" "x-risu-api-version": "4"
@@ -1319,7 +1324,7 @@ export async function downloadRisuHub(id:string) {
}) })
checkCharOrder() checkCharOrder()
let db = get(DataBase) let db = get(DataBase)
if(db.characters[db.characters.length-1] && db.goCharacterOnImport){ if(db.characters[db.characters.length-1] && (db.goCharacterOnImport || arg.forceRedirect)){
const index = db.characters.length-1 const index = db.characters.length-1
characterFormatUpdate(index); characterFormatUpdate(index);
selectedCharID.set(index); selectedCharID.set(index);
@@ -1328,17 +1333,23 @@ export async function downloadRisuHub(id:string) {
} }
const result = await res.json() const result = await res.json()
const data:CharacterCardV2Risu = result.card const data:CharacterCardV3 = result.card
const img:string = result.img const img:string = result.img
data.data.extensions.risuRealmImportId = id
await importCharacterCardSpec(data, await getHubResources(img), 'hub') await importCharacterCardSpec(data, await getHubResources(img), 'hub')
checkCharOrder() checkCharOrder()
let db = get(DataBase) let db = get(DataBase)
if(db.characters[db.characters.length-1] && db.goCharacterOnImport){ if(db.characters[db.characters.length-1] && (db.goCharacterOnImport || arg.forceRedirect)){
const index = db.characters.length-1 const index = db.characters.length-1
characterFormatUpdate(index); characterFormatUpdate(index);
selectedCharID.set(index); selectedCharID.set(index);
} alertStore.set({
type: 'none',
msg: ''
})
}
} catch (error) { } catch (error) {
console.error(error) console.error(error)
alertError("Error while importing") alertError("Error while importing")

View File

@@ -3,6 +3,7 @@ import { DataBase, setDatabase } from "../storage/database";
import { downloadFile } from "../storage/globalApi"; import { downloadFile } from "../storage/globalApi";
import { BufferToText, selectSingleFile } from "../util"; import { BufferToText, selectSingleFile } from "../util";
import { alertError } from "../alert"; import { alertError } from "../alert";
import { isLite } from "../lite";
export interface ColorScheme{ export interface ColorScheme{
bgcolor: string; bgcolor: string;
@@ -119,6 +120,10 @@ export function updateColorScheme(){
colorScheme = structuredClone(defaultColorScheme) colorScheme = structuredClone(defaultColorScheme)
} }
if(get(isLite)){
colorScheme = structuredClone(colorShemes.light)
}
//set css variables //set css variables
document.documentElement.style.setProperty("--risu-theme-bgcolor", colorScheme.bgcolor); document.documentElement.style.setProperty("--risu-theme-bgcolor", colorScheme.bgcolor);
document.documentElement.style.setProperty("--risu-theme-darkbg", colorScheme.darkbg); document.documentElement.style.setProperty("--risu-theme-darkbg", colorScheme.darkbg);
@@ -180,9 +185,11 @@ export function updateTextTheme(){
if(!root){ if(!root){
return return
} }
switch(db.textTheme){ let textTheme = get(isLite) ? 'standard' : db.textTheme
let colorScheme = get(isLite) ? 'light' : db.colorScheme.type
switch(textTheme){
case "standard":{ case "standard":{
if(db.colorScheme.type === 'dark'){ if(colorScheme === 'dark'){
root.style.setProperty('--FontColorStandard', '#fafafa'); root.style.setProperty('--FontColorStandard', '#fafafa');
root.style.setProperty('--FontColorItalic', '#8C8D93'); root.style.setProperty('--FontColorItalic', '#8C8D93');
root.style.setProperty('--FontColorBold', '#fafafa'); root.style.setProperty('--FontColorBold', '#fafafa');
@@ -200,7 +207,7 @@ export function updateTextTheme(){
break break
} }
case "highcontrast":{ case "highcontrast":{
if(db.colorScheme.type === 'dark'){ if(colorScheme === 'dark'){
root.style.setProperty('--FontColorStandard', '#f8f8f2'); root.style.setProperty('--FontColorStandard', '#f8f8f2');
root.style.setProperty('--FontColorItalic', '#F1FA8C'); root.style.setProperty('--FontColorItalic', '#F1FA8C');
root.style.setProperty('--FontColorBold', '#8BE9FD'); root.style.setProperty('--FontColorBold', '#8BE9FD');

6
src/ts/lite.ts Normal file
View File

@@ -0,0 +1,6 @@
import { writable } from "svelte/store";
if(import.meta.env.DEV){
console.log(`Lite Mode: ${import.meta.env.VITE_RISU_LITE}`)
}
export const isLite = writable(import.meta.env.VITE_RISU_LITE === 'TRUE')