✏️ 继续修正 import

This commit is contained in:
目棃
2024-06-26 22:28:05 +08:00
parent f2e4186042
commit 0061dfa988
44 changed files with 198 additions and 230 deletions

View File

@@ -5,6 +5,7 @@
*/
import { http } from "@tauri-apps/api";
import { Response } from "@tauri-apps/api/http";
/**
* @description Bili 插件导航请求
@@ -13,7 +14,7 @@ import { http } from "@tauri-apps/api";
*/
async function getNav(): Promise<TGApp.Plugins.Bili.Nav.NavData> {
const url = "https://api.bilibili.com/x/web-interface/nav";
return await http.fetch<TGApp.Plugins.Bili.Nav.NavResponse>(url).then((res) => {
return await http.fetch(url).then((res: Response<TGApp.Plugins.Bili.Nav.NavResponse>) => {
return res.data.data;
});
}

View File

@@ -5,8 +5,9 @@
*/
import { http } from "@tauri-apps/api";
import { Response } from "@tauri-apps/api/http";
import getWrid from "../utils/getWrid";
import getWrid from "../utils/getWrid.js";
/**
* @description 获取视频播放地址
@@ -31,14 +32,14 @@ async function getVideoUrl(cid: number, bvid: string): Promise<TGApp.Plugins.Bil
wrid: wridRes[1],
};
return await http
.fetch<TGApp.Plugins.Bili.Video.UrlResponse>(url, {
.fetch(url, {
method: "GET",
query: params,
headers: {
referer: "https://www.bilibili.com/",
},
})
.then((res) => {
.then((res: Response<TGApp.Plugins.Bili.Video.UrlResponse>) => {
return res.data.data;
});
}

View File

@@ -5,6 +5,7 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
/**
* @description 获取视频基本信息
@@ -26,10 +27,8 @@ async function getVideoView(
throw new Error("参数错误");
}
return await http
.fetch<TGApp.Plugins.Bili.Video.ViewResponse>(url, {
method: "GET",
})
.then((res) => {
.fetch(url, { method: "GET" })
.then((res: Response<TGApp.Plugins.Bili.Video.ViewResponse>) => {
return res.data.data;
});
}

View File

@@ -6,7 +6,7 @@
import md5 from "js-md5";
import getNav from "../request/getNav";
import getNav from "../request/getNav.js";
/**
* @description 获取 key 值

View File

@@ -5,15 +5,15 @@
* @since Beta v0.3.0
*/
import getAvatarCollect from "./request/getAvatarCollect";
import getAvatarHoldRate from "./request/getAvatarHoldRate";
import getAvatarUpRate from "./request/getAvatarUpRate";
import getAvatarUseRate from "./request/getAvatarUseRate";
import getOverview from "./request/getOverview";
import getTeamCollect from "./request/getTeamCollect";
import getWeaponCollect from "./request/getWeaponCollect";
import uploadData from "./request/uploadData";
import { transAvatars, transLocal } from "./utils/transLocal";
import getAvatarCollect from "./request/getAvatarCollect.js";
import getAvatarHoldRate from "./request/getAvatarHoldRate.js";
import getAvatarUpRate from "./request/getAvatarUpRate.js";
import getAvatarUseRate from "./request/getAvatarUseRate.js";
import getOverview from "./request/getOverview.js";
import getTeamCollect from "./request/getTeamCollect.js";
import getWeaponCollect from "./request/getWeaponCollect.js";
import uploadData from "./request/uploadData.js";
import { transAvatars, transLocal } from "./utils/transLocal.js";
const Hutao = {
Abyss: {

View File

@@ -5,8 +5,9 @@
*/
import { http } from "@tauri-apps/api";
import { Response } from "@tauri-apps/api/http";
import HutaoApi from "../api";
import HutaoApi from "../api/index.js";
/**
* @description 获取角色搭配数据
@@ -16,10 +17,8 @@ import HutaoApi from "../api";
async function getAvatarCollect(): Promise<TGApp.Plugins.Hutao.Abyss.AvatarCollocation[]> {
const url = HutaoApi.Abyss.avatar.collect;
return await http
.fetch<TGApp.Plugins.Hutao.Abyss.AvatarCollocationResponse>(url, {
method: "GET",
})
.then((res) => {
.fetch(url, { method: "GET" })
.then((res: Response<TGApp.Plugins.Hutao.Abyss.AvatarCollocationResponse>) => {
return res.data.data;
});
}

View File

@@ -5,8 +5,9 @@
*/
import { http } from "@tauri-apps/api";
import { Response } from "@tauri-apps/api/http";
import HutaoApi from "../api";
import HutaoApi from "../api/index.js";
/**
* @description 获取角色持有率数据
@@ -16,10 +17,8 @@ import HutaoApi from "../api";
async function getAvatarHoldRate(): Promise<TGApp.Plugins.Hutao.Abyss.AvatarHold[]> {
const url = HutaoApi.Abyss.avatar.holdRate;
return await http
.fetch<TGApp.Plugins.Hutao.Abyss.AvatarHoldResponse>(url, {
method: "GET",
})
.then((res) => {
.fetch(url, { method: "GET" })
.then((res: Response<TGApp.Plugins.Hutao.Abyss.AvatarHoldResponse>) => {
return res.data.data;
});
}

View File

@@ -5,8 +5,9 @@
*/
import { http } from "@tauri-apps/api";
import { Response } from "@tauri-apps/api/http";
import HutaoApi from "../api";
import HutaoApi from "../api/index.js";
/**
* @description 获取角色上场率数据
@@ -16,10 +17,8 @@ import HutaoApi from "../api";
async function getAvatarUpRate(): Promise<TGApp.Plugins.Hutao.Abyss.AvatarUp[]> {
const url = HutaoApi.Abyss.avatar.upRate;
return await http
.fetch<TGApp.Plugins.Hutao.Abyss.AvatarUpResponse>(url, {
method: "GET",
})
.then((res) => {
.fetch(url, { method: "GET" })
.then((res: Response<TGApp.Plugins.Hutao.Abyss.AvatarUpResponse>) => {
return res.data.data;
});
}

View File

@@ -5,8 +5,9 @@
*/
import { http } from "@tauri-apps/api";
import { Response } from "@tauri-apps/api/http";
import HutaoApi from "../api";
import HutaoApi from "../api/index.js";
/**
* @description 获取角色使用率
@@ -16,10 +17,8 @@ import HutaoApi from "../api";
async function getAvatarUseRate(): Promise<TGApp.Plugins.Hutao.Abyss.AvatarUse[]> {
const url = HutaoApi.Abyss.avatar.useRate;
return await http
.fetch<TGApp.Plugins.Hutao.Abyss.AvatarUseResponse>(url, {
method: "GET",
})
.then((res) => {
.fetch(url, { method: "GET" })
.then((res: Response<TGApp.Plugins.Hutao.Abyss.AvatarUseResponse>) => {
return res.data.data;
});
}

View File

@@ -5,8 +5,9 @@
*/
import { http } from "@tauri-apps/api";
import { Response } from "@tauri-apps/api/http";
import HutaoApi from "../api";
import HutaoApi from "../api/index.js";
/**
* @description 获取深渊概览数据
@@ -16,10 +17,8 @@ import HutaoApi from "../api";
async function getOverview(): Promise<TGApp.Plugins.Hutao.Abyss.OverviewData> {
const url = HutaoApi.Abyss.overview;
return await http
.fetch<TGApp.Plugins.Hutao.Abyss.OverviewResponse>(url, {
method: "GET",
})
.then((res) => {
.fetch(url, { method: "GET" })
.then((res: Response<TGApp.Plugins.Hutao.Abyss.OverviewResponse>) => {
return res.data.data;
});
}

View File

@@ -5,8 +5,9 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import HutaoApi from "../api";
import HutaoApi from "../api/index.js";
/**
* @description 获取队伍搭配数据
@@ -16,10 +17,8 @@ import HutaoApi from "../api";
async function getTeamCollect(): Promise<TGApp.Plugins.Hutao.Abyss.TeamCombination[]> {
const url = HutaoApi.Abyss.team;
return await http
.fetch<TGApp.Plugins.Hutao.Abyss.TeamCombinationResponse>(url, {
method: "GET",
})
.then((res) => {
.fetch(url, { method: "GET" })
.then((res: Response<TGApp.Plugins.Hutao.Abyss.TeamCombinationResponse>) => {
return res.data.data;
});
}

View File

@@ -1,13 +1,13 @@
/**
* @file plugins Hutao request getWeaponCollect.ts
* @description 获取武器搭配
* @author BTMuli <bt-muli@outlook.com>
* @since Alpha v0.2.0
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import HutaoApi from "../api";
import HutaoApi from "../api/index.js";
/**
* @description 获取武器搭配
@@ -17,10 +17,8 @@ import HutaoApi from "../api";
async function getWeaponCollect(): Promise<TGApp.Plugins.Hutao.Abyss.WeaponCollocation[]> {
const url = HutaoApi.Abyss.weapon;
return await http
.fetch<TGApp.Plugins.Hutao.Abyss.WeaponCollocationResponse>(url, {
method: "GET",
})
.then((res) => {
.fetch(url, { method: "GET" })
.then((res: Response<TGApp.Plugins.Hutao.Abyss.WeaponCollocationResponse>) => {
return res.data.data;
});
}

View File

@@ -5,8 +5,9 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import HutaoApi from "../api";
import HutaoApi from "../api/index.js";
/**
* @description 上传用户数据
@@ -19,11 +20,8 @@ async function uploadData(
): Promise<TGApp.Plugins.Hutao.Abyss.UploadResponse> {
const url = HutaoApi.Abyss.upload;
return await http
.fetch<TGApp.Plugins.Hutao.Abyss.UploadResponse>(url, {
method: "POST",
body: http.Body.json(data),
})
.then((res) => res.data);
.fetch(url, { method: "POST", body: http.Body.json(data) })
.then((res: Response<TGApp.Plugins.Hutao.Abyss.UploadResponse>) => res.data);
}
export default uploadData;

View File

@@ -86,11 +86,11 @@ function transLevel(data: TGApp.Sqlite.Abyss.Level): TGApp.Plugins.Hutao.Abyss.L
const battles: Array<{ Index: number; Avatars: number[] }> = [];
battles.push({
Index: 1,
Avatars: data.upBattle.characters.map((character) => character.id),
Avatars: data.upBattle!.characters.map((character) => character.id),
});
battles.push({
Index: 2,
Avatars: data.downBattle.characters.map((character) => character.id),
Avatars: data.downBattle!.characters.map((character) => character.id),
});
return {
Index: data.id,

View File

@@ -5,8 +5,9 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import MysApi from "../api";
import MysApi from "../api/index.js";
/**
* @description 获取投票信息
@@ -17,20 +18,14 @@ import MysApi from "../api";
*/
export async function getVoteInfo(id: string, uid: string): Promise<TGApp.Plugins.Mys.Vote.Info> {
const url = "https://bbs-api.miyoushe.com/apihub/api/getVotes";
const params = {
owner_uid: uid,
vote_ids: id,
};
const params = { owner_uid: uid, vote_ids: id };
return await http
.fetch<TGApp.Plugins.Mys.Vote.InfoResponse>(url, {
.fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
Referer: MysApi.PostReferer,
},
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res) => {
.then((res: Response<TGApp.Plugins.Mys.Vote.InfoResponse>) => {
return res.data.data.data[0];
});
}
@@ -47,20 +42,14 @@ export async function getVoteResult(
uid: string,
): Promise<TGApp.Plugins.Mys.Vote.Result> {
const url = "https://bbs-api.miyoushe.com/apihub/api/getVotesResult";
const params = {
owner_uid: uid,
vote_ids: id,
};
const params = { owner_uid: uid, vote_ids: id };
return await http
.fetch<TGApp.Plugins.Mys.Vote.ResultResponse>(url, {
.fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
Referer: MysApi.PostReferer,
},
headers: { "Content-Type": "application/json", Referer: MysApi.PostReferer },
query: params,
})
.then((res) => {
.then((res: Response<TGApp.Plugins.Mys.Vote.ResultResponse>) => {
return res.data.data.data[0];
});
}

View File

@@ -4,8 +4,8 @@
* @since Beta v0.4.4
*/
import { AppCharacterData } from "../../../data";
import getPostData from "../request/getPostData";
import { AppCharacterData } from "../../../data/index.js";
import getPostData from "../request/getPostData.js";
/**
* @description 根据单个卡池信息转为渲染用的卡池信息

View File

@@ -1,13 +1,12 @@
/**
* @file plugins Mys utils getPositionCard.ts
* @file plugins/Mys/utils/getPositionCard.ts
* @description Mys 插件热点追踪工具
* @author BTMuli <bt-muli@outlook.com>
* @since Alpha v0.2.1
* @since Beta v0.4.10
*/
/**
* @description 根据热点追踪信息转为渲染用的数据
* @since Alpha v0.1.5
* @since Beta v0.4.10
* @param {TGApp.Plugins.Mys.Position.Data[]} positionData 列表
* @returns {TGApp.Plugins.Mys.Position.RenderCard[]} 返回列表
*/
@@ -15,14 +14,14 @@ function getPositionCard(
positionData: TGApp.Plugins.Mys.Position.Data[],
): TGApp.Plugins.Mys.Position.RenderCard[] {
const res: TGApp.Plugins.Mys.Position.RenderCard[] = [];
positionData.map((position) => {
for (const position of positionData) {
let endStr: string;
if (position.end_time === "0") {
endStr = "";
} else {
endStr = new Date(Number(position.end_time)).toLocaleDateString().replace(/\//g, "-");
}
return res.push<TGApp.Plugins.Mys.Position.RenderCard>({
const card: TGApp.Plugins.Mys.Position.RenderCard = {
title: position.title,
postId: Number(position.url.split("/").pop()),
icon: position.icon,
@@ -33,8 +32,9 @@ function getPositionCard(
end: endStr,
endStamp: Number(position.end_time),
},
});
});
};
res.push(card);
}
return res;
}

View File

@@ -5,8 +5,8 @@
*/
import { getUiafStatus } from "../../../utils/UIAF.js";
import TGSqlite from "../index";
import { importUIAFData } from "../sql/updateData";
import TGSqlite from "../index.js";
import { importUIAFData } from "../sql/updateData.js";
/**
* @description 获取成就概况
@@ -15,7 +15,7 @@ import { importUIAFData } from "../sql/updateData";
*/
async function getOverview(): Promise<TGApp.Sqlite.Achievement.Overview> {
const db = await TGSqlite.getDB();
const res = await db.select<TGApp.Sqlite.Achievement.Overview>(
const res = await db.select<TGApp.Sqlite.Achievement.Overview[]>(
"SELECT SUM(totalCount) as total,SUM(finCount) AS fin From AchievementSeries",
);
return res[0];
@@ -29,7 +29,7 @@ async function getOverview(): Promise<TGApp.Sqlite.Achievement.Overview> {
async function getLatestAchiVersion(): Promise<string> {
const db = await TGSqlite.getDB();
type resType = { version: string };
const res = await db.select<resType>(
const res = await db.select<resType[]>(
"SELECT version FROM Achievements ORDER BY version DESC LIMIT 1;",
);
return res[0].version;
@@ -45,11 +45,11 @@ async function getSeries(id?: number): Promise<TGApp.Sqlite.Achievement.SeriesTa
const db = await TGSqlite.getDB();
let res: TGApp.Sqlite.Achievement.SeriesTable[];
if (id === undefined) {
res = await db.select<TGApp.Sqlite.Achievement.SeriesTable>(
res = await db.select<TGApp.Sqlite.Achievement.SeriesTable[]>(
"SELECT * FROM AchievementSeries ORDER BY `order`;",
);
} else {
res = await db.select<TGApp.Sqlite.Achievement.SeriesTable>(
res = await db.select<TGApp.Sqlite.Achievement.SeriesTable[]>(
"SELECT * FROM AchievementSeries WHERE id = ?;",
[id],
);
@@ -67,11 +67,11 @@ async function getAchievements(id?: string): Promise<TGApp.Sqlite.Achievement.Si
const db = await TGSqlite.getDB();
let res: TGApp.Sqlite.Achievement.SingleTable[];
if (id === undefined) {
res = await db.select<TGApp.Sqlite.Achievement.SingleTable>(
res = await db.select<TGApp.Sqlite.Achievement.SingleTable[]>(
"SELECT * FROM Achievements ORDER BY isCompleted,`order`;",
);
} else {
res = await db.select<TGApp.Sqlite.Achievement.SingleTable>(
res = await db.select<TGApp.Sqlite.Achievement.SingleTable[]>(
"SELECT * FROM Achievements WHERE series = ? ORDER BY isCompleted,`order`;",
[id],
);
@@ -88,7 +88,7 @@ async function getAchievements(id?: string): Promise<TGApp.Sqlite.Achievement.Si
async function getSeriesNameCard(id: string): Promise<string> {
const db = await TGSqlite.getDB();
type resType = { nameCard: string };
const res = await db.select<resType>("SELECT nameCard FROM AchievementSeries WHERE id = ?;", [
const res = await db.select<resType[]>("SELECT nameCard FROM AchievementSeries WHERE id = ?;", [
id,
]);
return res[0].nameCard;
@@ -108,12 +108,12 @@ async function searchAchievements(
const versionReg = /^v\d+(\.\d+)?$/;
if (versionReg.test(keyword)) {
const version = keyword.replace("v", "");
return await db.select<TGApp.Sqlite.Achievement.SingleTable>(
return await db.select<TGApp.Sqlite.Achievement.SingleTable[]>(
"SELECT * FROM Achievements WHERE version LIKE ? ORDER BY isCompleted,`order`;",
[`%${version}%`],
);
}
return await db.select<TGApp.Sqlite.Achievement.SingleTable>(
return await db.select<TGApp.Sqlite.Achievement.SingleTable[]>(
"SELECT * FROM Achievements WHERE name LIKE ? OR description LIKE ? ORDER BY isCompleted,`order`;",
[`%${keyword}%`, `%${keyword}%`],
);
@@ -160,9 +160,11 @@ function transDb2Uiaf(data: TGApp.Sqlite.Achievement.SingleTable): TGApp.Plugins
*/
async function getUIAF(): Promise<TGApp.Plugins.UIAF.Achievement[]> {
const db = await TGSqlite.getDB();
const data = await db.select<TGApp.Sqlite.Achievement.SingleTable>("SELECT * FROM Achievements;");
const data = await db.select<TGApp.Sqlite.Achievement.SingleTable[]>(
"SELECT * FROM Achievements;",
);
const res: TGApp.Plugins.UIAF.Achievement[] = [];
for (const item: TGApp.Sqlite.Achievement.SingleTable of data) {
for (const item of data) {
res.push(transDb2Uiaf(item));
}
return res;

View File

@@ -4,7 +4,7 @@
* @since Beta v0.4.5
*/
import TGSqlite from "../index";
import TGSqlite from "../index.js";
/**
* @description 获取单个帖子的收藏信息

View File

@@ -4,7 +4,7 @@
* @since Beta v0.4.9
*/
import minifySql from "../../../utils/minifySql";
import minifySql from "../../../utils/minifySql.js";
/**
* @description 导入UIAF数据-单项
@@ -12,7 +12,7 @@ import minifySql from "../../../utils/minifySql";
* @param {TGApp.Plugins.UIAF.Achievement} data
* @returns {string} sql
*/
export function importUIAFData(data: TGApp.Plugins.UIAF.Achievement): string[] {
export function importUIAFData(data: TGApp.Plugins.UIAF.Achievement): string {
let sql;
const isCompleted = data.status === 2 || data.status === 3;
if (isCompleted) {

View File

@@ -6,7 +6,7 @@
import { createRouter, createWebHistory } from "vue-router";
import routes from "./routes";
import routes from "./routes.js";
const router = createRouter({
history: createWebHistory(),

View File

@@ -4,11 +4,11 @@
* @since Beta v0.4.4
*/
import archiveRoutes from "./modules/archive";
import mainRoutes from "./modules/main";
import subRoutes from "./modules/sub";
import userRoutes from "./modules/user";
import wikiRoutes from "./modules/wiki";
import archiveRoutes from "./modules/archive.js";
import mainRoutes from "./modules/main.js";
import subRoutes from "./modules/sub.js";
import userRoutes from "./modules/user.js";
import wikiRoutes from "./modules/wiki.js";
// 合并路由
const routes = [...mainRoutes, ...subRoutes, ...archiveRoutes, ...wikiRoutes, ...userRoutes];

View File

@@ -8,8 +8,8 @@ import { path } from "@tauri-apps/api";
import { defineStore } from "pinia";
import { reactive, ref } from "vue";
import { getInitDeviceInfo } from "../../utils/toolFunc";
import { type AnnoLang, AnnoServer } from "../../web/request/getAnno";
import { getInitDeviceInfo } from "../../utils/toolFunc.js";
import { type AnnoLang, AnnoServer } from "../../web/request/getAnno.js";
// 用于存储用户数据的路径
const userDataDir = `${await path.appLocalDataDir()}userData`;

View File

@@ -9,19 +9,19 @@ import type { Event } from "@tauri-apps/api/event";
import type { UnlistenFn } from "@tauri-apps/api/helpers/event";
import { appWindow, WebviewWindow } from "@tauri-apps/api/window";
import showSnackbar from "../components/func/snackbar";
import TGSqlite from "../plugins/Sqlite";
import { useAppStore } from "../store/modules/app";
import { useUserStore } from "../store/modules/user";
import TGConstant from "../web/constant/TGConstant";
import { getCookieTokenBySToken } from "../web/request/getCookieToken";
import TGRequest from "../web/request/TGRequest";
import { getDS4JS } from "../web/utils/getRequestHeader";
import showSnackbar from "../components/func/snackbar.js";
import TGSqlite from "../plugins/Sqlite/index.js";
import { useAppStore } from "../store/modules/app.js";
import { useUserStore } from "../store/modules/user.js";
import TGConstant from "../web/constant/TGConstant.js";
import { getCookieTokenBySToken } from "../web/request/getCookieToken.js";
import TGRequest from "../web/request/TGRequest.js";
import { getDS4JS } from "../web/utils/getRequestHeader.js";
import { parseLink } from "./linkParser";
import TGLogger from "./TGLogger";
import { createPost } from "./TGWindow";
import { getDeviceInfo } from "./toolFunc";
import { parseLink } from "./linkParser.js";
import TGLogger from "./TGLogger.js";
import { createPost } from "./TGWindow.js";
import { getDeviceInfo } from "./toolFunc.js";
// invoke 参数
interface InvokeArg {

View File

@@ -7,11 +7,11 @@
import { dialog, fs, http, path } from "@tauri-apps/api";
import html2canvas from "html2canvas";
import showConfirm from "../components/func/confirm";
import showSnackbar from "../components/func/snackbar";
import showConfirm from "../components/func/confirm.js";
import showSnackbar from "../components/func/snackbar.js";
import TGLogger from "./TGLogger";
import { bytesToSize } from "./toolFunc";
import TGLogger from "./TGLogger.js";
import { bytesToSize } from "./toolFunc.js";
/**
* @description 保存图片-canvas

View File

@@ -7,7 +7,7 @@
import { invoke, window as TauriWindow } from "@tauri-apps/api";
import type { WindowOptions } from "@tauri-apps/api/window";
import TGLogger from "./TGLogger";
import TGLogger from "./TGLogger.js";
/**
* @description 创建TG窗口
@@ -50,7 +50,7 @@ export function createTGWindow(
.then(() => {
createTGWindow(url, label, title, width, height, resizable, visible);
})
.catch((err) => {
.catch((err: unknown) => {
console.error(err);
});
} else {
@@ -61,11 +61,11 @@ export function createTGWindow(
.then(() => {
console.log(`[createTGWindow][${label}] ${title} created.`);
})
.catch((err) => {
.catch((err: unknown) => {
console.error(err);
});
})
.catch((err) => {
.catch((err: unknown) => {
console.error(err);
});
}

View File

@@ -59,6 +59,7 @@ export async function verifyUiafData(path: string): Promise<boolean> {
try {
const fileJson = JSON.parse(fileData);
if (!validate(fileJson)) {
if (validate.errors === undefined || validate.errors === null) return false;
const error: ErrorObject = validate.errors[0];
showSnackbar({
text: `${error.instancePath || error.schemaPath} ${error.message}`,
@@ -89,6 +90,7 @@ export async function verifyUiafDataClipboard(): Promise<boolean> {
try {
const fileJson = JSON.parse(data);
if (!validate(fileJson)) {
if (validate.errors === undefined || validate.errors === null) return false;
const error: ErrorObject = validate.errors[0];
showSnackbar({
text: `${error.instancePath || error.schemaPath} ${error.message}`,

View File

@@ -12,7 +12,7 @@ import showSnackbar from "../components/func/snackbar.js";
import { UigfSchema } from "../data/index.js";
import TGLogger from "./TGLogger.js";
import { timestampToDate } from "./toolFunc";
import { timestampToDate } from "./toolFunc.js";
/**
* @description 获取 UIGF 时区
@@ -83,6 +83,7 @@ export async function verifyUigfData(path: string): Promise<boolean> {
try {
const fileJson = JSON.parse(fileData);
if (!validate(fileJson)) {
if (!validate.errors || validate.errors.length === 0) return false;
const error: ErrorObject = validate.errors[0];
showSnackbar({
text: `${error.instancePath || error.schemaPath} ${error.message}`,

View File

@@ -6,11 +6,11 @@
import { emit } from "@tauri-apps/api/event";
import showConfirm from "../components/func/confirm";
import showSnackbar from "../components/func/snackbar";
import showConfirm from "../components/func/confirm.js";
import showSnackbar from "../components/func/snackbar.js";
import TGClient from "./TGClient";
import { createPost } from "./TGWindow";
import TGClient from "./TGClient.js";
import { createPost } from "./TGWindow.js";
/**
* @function parsePost

View File

@@ -6,7 +6,7 @@
import { os, path } from "@tauri-apps/api";
import colorConvert from "color-convert";
import type { KEYWORD } from "color-convert/conversions";
import type { KEYWORD } from "color-convert/conversions.js";
import { v4 } from "uuid";
import { score } from "wcag-color";

View File

@@ -16,8 +16,8 @@ import { useRoute } from "vue-router";
import TSwitchTheme from "../components/app/t-switchTheme.vue";
import ToLoading from "../components/overlay/to-loading.vue";
import { AnnoLang, AnnoServer } from "../web/request/getAnno";
import TGRequest from "../web/request/TGRequest";
import { AnnoLang, AnnoServer } from "../web/request/getAnno.js";
import TGRequest from "../web/request/TGRequest.js";
// loading
const loading = ref<boolean>(true);

View File

@@ -30,13 +30,13 @@ import { useRoute } from "vue-router";
import TSwitchTheme from "../components/app/t-switchTheme.vue";
import TShareBtn from "../components/main/t-shareBtn.vue";
import ToLoading from "../components/overlay/to-loading.vue";
import { useAppStore } from "../store/modules/app";
import TGLogger from "../utils/TGLogger";
import { saveImgLocal } from "../utils/TGShare";
import { createTGWindow } from "../utils/TGWindow";
import { AnnoLang, AnnoServer } from "../web/request/getAnno";
import TGRequest from "../web/request/TGRequest";
import TGUtils from "../web/utils/TGUtils";
import { useAppStore } from "../store/modules/app.js";
import TGLogger from "../utils/TGLogger.js";
import { saveImgLocal } from "../utils/TGShare.js";
import { createTGWindow } from "../utils/TGWindow.js";
import { AnnoLang, AnnoServer } from "../web/request/getAnno.js";
import TGRequest from "../web/request/TGRequest.js";
import TGUtils from "../web/utils/TGUtils.js";
// loading
const loading = ref<boolean>(true);

View File

@@ -16,7 +16,7 @@ import { useRoute } from "vue-router";
import TSwitchTheme from "../components/app/t-switchTheme.vue";
import ToLoading from "../components/overlay/to-loading.vue";
import Mys from "../plugins/Mys";
import Mys from "../plugins/Mys/index.js";
// loading
const loading = ref<boolean>(true);

View File

@@ -93,11 +93,11 @@ import TbCollect from "../components/post/tb-collect.vue";
import TpAvatar from "../components/post/tp-avatar.vue";
import TpParser from "../components/post/tp-parser.vue";
import TpoCollection from "../components/post/tpo-collection.vue";
import Mys from "../plugins/Mys";
import { useAppStore } from "../store/modules/app";
import TGClient from "../utils/TGClient";
import TGLogger from "../utils/TGLogger";
import { createTGWindow } from "../utils/TGWindow";
import Mys from "../plugins/Mys/index.js";
import { useAppStore } from "../store/modules/app.js";
import TGClient from "../utils/TGClient.js";
import TGLogger from "../utils/TGLogger.js";
import { createTGWindow } from "../utils/TGWindow.js";
// loading
const loading = ref<boolean>(true);

1
src/vite-env.d.ts vendored
View File

@@ -47,5 +47,4 @@ interface ImportMetaEnv {
declare interface ImportMeta {
readonly env: ImportMetaEnv;
readonly glob: (path: string) => Record<string, () => Promise<any>>;
}

View File

@@ -5,9 +5,9 @@
* @since Beta v0.3.2
*/
import { BBSUserInfoApi } from "./BBS";
import { ENKA_API } from "./ENKA";
import { PassportTokenApi, PassportCookieTokenApi, PassportVerifyApi } from "./Passport";
import { BBSUserInfoApi } from "./BBS.js";
import { ENKA_API } from "./ENKA.js";
import { PassportTokenApi, PassportCookieTokenApi, PassportVerifyApi } from "./Passport.js";
import {
TakumiTokensApi,
TakumiRecordCardApi,
@@ -19,7 +19,7 @@ import {
TakumiCookieBindingRolesApi,
TakumiCalculateSyncAvatarListApi,
TakumiCalculateSyncAvatarDetailApi,
} from "./Takumi";
} from "./Takumi.js";
// 应用 API
const TGApi = {

View File

@@ -4,9 +4,9 @@
* @since Beta v0.3.6
*/
import { BBS_APP_ID, BBS_SALT, BBS_UA_MOBILE, BBS_UA_PC, BBS_VERSION } from "./bbs";
import SERVER from "./server";
import { GAME_BIZ } from "./utils";
import { BBS_APP_ID, BBS_SALT, BBS_UA_MOBILE, BBS_UA_PC, BBS_VERSION } from "./bbs.js";
import SERVER from "./server.js";
import { GAME_BIZ } from "./utils.js";
const TGConstant = {
BBS: {

View File

@@ -4,25 +4,25 @@
* @since Beta v0.4.5
*/
import { genAuthkey, genAuthkey2 } from "./genAuthkey";
import { getAbyss } from "./getAbyss";
import { getActionTicketBySToken } from "./getActionTicket";
import { getAnnoContent, getAnnoList } from "./getAnno";
import { getCookieTokenByGameToken, getCookieTokenBySToken } from "./getCookieToken";
import { getDeviceFp } from "./getDeviceFp";
import { genAuthkey, genAuthkey2 } from "./genAuthkey.js";
import { getAbyss } from "./getAbyss.js";
import { getActionTicketBySToken } from "./getActionTicket.js";
import { getAnnoContent, getAnnoList } from "./getAnno.js";
import { getCookieTokenByGameToken, getCookieTokenBySToken } from "./getCookieToken.js";
import { getDeviceFp } from "./getDeviceFp.js";
// import * from "./getEnkaData.ts";
import { getGachaLog } from "./getGachaLog";
import { getGameAccountsByCookie, getGameAccountsBySToken } from "./getGameAccounts";
import { getGameRecord } from "./getGameRecord";
import { getLTokenBySToken } from "./getLToken";
import { getGameRoleListByLToken } from "./getRoleList";
import { getStokenByGameToken, getTokenBySToken } from "./getStoken";
import getSyncAvatarDetail from "./getSyncAvatarDetail";
import getSyncAvatarListAll from "./getSyncAvatarListAll";
import { getTokensByLoginTicket } from "./getTokens";
import { getUserCollect } from "./getUserCollect";
import { getUserInfoByCookie } from "./getUserInfo";
import { verifyLToken } from "./verifyLToken";
import { getGachaLog } from "./getGachaLog.js";
import { getGameAccountsByCookie, getGameAccountsBySToken } from "./getGameAccounts.js";
import { getGameRecord } from "./getGameRecord.js";
import { getLTokenBySToken } from "./getLToken.js";
import { getGameRoleListByLToken } from "./getRoleList.js";
import { getStokenByGameToken, getTokenBySToken } from "./getStoken.js";
import getSyncAvatarDetail from "./getSyncAvatarDetail.js";
import getSyncAvatarListAll from "./getSyncAvatarListAll.js";
import { getTokensByLoginTicket } from "./getTokens.js";
import { getUserCollect } from "./getUserCollect.js";
import { getUserInfoByCookie } from "./getUserInfo.js";
import { verifyLToken } from "./verifyLToken.js";
const TGRequest = {
Anno: {

View File

@@ -5,12 +5,13 @@
*/
import { http } from "@tauri-apps/api";
import { Response } from "@tauri-apps/api/http";
import TGApi from "../api/TGApi";
import TGUtils from "../utils/TGUtils";
import TGApi from "../api/TGApi.js";
import TGUtils from "../utils/TGUtils.js";
/**
* @description 根据 login_ticket 获取游戏 Token包括 stoken 和 ltoken
* @description 根据 login_ticket 获取游戏 Token包括 sToken 和 lToken
* @since Beta v0.4.3
* @param {string} ticket 登录票证
* @param {string} uid 登录用户 uid
@@ -20,23 +21,15 @@ export async function getTokensByLoginTicket(
ticket: string,
uid: string,
): Promise<TGApp.BBS.Response.getTokensRes[] | TGApp.BBS.Response.Base> {
const cookie = {
login_ticket: ticket,
login_uid: uid,
};
const cookie = { login_ticket: ticket, login_uid: uid };
const url = TGApi.GameTokens.getTokens;
const params = { login_ticket: ticket, token_types: "3", uid };
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
return await http
.fetch<TGApp.BBS.Response.getTokens | TGApp.BBS.Response.Base>(url, {
method: "GET",
headers: header,
query: params,
})
.then((res) => {
.fetch(url, { method: "GET", headers: header, query: params })
.then((res: Response<TGApp.BBS.Response.getTokens | TGApp.BBS.Response.Base>) => {
console.log(res);
if (res.data.retcode !== 0) return <TGApp.BBS.Response.Base>res.data;
if (res.data.retcode !== 0) return res.data;
return res.data.data.list;
});
}

View File

@@ -5,9 +5,10 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGApi from "../api/TGApi";
import TGUtils from "../utils/TGUtils";
import TGApi from "../api/TGApi.js";
import TGUtils from "../utils/TGUtils.js";
/**
* @description 根据 cookie 获取用户信息
@@ -28,12 +29,8 @@ export async function getUserInfoByCookie(
const params = { gids: "2" };
const header = TGUtils.User.getHeader(cookie, "GET", params, "common", true);
return await http
.fetch<TGApp.Plugins.Mys.User.HomeResponse | TGApp.BBS.Response.Base>(url, {
method: "GET",
headers: header,
query: params,
})
.then((res) => {
.fetch(url, { method: "GET", headers: header, query: params })
.then((res: Response<TGApp.Plugins.Mys.User.HomeResponse | TGApp.BBS.Response.Base>) => {
if (res.data.retcode !== 0) return res.data;
return res.data.data.user_info;
});

View File

@@ -5,9 +5,10 @@
*/
import { http } from "@tauri-apps/api";
import type { Response } from "@tauri-apps/api/http";
import TGApi from "../api/TGApi";
import TGUtils from "../utils/TGUtils";
import TGApi from "../api/TGApi.js";
import TGUtils from "../utils/TGUtils.js";
/**
* @description 验证 ltoken 有效性,返回 mid
@@ -21,20 +22,13 @@ export async function verifyLToken(
ltuid: string,
): Promise<string | TGApp.BBS.Response.Base> {
const url = TGApi.GameTokens.verifyLToken;
const cookie = {
ltoken,
ltuid,
};
const cookie = { ltoken, ltuid };
const data = { ltoken };
const header = TGUtils.User.getHeader(cookie, "POST", data, "common");
return await http
.fetch<TGApp.BBS.Response.verifyUserInfoBySToken | TGApp.BBS.Response.Base>(url, {
method: "POST",
headers: header,
body: http.Body.json(data),
})
.then((res) => {
if (res.data.retcode !== 0) return res.data;
.fetch(url, { method: "POST", headers: header, body: http.Body.json(data) })
.then((res: Response<TGApp.BBS.Response.verifyUserInfoBySToken | TGApp.BBS.Response.Base>) => {
if (res.data.retcode !== 0) return <TGApp.BBS.Response.Base>res.data;
return res.data.data.user_info.mid;
});
}

View File

@@ -4,10 +4,10 @@
* @since Beta v0.3.4
*/
import { getAnnoCard } from "./getAnnoCard";
import { getRequestHeader } from "./getRequestHeader";
import { parseAnnoContent } from "./parseAnno";
import { getServerByUid, transCookie } from "./tools";
import { getAnnoCard } from "./getAnnoCard.js";
import { getRequestHeader } from "./getRequestHeader.js";
import { parseAnnoContent } from "./parseAnno.js";
import { getServerByUid, transCookie } from "./tools.js";
const TGUtils = {
Anno: {

View File

@@ -6,10 +6,10 @@
import Md5 from "js-md5";
import { getDeviceInfo, getRandomString } from "../../utils/toolFunc";
import TGConstant from "../constant/TGConstant";
import { getDeviceInfo, getRandomString } from "../../utils/toolFunc.js";
import TGConstant from "../constant/TGConstant.js";
import { transCookie, transParams } from "./tools";
import { transCookie, transParams } from "./tools.js";
/**
* @description 获取 salt

View File

@@ -4,10 +4,10 @@
* @since Beta v0.4.7
*/
import { saveImgLocal } from "../../utils/TGShare";
import { isColorSimilar } from "../../utils/toolFunc";
import { saveImgLocal } from "../../utils/TGShare.js";
import { isColorSimilar } from "../../utils/toolFunc.js";
import { decodeRegExp } from "./tools";
import { decodeRegExp } from "./tools.js";
/**
* @description 解析 a