Skip to content

Commit

Permalink
merge displayIME into setLoading
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Jul 16, 2023
1 parent 76e6662 commit 2d42d59
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 36 deletions.
18 changes: 5 additions & 13 deletions src/components/MyDeployer.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
<script setup lang="ts">
import { toRefs } from 'vue'
import { useNotification } from 'naive-ui'
import { worker } from '../workerAPI'
import {
changeIME,
deployed,
selectOptions
selectOptions,
setLoading
} from '../control'
import type MyMenu from './MyMenu.vue'
const props = defineProps<{
menu: InstanceType<typeof MyMenu> | undefined
}>()
const { menu } = toRefs(props)
const notification = useNotification()
Expand All @@ -28,14 +21,14 @@ worker.control('deployStatus', async (status: 'start' | 'failure' | 'success', s
content: 'Deployment started',
...options
})
menu.value?.setLoading(true)
setLoading(true)
break
case 'failure':
notification.error({
content: 'Deployment failed',
...options
})
menu.value?.setLoading(false)
setLoading(false)
break
case 'success':
notification.success({
Expand All @@ -57,9 +50,8 @@ worker.control('deployStatus', async (status: 'start' | 'failure' | 'success', s
}
const currentSchema = schemasJson[0].id
await changeIME(currentSchema)
menu.value?.displayIME(currentSchema)
}
menu.value?.setLoading(false)
setLoading(false)
break
}
})
Expand Down
19 changes: 3 additions & 16 deletions src/components/MyMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { WeatherMoon16Regular, Circle16Regular } from '@vicons/fluent'
import {
init,
deployed,
loading,
schemaId,
ime,
selectOptions,
variants,
variant,
Expand All @@ -15,6 +17,7 @@ import {
isEnglishPunctuation,
enableEmoji,
schemaExtended,
setLoading,
changeLanguage,
changeVariant,
changeWidth,
Expand All @@ -25,21 +28,9 @@ import {
} from '../control'
import { getTextarea, getQueryString } from '../util'
const ime = ref<string>('') // visual vs internal
function displayIME (value: string) {
ime.value = value
}
const showVariant = ref<boolean>(false)
const loading = ref<boolean>(true)
function setLoading (value: boolean) {
loading.value = value
}
init(getQueryString('schemaId'), getQueryString('variantName')).then(() => {
displayIME(schemaId.value)
showVariant.value = true
setLoading(false)
})
Expand All @@ -56,9 +47,7 @@ async function selectIME (targetIME: string) {
resetFocus()
showVariant.value = false
setLoading(true)
displayIME('')
await changeIME(targetIME)
displayIME(targetIME) // update UI after variant properly set
showVariant.value = true
setLoading(false)
}
Expand All @@ -80,8 +69,6 @@ function resetFocus () {
}
defineExpose({
displayIME,
setLoading,
selectIME
})
</script>
Expand Down
11 changes: 8 additions & 3 deletions src/components/MyPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import {
process,
selectCandidateOnCurrentPage
} from '../workerAPI'
import { hideComment, changeLanguage, syncOptions } from '../control'
import {
loading,
hideComment,
changeLanguage,
syncOptions
} from '../control'
import { isMobile, getTextarea } from '../util'
const props = defineProps<{
Expand Down Expand Up @@ -208,7 +213,7 @@ watch(text, (acNewText, acText) => {
// end: code specific to Android Chromium
function onKeydown (e: KeyboardEvent) {
if (debugMode.value) {
if (debugMode.value || loading.value) {
return
}
const { code, key } = e
Expand Down Expand Up @@ -289,7 +294,7 @@ function onKeydown (e: KeyboardEvent) {
}
function onKeyup (e: KeyboardEvent) {
if (debugMode.value) {
if (debugMode.value || loading.value) {
return
}
const { key } = e
Expand Down
11 changes: 11 additions & 0 deletions src/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ const SIMPLIFICATION = 'simplification'
const deployed = ref<boolean>(false)

const schemaId = ref<string>(schemas[0].id)
const ime = ref<string>('') // visual vs internal

const loading = ref<boolean>(true)

function setLoading (value: boolean) {
loading.value = value
ime.value = value ? '' : schemaId.value
}

const schemaExtended: string[] = []

Expand Down Expand Up @@ -273,7 +281,9 @@ function syncOptions (updatedOptions: string[]) {
export {
init,
deployed,
loading,
schemaId,
ime,
selectOptions,
variants,
variant,
Expand All @@ -284,6 +294,7 @@ export {
enableEmoji,
schemaExtended,
hideComment,
setLoading,
changeLanguage,
changeVariant,
changeWidth,
Expand Down
2 changes: 1 addition & 1 deletion src/views/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const AsyncEditor = defineAsyncComponent(() => import('../components/MyEditor.vu
:on-update-schema="menu?.selectIME"
/>
<my-font />
<my-deployer :menu="menu" />
<my-deployer />
<micro-plum />
<n-space>
Advanced
Expand Down
12 changes: 9 additions & 3 deletions test-device/test-ios.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { test, expect, devices } from '@playwright/test'
import { baseURL, textarea, panelBox, input, expectValue } from '../test/util'
import {
init,
textarea,
panelBox,
input,
expectValue
} from '../test/util'

test.use({
...devices['iPhone 13 Mini']
})

test('Panel placement', async ({ page }) => {
await page.goto(baseURL)
await init(page)

await textarea(page).click()
await input(page, 'zhiding')
Expand All @@ -15,7 +21,7 @@ test('Panel placement', async ({ page }) => {
})

test('Panel overflow', async ({ page }) => {
await page.goto(baseURL)
await init(page)

await textarea(page).click()
await input(page, 'aaaaaaaaaaaaaaaaaaaaa ')
Expand Down

0 comments on commit 2d42d59

Please sign in to comment.