refactor: change js to ts

This commit is contained in:
zyronon 2024-04-08 02:06:05 +08:00
parent c3b544503d
commit 21e1327174
6 changed files with 7 additions and 7 deletions

View File

@ -56,11 +56,11 @@ export const useBaseStore = defineStore('base', {
getters: {}, getters: {},
actions: { actions: {
async init() { async init() {
let r = await panel() const r = await panel()
if (r.success) { if (r.success) {
this.userinfo = r.data this.userinfo = r.data
} }
let r2 = await friends() const r2 = await friends()
if (r2.success) { if (r2.success) {
this.users = r2.data this.users = r2.data
} }
@ -80,7 +80,7 @@ export const useBaseStore = defineStore('base', {
this.excludeRoutes.push(val.value) this.excludeRoutes.push(val.value)
} }
} else { } else {
let resIndex = this.excludeRoutes.findIndex((v) => v === val.value) const resIndex = this.excludeRoutes.findIndex((v) => v === val.value)
if (resIndex !== -1) { if (resIndex !== -1) {
this.excludeRoutes.splice(resIndex, 1) this.excludeRoutes.splice(resIndex, 1)
} }

View File

@ -16,11 +16,11 @@ export default {
this.eventMap.set(eventType, [cb]) this.eventMap.set(eventType, [cb])
}, },
off(eventType, fn) { off(eventType, fn) {
let cbs = this.eventMap.has(eventType) const cbs = this.eventMap.has(eventType)
if (cbs) { if (cbs) {
if (fn) { if (fn) {
let cbs = this.eventMap.get(eventType) const cbs = this.eventMap.get(eventType)
let rIndex = cbs.findIndex((v) => v === fn) const rIndex = cbs.findIndex((v) => v === fn)
if (rIndex > -1) { if (rIndex > -1) {
cbs.splice(rIndex, 1) cbs.splice(rIndex, 1)
} }
@ -34,7 +34,7 @@ export default {
this.eventMap = new Map() this.eventMap = new Map()
}, },
emit(eventType, val) { emit(eventType, val) {
let cbs = this.eventMap.get(eventType) const cbs = this.eventMap.get(eventType)
if (cbs) { if (cbs) {
cbs.map((cb) => cb(val)) cbs.map((cb) => cb(val))
} }