feat: enhance app icon retrieval logic in home view (#11745)

- Updated app icon handling to use a dedicated function for improved clarity and maintainability.
- Introduced a new method, getAppIconSrc, to manage icon source retrieval based on app properties.
- Ensured proper handling of base64 and URL-based icons for better performance and consistency.
This commit is contained in:
KOMATA
2026-01-30 14:53:58 +08:00
committed by GitHub
parent 7b543ea5fe
commit 564333ea03
+10 -2
View File
@@ -27,7 +27,7 @@
<div class="h-app-card" v-for="(app, index) in apps" :key="index">
<el-row :gutter="5">
<el-col :span="5">
<el-avatar shape="square" :size="55" :src="'data:image/png;base64,' + app.icon" />
<el-avatar shape="square" :size="55" :src="getAppIconSrc(app)" />
</el-col>
<el-col :span="16">
<div class="h-app-content" v-if="!app.currentRow">
@@ -179,7 +179,7 @@
</template>
<script lang="ts" setup>
import { installedOp } from '@/api/modules/app';
import { getAppIconUrl, installedOp } from '@/api/modules/app';
import { getAgentSettingByKey } from '@/api/modules/setting';
import { changeLauncherStatus, loadAppLauncher, loadAppLauncherOption } from '@/api/modules/dashboard';
import i18n from '@/lang';
@@ -291,6 +291,14 @@ const loadOption = async () => {
options.value = res.data || [];
};
const getAppIconSrc = (app: any) => {
const icon = app?.icon || '';
if (icon.startsWith('app_') || icon === '') {
return getAppIconUrl(app.key);
}
return `data:image/png;base64,${icon}`;
};
defineExpose({
acceptParams,
});