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

View File

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

View File

@@ -1264,6 +1264,7 @@ export type hubType = {
authorname?:string
original?:string
type:string
hidden?:boolean
}
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 {
if(!(await alertTOS())){
return
if(!arg.forceRedirect){
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', {
headers: {
"x-risu-api-version": "4"
@@ -1319,7 +1324,7 @@ export async function downloadRisuHub(id:string) {
})
checkCharOrder()
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
characterFormatUpdate(index);
selectedCharID.set(index);
@@ -1328,17 +1333,23 @@ export async function downloadRisuHub(id:string) {
}
const result = await res.json()
const data:CharacterCardV2Risu = result.card
const data:CharacterCardV3 = result.card
const img:string = result.img
data.data.extensions.risuRealmImportId = id
await importCharacterCardSpec(data, await getHubResources(img), 'hub')
checkCharOrder()
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
characterFormatUpdate(index);
selectedCharID.set(index);
}
alertStore.set({
type: 'none',
msg: ''
})
}
} catch (error) {
console.error(error)
alertError("Error while importing")

View File

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