feat: 支持配置系统图标
This commit is contained in:
@@ -11,6 +11,12 @@
|
||||
<n-form-item :label="t('pages.settings.appName')">
|
||||
<n-input v-model:value="form.appName" class="control-wide" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="t('pages.settings.appIcon')">
|
||||
<div class="icon-setting">
|
||||
<img class="icon-preview" :src="currentIconUrl" alt="" />
|
||||
<media-upload v-model="form.appIconFiles" type="image" :max="1" />
|
||||
</div>
|
||||
</n-form-item>
|
||||
<n-form-item :label="t('pages.settings.watermarkText')">
|
||||
<n-input v-model:value="form.watermarkText" class="control-wide" />
|
||||
</n-form-item>
|
||||
@@ -81,11 +87,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { settingsApi } from '@/api';
|
||||
import { message } from '@/utils/feedback';
|
||||
import BackupRestorePanel from '@/components/BackupRestorePanel.vue';
|
||||
import MediaUpload from '@/components/MediaUpload.vue';
|
||||
import { DEFAULT_APP_ICON_URL, resolveAppIcon, setFavicon } from '@/utils/appIcon';
|
||||
|
||||
const { t } = useI18n();
|
||||
const saving = ref(false);
|
||||
@@ -95,6 +103,7 @@ const backupScheduleOptions = [
|
||||
];
|
||||
const form = reactive({
|
||||
appName: '',
|
||||
appIconFiles: [] as Array<{ key: string; url?: string; name?: string; type?: string }>,
|
||||
logRetentionDays: 365,
|
||||
operationLogRetentionDays: 180,
|
||||
watermarkText: '',
|
||||
@@ -109,6 +118,8 @@ const form = reactive({
|
||||
async function load() {
|
||||
const s = await settingsApi.getAll();
|
||||
form.appName = s.appName || '';
|
||||
const appIconUrl = s.appIconUrl || '';
|
||||
form.appIconFiles = appIconUrl && appIconUrl !== DEFAULT_APP_ICON_URL ? [{ key: appIconUrl, url: appIconUrl, name: t('pages.settings.appIcon'), type: 'image' }] : [];
|
||||
form.logRetentionDays = Number(s.logRetentionDays || 365);
|
||||
form.operationLogRetentionDays = Number(s.operationLogRetentionDays || 180);
|
||||
form.watermarkText = s.watermarkText || '';
|
||||
@@ -123,8 +134,10 @@ async function load() {
|
||||
async function save() {
|
||||
saving.value = true;
|
||||
try {
|
||||
const appIconUrl = form.appIconFiles[0]?.url || form.appIconFiles[0]?.key || '';
|
||||
await settingsApi.update({
|
||||
appName: form.appName,
|
||||
appIconUrl,
|
||||
logRetentionDays: String(form.logRetentionDays),
|
||||
operationLogRetentionDays: String(form.operationLogRetentionDays),
|
||||
watermarkText: form.watermarkText,
|
||||
@@ -135,6 +148,8 @@ async function save() {
|
||||
backupRetentionDays: String(form.backupRetentionDays),
|
||||
backupRetentionCount: String(form.backupRetentionCount),
|
||||
});
|
||||
setFavicon(appIconUrl);
|
||||
window.dispatchEvent(new CustomEvent('artveris-settings-updated'));
|
||||
message.success(t('pages.settings.saved'));
|
||||
} finally {
|
||||
saving.value = false;
|
||||
@@ -142,6 +157,8 @@ async function save() {
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
|
||||
const currentIconUrl = computed(() => resolveAppIcon(form.appIconFiles[0]?.url || form.appIconFiles[0]?.key));
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -229,6 +246,20 @@ onMounted(load);
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
.icon-setting {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
}
|
||||
.icon-preview {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--n-border-color);
|
||||
object-fit: cover;
|
||||
background: #f6f8fb;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.switch-field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user