diff --git a/components/md-render/md-render.vue b/components/md-render/md-render.vue index 5362565..4bc7762 100644 --- a/components/md-render/md-render.vue +++ b/components/md-render/md-render.vue @@ -24,11 +24,13 @@ const renderedHtml = computed(() => parseMarkdown(props.content)); const handleItemClick = (e) => { let { attrs } = e.detail.node; + console.log(attrs); let { 'data-copy-index': codeDataIndex, 'data-job-id': jobId, class: className } = attrs; switch (className) { case 'custom-card': - navTo('/packageA/pages/post/post?jobId=' + jobId); - return; + return navTo('/packageA/pages/post/post?jobId=' + jobId); + case 'custom-more': + return navTo('/packageA/pages/moreJobs/moreJobs?jobId=' + jobId); case 'copy-btn': uni.setClipboardData({ data: codeDataList[codeDataIndex], @@ -40,6 +42,7 @@ const handleItemClick = (e) => { }); }, }); + break; } }; @@ -258,6 +261,19 @@ ol { diff --git a/pages.json b/pages.json index 34ad3f9..03570eb 100644 --- a/pages.json +++ b/pages.json @@ -194,6 +194,13 @@ "navigationBarBackgroundColor": "#FFFFFF", "navigationStyle": "custom" } + }, + { + "path": "pages/moreJobs/moreJobs", + "style": { + "navigationBarTitleText": "更多岗位", + "navigationBarBackgroundColor": "#FFFFFF" + } } ] }], diff --git a/pages/search/search.vue b/pages/search/search.vue index eff777b..513227f 100644 --- a/pages/search/search.vue +++ b/pages/search/search.vue @@ -112,7 +112,7 @@ const searchParams = ref({}); const pageSize = ref(10); const { list, loading, refresh, loadMore } = usePagination( - (params) => $api.createRequest('/app/job/littleVideo', params), + (params) => $api.createRequest('/app/job/littleVideo', params, 'GET', true), dataToImg, // 转换函数 { pageSize: pageSize, @@ -122,6 +122,9 @@ const { list, loading, refresh, loadMore } = usePagination( onBeforeRequest: () => { loadmoreRef.value?.change('loading'); }, + onAfterRequest: () => { + loadmoreRef.value?.change('more'); + }, } ); @@ -244,7 +247,7 @@ function getJobList(type = 'add') { jobTitle: searchValue.value, }; - $api.createRequest('/app/job/list', params).then((resData) => { + $api.createRequest('/app/job/list', params, 'GET', true).then((resData) => { const { rows, total } = resData; if (type === 'add') { const str = pageState.pageSize * (pageState.page - 1); diff --git a/static/svg/seemore.svg b/static/svg/seemore.svg new file mode 100644 index 0000000..c67b4dd --- /dev/null +++ b/static/svg/seemore.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/stores/userChatGroupStore.js b/stores/userChatGroupStore.js index e43b785..8b688fe 100644 --- a/stores/userChatGroupStore.js +++ b/stores/userChatGroupStore.js @@ -18,6 +18,9 @@ import { UUID } from '../lib/uuid-min'; import config from '../config'; +import { + clearJobMoreMap +} from '@/utils/markdownParser'; const useChatGroupDBStore = defineStore("messageGroup", () => { const tableName = ref('messageGroup') @@ -57,6 +60,7 @@ const useChatGroupDBStore = defineStore("messageGroup", () => { if (!baseDB.isDBReady) await baseDB.initDB(); chatSessionID.value = sessionId const list = await baseDB.db.queryByField(massageName.value, 'parentGroupId', sessionId); + clearJobMoreMap() // 清空对话 加载更多参数 if (list.length) { console.log('本地数据库存在该对话数据', list) messages.value = list diff --git a/unpackage/.DS_Store b/unpackage/.DS_Store index 34e77da..20830e3 100644 Binary files a/unpackage/.DS_Store and b/unpackage/.DS_Store differ diff --git a/unpackage/dist/.DS_Store b/unpackage/dist/.DS_Store index 124f8b6..d59376b 100644 Binary files a/unpackage/dist/.DS_Store and b/unpackage/dist/.DS_Store differ diff --git a/unpackage/dist/build/.DS_Store b/unpackage/dist/build/.DS_Store index 8614cff..defd879 100644 Binary files a/unpackage/dist/build/.DS_Store and b/unpackage/dist/build/.DS_Store differ diff --git a/unpackage/dist/cache/.vite/deps/_metadata.json b/unpackage/dist/cache/.vite/deps/_metadata.json index 7724b6f..0e87990 100644 --- a/unpackage/dist/cache/.vite/deps/_metadata.json +++ b/unpackage/dist/cache/.vite/deps/_metadata.json @@ -1,8 +1,8 @@ { - "hash": "ab0eb594", - "configHash": "554cced5", + "hash": "5cf4c8aa", + "configHash": "0279f4bc", "lockfileHash": "5d26acb0", - "browserHash": "86a09ddc", + "browserHash": "5520a35c", "optimized": {}, "chunks": {} } \ No newline at end of file diff --git a/utils/markdownParser.js b/utils/markdownParser.js index 2b9c15e..1611be9 100644 --- a/utils/markdownParser.js +++ b/utils/markdownParser.js @@ -4,6 +4,7 @@ import parseHtml from '@/lib/html-parser.js'; // import DOMPurify from '@/lib/dompurify@3.2.4es.js'; export let codeDataList = [] +export let jobMoreMap = new Map() const md = new MarkdownIt({ html: true, // 允许 HTML 标签 @@ -16,23 +17,31 @@ const md = new MarkdownIt({ highlight: function(str, lang) { if (lang === 'job-json') { const result = safeExtractJson(str); - const jobId = result.appJobUrl.split('jobId=')[1] - return ` - -
- ${result.jobTitle} -
${result.salary}
-
-
${result.location}·${result.companyName}
-
-
-
${result.education}
-
${result.experience}
+ if (result) { // json解析成功 + const jobId = result.appJobUrl.split('jobId=')[1] + let domContext = ` +
+
+ ${result.jobTitle} +
${result.salary}
-
查看详情
-
- - ` +
${result.location}·${result.companyName}
+
+
+
${result.education}
+
${result.experience}
+
+
查看详情
+
+ + ` + if (result.data) { + jobMoreMap.set(jobId, result.data) + domContext += + `查看更多岗位
` + } + return domContext + } } //
${result.location}
//
${result.salary}
@@ -68,18 +77,54 @@ const md = new MarkdownIt({ } }) +function extractFirstJson(text) { + let stack = []; + let startIndex = -1; + let endIndex = -1; + + for (let i = 0; i < text.length; i++) { + const char = text[i]; + + if (char === '{') { + if (stack.length === 0) startIndex = i; // 记录第一个 '{' 的位置 + stack.push(char); + } else if (char === '}') { + stack.pop(); + if (stack.length === 0) { + endIndex = i; // 找到配对的 '}' + break; + } + } + } + + if (startIndex !== -1 && endIndex !== -1) { + const jsonString = text.slice(startIndex, endIndex + 1); + try { + const jsonObject = JSON.parse(jsonString); + return jsonObject; + } catch (e) { + return null; // 如果不是有效的 JSON + } + } + + return null; // 如果没有找到有效的 JSON 对象 +} + + function safeExtractJson(text) { try { - const match = text.match(/\{[\s\S]*?\}/); // 提取第一个完整的 JSON 块 - if (match) { - return JSON.parse(match[0]); - } + const jsonObject = extractFirstJson(text); + return jsonObject } catch (e) { console.error('JSON 解析失败:', e); } return null; } +export function clearJobMoreMap() { // 切换对话清空 + jobMoreMap.clear() +} + export function parseMarkdown(content) { if (!content) { return //处理特殊情况,比如网络异常导致的响应的 content 的值为空