fix load saved data

This commit is contained in:
2025-01-23 13:58:16 +08:00
parent e022cb5d89
commit a8754d7925
5 changed files with 69 additions and 30 deletions

View File

@@ -28,7 +28,7 @@ const props = defineProps<{ pluginId: string }>();
const loading = ref(false);
const data: SavedData = reactive({
buttonName: '',
joinTables: [] as JoinTable[],
joinTables: [createEmptyJoinTable()],
});
const cachedData: CachedData = reactive({
@@ -43,15 +43,16 @@ const mainArea = shallowRef<HTMLElement | null>(null);
const spinner = shallowRef<Spinner | null>(null);
onMounted(async () => {
spinner.value?.close(); // 修复不自动挂载到节点的 bug
const savedData = kintone.plugin.app.getConfig(props.pluginId);
// TODO
data.buttonName = savedData?.buttonName || '集約';
data.joinTables = savedData?.joinTables ? JSON.parse(savedData.joinTables) : [createEmptyJoinTable()];
nextTick(async () => {
spinner.value?.close(); // fix bug: kuc-spinner will not auto amount to target HTML element when init loading
const savedData = kintone.plugin.app.getConfig(props.pluginId);
loading.value = true;
cachedData.apps = await loadApps();
cachedData.currentAppFields = await loadAppFieldsAndLayout();
if (savedData?.joinTables) {
data.joinTables = JSON.parse(savedData.joinTables); //TODO JSON;
}
data.buttonName = savedData?.buttonName || '集約';
loading.value = false;
});
});