fix: Improve bisector

This commit is contained in:
JLoeve 2023-02-20 22:40:53 +08:00
parent de541ec953
commit 6ad8b3e27b
4 changed files with 5 additions and 13 deletions

View File

@ -40,7 +40,7 @@ export default Vue.extend({
<style lang="scss" scoped>
.bisector-dialog-content-container {
padding: 8px;
padding: 12px;
.bisector-dialog-content-text {
margin-bottom: 8px;
}

View File

@ -1,7 +1,7 @@
import { DialogInstance, showDialog } from '@/core/dialog'
import type { Settings } from '@/core/settings/types'
import { Toast } from '@/core/toast'
import { getRandomId, mountVueComponent, sleep } from '@/core/utils'
import { getRandomId, mountVueComponent, delay } from '@/core/utils'
import { useScopedConsole } from '@/core/utils/log'
import type { RecordValue } from '../types'
import type { BisectNext, BisectReturn } from './bisect'
@ -93,7 +93,7 @@ export const stop = async () => {
const msg = `部分组件未能还原状态:${getComponentNames(unmatchedComponents)}`
scopedConsole?.warn(`stop - ${msg}`)
Toast.error(msg, '组件二等分')
await sleep(3e3)
await delay(3e3)
}
scopedConsole?.log('stop - 清理状态')
bisectorGenerator = null
@ -117,7 +117,7 @@ export const next = async (seeingBad?: boolean, autoReload?: boolean) => {
bisectorOptions.bisectInitialState = { low, high }
const elementId = `bisector-result-toast-content-${getRandomId()}`
Toast.info(/* html */ `<div id="${elementId}"></div>`, '组件二等分结果')
await sleep()
await delay()
const vm = mountVueComponent<{ userComponent: UserComponent }>(
ResultToastContent,
`#${elementId}`,

View File

@ -30,7 +30,7 @@ export const component = defineComponentMetadata({
name: 'bisector-start',
getActions: async () => [
{
name: '开始/继续组件二等分',
name: '开始 / 继续组件二等分',
description: 'Start/Continue component bisection',
icon: 'mdi-view-split-horizontal',
action: async () => {

View File

@ -634,11 +634,3 @@ export const getRandomId = (length = 8) => {
.join('')
.substring(0, length)
}
/**
*
*
* @param ms setTimeout
* @returns
*/
export const sleep = (ms?: number) => new Promise(resolve => setTimeout(resolve, ms))