修复网盘bug
This commit is contained in:
@@ -1,409 +1,543 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page" @swipe="back" @click="nextDialogue">
|
<div class="page" @swipe="back" @click="nextDialogue">
|
||||||
<image src="internal://files/{{Img}}"></image>
|
<image src="internal://files/{{Img}}"></image>
|
||||||
<image style="position: absolute;top: 300px;left: 0;" src="/common/text_bg.png" if="{{gameData.scenes[currentScene].choices == undefined && Img !== 'bg.png'}}"></image>
|
<image
|
||||||
<text style="position: absolute;height: 50px;top: 250px;left: 8px;font-size: 28px;color: #FFFFFF;font-weight: bold" if="{{gameData.scenes[currentScene].choices == undefined && Img !== 'bg.png'}}">{{character}}</text>
|
style="position: absolute; top: 300px; left: 0"
|
||||||
<scroll scroll-y="true" bounces="true" class="scroll" id="scroll" if="{{gameData.scenes[currentScene].choices == undefined && Img !== 'bg.png'}}">
|
src="/common/text_bg.png"
|
||||||
<text style="color: #FFFFFF;font-weight: bold;width: 100%;text-align: left;font-size: {{settings.textSize}}px;">{{showText}}</text>
|
if="{{gameData.scenes[currentScene].choices == undefined && Img !== 'bg.png'}}"></image>
|
||||||
</scroll>
|
<text
|
||||||
<div class="page" style="background-color: #000000;" @click="nextDialogue">
|
style="
|
||||||
|
position: absolute;
|
||||||
</div>
|
height: 50px;
|
||||||
|
top: 250px;
|
||||||
|
left: 8px;
|
||||||
|
font-size: 28px;
|
||||||
|
color: #ffffff;
|
||||||
|
font-weight: bold;
|
||||||
|
"
|
||||||
|
if="{{gameData.scenes[currentScene].choices == undefined && Img !== 'bg.png'}}">
|
||||||
|
{{ character }}
|
||||||
|
</text>
|
||||||
|
<scroll
|
||||||
|
scroll-y="true"
|
||||||
|
bounces="true"
|
||||||
|
class="scroll"
|
||||||
|
id="scroll"
|
||||||
|
if="{{gameData.scenes[currentScene].choices == undefined && Img !== 'bg.png'}}">
|
||||||
|
<text
|
||||||
|
style="color: #FFFFFF;font-weight: bold;width: 100%;text-align: left;font-size: {{settings.textSize}}px;">
|
||||||
|
{{ showText }}
|
||||||
|
</text>
|
||||||
|
</scroll>
|
||||||
|
<div
|
||||||
|
class="page"
|
||||||
|
style="background-color: #000000"
|
||||||
|
@click="nextDialogue"></div>
|
||||||
<!--选项页-->
|
<!--选项页-->
|
||||||
<div class="page" style="position: absolute;" if="{{gameData.scenes[currentScene].choices !== undefined}}">
|
<div
|
||||||
|
class="page"
|
||||||
|
style="position: absolute"
|
||||||
|
if="{{gameData.scenes[currentScene].choices !== undefined}}">
|
||||||
<!--选项1-->
|
<!--选项1-->
|
||||||
<text class="choice" @click="selectChoice(0)">{{gameData.scenes[currentScene].choices[0].text}}</text>
|
<text class="choice" @click="selectChoice(0)">
|
||||||
|
{{ gameData.scenes[currentScene].choices[0].text }}
|
||||||
|
</text>
|
||||||
<!--选项2-->
|
<!--选项2-->
|
||||||
<text class="choice" style="top: 210px;" @click="selectChoice(1)">{{gameData.scenes[currentScene].choices[1].text}}</text>
|
<text class="choice" style="top: 210px" @click="selectChoice(1)">
|
||||||
|
{{ gameData.scenes[currentScene].choices[1].text }}
|
||||||
|
</text>
|
||||||
</div>
|
</div>
|
||||||
<!--菜单页-->
|
<!--菜单页-->
|
||||||
<div class="page" style="position: absolute;flex-wrap: nowrap;flex-direction: column;justify-content: center;align-items: center;background-color: #ffffff;" if="{{menu}}">
|
<div
|
||||||
|
class="page"
|
||||||
|
style="
|
||||||
|
position: absolute;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
background-color: #ffffff;
|
||||||
|
"
|
||||||
|
if="{{menu}}">
|
||||||
<text class="menu-btn" @click="toRecoveryPage(1)">保存</text>
|
<text class="menu-btn" @click="toRecoveryPage(1)">保存</text>
|
||||||
<text class="menu-btn" @click="toRecoveryPage(2)">加载</text>
|
<text class="menu-btn" @click="toRecoveryPage(2)">加载</text>
|
||||||
<text class="menu-btn" @click="skipScene(1)">跳过场景</text>
|
<text class="menu-btn" @click="skipScene(1)">跳过场景</text>
|
||||||
<text class="menu-btn" @click="skipChapter(chapter+1)">跳过章节</text>
|
<text class="menu-btn" @click="skipChapter(chapter + 1)">跳过章节</text>
|
||||||
<text class="menu-btn" @click="back('m')">返回</text>
|
<text class="menu-btn" @click="back('m')">返回</text>
|
||||||
</div>
|
</div>
|
||||||
<div class="page" style="position: absolute;background-color: #ffffff;" if="{{recovery===1}}" @swipe="back()">
|
<div
|
||||||
|
class="page"
|
||||||
|
style="position: absolute; background-color: #ffffff"
|
||||||
|
if="{{recovery===1}}"
|
||||||
|
@swipe="back()">
|
||||||
<scroll scroll-y="true" bounces="true" class="scroll1 page">
|
<scroll scroll-y="true" bounces="true" class="scroll1 page">
|
||||||
<text class="menu-btn">长按删除存档</text>
|
<text class="menu-btn">长按删除存档</text>
|
||||||
<text class="menu-btn">点击存档覆盖</text>
|
<text class="menu-btn">点击存档覆盖</text>
|
||||||
<text class="menu-btn" for="{{recoveryData}}" style="font-size: 30px;" @click="saveRecoveryData($idx)" @longpress="deleteRecoveryData($idx)">存档{{$idx+1}}</text>
|
<text
|
||||||
|
class="menu-btn"
|
||||||
|
for="{{recoveryData}}"
|
||||||
|
style="font-size: 30px"
|
||||||
|
@click="saveRecoveryData($idx)"
|
||||||
|
@longpress="deleteRecoveryData($idx)">
|
||||||
|
存档{{ $idx + 1 }}
|
||||||
|
</text>
|
||||||
<text class="menu-btn" @click="saveRecoveryData('new')">+</text>
|
<text class="menu-btn" @click="saveRecoveryData('new')">+</text>
|
||||||
</scroll>
|
</scroll>
|
||||||
</div>
|
</div>
|
||||||
<div class="page" style="position: absolute;background-color: #ffffff;" if="{{recovery===2}}" @swipe="back()">
|
<div
|
||||||
|
class="page"
|
||||||
|
style="position: absolute; background-color: #ffffff"
|
||||||
|
if="{{recovery===2}}"
|
||||||
|
@swipe="back()">
|
||||||
<scroll scroll-y="true" bounces="true" class="scroll1 page">
|
<scroll scroll-y="true" bounces="true" class="scroll1 page">
|
||||||
<text class="menu-btn">点击读取存档</text>
|
<text class="menu-btn">点击读取存档</text>
|
||||||
<text class="menu-btn" for="{{recoveryData}}" style="font-size: 30px;" @click="loadRecoveryData($idx)" @longpress="consoleData($idx)">存档{{$idx+1}}</text>
|
<text
|
||||||
|
class="menu-btn"
|
||||||
|
for="{{recoveryData}}"
|
||||||
|
style="font-size: 30px"
|
||||||
|
@click="loadRecoveryData($idx)"
|
||||||
|
@longpress="consoleData($idx)">
|
||||||
|
存档{{ $idx + 1 }}
|
||||||
|
</text>
|
||||||
</scroll>
|
</scroll>
|
||||||
</div>
|
</div>
|
||||||
<div class="page" style="position: absolute;background-color: #ffffff;flex-wrap: nowrap;flex-direction: column;align-items: center;justify-content: center;" if="{{END != ''}}" @swipe="back()">
|
<div
|
||||||
<text style="font-size: 30px;text-align: center;color: #000000;">达成结局:{{END}}</text>
|
class="page"
|
||||||
<text style="font-size: 30px;text-align: center;color: #000000;" @click="back('e')">返回主页</text>
|
style="
|
||||||
|
position: absolute;
|
||||||
|
background-color: #ffffff;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
"
|
||||||
|
if="{{END != ''}}"
|
||||||
|
@swipe="back()">
|
||||||
|
<text style="font-size: 30px; text-align: center; color: #000000">
|
||||||
|
达成结局:{{ END }}
|
||||||
|
</text>
|
||||||
|
<text
|
||||||
|
style="font-size: 30px; text-align: center; color: #000000"
|
||||||
|
@click="back('e')">
|
||||||
|
返回主页
|
||||||
|
</text>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import router from '@blueos.app.appmanager.router';
|
import router from '@blueos.app.appmanager.router'
|
||||||
import storage from '@blueos.storage.storage';
|
import storage from '@blueos.storage.storage'
|
||||||
import prompt from '@blueos.window.prompt';
|
import prompt from '@blueos.window.prompt'
|
||||||
import file from '@blueos.storage.file';
|
import file from '@blueos.storage.file'
|
||||||
let t1;
|
let t1, t2, t3
|
||||||
export default {
|
export default {
|
||||||
data: {
|
data: {
|
||||||
gameData: {
|
gameData: {
|
||||||
scenes: [
|
scenes: [],
|
||||||
|
},
|
||||||
]
|
index: 0,
|
||||||
|
canContinue: true,
|
||||||
|
currentScene: 0,
|
||||||
|
currentDialogue: 0,
|
||||||
|
Img: 'bg.png',
|
||||||
|
showText: '',
|
||||||
|
character: '',
|
||||||
|
settings: {
|
||||||
|
textSpeed: 40,
|
||||||
|
textSize: 22,
|
||||||
|
},
|
||||||
|
chapter: 0,
|
||||||
|
menu: false,
|
||||||
|
recovery: 0,
|
||||||
|
choice: [],
|
||||||
|
recoveryData: [],
|
||||||
|
load: null,
|
||||||
|
END: '',
|
||||||
|
jsonDataList: [
|
||||||
|
'b999.json',
|
||||||
|
'b101.json',
|
||||||
|
'b102.json',
|
||||||
|
'b103.json',
|
||||||
|
'b111.json',
|
||||||
|
'b112.json',
|
||||||
|
'b113.json',
|
||||||
|
'b114.json',
|
||||||
|
'b121.json',
|
||||||
|
'b122.json',
|
||||||
|
'b123.json',
|
||||||
|
'b124.json',
|
||||||
|
'b200.json',
|
||||||
|
'b201.json',
|
||||||
|
'b202.json',
|
||||||
|
'b203.json',
|
||||||
|
'b204.json',
|
||||||
|
'b205.json',
|
||||||
|
'b206.json',
|
||||||
|
'b207.json',
|
||||||
|
'b301.json',
|
||||||
|
'b302.json',
|
||||||
|
'b303.json',
|
||||||
|
'b304.json',
|
||||||
|
'b401.json',
|
||||||
|
'b402.json',
|
||||||
|
'b403.json',
|
||||||
|
'b404.json',
|
||||||
|
'b405.json',
|
||||||
|
'b406.json',
|
||||||
|
'b407.json',
|
||||||
|
'b501.json',
|
||||||
|
'b601.json',
|
||||||
|
'b701.json',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
index: 0,
|
onInit() {
|
||||||
canContinue: true,
|
//
|
||||||
currentScene: 0,
|
router.clear()
|
||||||
currentDialogue: 0,
|
storage.get({
|
||||||
Img: 'bg.png',
|
key: 'recoveryData',
|
||||||
showText: '',
|
success: (data) => {
|
||||||
character: '',
|
if (data) {
|
||||||
settings: {
|
this.recoveryData = JSON.parse(data)
|
||||||
textSpeed: 40,
|
if (this.load) {
|
||||||
textSize: 22
|
if (this.load === 'TE') {
|
||||||
},
|
this.loadData('TE')
|
||||||
chapter: 0,
|
this.loadScene(this.currentScene)
|
||||||
menu: false,
|
} else {
|
||||||
recovery: 0,
|
this.loadRecoveryData(this.load)
|
||||||
choice: [],
|
}
|
||||||
recoveryData: [],
|
} else {
|
||||||
load: null,
|
this.loadData(this.chapter)
|
||||||
END: '',
|
this.loadScene(this.currentScene)
|
||||||
jsonDataList: [
|
|
||||||
'b999.json', 'b101.json', 'b102.json', 'b103.json', 'b111.json', 'b112.json', 'b113.json', 'b114.json',
|
|
||||||
'b121.json', 'b122.json', 'b123.json', 'b124.json', 'b200.json', 'b201.json', 'b202.json', 'b203.json',
|
|
||||||
'b204.json', 'b205.json', 'b206.json', 'b207.json', 'b301.json', 'b302.json', 'b303.json', 'b304.json',
|
|
||||||
'b401.json', 'b402.json', 'b403.json', 'b404.json', 'b405.json', 'b406.json', 'b407.json', 'b501.json',
|
|
||||||
'b601.json', 'b701.json'
|
|
||||||
],
|
|
||||||
},
|
|
||||||
onInit(){
|
|
||||||
//
|
|
||||||
router.clear();
|
|
||||||
storage.get({
|
|
||||||
key: 'recoveryData',
|
|
||||||
success: (data) => {
|
|
||||||
|
|
||||||
if(data){
|
|
||||||
this.recoveryData = JSON.parse(data);
|
|
||||||
if(this.load){
|
|
||||||
if(this.load === 'TE'){
|
|
||||||
this.loadData("TE");
|
|
||||||
this.loadScene(this.currentScene);
|
|
||||||
}
|
}
|
||||||
else{this.loadRecoveryData(this.load)}
|
} else {
|
||||||
|
this.loadData(this.chapter)
|
||||||
|
this.loadScene(this.currentScene)
|
||||||
}
|
}
|
||||||
else{
|
},
|
||||||
this.loadData(this.chapter);
|
fail: () => {},
|
||||||
this.loadScene(this.currentScene);
|
})
|
||||||
|
storage.get({
|
||||||
|
key: 'settings',
|
||||||
|
success: (data) => {
|
||||||
|
if (data) {
|
||||||
|
this.settings = JSON.parse(data)
|
||||||
}
|
}
|
||||||
}else{
|
},
|
||||||
|
fail: () => {},
|
||||||
this.loadData(this.chapter);
|
})
|
||||||
this.loadScene(this.currentScene);
|
},
|
||||||
}
|
async loadData(chapter) {
|
||||||
},
|
let num
|
||||||
fail:()=>{},
|
if (chapter == 'BE') {
|
||||||
});
|
num = 'b601.json'
|
||||||
storage.get({
|
} else if (chapter == 'TE') {
|
||||||
key: 'settings',
|
num = 'b701.json'
|
||||||
success: (data) => {
|
|
||||||
if(data){
|
|
||||||
this.settings = JSON.parse(data);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail:()=>{},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
async loadData(chapter){
|
|
||||||
let num;
|
|
||||||
if (chapter == "BE") {
|
|
||||||
num = 'b601.json';
|
|
||||||
} else if (chapter == "TE") {
|
|
||||||
num = 'b701.json';
|
|
||||||
} else {
|
|
||||||
num = this.jsonDataList[chapter];
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(num);
|
|
||||||
await file.readText({
|
|
||||||
uri: `internal://files/${num}`,
|
|
||||||
success: (data) =>{
|
|
||||||
this.gameData.scenes = JSON.parse(data.text);
|
|
||||||
//storage.getSync({ key: 'data' });
|
|
||||||
},
|
|
||||||
fail: function (_, code) {
|
|
||||||
prompt.showToast({message: code.toString()});
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
},
|
|
||||||
// 显示背景图
|
|
||||||
showBackground(image) {
|
|
||||||
this.Img = image;
|
|
||||||
},
|
|
||||||
// 显示对话
|
|
||||||
showDialogue(dialogue) {
|
|
||||||
this.showText = '';
|
|
||||||
this.character = dialogue.character;
|
|
||||||
this.canContinue = false;
|
|
||||||
this.index = 0;
|
|
||||||
this.zhuzi(dialogue.text);
|
|
||||||
},
|
|
||||||
zhuzi(text){
|
|
||||||
if (this.index < text.length){
|
|
||||||
this.showText += text.charAt(this.index);
|
|
||||||
this.index++;
|
|
||||||
t1 = setTimeout(() => {this.zhuzi(text);}, this.settings.textSpeed);
|
|
||||||
}
|
|
||||||
else{this.canContinue=true;}
|
|
||||||
},
|
|
||||||
onDestroy() {
|
|
||||||
// 解除内存占用
|
|
||||||
clearTimeout(t1);
|
|
||||||
},
|
|
||||||
// 加载场景
|
|
||||||
loadScene(sceneIndex) {
|
|
||||||
const scene = this.gameData.scenes[sceneIndex];
|
|
||||||
this.showBackground(scene.background);
|
|
||||||
this.currentDialogue = 0;
|
|
||||||
if(scene.choices){return}
|
|
||||||
this.showDialogue(scene.dialogues[this.currentDialogue]);
|
|
||||||
},
|
|
||||||
// 下一段对话
|
|
||||||
nextDialogue() {
|
|
||||||
if (this.canContinue) {
|
|
||||||
this.scrollToTop();//避免显示bug
|
|
||||||
this.canContinue = false;
|
|
||||||
const scene = this.gameData.scenes[this.currentScene];
|
|
||||||
if (this.currentDialogue < scene.dialogues.length - 1) {
|
|
||||||
this.currentDialogue++;
|
|
||||||
this.showDialogue(scene.dialogues[this.currentDialogue]);
|
|
||||||
} else if (this.currentScene < this.gameData.scenes.length - 1) {
|
|
||||||
if(scene.dialogues[this.currentDialogue].toScenes !== undefined){
|
|
||||||
console.log('跳转场景[选项]')
|
|
||||||
this.currentScene += scene.dialogues[this.currentDialogue].toScenes;
|
|
||||||
this.loadScene(this.currentScene);
|
|
||||||
}else{
|
|
||||||
console.log('跳转场景')
|
|
||||||
this.currentScene++;
|
|
||||||
this.loadScene(this.currentScene);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if(scene.dialogues[this.currentDialogue].END !== undefined){
|
num = this.jsonDataList[chapter]
|
||||||
this.END = scene.dialogues[this.currentDialogue].END;
|
}
|
||||||
this.getFin(this.END);
|
|
||||||
// 分支
|
|
||||||
}else if(scene.dialogues[this.currentDialogue].branch !== undefined){
|
|
||||||
console.log(this.choice)
|
|
||||||
console.log(scene.dialogues[this.currentDialogue].branch.choices)
|
|
||||||
if(JSON.stringify(this.choice)===JSON.stringify(scene.dialogues[this.currentDialogue].branch.choices)){
|
|
||||||
console.log('跳转章节[HE]')
|
|
||||||
this.chapter = scene.dialogues[this.currentDialogue].branch.toChapter;
|
|
||||||
this.loadData(this.chapter);
|
|
||||||
this.currentScene = 0;
|
|
||||||
this.currentDialogue = 0;
|
|
||||||
this.loadScene(this.currentScene);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
console.log('跳转章节[BE]')
|
|
||||||
this.chapter = "BE";
|
|
||||||
this.loadData(this.chapter);
|
|
||||||
this.currentScene = 0;
|
|
||||||
this.currentDialogue = 0;
|
|
||||||
this.loadScene(this.currentScene);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
this.Img = 'bg.png';
|
|
||||||
setTimeout(() => {
|
|
||||||
|
|
||||||
this.chapter++;
|
console.log(num)
|
||||||
this.loadData(this.chapter);
|
await file.readText({
|
||||||
this.currentScene = 0;
|
uri: `internal://files/${num}`,
|
||||||
this.currentDialogue = 0;
|
success: (data) => {
|
||||||
this.loadScene(this.currentScene);
|
this.gameData.scenes = JSON.parse(data.text)
|
||||||
}, 3000);
|
//storage.getSync({ key: 'data' });
|
||||||
|
},
|
||||||
|
fail: function (_, code) {
|
||||||
|
prompt.showToast({ message: code.toString() })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 显示背景图
|
||||||
|
showBackground(image) {
|
||||||
|
this.Img = image
|
||||||
|
},
|
||||||
|
// 显示对话
|
||||||
|
showDialogue(dialogue) {
|
||||||
|
this.showText = ''
|
||||||
|
this.character = dialogue.character
|
||||||
|
this.canContinue = false
|
||||||
|
this.index = 0
|
||||||
|
this.zhuzi(dialogue.text)
|
||||||
|
},
|
||||||
|
zhuzi(text) {
|
||||||
|
if (this.index < text.length) {
|
||||||
|
this.showText += text.charAt(this.index)
|
||||||
|
this.index++
|
||||||
|
t1 = setTimeout(() => {
|
||||||
|
this.zhuzi(text)
|
||||||
|
}, this.settings.textSpeed)
|
||||||
|
} else {
|
||||||
|
this.canContinue = true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDestroy() {
|
||||||
|
// 解除内存占用
|
||||||
|
clearTimeout(t1)
|
||||||
|
clearTimeout(t2)
|
||||||
|
clearTimeout(t3)
|
||||||
|
},
|
||||||
|
// 加载场景
|
||||||
|
loadScene(sceneIndex) {
|
||||||
|
const scene = this.gameData.scenes[sceneIndex]
|
||||||
|
this.showBackground(scene.background)
|
||||||
|
this.currentDialogue = 0
|
||||||
|
if (scene.choices) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.showDialogue(scene.dialogues[this.currentDialogue])
|
||||||
|
},
|
||||||
|
// 下一段对话
|
||||||
|
nextDialogue() {
|
||||||
|
if (this.canContinue) {
|
||||||
|
this.scrollToTop() //避免显示bug
|
||||||
|
this.canContinue = false
|
||||||
|
const scene = this.gameData.scenes[this.currentScene]
|
||||||
|
if (this.currentDialogue < scene.dialogues.length - 1) {
|
||||||
|
this.currentDialogue++
|
||||||
|
this.showDialogue(scene.dialogues[this.currentDialogue])
|
||||||
|
} else if (this.currentScene < this.gameData.scenes.length - 1) {
|
||||||
|
if (scene.dialogues[this.currentDialogue].toScenes !== undefined) {
|
||||||
|
console.log('跳转场景[选项]')
|
||||||
|
this.currentScene += scene.dialogues[this.currentDialogue].toScenes
|
||||||
|
this.loadScene(this.currentScene)
|
||||||
|
} else {
|
||||||
|
console.log('跳转场景')
|
||||||
|
this.currentScene++
|
||||||
|
this.loadScene(this.currentScene)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (scene.dialogues[this.currentDialogue].END !== undefined) {
|
||||||
|
this.END = scene.dialogues[this.currentDialogue].END
|
||||||
|
this.getFin(this.END)
|
||||||
|
// 分支
|
||||||
|
} else if (
|
||||||
|
scene.dialogues[this.currentDialogue].branch !== undefined
|
||||||
|
) {
|
||||||
|
console.log(this.choice)
|
||||||
|
console.log(scene.dialogues[this.currentDialogue].branch.choices)
|
||||||
|
if (
|
||||||
|
JSON.stringify(this.choice) ===
|
||||||
|
JSON.stringify(
|
||||||
|
scene.dialogues[this.currentDialogue].branch.choices
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
console.log('跳转章节[HE]')
|
||||||
|
this.chapter =
|
||||||
|
scene.dialogues[this.currentDialogue].branch.toChapter
|
||||||
|
this.loadData(this.chapter)
|
||||||
|
this.currentScene = 0
|
||||||
|
this.currentDialogue = 0
|
||||||
|
this.loadScene(this.currentScene)
|
||||||
|
} else {
|
||||||
|
console.log('跳转章节[BE]')
|
||||||
|
this.chapter = 'BE'
|
||||||
|
this.loadData(this.chapter)
|
||||||
|
this.currentScene = 0
|
||||||
|
this.currentDialogue = 0
|
||||||
|
this.loadScene(this.currentScene)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.Img = 'bg.png'
|
||||||
|
t2 = setTimeout(() => {
|
||||||
|
this.chapter++
|
||||||
|
this.loadData(this.chapter)
|
||||||
|
this.currentScene = 0
|
||||||
|
this.currentDialogue = 0
|
||||||
|
this.loadScene(this.currentScene)
|
||||||
|
}, 3000)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
back(a) {
|
||||||
back(a){
|
if (a == 'm' && this.menu) {
|
||||||
if(a=='m'&&this.menu){this.menu = false}
|
this.menu = false
|
||||||
else if(a.direction=='right'&&this.recovery!==0){this.recovery = 0}
|
} else if (a.direction == 'right' && this.recovery !== 0) {
|
||||||
else if(a.direction=='right'||a=='e'){router.replace({uri: "/pages/index"})}
|
this.recovery = 0
|
||||||
else if(a.direction=='left'){this.menu = true}
|
} else if (a.direction == 'right' || a == 'e') {
|
||||||
},
|
router.replace({ uri: '/pages/index' })
|
||||||
// 选择选项
|
} else if (a.direction == 'left') {
|
||||||
selectChoice(choiceIndex) {
|
this.menu = true
|
||||||
console.log('选择选项', choiceIndex)
|
}
|
||||||
this.choice.push(choiceIndex);
|
},
|
||||||
console.log(this.choice)
|
// 选择选项
|
||||||
const nextSceneIndex = this.gameData.scenes[this.currentScene].choices[choiceIndex].nextScene;
|
selectChoice(choiceIndex) {
|
||||||
this.currentScene += nextSceneIndex;
|
console.log('选择选项', choiceIndex)
|
||||||
this.loadScene(this.currentScene);
|
this.choice.push(choiceIndex)
|
||||||
},
|
console.log(this.choice)
|
||||||
toRecoveryPage(a){
|
const nextSceneIndex =
|
||||||
this.recovery = a;
|
this.gameData.scenes[this.currentScene].choices[choiceIndex].nextScene
|
||||||
},
|
this.currentScene += nextSceneIndex
|
||||||
saveRecoveryData(idx){
|
this.loadScene(this.currentScene)
|
||||||
const data = {
|
},
|
||||||
chapter: this.chapter,
|
toRecoveryPage(a) {
|
||||||
currentScene: this.currentScene,
|
this.recovery = a
|
||||||
currentDialogue: this.currentDialogue,
|
},
|
||||||
choice: this.choice,
|
saveRecoveryData(idx) {
|
||||||
}
|
const data = {
|
||||||
if(idx === 'new'){
|
chapter: this.chapter,
|
||||||
this.recoveryData.push(data);
|
currentScene: this.currentScene,
|
||||||
}else{
|
currentDialogue: this.currentDialogue,
|
||||||
this.recoveryData[idx] = data;
|
choice: this.choice,
|
||||||
}
|
}
|
||||||
this.saveData()
|
if (idx === 'new') {
|
||||||
prompt.showToast({
|
this.recoveryData.push(data)
|
||||||
message:"存档成功"
|
} else {
|
||||||
})
|
this.recoveryData[idx] = data
|
||||||
},
|
}
|
||||||
deleteRecoveryData(idx){
|
this.saveData()
|
||||||
this.recoveryData.splice(idx, 1);
|
prompt.showToast({
|
||||||
this.saveData()
|
message: '存档成功',
|
||||||
prompt.showToast({message: '删除成功'})
|
})
|
||||||
},
|
},
|
||||||
loadRecoveryData(idx){
|
deleteRecoveryData(idx) {
|
||||||
|
this.recoveryData.splice(idx, 1)
|
||||||
const data = this.recoveryData[parseInt(idx)];
|
this.saveData()
|
||||||
console.log('加载存档', data)
|
prompt.showToast({ message: '删除成功' })
|
||||||
this.chapter = data.chapter;
|
},
|
||||||
this.currentScene = data.currentScene;
|
loadRecoveryData(idx) {
|
||||||
this.currentDialogue = data.currentDialogue;
|
const data = this.recoveryData[parseInt(idx)]
|
||||||
this.choice = data.choice;
|
console.log('加载存档', data)
|
||||||
this.recovery = 0;
|
this.chapter = data.chapter
|
||||||
this.menu = false;
|
this.currentScene = data.currentScene
|
||||||
this.loadData(this.chapter);
|
this.currentDialogue = data.currentDialogue
|
||||||
this.loadScene(this.currentScene);
|
this.choice = data.choice
|
||||||
},
|
this.recovery = 0
|
||||||
skipScene(a){
|
this.menu = false
|
||||||
if(this.gameData.scenes[this.currentScene].dialogues[this.gameData.scenes[this.currentScene].dialogues.length-1].toScenes ==undefined && this.gameData.scenes[this.currentScene].choices==undefined && this.gameData.scenes[this.currentScene].dialogues[this.gameData.scenes[this.currentScene].dialogues.length-1].END==undefined && this.gameData.scenes[this.currentScene].dialogues[this.gameData.scenes[this.currentScene].dialogues.length-1].branch==undefined&&this.currentScene+a<this.gameData.scenes.length){
|
this.loadData(this.chapter)
|
||||||
this.currentScene+=a;
|
this.loadScene(this.currentScene)
|
||||||
this.loadScene(this.currentScene);
|
},
|
||||||
this.menu = false;
|
skipScene(a) {
|
||||||
}else{
|
if (
|
||||||
this.menu = false;
|
this.gameData.scenes[this.currentScene].dialogues[
|
||||||
prompt.showToast({message: '无法跳过'})
|
this.gameData.scenes[this.currentScene].dialogues.length - 1
|
||||||
}
|
].toScenes == undefined &&
|
||||||
},
|
this.gameData.scenes[this.currentScene].choices == undefined &&
|
||||||
skipChapter(a){
|
this.gameData.scenes[this.currentScene].dialogues[
|
||||||
this.Img = 'bg.png';
|
this.gameData.scenes[this.currentScene].dialogues.length - 1
|
||||||
this.menu = false;
|
].END == undefined &&
|
||||||
setTimeout(() => {
|
this.gameData.scenes[this.currentScene].dialogues[
|
||||||
this.chapter=a;
|
this.gameData.scenes[this.currentScene].dialogues.length - 1
|
||||||
this.loadData(this.chapter);
|
].branch == undefined &&
|
||||||
this.currentScene = 0;
|
this.currentScene + a < this.gameData.scenes.length
|
||||||
this.currentDialogue = 0;
|
) {
|
||||||
this.loadScene(this.currentScene);
|
this.currentScene += a
|
||||||
}, 3000);
|
this.loadScene(this.currentScene)
|
||||||
},
|
this.menu = false
|
||||||
saveData(){
|
} else {
|
||||||
storage.set({
|
this.menu = false
|
||||||
key: 'recoveryData',
|
prompt.showToast({ message: '无法跳过' })
|
||||||
value: JSON.stringify(this.recoveryData),
|
}
|
||||||
success: () => {},
|
},
|
||||||
fail:()=>{},
|
skipChapter(a) {
|
||||||
})
|
this.Img = 'bg.png'
|
||||||
},
|
this.menu = false
|
||||||
getFin(a){
|
t3 = setTimeout(() => {
|
||||||
let fin = {};
|
this.chapter = a
|
||||||
storage.get({
|
this.loadData(this.chapter)
|
||||||
key: 'fin',
|
this.currentScene = 0
|
||||||
success: (data) => {
|
this.currentDialogue = 0
|
||||||
if(data){
|
this.loadScene(this.currentScene)
|
||||||
fin = JSON.parse(data);
|
}, 3000)
|
||||||
}else{
|
},
|
||||||
fin = {"HE": false, "BE": false}
|
saveData() {
|
||||||
}
|
storage.set({
|
||||||
if(a=="Happy Ending"){
|
key: 'recoveryData',
|
||||||
fin.HE = true;
|
value: JSON.stringify(this.recoveryData),
|
||||||
}else if(a=="Bad Ending"){
|
success: () => {},
|
||||||
fin.BE = true;
|
fail: () => {},
|
||||||
}
|
})
|
||||||
this.saveFin(fin);
|
},
|
||||||
},
|
getFin(a) {
|
||||||
fail:()=>{},
|
let fin = {}
|
||||||
});
|
storage.get({
|
||||||
},
|
key: 'fin',
|
||||||
saveFin(a){
|
success: (data) => {
|
||||||
storage.set({
|
if (data) {
|
||||||
key: 'fin',
|
fin = JSON.parse(data)
|
||||||
value: JSON.stringify(a),
|
} else {
|
||||||
success: () => {},
|
fin = { HE: false, BE: false }
|
||||||
fail:()=>{},
|
}
|
||||||
})
|
if (a == 'Happy Ending') {
|
||||||
},
|
fin.HE = true
|
||||||
consoleData(idx){
|
} else if (a == 'Bad Ending') {
|
||||||
console.log('存档数据', this.recoveryData[idx])
|
fin.BE = true
|
||||||
},
|
}
|
||||||
scrollToTop() {
|
this.saveFin(fin)
|
||||||
this.$element('scroll').scrollTo({
|
},
|
||||||
top: 0,
|
fail: () => {},
|
||||||
left: 0,
|
})
|
||||||
behavior: 'instant'
|
},
|
||||||
})
|
saveFin(a) {
|
||||||
},
|
storage.set({
|
||||||
}
|
key: 'fin',
|
||||||
|
value: JSON.stringify(a),
|
||||||
|
success: () => {},
|
||||||
|
fail: () => {},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
consoleData(idx) {
|
||||||
|
console.log('存档数据', this.recoveryData[idx])
|
||||||
|
},
|
||||||
|
scrollToTop() {
|
||||||
|
this.$element('scroll').scrollTo({
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
behavior: 'instant',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.page {
|
.page {
|
||||||
width: 390px;
|
width: 390px;
|
||||||
height: 450px;
|
height: 450px;
|
||||||
}
|
}
|
||||||
.scroll{
|
.scroll {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
top: 300px;
|
top: 300px;
|
||||||
left: 8px;
|
left: 8px;
|
||||||
right: 8px;
|
right: 8px;
|
||||||
width: 390px;
|
width: 390px;
|
||||||
height: 155px;
|
height: 155px;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
.scroll1{
|
.scroll1 {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.choice {
|
.choice {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 250px;
|
width: 250px;
|
||||||
height: 61px;
|
height: 61px;
|
||||||
left: 43px;
|
left: 43px;
|
||||||
top: 100px;
|
top: 100px;
|
||||||
background-color: rgba(80, 192, 231, 0.7);
|
background-color: rgba(80, 192, 231, 0.7);
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.menu-btn {
|
.menu-btn {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
height: 61px;
|
height: 61px;
|
||||||
background-color: rgba(80, 192, 231, 0.7);
|
background-color: rgba(80, 192, 231, 0.7);
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -2,301 +2,424 @@
|
|||||||
<div class="page" @swipe="ban()">
|
<div class="page" @swipe="ban()">
|
||||||
<image src="/common/ev000b.png"></image>
|
<image src="/common/ev000b.png"></image>
|
||||||
<image
|
<image
|
||||||
style="position: absolute;top: 325px;left: 0;"
|
style="position: absolute; top: 325px; left: 0"
|
||||||
src="/common/text_bg.png"
|
src="/common/text_bg.png"></image>
|
||||||
></image>
|
|
||||||
<text class="text">显示速度({{ settings.textSpeed }}):</text>
|
<text class="text">显示速度({{ settings.textSpeed }}):</text>
|
||||||
<slider
|
<slider
|
||||||
class="slider"
|
class="slider"
|
||||||
min="20"
|
min="20"
|
||||||
max="60"
|
max="60"
|
||||||
step="1"
|
step="1"
|
||||||
onchange="changeTextSpeed()"
|
onchange="changeTextSpeed()"></slider>
|
||||||
></slider>
|
<text class="text" style="top: 163px">
|
||||||
<text class="text" style="top: 163px"
|
文字大小({{ settings.textSize }}):
|
||||||
>文字大小({{ settings.textSize }}):</text
|
</text>
|
||||||
>
|
|
||||||
<slider
|
<slider
|
||||||
class="slider"
|
class="slider"
|
||||||
style="top: 210px"
|
style="top: 210px"
|
||||||
min="20"
|
min="20"
|
||||||
max="32"
|
max="32"
|
||||||
step="1"
|
step="1"
|
||||||
onchange="changeTextSize()"
|
onchange="changeTextSize()"></slider>
|
||||||
></slider>
|
<text class="text" style="top: 15px; left: 60px" @click="saveSettings()">
|
||||||
<text class="text" style="top: 15px;left: 60px;" @click="saveSettings()"
|
保存
|
||||||
>保存</text
|
</text>
|
||||||
>
|
<text class="text" style="top: 15px; left: 175px" @click="back()">
|
||||||
<text class="text" style="top: 15px;left: 175px;" @click="back()"
|
退出
|
||||||
>退出</text
|
</text>
|
||||||
>
|
<text class="text" style="top: 15px; left: 280px" @click="gotolist()">
|
||||||
<text class="text" style="top: 15px;left: 280px;" @click="gotolist()"
|
去目录
|
||||||
>去目录</text
|
</text>
|
||||||
>
|
|
||||||
<text
|
<text
|
||||||
class="text"
|
class="text"
|
||||||
style="top: 250px;left:40px;color:red;"
|
style="top: 250px; left: 40px; color: red"
|
||||||
onclick="downloadFile(jsonDataList)"
|
onclick="downloadFile(jsonDataList)">
|
||||||
>下载文本</text
|
下载文本
|
||||||
>
|
</text>
|
||||||
<text
|
<text
|
||||||
class="text"
|
class="text"
|
||||||
style="top: 250px;left:250px;color:red;"
|
style="top: 250px; left: 250px; color: red"
|
||||||
onclick="downloadFile(jsonList)"
|
onclick="downloadFile(jsonList)">
|
||||||
>下载图像</text
|
下载图像
|
||||||
>
|
</text>
|
||||||
<scroll scroll-y="true" bounces="true" class="scroll">
|
<scroll scroll-y="true" bounces="true" class="scroll">
|
||||||
<text
|
<text
|
||||||
style="color: #FFFFFF;font-weight: bold;width: 100%;text-align: left;font-size: {{settings.textSize}}px;"
|
style="color: #FFFFFF;font-weight: bold;width: 100%;text-align: left;font-size: {{settings.textSize}}px;">
|
||||||
>{{ showText }}</text
|
{{ showText }}
|
||||||
>
|
</text>
|
||||||
</scroll>
|
</scroll>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import storage from '@blueos.storage.storage';
|
import storage from '@blueos.storage.storage'
|
||||||
import prompt from '@blueos.window.prompt';
|
import prompt from '@blueos.window.prompt'
|
||||||
import router from '@blueos.app.appmanager.router';
|
import router from '@blueos.app.appmanager.router'
|
||||||
import file from '@blueos.storage.file';
|
import file from '@blueos.storage.file'
|
||||||
import fetch from '@blueos.network.fetch';
|
import fetch from '@blueos.network.fetch'
|
||||||
import brightness from '@blueos.hardware.display.brightness';
|
import brightness from '@blueos.hardware.display.brightness'
|
||||||
var send = async (url, data, method = 'GET', responseType = 'text') => {
|
var send = async (url, data, method = 'GET', responseType = 'text') => {
|
||||||
console.log('send', url, method, responseType);
|
console.log('send', url, method, responseType)
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
fetch.fetch({
|
|
||||||
url: url,
|
|
||||||
data: method === 'GET' ? data : JSON.stringify(data),
|
|
||||||
method,
|
|
||||||
responseType,
|
|
||||||
success: function (response) {
|
|
||||||
console.log(`the status code of the response: ${response.code}`)
|
|
||||||
resolve(response.data);
|
|
||||||
},
|
|
||||||
fail: function (data, code) {
|
|
||||||
console.log(`${url} handling fail, errMsg = ${data}`);
|
|
||||||
console.log(`handling fail, errCode = ${code}`)
|
|
||||||
reject(data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
let t1, t2;
|
|
||||||
export default {
|
|
||||||
data: {
|
|
||||||
recovery: false,
|
|
||||||
settingsPage: true,
|
|
||||||
settings: {
|
|
||||||
textSpeed: 40,
|
|
||||||
textSize: 22
|
|
||||||
},
|
|
||||||
showText: '',
|
|
||||||
index: 0,
|
|
||||||
tips: false,
|
|
||||||
trueEnd: false,
|
|
||||||
jsonList: ['ATd1p1f1.png', 'ATRI_TrueEnding.png', 'bg.png', 'bg001.png', 'bg001d.png', 'bg001de.png', 'bg001e.png', 'bg001n.png', 'bg001y.png', 'bg002.png', 'bg002n2.png', 'bg003a.png', 'bg003an.png', 'bg004.png', 'bg004n2.png', 'bg005.png', 'bg005a.png', 'bg005n2.png', 'bg006.png', 'bg007.png', 'bg007c.png', 'bg007n.png', 'bg008.png', 'bg009.png', 'bg009e.png', 'bg009n.png', 'bg010.png', 'bg011a.png', 'bg011e.png', 'bg012.png', 'bg013.png', 'bg014a.png', 'bg015.png', 'bg015c.png', 'bg015n.png', 'bg015t.png', 'bg016a.png', 'bg017a.png', 'bg017b.png', 'bg017c.png', 'bg017n.png', 'bg017z.png', 'ev000b.png', 'ev001a.png', 'ev002b.png', 'ev003a.png', 'ev003b.png', 'ev003d.png', 'ev003f.png', 'ev004a.png', 'ev005a.png', 'ev006a.png', 'ev007a.png', 'ev008c.png', 'ev009a.png', 'ev010b.png', 'ev011c.png', 'ev012c.png', 'ev013a.png', 'ev014b.png', 'ev015a.png', 'ev016a.png', 'ev017a.png', 'ev018a.png', 'ev019a.png', 'ev020a.png', 'ev021a.png', 'ev101a.png', 'ev102a.png', 'ev103a.png', 'hurt.png', 'item020a.png', 'item028.png', 'item032a_0.png', 'item033b.png', 'item039b.png', 'item059b.png', 'item069a.png', 'item069b.png', 'item091a.png', 'item099.png', 'itemATRI.png', 'mask_dageki02ji.png', 'mask_yuge.png', 'none.png', 'none1.png', 'none2.png', 'sd004a.png', 'sd005a.png'],
|
|
||||||
fileList: null,
|
|
||||||
jsonDataList: [
|
|
||||||
'b999.json', 'b101.json', 'b102.json', 'b103.json', 'b111.json', 'b112.json', 'b113.json', 'b114.json',
|
|
||||||
'b121.json', 'b122.json', 'b123.json', 'b124.json', 'b200.json', 'b201.json', 'b202.json', 'b203.json',
|
|
||||||
'b204.json', 'b205.json', 'b206.json', 'b207.json', 'b301.json', 'b302.json', 'b303.json', 'b304.json',
|
|
||||||
'b401.json', 'b402.json', 'b403.json', 'b404.json', 'b405.json', 'b406.json', 'b407.json', 'b501.json',
|
|
||||||
'b601.json', 'b701.json'
|
|
||||||
]
|
|
||||||
,
|
|
||||||
missingFiles: []
|
|
||||||
},
|
|
||||||
async downloadJson(name) {
|
|
||||||
var cb;
|
|
||||||
var p = new Promise(resolve => cb = resolve);
|
|
||||||
// let byteSize = await send(`/photobyte/${id}`, null, 'GET', 'json')
|
|
||||||
await send(`http://download.chorblack.top/pd/local/atri/${name}`, null, 'GET', 'json').then(res => {
|
|
||||||
cb(res);
|
|
||||||
file.writeText({
|
|
||||||
uri: `internal://files/${name}`,
|
|
||||||
text: JSON.stringify(res),
|
|
||||||
success: function () {
|
|
||||||
},
|
|
||||||
fail: function (_, code) {
|
|
||||||
prompt.showToast({
|
|
||||||
message: `下载失败:${code}`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return await p;
|
|
||||||
},
|
|
||||||
async getFile(fileName) {
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
file.get({
|
fetch.fetch({
|
||||||
uri: `internal://files/${fileName}`,
|
url: url,
|
||||||
success: () => {
|
data: method === 'GET' ? data : JSON.stringify(data),
|
||||||
resolve(true);
|
method,
|
||||||
},
|
responseType,
|
||||||
fail: (_, code) => {
|
success: function (response) {
|
||||||
reject(`handling fail, code = ${code}`);
|
console.log(`the status code of the response: ${response.code}`)
|
||||||
},
|
resolve(response.data)
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
async downloadFile(data) {
|
|
||||||
prompt.showToast({ message: "开始下载" });
|
|
||||||
//await this.downloadJson('b999.json');
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
|
||||||
const fileName = data[i];
|
|
||||||
let isInFile = false;
|
|
||||||
try {
|
|
||||||
isInFile = await this.getFile(fileName);
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
if (!isInFile) {
|
|
||||||
try {
|
|
||||||
if (fileName.includes('.json')) {
|
|
||||||
await this.downloadJson(fileName);
|
|
||||||
} else {
|
|
||||||
await this.downloadPhoto(fileName);
|
|
||||||
}
|
|
||||||
prompt.showToast({
|
|
||||||
message: `还剩${data.length - i - 1}`
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`下载失败: ${fileName}`, error);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
prompt.showToast({
|
|
||||||
message: `下载完成`
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async downloadPhoto(name) {
|
|
||||||
var cb;
|
|
||||||
var p = new Promise(resolve => cb = resolve);
|
|
||||||
// let byteSize = await send(`/photobyte/${id}`, null, 'GET', 'json')
|
|
||||||
await send(`http://download.chorblack.top/pd/local/atri/${name}`, null, 'GET', 'arraybuffer').then(res => {
|
|
||||||
if (res.byteLength === 0) {
|
|
||||||
throw new Error('empty image');
|
|
||||||
}
|
|
||||||
cb(res);
|
|
||||||
file.writeArrayBuffer({
|
|
||||||
uri: `internal://files/${name}`,
|
|
||||||
buffer: new Uint8Array(res),
|
|
||||||
success: function () {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
fail: function (_, code) {
|
fail: function (data, code) {
|
||||||
prompt.showToast({
|
console.log(`${url} handling fail, errMsg = ${data}`)
|
||||||
message: `下载失败:${code}`
|
console.log(`handling fail, errCode = ${code}`)
|
||||||
})
|
reject(data)
|
||||||
}
|
},
|
||||||
});
|
})
|
||||||
});
|
|
||||||
return await p;
|
|
||||||
},
|
|
||||||
gotolist() {
|
|
||||||
router.push({
|
|
||||||
uri: '/pages/list',
|
|
||||||
|
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
onInit() {
|
let t1, t2
|
||||||
brightness.setKeepScreenOn({
|
export default {
|
||||||
keepScreenOn: true,
|
data: {
|
||||||
});
|
recovery: false,
|
||||||
storage.get({
|
settingsPage: true,
|
||||||
key: 'settings',
|
settings: {
|
||||||
success: (data) => {
|
textSpeed: 40,
|
||||||
if (data) {
|
textSize: 22,
|
||||||
this.settings = JSON.parse(data);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
fail: () => { },
|
showText: '',
|
||||||
});
|
index: 0,
|
||||||
this.zhuzi();
|
tips: false,
|
||||||
},
|
trueEnd: false,
|
||||||
zhuzi() {
|
jsonList: [
|
||||||
const text = `Atri -My Dear Moments-\n文字显示样本`
|
'ATd1p1f1.png',
|
||||||
if (this.index < text.length) {
|
'ATRI_TrueEnding.png',
|
||||||
this.showText += text.charAt(this.index);
|
'bg.png',
|
||||||
this.index++;
|
'bg001.png',
|
||||||
t1 = setTimeout(() => { this.zhuzi() }, this.settings.textSpeed)
|
'bg001d.png',
|
||||||
}
|
'bg001de.png',
|
||||||
else {
|
'bg001e.png',
|
||||||
if (this.settingsPage) {
|
'bg001n.png',
|
||||||
t2 = setTimeout(() => {
|
'bg001y.png',
|
||||||
this.index = 0;
|
'bg002.png',
|
||||||
this.showText = '';
|
'bg002n2.png',
|
||||||
this.zhuzi()
|
'bg003a.png',
|
||||||
}, 2000);
|
'bg003an.png',
|
||||||
|
'bg004.png',
|
||||||
|
'bg004n2.png',
|
||||||
|
'bg005.png',
|
||||||
|
'bg005a.png',
|
||||||
|
'bg005n2.png',
|
||||||
|
'bg006.png',
|
||||||
|
'bg007.png',
|
||||||
|
'bg007c.png',
|
||||||
|
'bg007n.png',
|
||||||
|
'bg008.png',
|
||||||
|
'bg009.png',
|
||||||
|
'bg009e.png',
|
||||||
|
'bg009n.png',
|
||||||
|
'bg010.png',
|
||||||
|
'bg011a.png',
|
||||||
|
'bg011e.png',
|
||||||
|
'bg012.png',
|
||||||
|
'bg013.png',
|
||||||
|
'bg014a.png',
|
||||||
|
'bg015.png',
|
||||||
|
'bg015c.png',
|
||||||
|
'bg015n.png',
|
||||||
|
'bg015t.png',
|
||||||
|
'bg016a.png',
|
||||||
|
'bg017a.png',
|
||||||
|
'bg017b.png',
|
||||||
|
'bg017c.png',
|
||||||
|
'bg017n.png',
|
||||||
|
'bg017z.png',
|
||||||
|
'ev000b.png',
|
||||||
|
'ev001a.png',
|
||||||
|
'ev002b.png',
|
||||||
|
'ev003a.png',
|
||||||
|
'ev003b.png',
|
||||||
|
'ev003d.png',
|
||||||
|
'ev003f.png',
|
||||||
|
'ev004a.png',
|
||||||
|
'ev005a.png',
|
||||||
|
'ev006a.png',
|
||||||
|
'ev007a.png',
|
||||||
|
'ev008c.png',
|
||||||
|
'ev009a.png',
|
||||||
|
'ev010b.png',
|
||||||
|
'ev011c.png',
|
||||||
|
'ev012c.png',
|
||||||
|
'ev013a.png',
|
||||||
|
'ev014b.png',
|
||||||
|
'ev015a.png',
|
||||||
|
'ev016a.png',
|
||||||
|
'ev017a.png',
|
||||||
|
'ev018a.png',
|
||||||
|
'ev019a.png',
|
||||||
|
'ev020a.png',
|
||||||
|
'ev021a.png',
|
||||||
|
'ev101a.png',
|
||||||
|
'ev102a.png',
|
||||||
|
'ev103a.png',
|
||||||
|
'hurt.png',
|
||||||
|
'item020a.png',
|
||||||
|
'item028.png',
|
||||||
|
'item032a_0.png',
|
||||||
|
'item033b.png',
|
||||||
|
'item039b.png',
|
||||||
|
'item059b.png',
|
||||||
|
'item069a.png',
|
||||||
|
'item069b.png',
|
||||||
|
'item091a.png',
|
||||||
|
'item099.png',
|
||||||
|
'itemATRI.png',
|
||||||
|
'mask_dageki02ji.png',
|
||||||
|
'mask_yuge.png',
|
||||||
|
'none.png',
|
||||||
|
'none1.png',
|
||||||
|
'none2.png',
|
||||||
|
'sd004a.png',
|
||||||
|
'sd005a.png',
|
||||||
|
],
|
||||||
|
fileList: null,
|
||||||
|
jsonDataList: [
|
||||||
|
'b999.json',
|
||||||
|
'b101.json',
|
||||||
|
'b102.json',
|
||||||
|
'b103.json',
|
||||||
|
'b111.json',
|
||||||
|
'b112.json',
|
||||||
|
'b113.json',
|
||||||
|
'b114.json',
|
||||||
|
'b121.json',
|
||||||
|
'b122.json',
|
||||||
|
'b123.json',
|
||||||
|
'b124.json',
|
||||||
|
'b200.json',
|
||||||
|
'b201.json',
|
||||||
|
'b202.json',
|
||||||
|
'b203.json',
|
||||||
|
'b204.json',
|
||||||
|
'b205.json',
|
||||||
|
'b206.json',
|
||||||
|
'b207.json',
|
||||||
|
'b301.json',
|
||||||
|
'b302.json',
|
||||||
|
'b303.json',
|
||||||
|
'b304.json',
|
||||||
|
'b401.json',
|
||||||
|
'b402.json',
|
||||||
|
'b403.json',
|
||||||
|
'b404.json',
|
||||||
|
'b405.json',
|
||||||
|
'b406.json',
|
||||||
|
'b407.json',
|
||||||
|
'b501.json',
|
||||||
|
'b601.json',
|
||||||
|
'b701.json',
|
||||||
|
],
|
||||||
|
missingFiles: [],
|
||||||
|
},
|
||||||
|
async downloadJson(name) {
|
||||||
|
var cb
|
||||||
|
var p = new Promise((resolve) => (cb = resolve))
|
||||||
|
// let byteSize = await send(`/photobyte/${id}`, null, 'GET', 'json')
|
||||||
|
await send(
|
||||||
|
`http://download.chorblack.top/directlink/local/atri/${name}`,
|
||||||
|
null,
|
||||||
|
'GET',
|
||||||
|
'json'
|
||||||
|
).then((res) => {
|
||||||
|
cb(res)
|
||||||
|
file.writeText({
|
||||||
|
uri: `internal://files/${name}`,
|
||||||
|
text: JSON.stringify(res),
|
||||||
|
success: function () {},
|
||||||
|
fail: function (_, code) {
|
||||||
|
prompt.showToast({
|
||||||
|
message: `下载失败:${code}`,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return await p
|
||||||
|
},
|
||||||
|
async getFile(fileName) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
file.get({
|
||||||
|
uri: `internal://files/${fileName}`,
|
||||||
|
success: () => {
|
||||||
|
resolve(true)
|
||||||
|
},
|
||||||
|
fail: (_, code) => {
|
||||||
|
reject(`handling fail, code = ${code}`)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async downloadFile(data) {
|
||||||
|
prompt.showToast({ message: '开始下载' })
|
||||||
|
//await this.downloadJson('b999.json');
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
const fileName = data[i]
|
||||||
|
let isInFile = false
|
||||||
|
try {
|
||||||
|
isInFile = await this.getFile(fileName)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
if (!isInFile) {
|
||||||
|
try {
|
||||||
|
if (fileName.includes('.json')) {
|
||||||
|
await this.downloadJson(fileName)
|
||||||
|
} else {
|
||||||
|
await this.downloadPhoto(fileName)
|
||||||
|
}
|
||||||
|
prompt.showToast({
|
||||||
|
message: `还剩${data.length - i - 1}`,
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`下载失败: ${fileName}`, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
prompt.showToast({
|
||||||
},
|
message: `下载完成`,
|
||||||
onDestroy() {
|
})
|
||||||
// 解除内存占用
|
},
|
||||||
clearTimeout(t1)
|
async downloadPhoto(name) {
|
||||||
clearInterval(t2)
|
var cb
|
||||||
},
|
var p = new Promise((resolve) => (cb = resolve))
|
||||||
exit() {
|
// let byteSize = await send(`/photobyte/${id}`, null, 'GET', 'json')
|
||||||
this.$app.exit()
|
await send(
|
||||||
},
|
`http://download.chorblack.top/directlink/local/atri/${name}`,
|
||||||
ban() {
|
null,
|
||||||
console.log('ban')
|
'GET',
|
||||||
},
|
'arraybuffer'
|
||||||
back() {
|
).then((res) => {
|
||||||
brightness.setKeepScreenOn({
|
if (res.byteLength === 0) {
|
||||||
keepScreenOn: false,
|
throw new Error('empty image')
|
||||||
})
|
}
|
||||||
router.replace({ uri: `pages/index` })
|
cb(res)
|
||||||
},
|
file.writeArrayBuffer({
|
||||||
changeTextSize(e) {
|
uri: `internal://files/${name}`,
|
||||||
this.settings.textSize = e.progress;
|
buffer: new Uint8Array(res),
|
||||||
},
|
success: function () {},
|
||||||
changeTextSpeed(e) {
|
fail: function (_, code) {
|
||||||
this.settings.textSpeed = e.progress;
|
prompt.showToast({
|
||||||
},
|
message: `下载失败:${code}`,
|
||||||
saveSettings() {
|
})
|
||||||
storage.set({
|
},
|
||||||
key: 'settings',
|
})
|
||||||
value: JSON.stringify(this.settings),
|
})
|
||||||
success: () => { prompt.showToast({ message: '保存成功' }) },
|
return await p
|
||||||
fail: () => { },
|
},
|
||||||
})
|
gotolist() {
|
||||||
},
|
router.push({
|
||||||
}
|
uri: '/pages/list',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onInit() {
|
||||||
|
brightness.setKeepScreenOn({
|
||||||
|
keepScreenOn: true,
|
||||||
|
})
|
||||||
|
storage.get({
|
||||||
|
key: 'settings',
|
||||||
|
success: (data) => {
|
||||||
|
if (data) {
|
||||||
|
this.settings = JSON.parse(data)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: () => {},
|
||||||
|
})
|
||||||
|
this.zhuzi()
|
||||||
|
},
|
||||||
|
zhuzi() {
|
||||||
|
const text = `Atri -My Dear Moments-\n文字显示样本`
|
||||||
|
if (this.index < text.length) {
|
||||||
|
this.showText += text.charAt(this.index)
|
||||||
|
this.index++
|
||||||
|
t1 = setTimeout(() => {
|
||||||
|
this.zhuzi()
|
||||||
|
}, this.settings.textSpeed)
|
||||||
|
} else {
|
||||||
|
if (this.settingsPage) {
|
||||||
|
t2 = setTimeout(() => {
|
||||||
|
this.index = 0
|
||||||
|
this.showText = ''
|
||||||
|
this.zhuzi()
|
||||||
|
}, 2000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDestroy() {
|
||||||
|
// 解除内存占用
|
||||||
|
clearTimeout(t1)
|
||||||
|
clearTimeout(t2)
|
||||||
|
},
|
||||||
|
exit() {
|
||||||
|
this.$app.exit()
|
||||||
|
},
|
||||||
|
ban() {
|
||||||
|
console.log('ban')
|
||||||
|
},
|
||||||
|
back() {
|
||||||
|
brightness.setKeepScreenOn({
|
||||||
|
keepScreenOn: false,
|
||||||
|
})
|
||||||
|
router.replace({ uri: `pages/index` })
|
||||||
|
},
|
||||||
|
changeTextSize(e) {
|
||||||
|
this.settings.textSize = e.progress
|
||||||
|
},
|
||||||
|
changeTextSpeed(e) {
|
||||||
|
this.settings.textSpeed = e.progress
|
||||||
|
},
|
||||||
|
saveSettings() {
|
||||||
|
storage.set({
|
||||||
|
key: 'settings',
|
||||||
|
value: JSON.stringify(this.settings),
|
||||||
|
success: () => {
|
||||||
|
prompt.showToast({ message: '保存成功' })
|
||||||
|
},
|
||||||
|
fail: () => {},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.page {
|
.page {
|
||||||
width: 390px;
|
width: 390px;
|
||||||
height: 450px;
|
height: 450px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scroll {
|
.scroll {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
top: 325px;
|
top: 325px;
|
||||||
left: 8px;
|
left: 8px;
|
||||||
right: 0;
|
right: 0;
|
||||||
width: 390px;
|
width: 390px;
|
||||||
height: 155px;
|
height: 155px;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
.slider {
|
.slider {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 230px;
|
width: 230px;
|
||||||
height: 50px; /* 新增高度限制 */
|
height: 50px; /* 新增高度限制 */
|
||||||
top: 125px;
|
top: 125px;
|
||||||
left: 53px;
|
left: 53px;
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
.text {
|
.text {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
height: 50px; /* 新增高度限制 */
|
height: 50px; /* 新增高度限制 */
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
top: 71px;
|
top: 71px;
|
||||||
left: 18px;
|
left: 18px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user