Skip to content

Commit 5c83adf

Browse files
committed
Fix login state check and deprecated event subscribers(eventemitter)
1 parent 3e4ecdc commit 5c83adf

10 files changed

Lines changed: 36 additions & 56 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy to gh-pages
1+
name: Run ts and eslint checks
22

33
on:
44
push:
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install Git
2828
run: sudo apt-get install git -y
2929

30-
- name: Switch to gh-pages branch
30+
- name: Configure git user
3131
run: |
3232
git config user.name "github-actions[bot]"
3333
git config user.email "github-actions[bot]@users.noreply.github.com"
@@ -38,6 +38,6 @@ jobs:
3838
- name: Eslint checks
3939
run: npm run eslint
4040

41-
- name: Build project
41+
- name: Building test
4242
run: npm run build
4343

README-zh.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
## 待办事项
4242

4343
如果你想开始贡献,方向如下:
44+
- [ ] 完成设置界面(包括i18n的切换,和导出错误日志等功能),组件在./views/settings user.config.ts system.config.ts 都已经有雏形了
45+
- [ ] 重新设计错误日志,现在的这支格式太烂了
4446
- [ ] 运行时的一些错误可能无法被检测
4547
- [ ] 修复窗口过大时的样式问题
4648
- [ ] 完善响应式设计,目前字体等大小都有问题

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ And most importantly, we sincerely thanks to the previous contributors: Arenfell
4141
## TO do list
4242

4343
If you want to start a contribution, here is some directions:
44+
- [ ] Complete the settings page(including i18n switch, export error log etc), the components in ./views/settings user.config.ts system.config.ts already have a prototype
45+
- [ ] Redesign the error log, the format now is terrible
4446
- [ ] Some errors in runtime may not be detected
4547
- [ ] Fix the style when the window is too large
4648
- [ ] Improve the responsive design, there are problems with font size and others now

src/components/messages/NotificationList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function fillInTemplate(data: string, message: PMessage) {
156156
// 处理加载事件
157157
// eslint-disable-next-line max-lines-per-function
158158
const handleLoad = async (noTemplates = true) => {
159-
if (!storageManager.getObj("userInfo").value?.ID) return;
159+
if (storageManager.getObj("userInfo").value?.Nickname == null) return;
160160
if (loading.value) return; // Lock
161161
if (noMore.value) return;
162162
loading.value = true;

src/config/user.config.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import i18n from "../services/i18n/i18n";
22
import Emitter from "../services/eventEmitter";
33
import storageManager from "../services/storage";
4+
import { showDialog } from "@popup/naiveui";
45

56
export const settingsConfig = [
67
{
@@ -17,7 +18,7 @@ export const settingsConfig = [
1718
],
1819
callBack: (newValue: string) => {
1920
i18n.global.locale.value = newValue as "English" | "Chinese";
20-
Emitter.emit("nWarning", {
21+
showDialog("warning", {
2122
title: i18n.global.t("login.reLogin"),
2223
content: i18n.global.t("login.reLoginContent"),
2324
positiveText: i18n.global.t("login.confirm"),
@@ -52,12 +53,18 @@ export const settingsConfig = [
5253
if (newValue === "off") {
5354
localStorage.removeItem("error_logs");
5455
}
55-
Emitter.emit("nWarning", {
56+
showDialog("warning", {
5657
title: i18n.global.t("login.reLogin"),
5758
content: i18n.global.t("login.reLoginContent"),
5859
positiveText: i18n.global.t("login.confirm"),
5960
onPositiveClick: async () => {
60-
Emitter.emit("loginRequired");
61+
storageManager.remove("userInfo");
62+
window.$Logger.logEvent({
63+
category: "Account",
64+
action: "Toggle-Error-Logger",
65+
label: newValue,
66+
timestamp: Date.now(),
67+
});
6168
},
6269
});
6370
},

src/i18n/getTagName.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Emitter from "../services/eventEmitter";
22
import i18n from ".";
3+
import { showMessage } from "@popup/naiveui";
34

45
let tagConfig = [
56
{
@@ -740,7 +741,9 @@ export default function (tag: string): string {
740741
if (tag.startsWith("C-")) return tag;
741742
const tagObj = tagConfig.find((t) => t.Identifier === tag);
742743
if (!tagObj) {
743-
Emitter.emit("error", `Tag not found: ${tag}`, 3);
744+
showMessage("error", i18n.global.t("errors.tagNotFound", { tag }), {
745+
duration: 5000,
746+
});
744747
return tag;
745748
}
746749
return (tagObj?.Subject as any)[i18n.global.locale.value] || "";

src/services/api/login.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/services/errorLogger.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Emitter from "./eventEmitter";
21
import { ref } from "vue";
32
import storageManager from "./storage";
3+
import { showNotification } from "@popup/naiveui";
44

55
interface ErrorLog {
66
timestamp: number;
@@ -71,7 +71,11 @@ class ErrorLogger {
7171
...context,
7272
});
7373

74-
Emitter.emit("error", error.message, 0, error);
74+
showNotification({
75+
title: "Unkown Error Occurred",
76+
content: error.message,
77+
description: error.stack ? error.stack.slice(0, 100) : "",
78+
});
7579
}
7680

7781
exportToTxt(): void {

src/services/i18n/getTagName.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Emitter from "../eventEmitter";
22
import i18n from "./i18n";
3+
import { showMessage } from "@popup/naiveui";
34

45
let tagConfig = [
56
{
@@ -740,7 +741,9 @@ export default function (tag: string): string {
740741
if (tag.startsWith("C-")) return tag;
741742
const tagObj = tagConfig.find((t) => t.Identifier === tag);
742743
if (!tagObj) {
743-
Emitter.emit("error", `Tag not found: ${tag}`, 3);
744+
showMessage("error", i18n.global.t("errors.tagNotFound", { tag }), {
745+
duration: 1000,
746+
});
744747
return tag;
745748
}
746749
return (tagObj?.Subject as any)[i18n.global.locale.value] || "";

src/services/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import i18n from "./i18n/i18n";
99
import Emitter from "./eventEmitter";
1010
import storageManager from "./storage";
11-
import router from "../router";
11+
import { showDialog } from "@popup/naiveui";
1212

1313
type PUser = {
1414
ID: string;
@@ -254,13 +254,13 @@ export function removeToken(obj: any) {
254254
}
255255

256256
export function checkLogin() {
257-
if (storageManager.getObj("userInfo").value?.loginStatus !== true) {
258-
Emitter.emit("nWarning", {
257+
if (storageManager.getObj("userInfo").value?.Nickname == null) {
258+
showDialog("warning", {
259259
title: i18n.global.t("login.loginRequired"),
260260
content: i18n.global.t("login.loginContent"),
261261
positiveText: i18n.global.t("login.confirm"),
262262
onPositiveClick: async () => {
263-
router.push({ name: "Home" });
263+
Emitter.emit("loginRequired");
264264
},
265265
});
266266
}

0 commit comments

Comments
 (0)