Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
R
rrpgLink_FrontEnd
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kesaubeeire
rrpgLink_FrontEnd
Commits
a7e59324
Commit
a7e59324
authored
Oct 21, 2023
by
KesaubeEire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: tag 汉化.
parent
93f8cf6d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
6 deletions
+32
-6
README.md
README.md
+1
-1
src/Content.svelte
src/Content.svelte
+17
-2
src/components/card.svelte
src/components/card.svelte
+9
-1
src/stores/index.js
src/stores/index.js
+5
-2
No files found.
README.md
View file @
a7e59324
...
...
@@ -57,7 +57,7 @@ npm run build:prod
-
[x] TAG
-
[x] 展示
-
[x] 搜索
-
[
] 汉化...
-
[
x] 汉化
-
[x] 主题切换
-
[x] 基础切换
-
[x] localstorage 记忆
...
...
src/Content.svelte
View file @
a7e59324
<script>
import Card from './components/card.svelte';
import { SvelteToast, toast } from '@zerodevx/svelte-toast';
import { _category, _env } from './stores';
import { _category, _env
, _tagTrans
} from './stores';
// -----------------------------
// 各种请求封装头 & 请求函数
...
...
@@ -12,6 +12,12 @@
params: { method: 'GET' }
};
/**请求封装头 -> 获取 TAG 翻译*/
const getTranslatedTag = {
url: `${$_env}/tag_translation.json`,
params: { method: 'GET' }
};
/**请求封装头 -> 获取所有资料*/
const getContentsRequest = {
url: `${$_env}/query.php?action=get`,
...
...
@@ -125,7 +131,7 @@
// -----------------------------
// NOTE: 初始化执行 -> 考虑用 onMount
// 初始化请求 -> 拉取所有分类
// TODO: 搞个记时, 每天一刷
// TODO: 搞个记时, 每天一刷
& 做一个主动更新的按钮
if (!$_category.length) {
createFetch(getLanguageCategory, data => {
if (process.env.APP_ENV === 'dev') console.log(data);
...
...
@@ -133,6 +139,15 @@
});
}
// 初始化请求 -> 拉取tag翻译
// TODO: 搞个记时, 每天一刷 & 做一个主动更新的按钮
if (!$_tagTrans.length) {
createFetch(getTranslatedTag, data => {
if (process.env.APP_ENV === 'dev') console.log(data);
$_tagTrans = data;
});
}
// 初始化请求 -> 拉取全部条目
createFetch(getContentsRequest, data => {
if (process.env.APP_ENV === 'dev') console.log(data);
...
...
src/components/card.svelte
View file @
a7e59324
<script>
import { _tagTrans } from '../stores';
/**父属性: 主标题*/
export let title;
/**父属性: 副标题*/
...
...
@@ -28,6 +30,12 @@
tags = raw_tags.slice(1, raw_tags.length - 1).split('|');
}
function getTransTag(tag) {
const res = $_tagTrans.filter(trans => trans.jp_tag_name == tag);
// if (res) console.log(res[0]);
return res[0]?.cn_tag_name;
}
// 图片错误 trigger
let _picError = false;
...
...
@@ -103,7 +111,7 @@
on:click={p_searchTag(tag)}
on:keypress={() => {}}
>
{tag}
{
getTransTag(tag) ??
tag}
</div>
{/each}
{/if}
...
...
src/stores/index.js
View file @
a7e59324
...
...
@@ -39,5 +39,8 @@ export const _theme = persistStore('_theme', "light");
/** 环境变量 */
export
const
_env
=
persistStore
(
'
_env
'
,
""
);
/**
环境变量
*/
/**
定时持久化: 分类
*/
export
const
_category
=
persistStore
(
'
_category
'
,
{});
/** 定时持久化: TAG 翻译 */
export
const
_tagTrans
=
persistStore
(
'
_tagTrans
'
,
{});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment