Commit 0af1634c authored by KesaubeEire's avatar KesaubeEire

feat: 卡片图片路径错误重新引导.

parent 8635c2dd
<script> <script>
import { toast } from '@zerodevx/svelte-toast';
import { _tagTrans } from '../stores'; import { _tagTrans } from '../stores';
/**父属性: 主标题*/ /**父属性: 主标题*/
...@@ -46,10 +47,28 @@ ...@@ -46,10 +47,28 @@
fetch(folder + '/rpg_info/info.json', { method: 'GET' }) fetch(folder + '/rpg_info/info.json', { method: 'GET' })
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
console.log(data); console.log(title, data);
// window.open(folder + '/rpg_info/' + data[1]); // window.open(folder + '/rpg_info/' + data[1]);
}); });
} }
/**图片错误处理*/
function picErrorHandler() {
_picError = true;
fetch(folder + '/rpg_info/info.json', { method: 'GET' })
.then(response => response.json())
.then(data => {
console.log('> 更正图片:\t', title, folder, data);
cover = folder + '/rpg_info/' + data[0];
// window.open(folder + '/rpg_info/' + data[1]);
})
.catch(err => {
cover = '/favicon.ico';
console.log(err);
toast.push(`Error报错:\t[${err.toString()}]`);
});
}
</script> </script>
<div class="card w-80 bg-primary text-primary-content shadow-xl"> <div class="card w-80 bg-primary text-primary-content shadow-xl">
...@@ -59,10 +78,7 @@ ...@@ -59,10 +78,7 @@
src={cover ?? '/favicon.ico'} src={cover ?? '/favicon.ico'}
alt={title ?? 'default alt'} alt={title ?? 'default alt'}
style={_picError ? 'height: 240px; width: 320px;' : ''} style={_picError ? 'height: 240px; width: 320px;' : ''}
on:error={() => { on:error={picErrorHandler}
cover = '/favicon.ico';
_picError = true;
}}
on:click={getInfoPics} on:click={getInfoPics}
on:keypress={() => {}} on:keypress={() => {}}
/> />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment