Skip to content

Commit

Permalink
fix: comment ref
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Mar 27, 2024
1 parent af585e5 commit 590c172
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
30 changes: 21 additions & 9 deletions src/utils/is-init.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { router } from '~/router'

import { RESTManager } from './rest'

export const checkIsInit = async (): Promise<boolean> => {
Expand All @@ -6,17 +8,27 @@ export const checkIsInit = async (): Promise<boolean> => {
return (
window.injectData?.INIT ??
(
await RESTManager.api.init.get<{ isInit: boolean }>({
errorHandler(e) {
if (e?.response.status == 404) {
return
await RESTManager.api.init
.get<{ isInit: boolean }>({
errorHandler(e) {
if (e?.response.status == 404) {
return { isInit: true }
}
throw e
},
})
.then((res) => {
if (typeof res !== 'object' || (res && !('isInit' in res))) {
console.log('err sss')
router.push('/setup-api')
message.error('api error')
}
throw e
},
})
).isInit
return res
})
).isInit === true
)
} catch (e) {
return true
console.error(e)
return false
}
}
6 changes: 3 additions & 3 deletions src/views/comments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ const ManageComment = defineComponent(() => {
render(row: any) {
const link = (() => {
switch (row.refType) {
case 'Post': {
case 'posts': {
return `${WEB_URL}/posts/${row.ref.category.slug}/${row.ref.slug}`
}
case 'Note': {
case 'notes': {
return `${WEB_URL}/notes/${row.ref.nid}`
}
case 'Page': {
case 'pages': {
return `${WEB_URL}/${row.ref.slug}`
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/views/setup-api/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { NButton, NCard, NForm, NFormItem, NSelect, NSwitch } from 'naive-ui'
import { defineComponent } from 'vue'

import { router } from '~/router'

const storeApiUrlKey = 'mx-admin:setup-api:url'
const storeGatewayUrlKey = 'mx-admin:setup-api:gateway'

Expand Down Expand Up @@ -41,9 +39,10 @@ export default defineComponent({
storeGatewayUrlKey,
JSON.stringify([...new Set(historyApiUrl.concat(gatewayUrl))]),
)

// location.href = url.toString()
router.push('/dashboard').then(() => location.reload())
const url = new URL(location.href)
url.hash = '#/dashboard'
location.href = url.toString()
location.reload()
}
const handleReset = () => {
localStorage.removeItem('__api')
Expand Down
4 changes: 3 additions & 1 deletion src/views/setup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type { PropType } from 'vue'
import type { UserModel } from '../../models/user'

import { showConfetti } from '~/utils/confetti'
import { checkIsInit } from '~/utils/is-init'

import { getToken, removeToken } from '../../utils'
import { RESTManager } from '../../utils/rest'
Expand All @@ -24,7 +25,8 @@ import styles from './index.module.css'
const useDefaultConfigs = () => inject<any>('configs')
export default defineComponent({
setup() {
onBeforeMount(() => {
onBeforeMount(async () => {
await checkIsInit()
if (getToken()) {
removeToken()
}
Expand Down

0 comments on commit 590c172

Please sign in to comment.