1. 清除缓存完成 2. 用户主页新增开始私信 3. 新增关于权限和screenWidth的错误检查

This commit is contained in:
Searchstars
2025-02-04 00:21:20 +08:00
parent 852bc848a5
commit 7cc73782d5
13 changed files with 418 additions and 37 deletions
+2
View File
@@ -7,11 +7,13 @@ const fs = require('fs');
const gitCommitHash = childProcess.execSync('git rev-parse HEAD').toString().trim();
const username = os.userInfo().username;
const buildTime = new Date().toISOString();
const designWidth = JSON.parse(fs.readFileSync("src/manifest.json")).config.designWidth
const buildInfoContent = `
export const GIT_COMMIT_HASH = "${gitCommitHash}";
export const BUILD_TIME = "${buildTime}";
export const BUILD_USER = "${username}";
export const DESIGN_WIDTH = ${designWidth};
`;
const buildInfoPath = path.resolve(__dirname, 'src/buildinfo.ts');
+49 -31
View File
@@ -6,44 +6,62 @@
<script>
export default {
props: {
text: {
default: ""
},
marginTop: {
default: ""
},
primary: {
default: "" //默认false 即空字符串
},
disabled: {
default: ""
},
color_bg: {
default: "#262626"
},
color_text: {
default: "#ffffff"
}
props: {
text: {
default: ""
},
Click(){
if(!this.disabled){
this.$emit('click')
}
marginTop: {
default: ""
},
onInit(){
if(this.primary){
this.color_bg = "#FF7DA8"
}
if(this.disabled){
this.color_text = "#5F5F5F"
}
primary: {
default: "" //默认false 即空字符串
},
disabled: {
default: false,
type: Boolean
}
},
data: {
disabledReal: false,
color_bg: "#262626",
color_text: "#ffffff"
},
Click() {
if (!this.disabledReal) {
this.$emit("click")
}
},
watchDisabledChange(newV, oldV) {
global.logger.log("[DefaultButton.watchDisabledChange] newV=", newV)
if (newV) {
this.color_bg = "#262626"
this.color_text = "#5F5F5F"
} else {
this.color_text = "#ffffff"
if (this.primary) {
this.color_bg = "#FF7DA8"
}
}
this.disabledReal = newV
global.logger.log("[DefaultButton.watchDisabledChange] disabledReal=", this.disabledReal)
},
onInit() {
if (this.primary) {
this.color_bg = "#FF7DA8"
}
// 初始化调用
this.watchDisabledChange(this.disabled, null)
this.$watch("disabled", "watchDisabledChange")
}
}
</script>
<style lang="less">
@import '@less/global.less';
@import "@less/global.less";
.featurebtn {
width: 322px;
+19 -1
View File
@@ -129,12 +129,30 @@
"title": "User",
"videos": "Videos",
"dynamices": "Dynamic",
"nocontent": "There is no content to show at present."
"nocontent": "There is no content to show at present.",
"senddm": "Send DM",
"uservideos": {
"title": "User contributions"
}
},
"sessionood": {
"title": "Some problems have occurred",
"sectitle": "Your account login seems to have expired, please try to log in again!",
"relogin": "Login again",
"exit": "Exit"
},
"permissionerror": {
"title": "Permission Error",
"sectitle": "You have not granted the necessary permissions to run HyperBili. Please restart the app and make sure that all permissions requested by the app have been granted.",
"exit": "Exit"
},
"screenwidtherror": {
"title": "Screen width does not match",
"sectitle": "The target design screen width of this version of HyperBili is not equal to the screen width of the device you are currently using. Please make sure that you download the correct version for your device from the official website, otherwise this may mean that HyperBili does not currently support your device.",
"exit": "Exit"
},
"cleartmp": {
"title": "Clear cache",
"clear": "Clear now"
}
}
+15
View File
@@ -135,6 +135,7 @@
"videos": "TA的视频",
"dynamices": "TA的动态",
"nocontent": "暂无可展示内容",
"senddm": "发送私信",
"uservideos": {
"title": "用户投稿"
}
@@ -144,5 +145,19 @@
"sectitle": "您的账号登录似乎已经过期,请尝试重新登录!",
"relogin": "重新登录",
"exit": "退出"
},
"permissionerror": {
"title": "权限错误",
"sectitle": "您没有授予运行HyperBili必要的权限。请重新启动该应用,并确保已授予该应用请求的所有权限。",
"exit": "退出"
},
"screenwidtherror": {
"title": "屏幕宽度不匹配",
"sectitle": "该版本的HyperBili的目标设计屏幕宽度与您目前所使用的设备的屏幕宽度并不相等。请确保您在官网下载了正确且适合您设备的版本,否则这可能代表HyperBili目前并不支持您的设备。",
"exit": "退出"
},
"cleartmp": {
"title": "清除缓存",
"clear": "立即清理"
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
@primaryColor: #FF7DA8;
@subPrimaryColor: #0D7AFF;
@baseColor: #262626;
@baseColorA: #262626af;
@baseColor: #222222;
@baseColorA: #222222af;
@blankColor: #00000000;
+9
View File
@@ -164,11 +164,20 @@
"pages/error/sessionood": {
"component": "sessionood"
},
"pages/error/permissionerror": {
"component": "permissionerror"
},
"pages/error/screenwidtherror": {
"component": "screenwidtherror"
},
"pages/user/userdynamic": {
"component": "userdynamic"
},
"pages/user/uservideos": {
"component": "uservideos"
},
"pages/app/features/settings/cleartmp": {
"component": "cleartmp"
}
}
}
@@ -0,0 +1,32 @@
@import '@less/defs.less';
@import '@less/color.less';
.cleartip {
font-size: 35px;
font-weight: 600;
color: #9E9E9E;
}
.typebox {
.radius(30px);
.flex-column(10px);
}
.tmptype {
.flex-row(10px 15px, #434343);
.radius(20px);
width: 100%;
justify-content: space-between;
align-items: center;
}
.typetxt {
font-weight: 600;
font-size: 30px;
}
.typesize {
font-weight: 600;
font-size: 30px;
color: gray;
}
@@ -0,0 +1,220 @@
<import name="title-bar" src="@components/TitleBar/TitleBar.ux"></import>
<import name="default-button" src="@components/DefaultButton/DefaultButton.ux"></import>
<template>
<div class="page">
<title-bar title="cleartmp.title"></title-bar>
<text class="cleartip" style="margin-top: 10px">请先选择类别</text>
<text class="cleartip">随后点击按钮以进行清理</text>
<div class="typebox" style="margin-top: 25px">
<div style="padding: 5px; width: 77%" for="{{tmps}}">
<div class="tmptype" onclick="SelectHandler($item.alias)" style="background-color: {{typeColors[$item.alias]}}">
<text class="typetxt">{{ $item.name }}</text>
<text class="typesize">{{ $item.size }}</text>
</div>
</div>
</div>
<default-button @click="ClearClick" primary="true" margin-top="25px" text="cleartmp.clear" disabled="{{cantClear}}"></default-button>
<text style="margin-top: 30px"></text>
</div>
</template>
<script>
import prompt from "@system.prompt"
import { asyncFile } from "../../../../../asyncapi/file"
export default {
private: {
tmps: [],
cantClear: true,
clearControl: {
imgs: false,
logs: false,
sc: false,
},
typeColors: {
imgs: "#434343",
logs: "#434343",
sc: "#434343",
others: "#222222"
}
},
RefreshPage(){
this.cantClear = true
this.clearControl = {
imgs: false,
logs: false,
sc: false,
}
this.typeColors = {
imgs: "#434343",
logs: "#434343",
sc: "#434343",
others: "#222222"
}
},
async ClearClick() {
const tasks = []
if (this.clearControl.imgs) {
const imgTemp = this.tmps.find(t => t.alias === "imgs")
if (imgTemp) {
imgTemp.list.forEach(uri => {
tasks.push(asyncFile.delete({ uri }))
})
}
}
if (this.clearControl.logs) {
const logTemp = this.tmps.find(t => t.alias === "logs")
if (logTemp) {
logTemp.list.forEach(uri => {
tasks.push(asyncFile.delete({ uri }))
})
}
}
if (this.clearControl.sc) {
const contents = await global.savedcontent.SavedContentManager.listAllContent()
contents.forEach(ct => {
tasks.push(global.savedcontent.SavedContentManager.deleteContent(ct.id))
})
}
await Promise.all(tasks)
prompt.showToast({
message: "清理完毕"
})
this.ScanTemps()
this.RefreshPage()
},
SelectHandler(name) {
switch (name) {
case "imgs":
this.clearControl.imgs = !this.clearControl.imgs
this.typeColors.imgs = this.clearControl.imgs ? "#FF7DA8" : "#434343"
break
case "logs":
this.clearControl.logs = !this.clearControl.logs
this.typeColors.logs = this.clearControl.logs ? "#FF7DA8" : "#434343"
break
case "sc":
if(!this.clearControl.sc){
prompt.showDialog({
message: "清除缓存内容即意味着清除您之前缓存的专栏、音频等内容,且该操作不可逆。确定要继续吗?",
success: (data) => {
this.clearControl.sc = true
this.typeColors.sc = this.clearControl.sc ? "#FF7DA8" : "#434343";
}
})
}
else{
this.clearControl.sc = false
this.typeColors.sc = this.clearControl.sc ? "#FF7DA8" : "#434343";
}
break
}
this.cantClear = !(this.clearControl.imgs || this.clearControl.logs || this.clearControl.sc)
global.logger.log("[ClearTmp.SelectHandler] cantClear: ", this.cantClear)
},
BytesToMB(bytes) {
return (bytes / (1024 * 1024)).toFixed(2)
},
async getSavedContentList() {
try {
const contents = await global.savedcontent.SavedContentManager.listAllContent()
const ret = await Promise.all(
contents.map(async content => {
const data = await asyncFile.get({ uri: content.fileUri })
return {
uri: content.fileUri,
length: data.length,
_labelIsSavedContent: true,
}
})
)
return ret
} catch (e) {
global.logger.error("在扫描临时文件(统计缓存内容)时出错:", e.toString())
}
},
async ScanTemps() {
try {
// 准备统计对象
const totalStats = {
images: { count: 0, size: 0, list: [] },
logs: { count: 0, size: 0, list: [] },
savedContent: { count: 0, size: 0 },
others: { count: 0, size: 0 },
}
// 并行获取文件列表
const [rootFiles, logFiles, savedContentFiles] = await Promise.all([
asyncFile.list({ uri: "internal://files/" }),
asyncFile.list({ uri: "internal://files/logs" }),
this.getSavedContentList(),
])
const fileList = [...rootFiles.fileList, ...logFiles.fileList, ...savedContentFiles]
for (const file of fileList) {
const { uri, length, _labelIsSavedContent } = file
if (/\.(jpg|png|avif|gif)/i.test(uri)) {
totalStats.images.count++
totalStats.images.size += length
totalStats.images.list.push(uri)
} else if (/\.log$/i.test(uri)) {
totalStats.logs.count++
totalStats.logs.size += length
totalStats.logs.list.push(uri)
} else if (_labelIsSavedContent) {
totalStats.savedContent.count++
totalStats.savedContent.size += length
} else {
totalStats.others.count++
totalStats.others.size += length
}
}
this.tmps = [
{
name: "临时图片",
alias: "imgs",
size: `${this.BytesToMB(totalStats.images.size)} MB`,
list: totalStats.images.list,
},
{
name: "日志文件",
alias: "logs",
size: `${this.BytesToMB(totalStats.logs.size)} MB`,
list: totalStats.logs.list,
},
{
name: "缓存内容",
alias: "sc",
size: `${this.BytesToMB(totalStats.savedContent.size)} MB`,
},
{
name: "其它",
alias: "others",
size: `${this.BytesToMB(totalStats.others.size)} MB`
}
]
} catch (e) {
global.logger.error("在扫描临时文件时出错:", e.toString())
}
},
onInit() {
this.ScanTemps()
},
}
</script>
<style lang="less">
@import "@less/global.less";
@import "./cleartmp.less";
</style>
+2 -2
View File
@@ -82,8 +82,8 @@ export default {
})
},
ClearTmp() {
prompt.showToast({
message: "当前不可用"
router.push({
uri: "pages/app/features/settings/cleartmp"
})
},
SwitchSet(name) {
@@ -0,0 +1,25 @@
<import name="default-button" src="@components/DefaultButton/DefaultButton.ux"></import>
<template>
<div class="page">
<image style="margin-top: 44px; width: 63px; height: 54px; object-fit: scale-down" src="/common/warning_icon.png"></image>
<text style="font-weight: 600; font-size: 28px; margin-top: 15px;">{{ $t("permissionerror.title") }}</text>
<text style="font-weight: 600; font-size: 28px; margin-top: 18px; width: 75%">{{ $t("permissionerror.sectitle") }}</text>
<default-button margin-top="15px" text="permissionerror.exit" @click="Exit"></default-button>
<text style="margin-top: 25px;"></text>
</div>
</template>
<script>
import router from "@system.router"
export default {
Exit(){
router.clear()
router.back()
}
}
</script>
<style lang="less">
@import '@less/global.less';
</style>
@@ -0,0 +1,25 @@
<import name="default-button" src="@components/DefaultButton/DefaultButton.ux"></import>
<template>
<div class="page">
<image style="margin-top: 44px; width: 63px; height: 54px; object-fit: scale-down" src="/common/warning_icon.png"></image>
<text style="font-weight: 600; font-size: 28px; margin-top: 15px;">{{ $t("screenwidtherror.title") }}</text>
<text style="font-weight: 600; font-size: 28px; margin-top: 18px; width: 75%">{{ $t("screenwidtherror.sectitle") }}</text>
<default-button margin-top="15px" text="screenwidtherror.exit" @click="Exit"></default-button>
<text style="margin-top: 25px;"></text>
</div>
</template>
<script>
import router from "@system.router"
export default {
Exit(){
router.clear()
router.back()
}
}
</script>
<style lang="less">
@import '@less/global.less';
</style>
+13
View File
@@ -1,6 +1,7 @@
<import name="title-bar" src="@components/TitleBar/TitleBar.ux"></import>
<import name="user-info" src="@components/UserInfo/UserInfo.ux"></import>
<import name="online-image" src="@components/BetterOnlineImage/BetterOnlineImage.ux"></import>
<import name="default-button" src="@components/DefaultButton/DefaultButton.ux"></import>
<template>
<div class="page">
@@ -29,6 +30,7 @@
<text class="desctxt gs">></text>
</div>
</div>
<default-button @click="GoDMPage" if="{loaded}" margin-top="25px" primary="true" text="user.senddm"></default-button>
<text style="margin-top: 30px"></text>
<image style="position: absolute; margin-top: 245px" if="{{anims.show_loading}}" src="{{anims.loading_src.value}}"></image>
</div>
@@ -74,6 +76,17 @@ export default {
}
})
},
GoDMPage(){
router.push({
uri: "pages/message/dmpage",
params: {
myId: global.biliclient.accountInfo.mid,
targetId: this.uid,
myPic: global.biliclient.accountInfo.face,
targetPic: this.user.face
}
})
},
WIPTips(){
prompt.showToast({
message: "该功能仍未开发完毕"
+5 -1
View File
@@ -1,4 +1,4 @@
import { device, network } from "./tsimports"
import { device, network, router } from "./tsimports"
export function formatNumber(num: number): string {
if (num < 1000) {
@@ -46,6 +46,10 @@ export function getDeviceSerial(): Promise<any> {
resolve(data.serial);
},
fail: (error) => {
router.clear();
router.replace({
uri: "pages/error/permissionerror"
});
reject(error);
}
});