fix: 简化天河链设置项

This commit is contained in:
Nixevol
2026-07-06 19:12:11 +08:00
parent 31571f12b0
commit e6961ef1ae
5 changed files with 18 additions and 24 deletions
+1 -3
View File
@@ -456,9 +456,7 @@
"tianheEnvCustom": "Custom",
"tianheBaseUrl": "API URL",
"tianheAppId": "App ID",
"tianheAppKey": "App Key",
"tianheUserId": "User ID",
"tianheUserKey": "User Key"
"tianheAppKey": "App Key"
},
"profile": {
"title": "Personal Info",
+1 -3
View File
@@ -456,9 +456,7 @@
"tianheEnvCustom": "自定义",
"tianheBaseUrl": "接口地址",
"tianheAppId": "App ID",
"tianheAppKey": "App Key",
"tianheUserId": "User ID",
"tianheUserKey": "User Key"
"tianheAppKey": "App Key"
},
"profile": {
"title": "个人信息",
-16
View File
@@ -111,16 +111,6 @@
<n-input v-model:value="form.tianheAppKey" type="password" show-password-on="click" class="text-control" />
</n-form-item>
</div>
<div class="setting-row">
<n-form-item :label="t('pages.settings.tianheUserId')">
<n-input v-model:value="form.tianheUserId" class="text-control" />
</n-form-item>
</div>
<div class="setting-row">
<n-form-item :label="t('pages.settings.tianheUserKey')">
<n-input v-model:value="form.tianheUserKey" type="password" show-password-on="click" class="text-control" />
</n-form-item>
</div>
</section>
</div>
</n-form>
@@ -184,8 +174,6 @@ const form = reactive({
tianheBaseUrl: TIANHE_TEST_URL,
tianheAppId: '',
tianheAppKey: '',
tianheUserId: '',
tianheUserKey: '',
});
async function load() {
@@ -207,8 +195,6 @@ async function load() {
form.tianheBaseUrl = s.tianheBaseUrl || TIANHE_TEST_URL;
form.tianheAppId = s.tianheAppId || '';
form.tianheAppKey = s.tianheAppKey || '';
form.tianheUserId = s.tianheUserId || '';
form.tianheUserKey = s.tianheUserKey || '';
}
function onTianheEnvChange(value: string) {
@@ -237,8 +223,6 @@ async function save() {
tianheBaseUrl: form.tianheBaseUrl,
tianheAppId: form.tianheAppId,
tianheAppKey: form.tianheAppKey,
tianheUserId: form.tianheUserId,
tianheUserKey: form.tianheUserKey,
});
setFavicon(appIconUrl);
window.dispatchEvent(new CustomEvent('artveris-settings-updated'));
+15 -2
View File
@@ -8,6 +8,7 @@ import { TianheProvider } from './tianhe.provider';
const TIANHE_TEST_URL = 'https://test.api.tichain.tianhecloud.com';
const TIANHE_PRODUCTION_URL = 'https://api.tichain.tianhecloud.com';
const DEFAULT_TIANHE_USER_ID = 'artveris-platform';
@Injectable()
export class BlockchainService {
@@ -45,8 +46,20 @@ export class BlockchainService {
baseUrl: configuredBaseUrl,
appId: settings.tianheAppId || this.config.get<string>('blockchain.tianhe.appId') || '',
appKey: settings.tianheAppKey || this.config.get<string>('blockchain.tianhe.appKey') || '',
userId: settings.tianheUserId || this.config.get<string>('blockchain.tianhe.userId') || '',
userKey: settings.tianheUserKey || this.config.get<string>('blockchain.tianhe.userKey') || '',
userId: this.tianheUserId(settings),
userKey: this.tianheUserKey(settings),
});
}
private tianheUserId(settings: Record<string, string>): string {
return settings.tianheUserId || this.config.get<string>('blockchain.tianhe.userId') || DEFAULT_TIANHE_USER_ID;
}
private tianheUserKey(settings: Record<string, string>): string {
const configured = settings.tianheUserKey || this.config.get<string>('blockchain.tianhe.userKey');
if (configured) return configured;
const appId = settings.tianheAppId || this.config.get<string>('blockchain.tianhe.appId') || '';
const appKey = settings.tianheAppKey || this.config.get<string>('blockchain.tianhe.appKey') || '';
return createHash('sha256').update(`artveris:tianhe:${appId}:${appKey}`).digest('hex');
}
}