Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-->

<script setup lang="ts">
import { usePngImage } from '@/utils/tools'
import { usePngImage } from '@/composables/use-png-image'

import type { GroupItem } from '@/components/common/button-group/types'

Expand Down
25 changes: 25 additions & 0 deletions bigtop-manager-ui/src/composables/use-png-image.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

const images = import.meta.glob('../assets/images/*.png', { eager: true, import: 'default' })

export function usePngImage(imageName: string = 'logo'): string {
const path = `../assets/images/${imageName}.png`
return (images[path] as string) || (images['../assets/images/logo.png'] as string)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
~ under the License.
-->
<script setup lang="ts">
import { usePngImage } from '@/utils/tools'
import { usePngImage } from '@/composables/use-png-image'
import { useAiChatStore } from '@/store/ai-assistant'

interface Emits {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-->

<script setup lang="ts">
import { usePngImage } from '@/utils/tools'
import { usePngImage } from '@/composables/use-png-image'
import { useStackStore } from '@/store/stack'
import { useServiceStore } from '@/store/service'
import { useCreateServiceStore } from '@/store/create-service'
Expand Down Expand Up @@ -104,7 +104,7 @@
}
}

const splitSearchStr = (splitStr: string) => {
const splitSearchStr = (splitStr: string = '--') => {
return splitStr.toString().split(new RegExp(`(?<=${searchStr.value})|(?=${searchStr.value})`, 'i'))
}

Expand Down Expand Up @@ -241,7 +241,7 @@
</template>
</div>
<a-tag :color="licenseOfConflictService.includes(item.license) ? 'error' : 'success'">
<span class="item-tag">{{ item.license }}</span>
<span class="item-tag">{{ item.license ?? '--' }}</span>
</a-tag>
</div>
</template>
Expand All @@ -256,12 +256,7 @@
</div>
</template>
<template #avatar>
<a-avatar
v-if="item.displayName"
:src="usePngImage(item.displayName.toLowerCase())"
:size="54"
class="header-icon"
/>
<a-avatar :src="usePngImage(item.name.toLowerCase())" :size="54" class="header-icon" />
</template>
</a-list-item-meta>
</a-list-item>
Expand All @@ -288,7 +283,7 @@
{{ item.displayName }}
</div>
<a-tag :color="licenseOfConflictService.includes(item.license) ? 'error' : 'success'">
<span class="item-tag">{{ item.license }}</span>
<span class="item-tag">{{ item.license ?? '--' }}</span>
</a-tag>
</div>
</template>
Expand All @@ -298,12 +293,7 @@
</div>
</template>
<template #avatar>
<a-avatar
v-if="item.displayName"
:src="usePngImage(item.displayName.toLowerCase())"
:size="54"
class="header-icon"
/>
<a-avatar :src="usePngImage(item.name.toLowerCase())" :size="54" class="header-icon" />
</template>
</a-list-item-meta>
</a-list-item>
Expand Down
2 changes: 1 addition & 1 deletion bigtop-manager-ui/src/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-->

<script setup lang="ts">
import { usePngImage } from '@/utils/tools'
import { usePngImage } from '@/composables/use-png-image'
const { t } = useI18n()
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<script setup lang="ts">
import { formatFromByte } from '@/utils/storage'
import { usePngImage } from '@/utils/tools'
import { usePngImage } from '@/composables/use-png-image'
import { CommonStatus } from '@/enums/state'
import { TIME_RANGES, STATUS_COLOR, POLLING_INTERVAL } from '@/utils/constant'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { CommonStatus } from '@/enums/state'
import { useJobProgress } from '@/store/job-progress'
import { useTabStore } from '@/store/tab-state'
import { usePngImage } from '@/utils/tools'
import { usePngImage } from '@/composables/use-png-image'
import { STATUS_COLOR } from '@/utils/constant'

import type { GroupItem } from '@/components/common/button-group/types'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
<script setup lang="ts">
import { Empty } from 'ant-design-vue'
import { formatFromByte } from '@/utils/storage.ts'
import { usePngImage, isEmpty } from '@/utils/tools'
import { isEmpty } from '@/utils/tools'
import { TIME_RANGES, STATUS_COLOR, POLLING_INTERVAL } from '@/utils/constant'
import { usePngImage } from '@/composables/use-png-image'
import { CommonStatus } from '@/enums/state.ts'

import { useServiceStore } from '@/store/service'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { useJobProgress } from '@/store/job-progress'

import { CommonStatus } from '@/enums/state'
import { usePngImage } from '@/utils/tools'
import { usePngImage } from '@/composables/use-png-image'
import { STATUS_COLOR } from '@/utils/constant'

import type { ServiceVO } from '@/api/service/types'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
type AuthPlatformStatusType
} from '@/api/llm-config/types'
import type { MenuItemType } from 'ant-design-vue/es/menu/src/interface'
import { usePngImage } from '@/utils/tools'
import { usePngImage } from '@/composables/use-png-image'

// eslint-disable-next-line @typescript-eslint/no-unused-vars
enum Actions {
Expand Down
10 changes: 0 additions & 10 deletions bigtop-manager-ui/src/utils/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@ export function copyText(text: string): Promise<any> {
})
}

/**
* Returns the URL of a PNG image from the assets folder.
*
* @param imageName - The name of the image (default is 'logo').
* @returns The URL of the image.
*/
export function usePngImage(imageName: string = 'logo'): string {
return new URL(`../assets/images/${imageName}.png`, import.meta.url).href
}

/**
* Scrolls the given container element to the bottom.
*
Expand Down
Loading