Files
halo/ui/console-src/modules/system/plugins/components/entity-fields/ReloadField.vue
Ryan Wang f40770ad64 chore: add prettier-plugin-organize-imports plugin to organize imports (#6836)
#### What type of PR is this?

/area ui
/kind improvement
/milestone 2.20.x

#### What this PR does / why we need it:

使用 https://github.com/simonhaenisch/prettier-plugin-organize-imports 优化 UI 项目的模块导入,之前我们是通过[配置 VSCode](9468e8741f/ui/.vscode/settings.json (L34-L36)) 来实现导入优化,但这种方式局限于 VSCode 编辑器,在其他编辑器无法得到统一的支持。

并且我们为 UI 添加了 git pre commit hook,在提交代码前会对已修改的文件执行 prettier,这样能够更好的保证一致性。

<img width="1475" alt="image" src="https://github.com/user-attachments/assets/755e2aba-be07-4fba-8007-6210ef44a8ef">

#### Does this PR introduce a user-facing change?

```release-note
None
```
2024-10-12 07:05:09 +00:00

48 lines
1.2 KiB
Vue

<script setup lang="ts">
import { PluginStatusPhaseEnum, type Plugin } from "@halo-dev/api-client";
import { IconInformation, VButton } from "@halo-dev/components";
import { computed } from "vue";
const props = withDefaults(
defineProps<{
plugin: Plugin;
}>(),
{}
);
const enabledJsModulesInfo =
(window["enabledPlugins"] as { name: string; version: string }[]) || [];
const currentJsModuleInfo = enabledJsModulesInfo.find((jsModuleInfo) => {
return jsModuleInfo.name === props.plugin.metadata.name;
});
const needsReloadWindow = computed(() => {
if (!currentJsModuleInfo) {
return false;
}
const { version } = props.plugin.spec;
const { phase } = props.plugin.status || {};
const isStarted = PluginStatusPhaseEnum.Started === phase;
return isStarted && version !== currentJsModuleInfo?.version;
});
function handleReloadWindow() {
window.location.reload();
}
</script>
<template>
<VButton v-if="needsReloadWindow" size="xs" @click="handleReloadWindow">
<template #icon>
<IconInformation class="h-full w-full" />
</template>
{{ $t("core.plugin.operations.reload_window.button") }}
</VButton>
</template>
<style lang="scss" scoped></style>