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 e3ece26
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions components/calculator/index.vue
Original file line number Diff line number Diff line change
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 e3ece26

Please sign in to comment.