| | |
| | | * @returns {string} 图片的完整URL |
| | | */ |
| | | export const getImageUrl = (imageName) => { |
| | | try { |
| | | return new URL('../assets/images/' + imageName, import.meta.url).href; |
| | | } catch (error) { |
| | | console.warn(`Failed to load image: ${imageName}`, error); |
| | | return ""; |
| | | } |
| | | // 使用 Vite 的 glob 功能动态导入图片资源 |
| | | const modules = import.meta.glob('../assets/images/**/*.{png,jpg,jpeg,gif,svg,webp}', { eager: true }); |
| | | // 移除开头的斜杠 |
| | | const cleanName = imageName.startsWith('/') ? imageName.slice(1) : imageName; |
| | | const path = `../assets/images/${cleanName}`; |
| | | return modules[path]?.default || ''; |
| | | }; |
| | | export const getUUID = () => { |
| | | let s = [] |
| | |
| | | } |
| | | } |
| | | |
| | | export const getOccupationName = (code) => { |
| | | export const getOccupationName = (id) => { |
| | | const { occupationItems } = useOptionItemsStore() |
| | | const obj = occupationItems.find(ele => ele.code == code) |
| | | const obj = occupationItems.find(ele => ele.id == id) |
| | | |
| | | return obj?.name || '' |
| | | return obj?.occupationJob || '' |
| | | } |
| | | |
| | | const levelKey = { |
| | | '5': '五级', |
| | | '4': '四级', |
| | | '3': '三级', |
| | | '2': '二级', |
| | | '1': '一级' |
| | | } |
| | | |
| | | export const getLevelItems = (occupationId) => { |
| | | const { occupationItems } = useOptionItemsStore() |
| | | const obj = occupationItems.find(ele => ele.id == occupationId) |
| | | if (!obj) return [] |
| | | let levelItems = [] |
| | | obj.levelStr.split(',').forEach(ele => { |
| | | levelItems.push({ name: levelKey[ele], value: ele },) |
| | | }) |
| | | return levelItems || [] |
| | | } |
| | | |
| | | export const getLevelName = (levelStr) => { |
| | | let levelList = levelStr?.split(',') || [] |
| | | let tempList = [] |
| | | levelList.forEach(ele => { |
| | | tempList.push(levelKey[ele]) |
| | | }) |
| | | return tempList.join(',') |
| | | } |
| | | |
| | | export const getJobName = (occupationCode, jobCode) => { |
| | |
| | | |
| | | return job.jobName || '' |
| | | } |
| | | |
| | | export const getFileUrlName = (url = '') => { |
| | | const fullFilename = url.substring(url.lastIndexOf('/') + 1); |
| | | return fullFilename || '' |
| | | } |