Files
dcalc/frontend-ui/src/pages/Character/Config/import.vue
T
2026-08-04 17:57:01 +08:00

73 lines
2.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script lang="tsx">
import { useAsyncState } from '@vueuse/core'
import { defineComponent, ref } from 'vue'
import api from '@/api'
import { useDialog } from '@/components/hooks/dialog'
import { isShow, onShow } from '@/components/hooks/show'
import { useConfigStore } from '@/stores'
export default defineComponent({
setup() {
const configStore = useConfigStore()
const uid = ref('')
const { state, execute, isLoading } = useAsyncState(
async () => {
const res = await api.getConfigFromHelper(uid.value)
configStore.config.equips = res.equips
configStore.config.avatar = res.avatars
configStore.config.avatarLink = res.avatarLink
configStore.config.emblems = res.emblems
configStore.config.sundry.fog = res.fogOathLv
configStore.config.oaths = res.oaths
const { alert } = useDialog()
visible.value = false
await alert({
content: '导入成功',
})
return res
},
undefined,
{
resetOnExecute: false,
immediate: false,
onError: Promise.reject,
},
)
onShow(
() => {
uid.value = ''
state.value = undefined
},
{ immediate: true },
)
const visible = isShow()
return () => {
return (
<>
<div class="h-30 w-80 py-2 px-4 text-#e9c556">
<div class="flex justify-around items-center">
助手社区ID
<calc-input class="!w-60" v-model={uid.value} />
</div>
<div>
<p class="text-#e9c556/80">* 点击导入后会从助手通过文字识别获取打造</p>
<p class="text-#e9c556/80">* 部分打造无法获取,此处仅做快捷导入</p>
</div>
<div class="flex justify-around items-center">
<calc-button onClick={execute} disabled={isLoading.value}>
导入
</calc-button>
<calc-button onClick={() => (visible.value = false)}>取消</calc-button>
</div>
</div>
</>
)
}
},
})
</script>