feat: 完善安装部署与数字溯源码
This commit is contained in:
@@ -116,6 +116,12 @@ export const settingsApi = {
|
||||
update: (data: object) => put('/settings', data),
|
||||
};
|
||||
|
||||
export const storageApi = {
|
||||
test: (data: object) => post('/storage/test', data),
|
||||
migrate: (data: object) => post('/storage/migrate', data),
|
||||
confirm: (data: object) => post('/storage/confirm', data),
|
||||
};
|
||||
|
||||
export const operationLogApi = {
|
||||
list: (params: object) => get<PageResult<any>>('/operation-logs', params),
|
||||
};
|
||||
|
||||
@@ -20,6 +20,10 @@ const instance: AxiosInstance = axios.create({
|
||||
});
|
||||
|
||||
function resolveErrorMessage(body: any, fallbackKey = 'common.msg.networkError'): string {
|
||||
if (body?.messageKey) {
|
||||
const translated = i18n.global.t(body.messageKey, body.params || {});
|
||||
if (translated !== body.messageKey) return translated;
|
||||
}
|
||||
if (body?.code !== undefined && body?.code !== null) {
|
||||
const key = `common.errorCode.${body.code}`;
|
||||
const translated = i18n.global.t(key);
|
||||
@@ -38,6 +42,8 @@ instance.interceptors.request.use((config) => {
|
||||
config.headers = config.headers ?? {};
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
config.headers = config.headers ?? {};
|
||||
config.headers['Accept-Language'] = String(i18n.global.locale.value || 'zh-CN');
|
||||
return config;
|
||||
});
|
||||
|
||||
|
||||
@@ -442,6 +442,24 @@
|
||||
"filingInfo": "Filing Info",
|
||||
"carouselInterval": "Carousel Interval",
|
||||
"carouselIntervalHint": "Seconds each media stays; decimals allowed. 0 disables auto-advance (manual loop still works).",
|
||||
"clientBaseUrl": "Client URL",
|
||||
"storageSettings": "Storage & CDN",
|
||||
"storageDriver": "Storage",
|
||||
"storageDriverLocal": "Local",
|
||||
"storageDriverOss": "OSS/S3",
|
||||
"storageLocalDir": "Local Dir",
|
||||
"cdnBaseUrl": "CDN URL",
|
||||
"ossEndpoint": "OSS Endpoint",
|
||||
"ossRegion": "OSS Region",
|
||||
"ossBucket": "OSS Bucket",
|
||||
"ossAccessKeyId": "AccessKey ID",
|
||||
"ossAccessKeySecret": "AccessKey Secret",
|
||||
"testStorage": "Test",
|
||||
"migrateStorage": "Migrate",
|
||||
"confirmStorage": "Switch",
|
||||
"storageTested": "Storage connection verified",
|
||||
"storageMigrated": "{n} files migrated",
|
||||
"storageConfirmed": "Storage settings switched",
|
||||
"backupEnabled": "Enable Scheduled Backup",
|
||||
"backupSchedule": "Scheduled Backup",
|
||||
"backupRetentionDays": "Backup Days",
|
||||
@@ -542,5 +560,37 @@
|
||||
"AUTO_BEFORE_RESTORE": "Auto Snapshot Before Restore"
|
||||
}
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"SUCCESS": "Success",
|
||||
"BAD_REQUEST": "Invalid request",
|
||||
"UNAUTHORIZED": "Not logged in or session expired",
|
||||
"FORBIDDEN": "You do not have permission",
|
||||
"NOT_FOUND": "Resource not found",
|
||||
"VALIDATION_FAILED": "Validation failed",
|
||||
"INTERNAL_ERROR": "Internal server error",
|
||||
"TOO_MANY_REQUESTS": "Too many requests. Please try again later.",
|
||||
"INVALID_CREDENTIALS": "Incorrect username or password",
|
||||
"TOKEN_EXPIRED": "Session expired. Please log in again.",
|
||||
"USER_DISABLED": "This account has been disabled",
|
||||
"OLD_PASSWORD_WRONG": "Current password is incorrect",
|
||||
"USERNAME_EXISTS": "Username already exists",
|
||||
"TEMPLATE_NOT_FOUND": "Template not found",
|
||||
"TEMPLATE_IN_USE": "Template is in use and cannot be deleted",
|
||||
"ARTWORK_NOT_FOUND": "Artwork not found",
|
||||
"TRACE_CODE_NOT_FOUND": "Trace code not found",
|
||||
"TRACE_CODE_INVALID": "Trace code is invalid",
|
||||
"TRACE_CODE_DISABLED": "Trace code has been disabled",
|
||||
"TRACE_CODE_ABNORMAL": "Trace code status is abnormal",
|
||||
"TRACE_CODE_ALREADY_BOUND": "Trace code is already bound to an artwork",
|
||||
"IMPORT_PARSE_FAILED": "Import file parsing failed",
|
||||
"FILE_TYPE_NOT_ALLOWED": "File type is not supported",
|
||||
"FILE_TOO_LARGE": "File exceeds the size limit",
|
||||
"CERTIFICATE_NOT_FOUND": "Certificate not found",
|
||||
"JOB_NOT_FOUND": "Task not found",
|
||||
"BATCH_NOT_FOUND": "Batch not found",
|
||||
"ARTWORK_IN_USE": "Artwork file has business data and cannot be deleted",
|
||||
"OSS_CONFIG_INCOMPLETE": "OSS configuration is incomplete",
|
||||
"STORAGE_MIGRATION_REQUIRED": "Please migrate files to the target storage before switching"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,6 +442,24 @@
|
||||
"filingInfo": "备案信息",
|
||||
"carouselInterval": "客户端轮播间隔",
|
||||
"carouselIntervalHint": "每张媒体停留秒数,支持小数;填 0 则不自动切换(仍可手动循环切换)",
|
||||
"clientBaseUrl": "客户端地址",
|
||||
"storageSettings": "存储与 CDN",
|
||||
"storageDriver": "存储方式",
|
||||
"storageDriverLocal": "本地",
|
||||
"storageDriverOss": "OSS/S3",
|
||||
"storageLocalDir": "本地目录",
|
||||
"cdnBaseUrl": "CDN 地址",
|
||||
"ossEndpoint": "OSS Endpoint",
|
||||
"ossRegion": "OSS Region",
|
||||
"ossBucket": "OSS Bucket",
|
||||
"ossAccessKeyId": "AccessKey ID",
|
||||
"ossAccessKeySecret": "AccessKey Secret",
|
||||
"testStorage": "测试",
|
||||
"migrateStorage": "迁移",
|
||||
"confirmStorage": "切换",
|
||||
"storageTested": "存储连接测试通过",
|
||||
"storageMigrated": "已迁移 {n} 个文件",
|
||||
"storageConfirmed": "存储配置已切换",
|
||||
"backupEnabled": "启用定时备份",
|
||||
"backupSchedule": "定时备份",
|
||||
"backupRetentionDays": "备份保留天数",
|
||||
@@ -542,5 +560,37 @@
|
||||
"AUTO_BEFORE_RESTORE": "恢复前自动快照"
|
||||
}
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"SUCCESS": "成功",
|
||||
"BAD_REQUEST": "请求参数有误",
|
||||
"UNAUTHORIZED": "未登录或登录已过期",
|
||||
"FORBIDDEN": "没有操作权限",
|
||||
"NOT_FOUND": "资源不存在",
|
||||
"VALIDATION_FAILED": "数据校验失败",
|
||||
"INTERNAL_ERROR": "服务器内部错误",
|
||||
"TOO_MANY_REQUESTS": "请求过于频繁,请稍后再试",
|
||||
"INVALID_CREDENTIALS": "用户名或密码错误",
|
||||
"TOKEN_EXPIRED": "登录已过期,请重新登录",
|
||||
"USER_DISABLED": "账号已被停用",
|
||||
"OLD_PASSWORD_WRONG": "原密码不正确",
|
||||
"USERNAME_EXISTS": "用户名已存在",
|
||||
"TEMPLATE_NOT_FOUND": "模板不存在",
|
||||
"TEMPLATE_IN_USE": "模板已被使用,无法删除",
|
||||
"ARTWORK_NOT_FOUND": "艺术品不存在",
|
||||
"TRACE_CODE_NOT_FOUND": "追溯码不存在",
|
||||
"TRACE_CODE_INVALID": "追溯码无效",
|
||||
"TRACE_CODE_DISABLED": "追溯码已停用",
|
||||
"TRACE_CODE_ABNORMAL": "追溯码状态异常",
|
||||
"TRACE_CODE_ALREADY_BOUND": "追溯码已绑定作品",
|
||||
"IMPORT_PARSE_FAILED": "导入文件解析失败",
|
||||
"FILE_TYPE_NOT_ALLOWED": "不支持的文件类型",
|
||||
"FILE_TOO_LARGE": "文件超出大小限制",
|
||||
"CERTIFICATE_NOT_FOUND": "认证文件不存在",
|
||||
"JOB_NOT_FOUND": "任务不存在",
|
||||
"BATCH_NOT_FOUND": "批次不存在",
|
||||
"ARTWORK_IN_USE": "艺术品档案已有业务数据,无法删除",
|
||||
"OSS_CONFIG_INCOMPLETE": "OSS 配置不完整",
|
||||
"STORAGE_MIGRATION_REQUIRED": "请先完成目标存储迁移,再确认切换"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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