🎨 规范化代码

This commit is contained in:
BTMuli
2025-12-24 02:46:28 +08:00
parent 8500668213
commit 651a89145f
199 changed files with 5067 additions and 5390 deletions

View File

@@ -3,76 +3,76 @@
* @since Beta v0.9.1
*/
import { AnnoLangEnum } from "@enum/anno.js";
import { GameServerEnum } from "@enum/game.js";
import bbsEnum from "@enum/bbs.js";
import gameEnum from "@enum/game.js";
import { path } from "@tauri-apps/api";
import { getInitDeviceInfo } from "@utils/toolFunc.js";
import { defineStore } from "pinia";
import { ref } from "vue";
/* 用于存储用户数据的路径 */
/** 用于存储用户数据的路径 */
const userDataDir: Readonly<string> = `${await path.appLocalDataDir()}${path.sep()}userData`;
/* 用于存放数据库的路径 */
/** 用于存放数据库的路径 */
const dbDataPath: Readonly<string> = `${await path.appConfigDir()}${path.sep()}TeyvatGuide.db`;
/* 用于存放日志的路径 */
/** 用于存放日志的路径 */
const logDataDir: Readonly<string> = await path.appLogDir();
/* 资讯类型 TODO:改成枚举类 */
export type NewsType = "notice" | "activity" | "news";
const useAppStore = defineStore(
"app",
() => {
/* 应用打包时间 */
/** 应用打包时间 */
const buildTime = ref<string>("");
/* 侧边栏设置 */
/** 侧边栏设置 */
const sidebar = ref({ collapse: true });
/* 开发者模式 */
/** 开发者模式 */
const devMode = ref<boolean>(false);
/* 应用主题 */
/** 应用主题 */
const theme = ref<string>("default");
/* 是否登录 */
/** 是否登录 */
const isLogin = ref<boolean>(false);
/* 用户数据目录 */
/** 用户数据目录 */
const userDir = ref<string>(userDataDir);
/* 数据库路径 */
/** 数据库路径 */
const dbPath = ref<Readonly<string>>(dbDataPath);
/* 日志目录 */
/** 日志目录 */
const logDir = ref<string>(logDataDir);
/* 游戏安装目录 */
/** 游戏安装目录 */
const gameDir = ref<string>("未设置");
/* 设备信息 */
/** 设备信息 */
const deviceInfo = ref<TGApp.App.Device.DeviceInfo>(getInitDeviceInfo());
/* 服务器 */
const server = ref<TGApp.Game.Base.ServerTypeEnum>(GameServerEnum.CN_QD01);
/* 语言 */
const lang = ref<TGApp.BBS.Announcement.AnnoLangEnum>(AnnoLangEnum.CHS);
/* 最近的资讯类型 */
const recentNewsType = ref<NewsType>("notice");
/* 是否开启分辨率回正 */
/** 服务器 */
const server = ref<TGApp.Game.Base.ServerTypeEnum>(gameEnum.server.CN_QD01);
/** 语言 */
const lang = ref<TGApp.Game.Anno.AnnoLangEnum>(gameEnum.anno.lang.CHS);
/** 最近的资讯类型 */
const recentNewsType = ref<TGApp.BBS.Post.NewsTypeEnum>(bbsEnum.post.newsType.NOTICE);
/** 是否开启分辨率回正 */
const needResize = ref<string>("true");
/**
* 分享图生成默认设置
* @remarks 为0表示默认保存到文件为数字表示当大小超过xMB时保存到文件否则保存到剪贴板
* @example
* 0 - 默认保存到文件
* 10 - 当大小超过10MB时保存到文件否则保存到剪贴板
*/
const shareDefaultFile = ref<number>(10);
/* 图像压缩质量 */
/** 图像压缩质量 */
const imageQualityPercent = ref<number>(80);
/* 无痕浏览 */
/** 无痕浏览 */
const incognito = ref<boolean>(true);
/* 帖子宽窄视图 */
/** 帖子宽窄视图 */
const postViewWide = ref<boolean>(true);
/* 是否取消点赞 */
/** 是否取消点赞 */
const cancelLike = ref<boolean>(true);
/* 关闭窗口时最小化到托盘 */
/** 关闭窗口时最小化到托盘 */
const closeToTray = ref<boolean>(false);
/** 是否是管理员模式 */
const isInAdmin = ref<boolean>(false);
/**
* 初始化应用状态
* @since Beta v0.8.9
* @since Beta v0.9.1
* @remarks 用于首次运行或重置应用状态
* @returns void
* @returns 无返回值
*/
function init(): void {
devMode.value = false;
@@ -81,7 +81,7 @@ const useAppStore = defineStore(
sidebar.value.collapse = true;
server.value = "cn_gf01";
lang.value = "zh-cn";
recentNewsType.value = "notice";
recentNewsType.value = bbsEnum.post.newsType.NOTICE;
needResize.value = "true";
gameDir.value = "未设置";
shareDefaultFile.value = 10;
@@ -95,8 +95,8 @@ const useAppStore = defineStore(
/**
* 切换应用主题
* @since unknown
* @returns void
* @since Beta v0.9.1
* @returns 无返回值
*/
function changeTheme(): void {
if (theme.value === "default") theme.value = "dark";
@@ -105,8 +105,8 @@ const useAppStore = defineStore(
/**
* 初始化设备信息
* @since unknown
* @returns void
* @since Beta v0.9.1
* @returns 无返回值
*/
function initDevice(): void {
deviceInfo.value = getInitDeviceInfo();
@@ -114,9 +114,10 @@ const useAppStore = defineStore(
/**
* 获取图片压缩后的URL
* @param {string} url 图片原始URL
* @param {string} [fmt] 图片格式
* @returns {string} 压缩后的图片URL
* @since Beta v0.9.1
* @param url - 图片原始URL
* @param fmt - 图片格式,可选参数
* @returns 压缩后的图片URL
*/
function getImageUrl(url: string, fmt?: string): string {
let check = true;

View File

@@ -1,6 +1,5 @@
/**
* @file store/modules/bbs.ts
* @description BBS 模块状态管理
* 米社数据状态管理
* @since Beta v0.8.2
*/
import apiHubReq from "@req/apiHubReq.js";
@@ -24,7 +23,9 @@ const useBBSStore = defineStore(
async function refreshGameUidCards(): Promise<void> {
const resp = await apiHubReq.appConfig();
if ("retcode" in resp) return;
const conf = <TGApp.BBS.AppConfig.GameUidCardFullConf>JSON.parse(resp.game_uid_card_config);
const conf = <TGApp.BBS.AppConfig.GameUidCardConfigParse>(
JSON.parse(resp.game_uid_card_config)
);
gameUidCards.value = conf.game_uid_card_conf;
}

View File

@@ -1,6 +1,5 @@
/**
* @file store/modules/user.ts
* @description 用户信息模块
* 用户信息模块
* @since Beta v0.7.6
*/