Commit aab5ec8d authored by JoyJ's avatar JoyJ

fix category

parent d6253128
Pipeline #23795 canceled with stages
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
// ----------------------------- // -----------------------------
let List = []; let List = [];
let categoryList = [];
/**获取所有资料*/ /**获取所有资料*/
const getContents = { const getContents = {
...@@ -18,6 +19,17 @@ ...@@ -18,6 +19,17 @@
} }
}; };
const getCategoryList = {
url: `${$_env}/query.php?action=get_category`,
params: {
method: 'GET',
headers: {
'Content-Type': 'application/json;charset=UTF-8',
'Access-Control-Allow-Origin': true
}
}
}
/**创建 fetch 函数 /**创建 fetch 函数
* @param {object} param0 参数对象 * @param {object} param0 参数对象
* @param {function} callback 回调函数 * @param {function} callback 回调函数
...@@ -46,6 +58,13 @@ ...@@ -46,6 +58,13 @@
}); });
} }
createFetch(getCategoryList, data => {
console.log(data);
data.forEach(function(category){
categoryList[category.id]=category.category_name;
});
})
createFetch(getContents, data => { createFetch(getContents, data => {
console.log(data); console.log(data);
showList(data); showList(data);
...@@ -54,6 +73,7 @@ ...@@ -54,6 +73,7 @@
function showList(data) { function showList(data) {
List = [...List, ...data]; List = [...List, ...data];
} }
</script> </script>
<!-- ----------------------------------------------- DOM ----------------------------------------------- --> <!-- ----------------------------------------------- DOM ----------------------------------------------- -->
...@@ -64,7 +84,7 @@ ...@@ -64,7 +84,7 @@
title={item.cn_name} title={item.cn_name}
sub_title={item.jp_name} sub_title={item.jp_name}
cover={$_env + item.folder + '/rpg_info/1.jpg' ?? ''} cover={$_env + item.folder + '/rpg_info/1.jpg' ?? ''}
language={item.category} language={categoryList[item.category] || "未知"}
raw_tags={item.tags} raw_tags={item.tags}
/> />
{/each} {/each}
......
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