From 737179a0ce34147269cccf288fecd0e7bb4c309b Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期三, 11 二月 2026 10:42:19 +0800
Subject: [PATCH] 成绩查询+个人中心

---
 src/utils/tool.js |   51 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/src/utils/tool.js b/src/utils/tool.js
index 9826791..411e105 100644
--- a/src/utils/tool.js
+++ b/src/utils/tool.js
@@ -5,12 +5,12 @@
  * @returns {string} 鍥剧墖鐨勫畬鏁碪RL
  */
 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 = []
@@ -66,11 +66,39 @@
   }
 }
 
-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) => {
@@ -82,4 +110,9 @@
   if (!job) return ''
 
   return job.jobName || ''
+}
+
+export const getFileUrlName = (url = '') => {
+  const fullFilename = url.substring(url.lastIndexOf('/') + 1);
+  return fullFilename || ''
 }
\ No newline at end of file

--
Gitblit v1.8.0