426 lines
10 KiB
XML
426 lines
10 KiB
XML
<template>
|
||
<div class="page" @swipe="ban()">
|
||
<image src="/common/ev000b.png"></image>
|
||
<image
|
||
style="position: absolute; top: 325px; left: 0"
|
||
src="/common/text_bg.png"></image>
|
||
<text class="text">显示速度({{ settings.textSpeed }}):</text>
|
||
<slider
|
||
class="slider"
|
||
min="20"
|
||
max="60"
|
||
step="1"
|
||
onchange="changeTextSpeed()"></slider>
|
||
<text class="text" style="top: 163px">
|
||
文字大小({{ settings.textSize }}):
|
||
</text>
|
||
<slider
|
||
class="slider"
|
||
style="top: 210px"
|
||
min="20"
|
||
max="32"
|
||
step="1"
|
||
onchange="changeTextSize()"></slider>
|
||
<text class="text" style="top: 15px; left: 60px" @click="saveSettings()">
|
||
保存
|
||
</text>
|
||
<text class="text" style="top: 15px; left: 175px" @click="back()">
|
||
退出
|
||
</text>
|
||
<text class="text" style="top: 15px; left: 280px" @click="gotolist()">
|
||
去目录
|
||
</text>
|
||
<text
|
||
class="text"
|
||
style="top: 250px; left: 40px; color: red"
|
||
onclick="downloadFile(jsonDataList)">
|
||
下载文本
|
||
</text>
|
||
<text
|
||
class="text"
|
||
style="top: 250px; left: 250px; color: red"
|
||
onclick="downloadFile(jsonList)">
|
||
下载图像
|
||
</text>
|
||
<scroll scroll-y="true" bounces="true" class="scroll">
|
||
<text
|
||
style="color: #FFFFFF;font-weight: bold;width: 100%;text-align: left;font-size: {{settings.textSize}}px;">
|
||
{{ showText }}
|
||
</text>
|
||
</scroll>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import storage from '@blueos.storage.storage'
|
||
import prompt from '@blueos.window.prompt'
|
||
import router from '@blueos.app.appmanager.router'
|
||
import file from '@blueos.storage.file'
|
||
import fetch from '@blueos.network.fetch'
|
||
import brightness from '@blueos.hardware.display.brightness'
|
||
var send = async (url, data, method = 'GET', responseType = 'text') => {
|
||
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) => {
|
||
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: `下载完成`,
|
||
})
|
||
},
|
||
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) {
|
||
prompt.showToast({
|
||
message: `下载失败:${code}`,
|
||
})
|
||
},
|
||
})
|
||
})
|
||
return await p
|
||
},
|
||
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>
|
||
|
||
<style>
|
||
.page {
|
||
width: 390px;
|
||
height: 450px;
|
||
}
|
||
|
||
.scroll {
|
||
position: absolute;
|
||
bottom: 0;
|
||
top: 325px;
|
||
left: 8px;
|
||
right: 0;
|
||
width: 390px;
|
||
height: 155px;
|
||
text-overflow: ellipsis;
|
||
}
|
||
.slider {
|
||
position: absolute;
|
||
width: 230px;
|
||
height: 50px; /* 新增高度限制 */
|
||
top: 125px;
|
||
left: 53px;
|
||
opacity: 0.5;
|
||
}
|
||
.text {
|
||
position: absolute;
|
||
font-size: 24px;
|
||
height: 50px; /* 新增高度限制 */
|
||
color: #ffffff;
|
||
top: 71px;
|
||
left: 18px;
|
||
font-weight: bold;
|
||
}
|
||
</style>
|