UPDATE: VERSION-20260317

This commit is contained in:
libertyspy
2026-03-17 10:21:00 +08:00
parent 185e490560
commit c724a7acf7
3 changed files with 75 additions and 42 deletions

View File

@@ -1291,6 +1291,10 @@
}
}
.ant-select:not(.ant-select-customize-input) .ant-select-selector{
border: 1px solid #475f71
}
.ant-input-affix-wrapper.ant-input-password input:-webkit-autofill,
.ant-input-affix-wrapper.ant-input-password input:-webkit-autofill:hover,
.ant-input-affix-wrapper.ant-input-password input:-webkit-autofill:focus,
@@ -1504,9 +1508,7 @@
border-inline-end-width: 1px;
}
}
.ant-select:not(.ant-select-customize-input) .ant-select-selector{
border: 1px solid #2c2a2a;
}
.ant-select .ant-select-selection-placeholder,
.ant-select .ant-select-selection-search-input{
background: transparent

View File

@@ -35,9 +35,9 @@
</template>
<script lang="ts">
import { computed, defineComponent, onMounted, type PropType, ref, watch } from 'vue';
import type { Platform, PlatformComponent, PlatformComponentPayload, PlatformWithComponents, PlatformWithComponentsResponse } from '../types';
import { findAllPlatformWithComponents } from './api';
import { computed, defineComponent, type PropType, ref, watch } from 'vue';
import type { PlatformComponentPayload } from '../types';
import { usePlatformComponents } from './store';
export default defineComponent({
name: 'PlatformSelect',
@@ -57,45 +57,16 @@ export default defineComponent({
change: (payload: PlatformComponentPayload) => true,
},
setup(props, { emit }) {
const loading = ref<boolean>(true);
const platforms = ref<PlatformWithComponents[]>([]);
const platformMap = ref<Map<number, Platform>>(new Map());
const componentMap = ref<Map<number, PlatformComponent>>(new Map());
const { loading, platforms, platformMap, componentMap } = usePlatformComponents();
const innerPlatformId = ref<number | null>(null);
const innerComponentId = ref<number | null>(null);
const innerPlatformId = ref<number | null>(props.platformId);
const innerComponentId = ref<number | null>(props.componentId);
const selectedPlatformComponents = computed(() => {
const platform = platforms.value.find(p => p.id === innerPlatformId.value);
return platform?.components || [];
});
const loadData = async () => {
try {
loading.value = true;
const res: PlatformWithComponentsResponse = await findAllPlatformWithComponents();
const data = res.data || [];
platforms.value = data;
platformMap.value.clear();
componentMap.value.clear();
data.forEach(platform => {
platformMap.value.set(platform.id, platform);
platform.components?.forEach(component => {
componentMap.value.set(component.id, component);
});
});
innerPlatformId.value = props.platformId;
innerComponentId.value = props.componentId;
} catch (err) {
console.error('加载平台组件失败:', err);
} finally {
loading.value = false;
}
};
const emitChange = () => {
// 根据ID获取完整对象
const platform = platformMap.value.get(innerPlatformId.value || -1) || null;
@@ -135,10 +106,6 @@ export default defineComponent({
watch(innerComponentId, emitChange);
onMounted(() => {
loadData();
});
return {
loading,
platforms,

View File

@@ -0,0 +1,64 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import { onMounted, ref, type Ref } from 'vue';
import type { Platform, PlatformComponent, PlatformWithComponents, PlatformWithComponentsResponse } from '../types';
import { findAllPlatformWithComponents } from './api';
const loading: Ref<boolean> = ref<boolean>(true);
const platforms: Ref<PlatformWithComponents[]> = ref<PlatformWithComponents[]>([]);
const platformMap: Ref<Map<number, Platform>> = ref<Map<number, Platform>>(new Map());
const componentMap: Ref<Map<number, PlatformComponent>> = ref<Map<number, PlatformComponent>>(new Map());
const loaded: Ref<boolean> = ref<boolean>(false);
export interface UsePlatformComponentsReturn {
loading: Ref<boolean>;
platforms: Ref<PlatformWithComponents[]>;
platformMap: Ref<Map<number, Platform>>;
componentMap: Ref<Map<number, PlatformComponent>>;
loaded: Ref<boolean>;
}
export const usePlatformComponents = (): UsePlatformComponentsReturn => {
const load = () => {
if (!loaded.value) {
loading.value = true;
platformMap.value.clear();
componentMap.value.clear();
findAllPlatformWithComponents()
.then((res: PlatformWithComponentsResponse) => { // 显式标注响应类型
platforms.value = res.data || [];
platforms.value.forEach(platform => {
platformMap.value.set(platform.id, platform);
platform.components?.forEach(component => {
componentMap.value.set(component.id, component);
});
});
loaded.value = true;
})
.catch((err: unknown) => {
console.error('加载平台组件失败:', err);
})
.finally(() => {
loading.value = false;
});
}
};
onMounted(() => load());
return {
loading,
platforms,
platformMap,
componentMap,
loaded,
};
};