feat: 支持配置系统图标
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
@expand="collapsed = false"
|
||||
>
|
||||
<div class="brand">
|
||||
<span class="brand-logo">艺</span>
|
||||
<img class="brand-logo" :src="appIconUrl" alt="" />
|
||||
<span v-show="!collapsed" class="brand-name text-ellipsis">{{ appName }}</span>
|
||||
</div>
|
||||
<n-menu
|
||||
@@ -76,6 +76,7 @@ import {
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { settingsApi } from '@/api';
|
||||
import { dialog } from '@/utils/feedback';
|
||||
import { resolveAppIcon, setFavicon } from '@/utils/appIcon';
|
||||
import LangSwitch from '@/components/LangSwitch.vue';
|
||||
import ThemeSwitch from '@/components/ThemeSwitch.vue';
|
||||
|
||||
@@ -86,6 +87,7 @@ const auth = useAuthStore();
|
||||
|
||||
const collapsed = ref(window.innerWidth < 900);
|
||||
const appName = ref(t('pages.login.title'));
|
||||
const appIconUrl = ref(resolveAppIcon());
|
||||
const filingInfo = ref('');
|
||||
|
||||
function renderIcon(icon: unknown) {
|
||||
@@ -139,20 +141,29 @@ function onUser(key: string) {
|
||||
}
|
||||
|
||||
let resizeHandler: () => void;
|
||||
async function loadSettings() {
|
||||
try {
|
||||
const s = await settingsApi.getAll();
|
||||
if (s.appName) appName.value = s.appName;
|
||||
appIconUrl.value = resolveAppIcon(s.appIconUrl);
|
||||
setFavicon(appIconUrl.value);
|
||||
filingInfo.value = s.filingInfo || '';
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
onMounted(async () => {
|
||||
resizeHandler = () => {
|
||||
collapsed.value = window.innerWidth < 900;
|
||||
};
|
||||
window.addEventListener('resize', resizeHandler);
|
||||
try {
|
||||
const s = await settingsApi.getAll();
|
||||
if (s.appName) appName.value = s.appName;
|
||||
filingInfo.value = s.filingInfo || '';
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
window.addEventListener('artveris-settings-updated', loadSettings);
|
||||
await loadSettings();
|
||||
});
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', resizeHandler);
|
||||
window.removeEventListener('artveris-settings-updated', loadSettings);
|
||||
});
|
||||
onUnmounted(() => window.removeEventListener('resize', resizeHandler));
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -164,15 +175,11 @@ onUnmounted(() => window.removeEventListener('resize', resizeHandler));
|
||||
padding: 0 16px;
|
||||
}
|
||||
.brand-logo {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 8px;
|
||||
background: var(--brand);
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
object-fit: cover;
|
||||
background: #f6f8fb;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.brand-name {
|
||||
|
||||
Reference in New Issue
Block a user