mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🎨 一些小改动
This commit is contained in:
@@ -59,7 +59,7 @@ onMounted(() => {
|
|||||||
transition: all 0.3s ease-in-out;
|
transition: all 0.3s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.back-top :hover {
|
.back-top:hover {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transform: scale(0.9);
|
transform: scale(0.9);
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
// vue
|
// vue
|
||||||
import { onMounted, ref, shallowRef } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import TMiniAvatar from "./t-mini-avatar.vue";
|
import TMiniAvatar from "./t-mini-avatar.vue";
|
||||||
import TMiniWeapon from "./t-mini-weapon.vue";
|
import TMiniWeapon from "./t-mini-weapon.vue";
|
||||||
import TCalendarMaterial from "./t-calendar-material.vue";
|
import TCalendarMaterial from "./t-calendar-material.vue";
|
||||||
|
|||||||
@@ -64,7 +64,6 @@
|
|||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list-group>
|
</v-list-group>
|
||||||
<v-divider />
|
|
||||||
<div class="bottom-menu">
|
<div class="bottom-menu">
|
||||||
<v-list-item>
|
<v-list-item>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
|
|||||||
@@ -1,168 +0,0 @@
|
|||||||
<template>
|
|
||||||
<h1>用户页</h1>
|
|
||||||
<div class="testDiv">
|
|
||||||
<v-btn @click="updateTokens">
|
|
||||||
更新 Tokens
|
|
||||||
</v-btn>
|
|
||||||
<v-btn @click="vertifyStoken">
|
|
||||||
验证 stoken
|
|
||||||
</v-btn>
|
|
||||||
<v-btn @click="getLToken">
|
|
||||||
获取 ltoken
|
|
||||||
</v-btn>
|
|
||||||
<v-btn @click="getUserGameCard">
|
|
||||||
获取游戏数据
|
|
||||||
</v-btn>
|
|
||||||
<v-btn @click="getBindRole">
|
|
||||||
获取绑定角色
|
|
||||||
</v-btn>
|
|
||||||
<v-btn @click="getBindRoleV2">
|
|
||||||
获取绑定角色 v2
|
|
||||||
</v-btn>
|
|
||||||
<v-btn @click="getCookieToken">
|
|
||||||
获取 cookieToken
|
|
||||||
</v-btn>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script setup lang="ts">
|
|
||||||
// vue
|
|
||||||
import { onMounted, ref } from "vue";
|
|
||||||
// tauri
|
|
||||||
import { dialog } from "@tauri-apps/api";
|
|
||||||
// utils
|
|
||||||
import TGRequest from "../core/request/TGRequest";
|
|
||||||
import TGSqlite from "../utils/TGSqlite";
|
|
||||||
import TGUtils from "../core/utils/TGUtils";
|
|
||||||
|
|
||||||
const cookie = ref({} as BTMuli.User.Base.Cookie);
|
|
||||||
|
|
||||||
export interface tokenRes {
|
|
||||||
name: string;
|
|
||||||
token: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const getCookie = await TGSqlite.getDataByKey("AppData", "key", "cookie") as Array<{
|
|
||||||
key: string;
|
|
||||||
value: string;
|
|
||||||
updated: string;
|
|
||||||
}>;
|
|
||||||
cookie.value = JSON.parse(getCookie[0].value) as BTMuli.User.Base.Cookie;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 根据获取到的 cookie.login_ticket 获取 stoken 和 ltoken
|
|
||||||
async function updateTokens () {
|
|
||||||
const tokenRes = await TGRequest.User.byLoginTicket.getLTokens(cookie.value);
|
|
||||||
console.log(tokenRes);
|
|
||||||
if (Array.isArray(tokenRes)) {
|
|
||||||
const lToken = tokenRes.find((item) => item.name === "ltoken");
|
|
||||||
const sToken = tokenRes.find((item) => item.name === "stoken");
|
|
||||||
if (lToken) await TGSqlite.saveAppData("ltoken", lToken.token);
|
|
||||||
if (sToken) await TGSqlite.saveAppData("stoken", sToken.token);
|
|
||||||
} else {
|
|
||||||
await dialog.message(
|
|
||||||
tokenRes.message,
|
|
||||||
{
|
|
||||||
type: "error",
|
|
||||||
title: `获取 Token 失败,retcode: ${tokenRes.retcode}`,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证 stoken 的有效性
|
|
||||||
async function vertifyStoken () {
|
|
||||||
// 获取 stoken
|
|
||||||
const stoken = (await TGSqlite.getDataByKey("AppData", "key", "stoken") as unknown as Array<{
|
|
||||||
key: string;
|
|
||||||
value: string;
|
|
||||||
}>)[0].value as string;
|
|
||||||
console.log("stoken", stoken);
|
|
||||||
const vertifyRes = await TGRequest.User.bySToken.vertify(cookie.value, stoken);
|
|
||||||
console.log(vertifyRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取 ltoken
|
|
||||||
async function getLToken () {
|
|
||||||
const stoken = (await TGSqlite.getDataByKey("AppData", "key", "stoken") as unknown as Array<{
|
|
||||||
key: string;
|
|
||||||
value: string;
|
|
||||||
}>)[0].value as string;
|
|
||||||
console.log("stoken", stoken);
|
|
||||||
const tokenRes = await TGRequest.User.bySToken.getLToken(cookie.value, stoken);
|
|
||||||
console.log(tokenRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取 cookieToken, done, 但是登录失效
|
|
||||||
async function getCookieToken () {
|
|
||||||
const stoken = (await TGSqlite.getDataByKey("AppData", "key", "stoken") as unknown as Array<{
|
|
||||||
key: string;
|
|
||||||
value: string;
|
|
||||||
}>)[0].value as string;
|
|
||||||
console.log("stoken", stoken);
|
|
||||||
const cookieRes = await TGRequest.User.bySToken.getCookieToken(cookie.value, stoken);
|
|
||||||
console.log(cookieRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取游戏数据
|
|
||||||
async function getUserGameCard () {
|
|
||||||
const gameCard = await TGRequest.User.byCookie.getGameCard(cookie.value);
|
|
||||||
console.log(gameCard);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 通过 stoken 获取绑定角色,但是登录失效
|
|
||||||
async function getBindRole () {
|
|
||||||
const ck = TGUtils.Tools.cookieToString(cookie.value);
|
|
||||||
const stoken = (await TGSqlite.getDataByKey("AppData", "key", "stoken") as unknown as Array<{
|
|
||||||
key: string;
|
|
||||||
value: string;
|
|
||||||
}>)[0].value as string;
|
|
||||||
const bindRole = await TGRequest.User.bySToken.getAccounts(ck, stoken);
|
|
||||||
console.log(bindRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 通过 cookie 获取绑定角色
|
|
||||||
async function getBindRoleV2 () {
|
|
||||||
const ck = TGUtils.Tools.cookieToString(cookie.value);
|
|
||||||
const bindRole = await TGRequest.User.byCookie.getAccounts(ck);
|
|
||||||
console.log(bindRole);
|
|
||||||
// 如果是数组,说明数据获取成功
|
|
||||||
if (Array.isArray(bindRole)) {
|
|
||||||
bindRole.map(async (role: BTMuli.User.Game.Account) => {
|
|
||||||
const sql = `
|
|
||||||
INSERT INTO GameAccount (gameBiz, gameUid, isChosen, isOfficial, level, nickname, region, regionName, updated)
|
|
||||||
VALUES ('${role.game_biz}', '${role.game_uid}', ${role.is_chosen ? 1 : 0}, ${role.is_official ? 1 : 0}, '${role.level}', '${role.nickname}', '${role.region}', '${role.region_name}', datetime('now', 'localtime'))
|
|
||||||
ON CONFLICT (gameBiz, gameUid) DO UPDATE SET
|
|
||||||
isChosen = ${role.is_chosen ? 1 : 0},
|
|
||||||
isOfficial = ${role.is_official ? 1 : 0},
|
|
||||||
level = '${role.level}',
|
|
||||||
nickname = '${role.nickname}',
|
|
||||||
region = '${role.region}',
|
|
||||||
regionName = '${role.region_name}',
|
|
||||||
updated = datetime('now', 'localtime');
|
|
||||||
`;
|
|
||||||
// 保存到数据库
|
|
||||||
await TGSqlite.saveData(sql);
|
|
||||||
});
|
|
||||||
console.log("保存成功");
|
|
||||||
} else {
|
|
||||||
await dialog.message(
|
|
||||||
bindRole.message,
|
|
||||||
{
|
|
||||||
type: "error",
|
|
||||||
title: `获取绑定角色失败,retcode: ${bindRole.retcode}`,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<style scoped>
|
|
||||||
.testDiv {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: space-between;
|
|
||||||
width: 100%;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
7
src/pages/User/test.vue
Normal file
7
src/pages/User/test.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<h1>测试页</h1>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
</script>
|
||||||
|
<style lang="css" scoped>
|
||||||
|
</style>
|
||||||
@@ -224,7 +224,7 @@ export interface UserCommunityInfo {
|
|||||||
/**
|
/**
|
||||||
* @description 用户信息-在 post 中的用户信息
|
* @description 用户信息-在 post 中的用户信息
|
||||||
* @since Alpha v0.1.2
|
* @since Alpha v0.1.2
|
||||||
* @interface UserUserInfoPost
|
* @interface UserInfoPost
|
||||||
* @property {string} uid 用户 ID
|
* @property {string} uid 用户 ID
|
||||||
* @property {string} nickname 用户昵称
|
* @property {string} nickname 用户昵称
|
||||||
* @property {string} introduce 用户简介
|
* @property {string} introduce 用户简介
|
||||||
|
|||||||
@@ -2,13 +2,12 @@
|
|||||||
* @file router modules main.ts
|
* @file router modules main.ts
|
||||||
* @description 主路由模块
|
* @description 主路由模块
|
||||||
* @author BTMuli<bt-muli@outlook.com>
|
* @author BTMuli<bt-muli@outlook.com>
|
||||||
* @since Alpha v0.2.0
|
* @since Alpha v0.1.5
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 信息展示
|
// 信息展示
|
||||||
import Announcements from "../../pages/Announcements.vue";
|
import Announcements from "../../pages/Announcements.vue";
|
||||||
import Home from "../../pages/Home.vue";
|
import Home from "../../pages/Home.vue";
|
||||||
import User from "../../pages/User.vue";
|
|
||||||
// 数据交互
|
// 数据交互
|
||||||
import Achievements from "../../pages/Achievements.vue";
|
import Achievements from "../../pages/Achievements.vue";
|
||||||
// 应用配置相关
|
// 应用配置相关
|
||||||
@@ -20,11 +19,6 @@ const mainRoutes = [
|
|||||||
name: "首页",
|
name: "首页",
|
||||||
component: Home,
|
component: Home,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: "/user",
|
|
||||||
name: "用户",
|
|
||||||
component: User,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: "/achievements",
|
path: "/achievements",
|
||||||
name: "成就",
|
name: "成就",
|
||||||
|
|||||||
21
src/router/modules/user.ts
Normal file
21
src/router/modules/user.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* @file router modules user.ts
|
||||||
|
* @description user 路由模块
|
||||||
|
* @author BTMuli<bt-muli@outlook.com>
|
||||||
|
* @since Alpha v0.2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
// user test
|
||||||
|
import test from "../../pages/User/test.vue";
|
||||||
|
// user main
|
||||||
|
// user sub
|
||||||
|
|
||||||
|
const userRoutes = [
|
||||||
|
{
|
||||||
|
path: "/user/test",
|
||||||
|
name: "测试",
|
||||||
|
component: test,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default userRoutes;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
* @file router routes.ts
|
* @file router routes.ts
|
||||||
* @description 路由配置
|
* @description 路由配置
|
||||||
* @author BTMuli<bt-muli@outlook.com>
|
* @author BTMuli<bt-muli@outlook.com>
|
||||||
* @since Alpha v0.1.3
|
* @since Alpha v0.2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 主路由
|
// 主路由
|
||||||
@@ -11,8 +11,15 @@ import mainRoutes from "./modules/main";
|
|||||||
import subRoutes from "./modules/sub";
|
import subRoutes from "./modules/sub";
|
||||||
// Wiki 路由
|
// Wiki 路由
|
||||||
import wikiRoutes from "./modules/wiki";
|
import wikiRoutes from "./modules/wiki";
|
||||||
|
// user 路由
|
||||||
|
import userRoutes from "./modules/user";
|
||||||
|
|
||||||
// 合并路由
|
// 合并路由
|
||||||
const routes = [...mainRoutes, ...subRoutes, ...wikiRoutes];
|
const routes = [
|
||||||
|
...mainRoutes,
|
||||||
|
...subRoutes,
|
||||||
|
...wikiRoutes,
|
||||||
|
...userRoutes,
|
||||||
|
];
|
||||||
|
|
||||||
export default routes;
|
export default routes;
|
||||||
|
|||||||
2
src/types/GCG.d.ts
vendored
2
src/types/GCG.d.ts
vendored
@@ -11,7 +11,7 @@ declare namespace BTMuli.Genshin.Wiki.GCG {
|
|||||||
* @since Alpha v0.1.3
|
* @since Alpha v0.1.3
|
||||||
* @interface BriefInfo
|
* @interface BriefInfo
|
||||||
* @property {number} id - 卡牌 ID
|
* @property {number} id - 卡牌 ID
|
||||||
* @property {umber} content_id - 观测枢 ID
|
* @property {number} content_id - 观测枢 ID
|
||||||
* @property {string} name - 卡牌名称
|
* @property {string} name - 卡牌名称
|
||||||
* @property {string} type - 卡牌类型
|
* @property {string} type - 卡牌类型
|
||||||
* @property {string} icon - 卡牌图标
|
* @property {string} icon - 卡牌图标
|
||||||
|
|||||||
2
src/types/UserRequest.d.ts
vendored
2
src/types/UserRequest.d.ts
vendored
@@ -28,7 +28,7 @@ declare namespace BTMuli.User.Base {
|
|||||||
* @property {string} stoken stoken
|
* @property {string} stoken stoken
|
||||||
* @property {string} stuid stoken 对应的 uid
|
* @property {string} stuid stoken 对应的 uid
|
||||||
* @description stoken_v2 与 mid 一起使用,这是新版本的 token
|
* @description stoken_v2 与 mid 一起使用,这是新版本的 token
|
||||||
* @todo 目前只完成 mid 的获取,stoken_v2 的获取还没完成
|
* @see https://github.com/BTMuli/Tauri.Genshin/issues/18
|
||||||
* @property {string} stokenV2 stoken_v2
|
* @property {string} stokenV2 stoken_v2
|
||||||
* @property {string} mid mid
|
* @property {string} mid mid
|
||||||
* @returns Cookie
|
* @returns Cookie
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ enum SERVER {
|
|||||||
OS_ASIA = "os_asia",
|
OS_ASIA = "os_asia",
|
||||||
OS_CHT = "os_cht",
|
OS_CHT = "os_cht",
|
||||||
UNKNOWN = "unknown",
|
UNKNOWN = "unknown",
|
||||||
};
|
}
|
||||||
|
|
||||||
export default SERVER;
|
export default SERVER;
|
||||||
|
|||||||
Reference in New Issue
Block a user