feat: 完善安装部署与数字溯源码
This commit is contained in:
@@ -47,6 +47,11 @@
|
||||
/>
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.clientBaseUrl')">
|
||||
<n-input v-model:value="form.clientBaseUrl" class="url-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="settings-side-stack">
|
||||
@@ -112,6 +117,59 @@
|
||||
</n-form-item>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="settings-card storage-card">
|
||||
<div class="card-title">
|
||||
<span>{{ t('pages.settings.storageSettings') }}</span>
|
||||
<div class="card-actions">
|
||||
<n-button size="small" :loading="testingStorage" @click="testStorage">{{ t('pages.settings.testStorage') }}</n-button>
|
||||
<n-button size="small" :loading="migratingStorage" @click="migrateStorage">{{ t('pages.settings.migrateStorage') }}</n-button>
|
||||
<n-button size="small" type="primary" :loading="confirmingStorage" @click="confirmStorage">{{ t('pages.settings.confirmStorage') }}</n-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.storageDriver')">
|
||||
<n-select v-model:value="form.storageDriver" :options="storageDriverOptions" class="select-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.storageLocalDir')">
|
||||
<n-input v-model:value="form.storageLocalDir" class="url-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.cdnBaseUrl')">
|
||||
<n-input v-model:value="form.cdnBaseUrl" class="url-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<template v-if="form.storageDriver === 'oss'">
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.ossEndpoint')">
|
||||
<n-input v-model:value="form.ossEndpoint" class="url-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.ossRegion')">
|
||||
<n-input v-model:value="form.ossRegion" class="text-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.ossBucket')">
|
||||
<n-input v-model:value="form.ossBucket" class="text-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.ossAccessKeyId')">
|
||||
<n-input v-model:value="form.ossAccessKeyId" class="text-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<n-form-item :label="t('pages.settings.ossAccessKeySecret')">
|
||||
<n-input v-model:value="form.ossAccessKeySecret" type="password" show-password-on="click" class="text-control" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
</div>
|
||||
</n-form>
|
||||
|
||||
@@ -126,7 +184,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { settingsApi } from '@/api';
|
||||
import { settingsApi, storageApi } from '@/api';
|
||||
import { message } from '@/utils/feedback';
|
||||
import BackupRestorePanel from '@/components/BackupRestorePanel.vue';
|
||||
import MediaUpload from '@/components/MediaUpload.vue';
|
||||
@@ -134,6 +192,9 @@ import { DEFAULT_APP_ICON_URL, resolveAppIcon, setFavicon } from '@/utils/appIco
|
||||
|
||||
const { t } = useI18n();
|
||||
const saving = ref(false);
|
||||
const testingStorage = ref(false);
|
||||
const migratingStorage = ref(false);
|
||||
const confirmingStorage = ref(false);
|
||||
const TIANHE_TEST_URL = 'https://test.api.tichain.tianhecloud.com';
|
||||
const TIANHE_PRODUCTION_URL = 'https://api.tichain.tianhecloud.com';
|
||||
const blockchainDriverOptions = computed(() => [
|
||||
@@ -150,6 +211,10 @@ const backupScheduleOptions = computed(() => [
|
||||
{ label: t('pages.settings.scheduleDaily'), value: 'daily' },
|
||||
{ label: t('pages.settings.scheduleWeekly'), value: 'weekly' },
|
||||
]);
|
||||
const storageDriverOptions = computed(() => [
|
||||
{ label: t('pages.settings.storageDriverLocal'), value: 'local' },
|
||||
{ label: t('pages.settings.storageDriverOss'), value: 'oss' },
|
||||
]);
|
||||
const backupScheduleValue = computed({
|
||||
get: () => (form.backupEnabled ? form.backupSchedule : 'off'),
|
||||
set: (value: string) => {
|
||||
@@ -165,6 +230,7 @@ const form = reactive({
|
||||
watermarkText: '',
|
||||
filingInfo: '',
|
||||
carouselInterval: 3,
|
||||
clientBaseUrl: '',
|
||||
backupEnabled: false,
|
||||
backupSchedule: 'daily',
|
||||
backupRetentionDays: 30,
|
||||
@@ -174,6 +240,15 @@ const form = reactive({
|
||||
tianheBaseUrl: TIANHE_TEST_URL,
|
||||
tianheAppId: '',
|
||||
tianheAppKey: '',
|
||||
storageDriver: 'local',
|
||||
storageLocalDir: './storage',
|
||||
storagePublicPrefix: '/uploads',
|
||||
cdnBaseUrl: '',
|
||||
ossEndpoint: '',
|
||||
ossRegion: '',
|
||||
ossBucket: '',
|
||||
ossAccessKeyId: '',
|
||||
ossAccessKeySecret: '',
|
||||
});
|
||||
|
||||
async function load() {
|
||||
@@ -186,6 +261,7 @@ async function load() {
|
||||
form.watermarkText = s.watermarkText || '';
|
||||
form.filingInfo = s.filingInfo || '';
|
||||
form.carouselInterval = Number(s.carouselInterval ?? 3);
|
||||
form.clientBaseUrl = s.clientBaseUrl || `${location.origin}/trace`;
|
||||
form.backupEnabled = s.backupEnabled === 'true';
|
||||
form.backupSchedule = s.backupSchedule || 'daily';
|
||||
form.backupRetentionDays = Number(s.backupRetentionDays || 30);
|
||||
@@ -195,6 +271,15 @@ async function load() {
|
||||
form.tianheBaseUrl = s.tianheBaseUrl || TIANHE_TEST_URL;
|
||||
form.tianheAppId = s.tianheAppId || '';
|
||||
form.tianheAppKey = s.tianheAppKey || '';
|
||||
form.storageDriver = s.storageDriver || 'local';
|
||||
form.storageLocalDir = s.storageLocalDir || './storage';
|
||||
form.storagePublicPrefix = s.storagePublicPrefix || '/uploads';
|
||||
form.cdnBaseUrl = s.cdnBaseUrl || '';
|
||||
form.ossEndpoint = s.ossEndpoint || '';
|
||||
form.ossRegion = s.ossRegion || '';
|
||||
form.ossBucket = s.ossBucket || '';
|
||||
form.ossAccessKeyId = s.ossAccessKeyId || '';
|
||||
form.ossAccessKeySecret = s.ossAccessKeySecret || '';
|
||||
}
|
||||
|
||||
function onTianheEnvChange(value: string) {
|
||||
@@ -214,6 +299,7 @@ async function save() {
|
||||
watermarkText: form.watermarkText,
|
||||
filingInfo: form.filingInfo,
|
||||
carouselInterval: String(form.carouselInterval),
|
||||
clientBaseUrl: form.clientBaseUrl,
|
||||
backupEnabled: String(form.backupEnabled),
|
||||
backupSchedule: form.backupSchedule,
|
||||
backupRetentionDays: String(form.backupRetentionDays),
|
||||
@@ -232,6 +318,49 @@ async function save() {
|
||||
}
|
||||
}
|
||||
|
||||
function storagePayload() {
|
||||
return {
|
||||
driver: form.storageDriver,
|
||||
localDir: form.storageLocalDir,
|
||||
cdnBaseUrl: form.cdnBaseUrl,
|
||||
ossEndpoint: form.ossEndpoint,
|
||||
ossRegion: form.ossRegion,
|
||||
ossBucket: form.ossBucket,
|
||||
ossAccessKeyId: form.ossAccessKeyId,
|
||||
ossAccessKeySecret: form.ossAccessKeySecret,
|
||||
};
|
||||
}
|
||||
|
||||
async function testStorage() {
|
||||
testingStorage.value = true;
|
||||
try {
|
||||
await storageApi.test(storagePayload());
|
||||
message.success(t('pages.settings.storageTested'));
|
||||
} finally {
|
||||
testingStorage.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function migrateStorage() {
|
||||
migratingStorage.value = true;
|
||||
try {
|
||||
const res: any = await storageApi.migrate(storagePayload());
|
||||
message.success(t('pages.settings.storageMigrated', { n: res.copied ?? 0 }));
|
||||
} finally {
|
||||
migratingStorage.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmStorage() {
|
||||
confirmingStorage.value = true;
|
||||
try {
|
||||
await storageApi.confirm(storagePayload());
|
||||
message.success(t('pages.settings.storageConfirmed'));
|
||||
} finally {
|
||||
confirmingStorage.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
|
||||
const currentIconUrl = computed(() => resolveAppIcon(form.appIconFiles[0]?.url || form.appIconFiles[0]?.key));
|
||||
@@ -311,6 +440,14 @@ const currentIconUrl = computed(() => resolveAppIcon(form.appIconFiles[0]?.url |
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
line-height: 20px;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
.card-actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.setting-row {
|
||||
padding: 8px 12px;
|
||||
|
||||
Reference in New Issue
Block a user