chore: prepare anxinyan release
This commit is contained in:
@@ -1346,6 +1346,7 @@ export interface AdminSystemConfigGroupItem {
|
||||
placeholder: string;
|
||||
remark: string;
|
||||
is_secret: boolean;
|
||||
read_only?: boolean;
|
||||
value: string;
|
||||
options?: Array<{
|
||||
label: string;
|
||||
|
||||
@@ -36,6 +36,7 @@ async function fetchConfigs() {
|
||||
try {
|
||||
const response = await adminApi.getSystemConfigs();
|
||||
groups.value = sortGroups(response.data.groups);
|
||||
groups.value.forEach(applyDerivedConfigValues);
|
||||
groupSnapshots.value = cloneSnapshot(groups.value);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -63,9 +64,52 @@ function markFieldSnapshot(groupCode: string, configKey: string, value: string)
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeH5PageBaseUrl(value: string) {
|
||||
let baseUrl = value.trim();
|
||||
if (!baseUrl) return "";
|
||||
|
||||
const hashIndex = baseUrl.indexOf("#");
|
||||
if (hashIndex !== -1) {
|
||||
baseUrl = baseUrl.slice(0, hashIndex);
|
||||
}
|
||||
|
||||
if (!/^https?:\/\//i.test(baseUrl)) {
|
||||
baseUrl = `https://${baseUrl.replace(/^\/+/, "")}`;
|
||||
}
|
||||
|
||||
return baseUrl.replace(/\/+$/, "");
|
||||
}
|
||||
|
||||
function buildH5OAuthRedirectUrl(pageBaseUrl: string) {
|
||||
const baseUrl = normalizeH5PageBaseUrl(pageBaseUrl);
|
||||
return baseUrl ? `${baseUrl}/#/pages/auth/login` : "";
|
||||
}
|
||||
|
||||
function applyDerivedConfigValues(group: AdminSystemConfigGroupItem) {
|
||||
if (group.group_code !== "h5") return;
|
||||
|
||||
const pageBaseUrl = group.items.find((item) => item.config_key === "page_base_url");
|
||||
const oauthRedirectUrl = group.items.find((item) => item.config_key === "oauth_redirect_url");
|
||||
if (!oauthRedirectUrl) return;
|
||||
|
||||
oauthRedirectUrl.value = buildH5OAuthRedirectUrl(pageBaseUrl?.value || "");
|
||||
}
|
||||
|
||||
function handleFieldValueChange(
|
||||
group: AdminSystemConfigGroupItem,
|
||||
item: AdminSystemConfigGroupItem["items"][number],
|
||||
value: string | number,
|
||||
) {
|
||||
if (item.read_only) return;
|
||||
|
||||
item.value = String(value ?? "");
|
||||
applyDerivedConfigValues(group);
|
||||
}
|
||||
|
||||
async function saveGroup(group: AdminSystemConfigGroupItem) {
|
||||
savingGroupCode.value = group.group_code;
|
||||
try {
|
||||
applyDerivedConfigValues(group);
|
||||
const items = group.items.map((item) => ({
|
||||
config_group: group.group_code,
|
||||
config_key: item.config_key,
|
||||
@@ -216,17 +260,21 @@ onMounted(fetchConfigs);
|
||||
</el-select>
|
||||
<el-input
|
||||
v-else-if="item.field_type !== 'textarea'"
|
||||
v-model="item.value"
|
||||
:model-value="item.value"
|
||||
:type="item.field_type === 'password' ? 'password' : 'text'"
|
||||
show-password
|
||||
:disabled="item.read_only"
|
||||
:placeholder="item.placeholder"
|
||||
@update:model-value="handleFieldValueChange(group, item, $event)"
|
||||
/>
|
||||
<el-input
|
||||
v-else
|
||||
v-model="item.value"
|
||||
:model-value="item.value"
|
||||
type="textarea"
|
||||
:rows="5"
|
||||
:disabled="item.read_only"
|
||||
:placeholder="item.placeholder"
|
||||
@update:model-value="handleFieldValueChange(group, item, $event)"
|
||||
/>
|
||||
<div style="margin-top: 6px; color: var(--admin-text-subtle); font-size: 12px;">
|
||||
{{ item.remark }}
|
||||
|
||||
Reference in New Issue
Block a user