Skip to content

Commit

Permalink
refine api
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuiantw1212 committed May 12, 2024
1 parent f8f19ae commit 67237ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions components/calculator/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@

<h2 id="_五子登科" tabindex="-1">五子登科<a class="header-anchor" href="#五子登科"
aria-label="Permalink to &quot;五子登科&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_資產試算" tabindex="-1">證券資產試算<a class="header-anchor" href="#證券資產試算"
aria-label="Permalink to &quot;證券資產試算&quot;">&ZeroWidthSpace;</a></h3>
<h3 id="_資產試算" tabindex="-1">證券試算<a class="header-anchor" href="#證券試算"
aria-label="Permalink to &quot;證券試算&quot;">&ZeroWidthSpace;</a></h3>
<Asset v-model="userForm.security" :config="config" :profile="userForm.profile" :career="userForm.career"
:spouse="userForm.spouse" :parenting="userForm.parenting" :estate="userForm.estate"
:retirement="userForm.retirement" ref="SecurityRef" @update:model-value="onSecurityChanged()">
Expand Down Expand Up @@ -105,6 +105,11 @@
</div>
</template>
<script setup lang="ts">
/**
* 技術難點,卡片之間互相有交互資料連動,
* 要在避免無線迴圈的狀況下正確更新關聯資料。
* 目前卡片的debounce150ms,初始化的間隔抓200ms,看起來是正常的。
*/
import firebase from 'firebase/compat/app';
import { onMounted, ref, reactive, nextTick, } from 'vue'
import { ElMessage, ElMessageBox, } from 'element-plus'
Expand Down Expand Up @@ -254,9 +259,19 @@ function setUserAndInitialize(form, { showMessage = false }) {
ElMessage.info('載入成功')
}
nextTick(async () => {
await ProfileRef.value.calculateProfile()
changeAllCards({
propagate: true
})
setTimeout(() => {
changeAllCards({
propagate: false
})
}, 200);
// setTimeout(() => {
// })
// nextTick(() => {
// })
window.scrollTo(0, 0)
})
}
Expand Down Expand Up @@ -493,11 +508,6 @@ async function changeAllCards(from) {
const {
propagate = false,
} = from
if (!from.profile) {
await ProfileRef.value.calculateProfile({
propagate,
})
}
if (!from.career) {
await CareerRef.value.calculateCareer({
propagate,
Expand Down
2 changes: 1 addition & 1 deletion components/calculator/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ const { VITE_BASE_URL } = import.meta.env
import { ref, nextTick, computed, onMounted, onBeforeUnmount } from 'vue'
import firebase from 'firebase/compat/app';
import econSelect from '../econSelect.vue'
import { fa } from 'element-plus/es/locale';
const emits = defineEmits(['update:modelValue', 'signOut', 'upload'])
const loginDialogVisible = ref(false)
const firebaseUI = ref()
Expand Down Expand Up @@ -244,6 +243,7 @@ function openSignInDialog() {
}
})
}
async function calculateProfile(options: any = { propagate: true }) {
const { propagate = true } = options
customDebounce(() => {
Expand Down

0 comments on commit 67237ae

Please sign in to comment.