更新logger
This commit is contained in:
+5
-2
@@ -13,7 +13,7 @@ import * as jumpcheck from "./jumpcheck"
|
||||
import * as htmlparser from "./htmlparser"
|
||||
import * as savedcontent from "./savedcontent"
|
||||
import * as bgimg from "./bgimg"
|
||||
import * as buildinfo from "./buildinfo"
|
||||
import logger from "./logger/logger"
|
||||
export default {
|
||||
dayjs: dayjs,
|
||||
animengine: animengine,
|
||||
@@ -25,12 +25,15 @@ export default {
|
||||
articletools: articletools,
|
||||
htmlparser: htmlparser,
|
||||
savedcontent: savedcontent,
|
||||
buildinfo: buildinfo,
|
||||
bgimg: bgimg,
|
||||
logger: logger,
|
||||
DEVICE_INFO: null,
|
||||
async onCreate() {
|
||||
console.log("app created")
|
||||
|
||||
console.log("create global logger")
|
||||
global.logger = this.logger
|
||||
|
||||
console.log("appinit > loadSettings")
|
||||
settings.loadSettings()
|
||||
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ export function parseArticlePageHtml(html: string): any | null {
|
||||
// 解析 JSON 并返回结果
|
||||
return JSON.parse(initialStateMatch[1]);
|
||||
} catch (error) {
|
||||
console.error('Error parsing __INITIAL_STATE__:', error);
|
||||
global.logger.error('Error parsing __INITIAL_STATE__:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export function parseArticlePageHtml(html: string): any | null {
|
||||
|
||||
export function PatchArticleContent(doms: any) {
|
||||
try{
|
||||
console.log("dom length: ", doms.length);
|
||||
global.logger.log("dom length: ", doms.length);
|
||||
|
||||
// 使用显式的栈结构避免递归,防止栈溢出
|
||||
const stack = [...doms]; // 将所有dom节点放入栈中
|
||||
@@ -67,7 +67,7 @@ export function PatchArticleContent(doms: any) {
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
console.error("[articletools] Patch Error: " + e.toString())
|
||||
global.logger.error("[articletools] Patch Error: " + e.toString())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -24,6 +24,6 @@ export function Init(){
|
||||
|
||||
export function GetBackgroundImageSrc(){
|
||||
var pageName = router.getState().name
|
||||
console.log("[GetBackgroundImageSrc]", router.getState().name, BGIMG_PAGES_MAP[pageName])
|
||||
global.logger.log("[GetBackgroundImageSrc]", router.getState().name, BGIMG_PAGES_MAP[pageName])
|
||||
return BGIMG_PAGES_MAP[pageName]
|
||||
}
|
||||
@@ -19,7 +19,7 @@ export const BilibiliClientLoginMethods = {
|
||||
|
||||
// 获取二维码信息
|
||||
async loginQR(this: any): Promise<{ url: string, qrcode_key: string }> {
|
||||
console.log("请求登录二维码");
|
||||
global.logger.log("请求登录二维码");
|
||||
const response = await this.getRequest('https://passport.bilibili.com/x/passport-login/web/qrcode/generate');
|
||||
if (response && response.data) {
|
||||
this.qrCodeKey = response.data.data.qrcode_key;
|
||||
@@ -37,7 +37,7 @@ export const BilibiliClientLoginMethods = {
|
||||
this.biliJct = accountData.biliJct;
|
||||
this.dedeUserID = accountData.dedeUserID;
|
||||
this.sid = accountData.sid;
|
||||
console.log('使用存储的账号数据登录成功');
|
||||
global.logger.log('使用存储的账号数据登录成功');
|
||||
await this.updateAccountInfo();
|
||||
await this.updateBUVID();
|
||||
return { success: true, message: "登录成功" };
|
||||
@@ -48,7 +48,7 @@ export const BilibiliClientLoginMethods = {
|
||||
|
||||
this.extractCookiesFromResponse(response.headers['Set-Cookie']);
|
||||
await this.storeAccountData();
|
||||
console.log('使用二维码登录并存储账号数据成功');
|
||||
global.logger.log('使用二维码登录并存储账号数据成功');
|
||||
await this.updateAccountInfo();
|
||||
await this.updateBUVID();
|
||||
return { success: true, message: "登录成功" };
|
||||
@@ -92,7 +92,7 @@ export const BilibiliClientLoginMethods = {
|
||||
resolve(data ? JSON.parse(data) as AccountData : null);
|
||||
},
|
||||
fail: (data: any, code: number) => {
|
||||
console.log(`获取存储的账号数据失败,错误码 = ${code}`);
|
||||
global.logger.log(`获取存储的账号数据失败,错误码 = ${code}`);
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
@@ -108,11 +108,11 @@ export const BilibiliClientLoginMethods = {
|
||||
key: 'bilibili_account',
|
||||
value: JSON.stringify(accountData),
|
||||
success: () => {
|
||||
console.log('账号数据存储成功');
|
||||
global.logger.log('账号数据存储成功');
|
||||
resolve();
|
||||
},
|
||||
fail: (data: any, code: number) => {
|
||||
console.log(`存储账号数据失败,错误码 = ${code}`);
|
||||
global.logger.log(`存储账号数据失败,错误码 = ${code}`);
|
||||
reject();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { crypto } from '../../tsimports';
|
||||
import { getMixinKey } from '../utils/utils';
|
||||
import * as eula from '../../eula'
|
||||
import semver from 'semver';
|
||||
import * as eula from '../../eula';
|
||||
|
||||
// API请求相关的方法
|
||||
export const BilibiliClientAPIRequestMethods = {
|
||||
@@ -42,14 +43,14 @@ export const BilibiliClientAPIRequestMethods = {
|
||||
.join("&");
|
||||
|
||||
const wbi_sign = crypto.hashDigest({ data: query + mixin_key, algo: "MD5" });
|
||||
console.log("wbi_sign: " + wbi_sign);
|
||||
global.logger.log("wbi_sign: " + wbi_sign);
|
||||
|
||||
return `${query}&w_rid=${wbi_sign}`;
|
||||
},
|
||||
|
||||
// 发送GET请求
|
||||
async getRequest(this: any, url: string, responseType: string = "json"): Promise<any> {
|
||||
console.log("getRequest: " + url);
|
||||
global.logger.log("getRequest: " + url);
|
||||
try {
|
||||
const response = await this.fetch.fetch({
|
||||
url,
|
||||
@@ -58,7 +59,7 @@ export const BilibiliClientAPIRequestMethods = {
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error(`GET请求失败,错误码 = ${error.code}`);
|
||||
global.logger.error(`GET请求失败,错误码 = ${error.code}`);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -73,7 +74,7 @@ export const BilibiliClientAPIRequestMethods = {
|
||||
|
||||
// 发送POST请求
|
||||
async postRequest(this: any, url: string, data: string, content_type: string, custom_headers: any = null): Promise<any> {
|
||||
console.log(`postRequest: ${url}, body: ${data}, contentType: ${content_type}`);
|
||||
global.logger.log(`postRequest: ${url}, body: ${data}, contentType: ${content_type}`);
|
||||
let headers = { ...this.getHeaders(), "Content-Type": content_type }
|
||||
if (custom_headers) {
|
||||
headers = custom_headers
|
||||
@@ -88,7 +89,7 @@ export const BilibiliClientAPIRequestMethods = {
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error(`POST请求失败,错误码 = ${error.code}`);
|
||||
global.logger.error(`POST请求失败,错误码 = ${error.code}`);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
@@ -107,9 +108,9 @@ export const BilibiliClientAPIRequestMethods = {
|
||||
url: "https://gitee.com/search__stars/hb_ota_info/raw/master/current_ver",
|
||||
header: this.getHeaders()
|
||||
});
|
||||
console.log(latestVerGet.data);
|
||||
global.logger.log(latestVerGet.data);
|
||||
const latestVer = latestVerGet.data.data;
|
||||
if (latestVer != this.version) {
|
||||
if (semver.lt(this.version, latestVer)) {
|
||||
return {
|
||||
update: true,
|
||||
msg: `检查到更新v${latestVer},请前往hyperbili.astralsight.space下载更新`
|
||||
|
||||
@@ -36,7 +36,7 @@ export const BilibiliClientSearchMethods = {
|
||||
|
||||
// 全站搜索,但是按类型细分
|
||||
async searchContentWithType(this: any, keyword: string, search_type: string) {
|
||||
console.log("[searchContentWithType] keyword=" + keyword + " type=" + search_type)
|
||||
global.logger.log("[searchContentWithType] keyword=" + keyword + " type=" + search_type)
|
||||
const url = "https://api.bilibili.com/x/web-interface/wbi/search/type"
|
||||
const response = await this.getRequestWbi(url, {
|
||||
keyword,
|
||||
|
||||
@@ -34,7 +34,7 @@ export const BilibiliClientVideoActionMethods = {
|
||||
const response = await this.postRequest(url, data, "application/x-www-form-urlencoded");
|
||||
return response.data.code;
|
||||
} catch (error) {
|
||||
console.error("Error starring video: ", error);
|
||||
global.logger.error("Error starring video: ", error);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -52,7 +52,7 @@ export const BilibiliClientVideoMethods = {
|
||||
platform: "html5"
|
||||
});
|
||||
|
||||
console.log(response);
|
||||
global.logger.log(response);
|
||||
return response.data.data;
|
||||
},
|
||||
};
|
||||
@@ -84,7 +84,7 @@ export default {
|
||||
request.onDownloadComplete({
|
||||
token: data.token,
|
||||
success: (data) => {
|
||||
console.log("[BetterOnlineImage] Image Saved in: " + data.uri)
|
||||
global.logger.log("[BetterOnlineImage] Image Saved in: " + data.uri)
|
||||
this.localsrc = data.uri
|
||||
this.show_loading = false
|
||||
this.show_image = true
|
||||
@@ -94,11 +94,11 @@ export default {
|
||||
})
|
||||
},
|
||||
onDestroy(){
|
||||
console.log("[BetterOnlineImage] onDestroy, deleting image in: " + this.localsrc)
|
||||
global.logger.log("[BetterOnlineImage] onDestroy, deleting image in: " + this.localsrc)
|
||||
file.delete({
|
||||
uri: this.localsrc,
|
||||
success: () => {
|
||||
console.log("[BetterOnlineImage] Image deleted.")
|
||||
global.logger.log("[BetterOnlineImage] Image deleted.")
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -77,13 +77,13 @@ export default {
|
||||
props: ["doms"],
|
||||
onInit() {
|
||||
if (this.doms) {
|
||||
console.log("[html-renderer] doms存在且有效,开始渲染")
|
||||
global.logger.log("[html-renderer] doms存在且有效,开始渲染")
|
||||
} else {
|
||||
console.log("[html-renderer] doms无效,拒绝渲染")
|
||||
global.logger.log("[html-renderer] doms无效,拒绝渲染")
|
||||
}
|
||||
},
|
||||
openImage(evt) {
|
||||
console.log("[html-renderer] image clicked. openImage src=" + evt.detail.src)
|
||||
global.logger.log("[html-renderer] image clicked. openImage src=" + evt.detail.src)
|
||||
router.push({
|
||||
uri: "pages/tools/picturedetail",
|
||||
params: {
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
"about": {
|
||||
"title": "About the App",
|
||||
"developers": "Developers Involved",
|
||||
"commitHash": "Commit Hash",
|
||||
"buildTime": "Build Time",
|
||||
"builder": "Builder",
|
||||
"moreResources": "For more resources, visit",
|
||||
"disclaimer": "Disclaimer"
|
||||
},
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@ export async function NetworkCheck(): Promise<boolean> {
|
||||
network.getType({
|
||||
success: function (data: { type: string }) {
|
||||
if (!data.type) {
|
||||
console.log('Network type is empty or undefined.');
|
||||
global.logger.log('Network type is empty or undefined.');
|
||||
resolve(false);
|
||||
} else if (data.type === 'none') {
|
||||
resolve(false);
|
||||
@@ -31,11 +31,11 @@ export async function NetworkCheck(): Promise<boolean> {
|
||||
}
|
||||
},
|
||||
fail: function () {
|
||||
console.log('Failed to get network type.');
|
||||
global.logger.log('Failed to get network type.');
|
||||
resolve(false);
|
||||
},
|
||||
complete: function () {
|
||||
console.log('Network type check completed.');
|
||||
global.logger.log('Network type check completed.');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
@primaryColor: #FF7DA8;
|
||||
@subPrimaryColor: #0D7AFF;
|
||||
@baseColor: #262626;
|
||||
@baseColorA: #262626af;
|
||||
@baseColorA: #262626af;
|
||||
|
||||
@blankColor: #00000000;
|
||||
@@ -0,0 +1,90 @@
|
||||
import { file } from "../tsimports";
|
||||
|
||||
type LogLevel = 'log' | 'warn' | 'error';
|
||||
|
||||
interface LogEntry {
|
||||
timestamp: string;
|
||||
level: LogLevel;
|
||||
message: string;
|
||||
}
|
||||
|
||||
class Logger {
|
||||
private logDirectory: string = 'internal://files/logs/';
|
||||
private logFilePath: string;
|
||||
|
||||
// 定义日志级别的样式
|
||||
private styles: { [key in LogLevel]: string } = {
|
||||
log: 'color: green;',
|
||||
warn: 'color: orange;',
|
||||
error: 'color: red;',
|
||||
};
|
||||
|
||||
constructor() {
|
||||
const startTime = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
this.logFilePath = `${this.logDirectory}log-${startTime}.log`;
|
||||
|
||||
this.initializeLogDirectory();
|
||||
}
|
||||
|
||||
private initializeLogDirectory() {
|
||||
const mkdirParams = {
|
||||
uri: this.logDirectory,
|
||||
recursive: true,
|
||||
success: () => console.log('Log directory created successfully'),
|
||||
fail: (err: any) => console.error('Failed to create log directory', err),
|
||||
};
|
||||
|
||||
// @ts-ignore QuickApp API
|
||||
file.mkdir(mkdirParams);
|
||||
}
|
||||
|
||||
public log(...args: any[]) {
|
||||
this.printAndStore('log', args);
|
||||
}
|
||||
|
||||
public warn(...args: any[]) {
|
||||
this.printAndStore('warn', args);
|
||||
}
|
||||
|
||||
public error(...args: any[]) {
|
||||
this.printAndStore('error', args);
|
||||
}
|
||||
|
||||
private printAndStore(level: LogLevel, args: any[]) {
|
||||
const timestamp = new Date().toISOString();
|
||||
const style = this.styles[level];
|
||||
|
||||
// 将所有参数序列化为字符串
|
||||
const message = args.map((arg) => this.safeStringify(arg)).join(' ');
|
||||
|
||||
// 在控制台输出日志
|
||||
console.log(`%c[${timestamp}] [${level.toUpperCase()}] ${message}`, style);
|
||||
|
||||
// 同步日志到文件
|
||||
this.flushLogToFile(`[${timestamp}] [${level.toUpperCase()}] ${message}`);
|
||||
}
|
||||
|
||||
private flushLogToFile(logEntry: string) {
|
||||
const writeParams = {
|
||||
uri: this.logFilePath,
|
||||
text: logEntry + '\n',
|
||||
append: true,
|
||||
fail: (err: any) => console.error('Failed to write log to file', err),
|
||||
};
|
||||
|
||||
// @ts-ignore QuickApp API
|
||||
file.writeText(writeParams);
|
||||
}
|
||||
|
||||
private safeStringify(obj: any): string {
|
||||
try {
|
||||
if (typeof obj === 'string') return obj;
|
||||
return JSON.stringify(obj, null, 2); // 美化输出
|
||||
} catch (err) {
|
||||
return '[Circular or Unsupported Object]';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const logger = new Logger();
|
||||
export default logger;
|
||||
@@ -11,7 +11,7 @@
|
||||
.w(130px);
|
||||
.h(130px);
|
||||
.radius(50%);
|
||||
background-color: #222222;
|
||||
background-color: @baseColor;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
@@ -35,7 +35,7 @@
|
||||
}
|
||||
|
||||
.btn {
|
||||
.flex-column(0px, #00000000);
|
||||
.flex-column(0px, @blankColor);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -50,6 +50,6 @@
|
||||
}
|
||||
|
||||
.btnline {
|
||||
.flex-row(0px, #00000000);
|
||||
.flex-row(0px, @blankColor);
|
||||
width: 300px;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ export default {
|
||||
}
|
||||
},
|
||||
DoScrollTip(){
|
||||
console.log("scroll bottom!")
|
||||
global.logger.log("scroll bottom!")
|
||||
this.showChangePageFX = true
|
||||
this.anims.ChangePageFX = new this.$app.$def.animengine.DomAnim(
|
||||
"arealist",
|
||||
@@ -88,7 +88,7 @@ export default {
|
||||
},700)
|
||||
},
|
||||
onInit(){
|
||||
console.log("lastpage=", this.lastpage)
|
||||
global.logger.log("lastpage=", this.lastpage)
|
||||
this.colors[this.lastpage] = "#FF7DA8"
|
||||
},
|
||||
GoPage(pagename){
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
try {
|
||||
const result = await this.$app.$def.biliclient.login(true, this.qrpoll_interval)
|
||||
if (result.success) {
|
||||
console.log("登录成功")
|
||||
global.logger.log("登录成功")
|
||||
prompt.showToast({message: "登录成功"})
|
||||
router.replace({uri: "pages/app/entry/introduction"})
|
||||
clearInterval(this.qrpoll_interval)
|
||||
@@ -42,20 +42,20 @@ export default {
|
||||
prompt.showToast({message: result.message, duration: 5000})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("轮询QR登录时出错:", error)
|
||||
global.logger.error("轮询QR登录时出错:", error)
|
||||
}
|
||||
},
|
||||
async GetQR() {
|
||||
try {
|
||||
const get_result = await this.$app.$def.biliclient.loginQR()
|
||||
this.qr_value = get_result.url
|
||||
console.log(get_result)
|
||||
global.logger.log(get_result)
|
||||
this.show_qr = true
|
||||
this.show_loading = false
|
||||
|
||||
this.qrpoll_interval = setInterval(() => this.PollQR(), 1500)
|
||||
} catch (error) {
|
||||
console.error("获取QR码时出错:", error)
|
||||
global.logger.error("获取QR码时出错:", error)
|
||||
prompt.showToast({message: "无法获取QR码,请重试", duration: 3000})
|
||||
this.show_loading = false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
@import '@less/defs.less';
|
||||
@import '@less/color.less';
|
||||
|
||||
// 瀑布流总框架
|
||||
.waterfall {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 340px;
|
||||
}
|
||||
|
||||
// 竖向瀑布流框架
|
||||
.waterfall-column {
|
||||
.flex-column(0, @blankColor);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<import name="switch-bar" src="@components/SwitchBar/SwitchBar.ux"></import>
|
||||
<import name="dynamic-show" src="@components/Dynamic/Dynamic.ux"></import>
|
||||
|
||||
<template>
|
||||
<div class="page">
|
||||
<scroll class="scroll">
|
||||
<switch-bar title="动态" static></switch-bar>
|
||||
<div class="waterfall">
|
||||
<div class="waterfall-column">
|
||||
<dynamic-show for="{{dynamic.items}}"></dynamic-show>
|
||||
</div>
|
||||
<div class="waterfall-column">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</scroll>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
private: {
|
||||
dynamic: {
|
||||
items: [
|
||||
// 带图动态
|
||||
{
|
||||
id_str: "xxx",
|
||||
type: "DYNAMIC_TYPE_DRAW",
|
||||
modules: {
|
||||
module_author: {
|
||||
face: "https://i2.hdslb.com/bfs/face/779056d80a36cbd1ae276067e208007ae0da18f6.jpg",
|
||||
name: "OneMicroSpace"
|
||||
},
|
||||
module_dynamic: {
|
||||
desc: {
|
||||
text: "SpaceX龙飞船下一次发射即将开始"
|
||||
},
|
||||
major: {
|
||||
type: "MAJOR_TYPE_DRAW",
|
||||
draw: {
|
||||
items: [
|
||||
{
|
||||
src: "https://i0.hdslb.com/bfs/new_dyn/3f30beecf4c48a263e658b6a5d92ed2413945088.jpg"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import "@less/global.less";
|
||||
@import "./dynamic.less";
|
||||
</style>
|
||||
@@ -72,7 +72,7 @@ export default {
|
||||
home_vid_count
|
||||
)
|
||||
} catch (error) {
|
||||
console.error("获取推荐视频时出错:", error)
|
||||
global.logger.error("获取推荐视频时出错:", error)
|
||||
prompt.showToast({message: "获取推荐视频失败,请重试。"})
|
||||
} finally {
|
||||
this.anims.loading.stop()
|
||||
@@ -87,7 +87,7 @@ export default {
|
||||
prompt.showToast({message: result.msg, duration: 6000})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("检查更新时出错:", error)
|
||||
global.logger.error("检查更新时出错:", error)
|
||||
}
|
||||
},
|
||||
onInit() {
|
||||
|
||||
@@ -32,7 +32,7 @@ export default {
|
||||
|
||||
return new_content
|
||||
} catch (e) {
|
||||
console.error("[savedcontent.PatchContent] Patch Error: " + e.toString())
|
||||
global.logger.error("[savedcontent.PatchContent] Patch Error: " + e.toString())
|
||||
}
|
||||
},
|
||||
async OpenArticle(id) {
|
||||
@@ -48,9 +48,9 @@ export default {
|
||||
},
|
||||
async LoadContent() {
|
||||
var origin_content = await this.$app.$def.savedcontent.SavedContentManager.listAllContent()
|
||||
console.log(origin_content)
|
||||
global.logger.log(origin_content)
|
||||
this.content = this.PatchContent(origin_content)
|
||||
console.log(this.content)
|
||||
global.logger.log(this.content)
|
||||
},
|
||||
onInit() {
|
||||
this.LoadContent()
|
||||
|
||||
@@ -74,7 +74,7 @@ export default {
|
||||
},
|
||||
onInit() {
|
||||
this.version = "v" + this.$app.$def.biliclient.version
|
||||
console.log(this.buildinfo)
|
||||
global.logger.log(this.buildinfo)
|
||||
},
|
||||
OpenDisclaimer() {
|
||||
router.push({
|
||||
|
||||
@@ -33,9 +33,9 @@ export default {
|
||||
message: "开始缓存"
|
||||
})
|
||||
var articleHtml = await this.$app.$def.biliclient.getArticle(this.cvid, false)
|
||||
console.log("articleHtml=" + articleHtml)
|
||||
global.logger.log("articleHtml=" + articleHtml)
|
||||
var id = await this.$app.$def.savedcontent.SavedContentManager.storeContent(this.cvtitle, articleHtml, "article")
|
||||
console.log("id=" + id)
|
||||
global.logger.log("id=" + id)
|
||||
prompt.showToast({
|
||||
message: "专栏 " + this.cvtitle + " 缓存完毕!存储id=" + id,
|
||||
duration: 5000
|
||||
|
||||
@@ -81,8 +81,8 @@ export default {
|
||||
this.article_content = article_full
|
||||
this.max_page_num = this.article_content.length
|
||||
|
||||
console.log(article.readInfo.content)
|
||||
console.log(JSON.stringify(this.article_content))
|
||||
global.logger.log(article.readInfo.content)
|
||||
global.logger.log(JSON.stringify(this.article_content))
|
||||
|
||||
this.anims.loading.stop()
|
||||
this.show_loading = false
|
||||
@@ -90,7 +90,7 @@ export default {
|
||||
this.showarticle = true
|
||||
}
|
||||
catch(e){
|
||||
console.error(e.toString())
|
||||
global.logger.error(e.toString())
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
@@ -51,7 +51,7 @@ export default {
|
||||
|
||||
this.folders = await Promise.all(folderPromises)
|
||||
} catch (error) {
|
||||
console.error("加载收藏夹时发生错误:", error)
|
||||
global.logger.error("加载收藏夹时发生错误:", error)
|
||||
} finally {
|
||||
this.show_loading = false
|
||||
this.anims.loading.stop()
|
||||
|
||||
@@ -90,7 +90,7 @@ export default {
|
||||
// 并行获取所有视频信息
|
||||
this.foldervid_vids = await Promise.all(videoInfoPromises)
|
||||
} catch (error) {
|
||||
console.error("加载视频时发生错误:", error)
|
||||
global.logger.error("加载视频时发生错误:", error)
|
||||
} finally {
|
||||
this.show_loading = false
|
||||
this.anims.loading.stop()
|
||||
@@ -98,7 +98,7 @@ export default {
|
||||
},
|
||||
onInit() {
|
||||
this.maxpn = Math.ceil(this.vidcount / 5)
|
||||
console.log("maxpn=" + this.maxpn)
|
||||
global.logger.log("maxpn=" + this.maxpn)
|
||||
|
||||
this.anims.loading = new this.$app.$def.animengine.SequenceAnim(
|
||||
"folderVideosPage",
|
||||
|
||||
@@ -39,7 +39,7 @@ export default {
|
||||
)
|
||||
this.history = await Promise.all(videoInfoPromises)
|
||||
} catch (error) {
|
||||
console.error("加载历史记录时发生错误:", error)
|
||||
global.logger.error("加载历史记录时发生错误:", error)
|
||||
} finally {
|
||||
this.show_loading = false
|
||||
this.anims.loading.stop()
|
||||
|
||||
@@ -69,7 +69,7 @@ export default {
|
||||
this.show_dmlist = true
|
||||
}
|
||||
catch(e){
|
||||
console.error(e.toString())
|
||||
global.logger.error(e.toString())
|
||||
}
|
||||
},
|
||||
GoDMPage(targetId){
|
||||
|
||||
@@ -84,7 +84,7 @@ export default {
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("发送评论时发生错误:", error)
|
||||
global.logger.error("发送评论时发生错误:", error)
|
||||
prompt.showToast({message: "发送失败,请重试。", duration: 4000})
|
||||
}
|
||||
},
|
||||
@@ -136,7 +136,7 @@ export default {
|
||||
|
||||
this.replies = replyData.replies
|
||||
} catch (error) {
|
||||
console.error("加载评论时发生错误:", error)
|
||||
global.logger.error("加载评论时发生错误:", error)
|
||||
prompt.showToast({message: "加载评论失败,请重试。", duration: 4000})
|
||||
} finally {
|
||||
this.anims.loading.stop()
|
||||
@@ -146,7 +146,7 @@ export default {
|
||||
},
|
||||
onInit() {
|
||||
this.maxpn = Math.ceil(this.replycount / 10)
|
||||
console.log("maxpn=", this.maxpn)
|
||||
global.logger.log("maxpn=", this.maxpn)
|
||||
|
||||
this.anims.loading = new this.$app.$def.animengine.SequenceAnim(
|
||||
"replysPage",
|
||||
|
||||
@@ -44,7 +44,7 @@ export default {
|
||||
this.reply_clone.rpid,
|
||||
1
|
||||
)
|
||||
console.log(result)
|
||||
global.logger.log(result)
|
||||
if (result.code == 0) {
|
||||
prompt.showToast({
|
||||
message: "点赞成功!"
|
||||
|
||||
@@ -145,7 +145,7 @@ export default {
|
||||
},
|
||||
OpenVideo(bvid) {
|
||||
global.runGC()
|
||||
console.log("[searchresult -> videodetail] open bvid: " + bvid)
|
||||
global.logger.log("[searchresult -> videodetail] open bvid: " + bvid)
|
||||
router.push({
|
||||
uri: "pages/video/videodetail",
|
||||
params: {bvid}
|
||||
@@ -180,7 +180,7 @@ export default {
|
||||
bvid: video.bvid || ""
|
||||
})
|
||||
})
|
||||
console.log("[searchresult.PatchSearchResult] 已处理视频")
|
||||
global.logger.log("[searchresult.PatchSearchResult] 已处理视频")
|
||||
|
||||
// 处理 comprehensive_videos
|
||||
comprehensiveVideosList.forEach((video) => {
|
||||
@@ -192,7 +192,7 @@ export default {
|
||||
bvid: video.bvid || ""
|
||||
})
|
||||
})
|
||||
console.log("[searchresult.PatchSearchResult] 已处理综合视频")
|
||||
global.logger.log("[searchresult.PatchSearchResult] 已处理综合视频")
|
||||
|
||||
// 处理 articles
|
||||
articlesList.forEach((article) => {
|
||||
@@ -204,14 +204,14 @@ export default {
|
||||
}
|
||||
articles.push(article)
|
||||
})
|
||||
console.log("[searchresult.PatchSearchResult] 已处理文章")
|
||||
global.logger.log("[searchresult.PatchSearchResult] 已处理文章")
|
||||
|
||||
// 原地更新 videos 数组,如果不是数组则直接赋值新的数组并记录警告
|
||||
if (Array.isArray(search.videos)) {
|
||||
search.videos.splice(0, search.videos.length, ...videos)
|
||||
} else {
|
||||
search.videos = videos
|
||||
console.warn("[searchresult.PatchSearchResult] 'videos' 不是数组。已初始化为空数组。")
|
||||
global.logger.warn("[searchresult.PatchSearchResult] 'videos' 不是数组。已初始化为空数组。")
|
||||
}
|
||||
|
||||
// 原地更新 comprehensive_videos 数组,如果不是数组则直接赋值新的数组并记录警告
|
||||
@@ -223,7 +223,7 @@ export default {
|
||||
)
|
||||
} else {
|
||||
search.comprehensive_videos = comprehensive_videos
|
||||
console.warn(
|
||||
global.logger.warn(
|
||||
"[searchresult.PatchSearchResult] 'comprehensive_videos' 不是数组。已初始化为空数组。"
|
||||
)
|
||||
}
|
||||
@@ -233,7 +233,7 @@ export default {
|
||||
search.articles.splice(0, search.articles.length, ...articles)
|
||||
} else {
|
||||
search.articles = articles
|
||||
console.warn("[searchresult.PatchSearchResult] 'articles' 不是数组。已初始化为空数组。")
|
||||
global.logger.warn("[searchresult.PatchSearchResult] 'articles' 不是数组。已初始化为空数组。")
|
||||
}
|
||||
|
||||
// 确保 comprehensive_status 存在
|
||||
@@ -243,7 +243,7 @@ export default {
|
||||
this.comprehensive_status.has_users_result = usersList.length > 0
|
||||
this.comprehensive_status.has_video_result = videos.length > 0
|
||||
} catch (e) {
|
||||
console.error("[searchresult.PatchSearchResult] 处理错误:", e)
|
||||
global.logger.error("[searchresult.PatchSearchResult] 处理错误:", e)
|
||||
}
|
||||
},
|
||||
async DoSearch() {
|
||||
|
||||
@@ -85,12 +85,12 @@ export default {
|
||||
}
|
||||
},
|
||||
onScroll(args) {
|
||||
//console.log(args);
|
||||
//global.logger.log(args);
|
||||
},
|
||||
onReady() {
|
||||
this.$element("img").getBoundingClientRect({
|
||||
success: (rect) => {
|
||||
console.log("image loaded: ", rect);
|
||||
global.logger.log("image loaded: ", rect);
|
||||
this.base_height = rect.height;
|
||||
this.base_width = rect.width;
|
||||
if(rect.width > 800 && rect.height > 800){
|
||||
@@ -106,7 +106,7 @@ export default {
|
||||
});
|
||||
device.getInfo({
|
||||
success: (info) => {
|
||||
console.log(info);
|
||||
global.logger.log(info);
|
||||
this.deviceInfo = info;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -77,7 +77,7 @@ export default {
|
||||
replymode: false
|
||||
},
|
||||
onInit() {
|
||||
console.log("[videodetail] load bvid: " + this.bvid);
|
||||
global.logger.log("[videodetail] load bvid: " + this.bvid);
|
||||
this.GetVideoDetail()
|
||||
this.UpdateVideoToolbarStatus()
|
||||
},
|
||||
|
||||
+7
-7
@@ -70,11 +70,11 @@ function fileDelete(uri: string): Promise<void> {
|
||||
// 同步 storageIndex 到本地文件
|
||||
async function saveStorageIndex(): Promise<void> {
|
||||
try {
|
||||
console.log(storageIndex)
|
||||
global.logger.log(storageIndex)
|
||||
const indexData = JSON.stringify(storageIndex);
|
||||
await fileWrite(indexFileUri, indexData);
|
||||
} catch (e) {
|
||||
console.error(`[SavedContentManager] saveStorageIndex Error: ${e.toString()}`);
|
||||
global.logger.error(`[SavedContentManager] saveStorageIndex Error: ${e.toString()}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ async function loadStorageIndex(): Promise<void> {
|
||||
storageIndex = [];
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`[SavedContentManager] loadStorageIndex Error: ${e.toString()}`);
|
||||
global.logger.error(`[SavedContentManager] loadStorageIndex Error: ${e.toString()}`);
|
||||
storageIndex = [];
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ export class SavedContentManager {
|
||||
// 初始化时加载 storageIndex
|
||||
static async initialize(): Promise<void> {
|
||||
await loadStorageIndex()
|
||||
console.log("loaded SavedContent StorageIndex", storageIndex)
|
||||
global.logger.log("loaded SavedContent StorageIndex", storageIndex)
|
||||
}
|
||||
|
||||
// 存储内容
|
||||
@@ -124,7 +124,7 @@ export class SavedContentManager {
|
||||
|
||||
return id;
|
||||
} catch (e) {
|
||||
console.error(`[SavedContentManager] storeContent Error: ${e.toString()}`);
|
||||
global.logger.error(`[SavedContentManager] storeContent Error: ${e.toString()}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ export class SavedContentManager {
|
||||
|
||||
return await fileRead(content.fileUri);
|
||||
} catch (e) {
|
||||
console.error(`[SavedContentManager] getContent Error: ${e.toString()}`);
|
||||
global.logger.error(`[SavedContentManager] getContent Error: ${e.toString()}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ export class SavedContentManager {
|
||||
storageIndex.splice(contentIndex, 1);
|
||||
await saveStorageIndex();
|
||||
} catch (e) {
|
||||
console.error(`[SavedContentManager] deleteContent Error: ${e.toString()}`);
|
||||
global.logger.error(`[SavedContentManager] deleteContent Error: ${e.toString()}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -37,10 +37,10 @@ export function loadSettings(): void {
|
||||
...storedSettings
|
||||
};
|
||||
}
|
||||
console.log('Settings loaded:', SETTINGS);
|
||||
global.logger.log('Settings loaded:', SETTINGS);
|
||||
},
|
||||
fail: function (data, code) {
|
||||
console.log(`Failed to load settings, code = ${code}`);
|
||||
global.logger.log(`Failed to load settings, code = ${code}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -54,10 +54,10 @@ export function saveSettings(params: Partial<SettingsInterface>): void {
|
||||
key: 'settings',
|
||||
value: JSON.stringify(SETTINGS),
|
||||
success: function () {
|
||||
console.log('Settings saved successfully');
|
||||
global.logger.log('Settings saved successfully');
|
||||
},
|
||||
fail: function (data, code) {
|
||||
console.log(`Failed to save settings, code = ${code}`);
|
||||
global.logger.log(`Failed to save settings, code = ${code}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user