Skip to content

Commit b63c75a

Browse files
解决build报错:ts类型规范问题
1 parent c51b352 commit b63c75a

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

src/components/normal/Snackbar.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import { useSnackbarStore } from "@/stores/snackbarStore";
33
const snackbarStore = useSnackbarStore();
44
5-
const getIcon = (type) => {
5+
type IconType = 'info' | 'success' | 'error' | 'warning';
6+
const getIcon = (type: IconType) => {
67
const icon = {
78
info: "mdi-information",
89
success: "mdi-check-circle",

src/stores/authStore.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ export const useAuthStore = defineStore("auth", {
88
isLoggedIn: false,
99
user: null as UserInfo | null
1010
}),
11-
12-
persist: {
13-
enabled: true,
14-
strategies: [{ storage: localStorage, paths: ["isLoggedIn"] }],
15-
},
11+
persist: true,
1612

1713
getters: {},
1814

src/stores/snackbarStore.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { defineStore } from "pinia";
2+
type IconType = 'info' | 'success' | 'error' | 'warning';
23
export const useSnackbarStore = defineStore({
34
id: "snackbarStore",
45
state: () => ({
56
isShow: false,
67
message: "",
7-
type: "",
8+
type: "info" as IconType,
89
}),
910
getters: {},
1011
actions: {
1112
showMessage(message: string) {
1213
this.isShow = true;
1314
this.message = message;
14-
this.type = "";
15+
this.type = "info";
1516
},
1617

1718
showErrorMessage(message: string) {
@@ -24,11 +25,6 @@ export const useSnackbarStore = defineStore({
2425
this.message = message;
2526
this.type = "success";
2627
},
27-
showInfoMessage(message: string) {
28-
this.isShow = true;
29-
this.message = message;
30-
this.type = "info";
31-
},
3228
showWarningMessage(message: string) {
3329
this.isShow = true;
3430
this.message = message;

0 commit comments

Comments
 (0)