Skip to content

Commit

Permalink
v1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
050644zf committed Oct 11, 2024
1 parent 371e785 commit c9d3ee0
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 32 deletions.
4 changes: 2 additions & 2 deletions reader/src/ASTRv2/ASTR.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<n-layout class="site">
<n-config-provider :theme="rhineTheme">
<n-loading-bar-provider>
<n-dialog-provider>
<n-dialog-provider><n-message-provider>
<router-view></router-view>
</n-dialog-provider>
</n-message-provider></n-dialog-provider>
</n-loading-bar-provider>
<Footer></Footer>
</n-config-provider>
Expand Down
2 changes: 1 addition & 1 deletion reader/src/ASTRv2/astr-i18n
Submodule astr-i18n updated 2 files
+7 −2 en_US.json
+7 −2 zh_CN.json
93 changes: 65 additions & 28 deletions reader/src/ASTRv2/contentpage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
v-if="strMatch(line.prop, 'animtext')"
:inputline="line"
></Animtext>

<div class="blank" v-if="strMatch(line.prop, '__blank')" style="height: 15px"></div>

<!-- <div style="clear: both;"></div> -->
</div>
Expand Down Expand Up @@ -175,7 +175,7 @@ import {
ChevronLeftOutlined,
ChevronRightOutlined,
} from "@vicons/material";
import { useLoadingBar, useDialog } from "naive-ui";
import { useLoadingBar, useDialog, useMessage, messageDark } from "naive-ui";
import { defineComponent, ref } from "vue";
export default {
Expand All @@ -192,6 +192,7 @@ export default {
loading: true,
loadingbar: useLoadingBar(),
dialog: useDialog(),
message: useMessage(),
mdata: window.sessionStorage.getItem("menudata")
? JSON.parse(window.sessionStorage.getItem("menudata"))
: {},
Expand Down Expand Up @@ -253,33 +254,69 @@ export default {
methods: {
async getStoryData() {
this.loading = true;
fetch(
"https://raw.githubusercontent.com/050644zf/ArknightsStoryJson/main/" +
this.server +
"/gamedata/story/" +
this.path +
".json"
)
.then((res) => res.json())
.then((s) => {
this.data = s;
this.eventid = s.eventid;
})
.then(() => {
this.storyOpts = this.getStoryOpts();
this.loading = false;
this.loadingbar.finish();
this.scrollToHash();
})
.catch((e) => {
this.loadingbar.error();
console.log(e);
this.dialog.error({
title: "Fail to Load Story Data",
content:
"This maybe because the story is not availble in this server or the story is not exist. If you sure the story is exist in this server, please summit a issue. ",
});
// using await
try{
let res = await fetch(
"https://raw.githubusercontent.com/050644zf/ArknightsStoryJson/main/" +
this.server +
"/gamedata/story/" +
this.path +
".json"
);
let s = await res.json();
let altserver = func.alt;
if (altserver){
try{
let res2 = await fetch(
"https://raw.githubusercontent.com/050644zf/ArknightsStoryJson/main/" +
altserver +
"/gamedata/story/" +
this.path +
".json"
);
this.altserverdata = await res2.json();
// merge the alt server data into the main data in data.storyList
let newStoryList = [];
for (let i in s.storyList.length > this.altserverdata.storyList.length ? s.storyList : this.altserverdata.storyList) {
if (s.storyList[i]) {
newStoryList.push(s.storyList[i]);
}
// merge if prop is 'nameline' or 'subtitle'
if (this.altserverdata.storyList[i]) {
const prop = this.altserverdata.storyList[i].prop;
if (this.strMatch(prop, 'name') || this.strMatch(prop, 'subtitle')|| this.strMatch(prop, 'sticker') || this.strMatch(prop, 'multiline') || this.strMatch(prop, 'decision') || this.strMatch(prop, 'animtext')) {
newStoryList.push(this.altserverdata.storyList[i]);
newStoryList.push({ id: -1, prop: '__blank' });
}
}
}
let newStoryList2 = newStoryList.filter(e => e );
s.storyList = newStoryList2;
} catch (e) {
this.message.error(this.$t("contentpage.altLangLoadFail"));
}
}
this.data = s;
this.eventid = s.eventid;
this.storyOpts = this.getStoryOpts();
this.loading = false;
this.loadingbar.finish();
this.scrollToHash();
} catch (e) {
this.loadingbar.error();
console.log(e);
this.dialog.error({
title: this.$t("contentpage.dataLoadFail"),
content:
this.$t("contentpage.dataLoadFailDesc"),
});
}
},
getStoryOpts() {
var opts = [];
Expand Down
5 changes: 5 additions & 0 deletions reader/src/ASTRv2/func.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const rarity_colors = [
var urlParams = new URLSearchParams(window.location.search);
var server = urlParams.get("s");
var l = window.localStorage.getItem("lang");
var alt = window.localStorage.getItem("alt");
var doctor = window.localStorage.getItem("doctor");
var hidetip = window.localStorage.getItem("hidetip");
var showDelay = window.localStorage.getItem("showDelay");
Expand All @@ -54,6 +55,9 @@ const currentwversion = 13;
if (!server) {
server = "zh_CN";
}
if (!alt) {
alt = null;
}
if (!l || l == "none" || l == "Default") {
l = navigator.language.replace("-", "_");
}
Expand Down Expand Up @@ -106,6 +110,7 @@ export default {
professions_aceship: professions_aceship,
rarity_colors: rarity_colors,
l: l,
alt: alt,
langList: langList,
serverList: serverList,
server: server,
Expand Down
2 changes: 1 addition & 1 deletion reader/src/ASTRv2/header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</router-link>
<n-text depth="3" class="astrversion">
Arknights Story Text Reader <br />
Version 1.7
Version 1.9
</n-text>
</n-space>
</n-space>
Expand Down
5 changes: 5 additions & 0 deletions reader/src/ASTRv2/menupage/homepage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<n-collapse arrow-placement="right">
<n-collapse-item>
<template #header> 点击展开 / Click to Unfold </template>
<n-h4>v1.9</n-h4>
<n-oi>
<n-li>New Feature that can display alternative language when reading story. Now available in settings.</n-li>
<n-li>Add i18n keys for error.</n-li>
</n-oi>
<n-h4>v1.8.1</n-h4>
<n-oi>
<n-li>Add support for new property <n-text code>animtext</n-text>. <n-a href="https://github.com/050644zf/ArknightsStoryTextReader/issues/64">#64</n-a></n-li>
Expand Down
19 changes: 19 additions & 0 deletions reader/src/ASTRv2/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@
</n-radio-group>
</n-space>

<n-space vertical item-style="display: flex" justify="space-between">
<n-space item-style="display:flex;" align="center">
<n-icon>
<LangIcon />
</n-icon>
{{ $t('settings.altLang') }}:
<n-radio-group v-model:value="altLang">
<n-radio-button :key="NULL" :value="null">
{{ $t('settings.none') }}
</n-radio-button>
<n-radio-button v-for="lang in langOpts" :key="lang" :value="lang">
{{ lang }}
</n-radio-button>
</n-radio-group>
</n-space>
</n-space>

<n-space item-style="display:flex;" align="center">
<n-icon>
<MirrorIcon />
Expand Down Expand Up @@ -171,6 +188,7 @@ export default {
data() {
return {
currentLang: func.l,
altLang: func.alt,
langOpts: func.langList,
doctor: func.doctor,
showDelay: func.showDelay,
Expand Down Expand Up @@ -214,6 +232,7 @@ export default {
window.localStorage.setItem("mirror", this.mirror);
window.localStorage.setItem("hideName", this.hideName);
window.localStorage.setItem("lang", this.currentLang);
window.localStorage.setItem("alt", this.altLang);
window.localStorage.setItem("bgMode", this.bgMode);
window.localStorage.setItem("fontsize", this.fontsize);
window.localStorage.setItem("margin", this.margin);
Expand Down

0 comments on commit c9d3ee0

Please sign in to comment.