flat: 修改
This commit is contained in:
@@ -24,11 +24,13 @@ const renderedHtml = computed(() => parseMarkdown(props.content));
|
|||||||
|
|
||||||
const handleItemClick = (e) => {
|
const handleItemClick = (e) => {
|
||||||
let { attrs } = e.detail.node;
|
let { attrs } = e.detail.node;
|
||||||
|
console.log(attrs);
|
||||||
let { 'data-copy-index': codeDataIndex, 'data-job-id': jobId, class: className } = attrs;
|
let { 'data-copy-index': codeDataIndex, 'data-job-id': jobId, class: className } = attrs;
|
||||||
switch (className) {
|
switch (className) {
|
||||||
case 'custom-card':
|
case 'custom-card':
|
||||||
navTo('/packageA/pages/post/post?jobId=' + jobId);
|
return navTo('/packageA/pages/post/post?jobId=' + jobId);
|
||||||
return;
|
case 'custom-more':
|
||||||
|
return navTo('/packageA/pages/moreJobs/moreJobs?jobId=' + jobId);
|
||||||
case 'copy-btn':
|
case 'copy-btn':
|
||||||
uni.setClipboardData({
|
uni.setClipboardData({
|
||||||
data: codeDataList[codeDataIndex],
|
data: codeDataList[codeDataIndex],
|
||||||
@@ -40,6 +42,7 @@ const handleItemClick = (e) => {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -258,6 +261,19 @@ ol {
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style lang="stylus">
|
<style lang="stylus">
|
||||||
|
.custom-more{
|
||||||
|
display: flex
|
||||||
|
justify-content: flex-end
|
||||||
|
color: #256BFA
|
||||||
|
padding-top: 5rpx
|
||||||
|
padding-bottom: 14rpx
|
||||||
|
.more-icon{
|
||||||
|
width: 60rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
background: url('@/static/svg/seemore.svg') center center no-repeat;
|
||||||
|
background-size: 100% 100%
|
||||||
|
}
|
||||||
|
}
|
||||||
.custom-card
|
.custom-card
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0,0,0,0.04);
|
box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0,0,0,0.04);
|
||||||
|
@@ -49,7 +49,7 @@ export function usePagination(
|
|||||||
|
|
||||||
const fetchData = async (type = 'refresh') => {
|
const fetchData = async (type = 'refresh') => {
|
||||||
if (loading.value) return Promise.resolve()
|
if (loading.value) return Promise.resolve()
|
||||||
|
console.log(type)
|
||||||
loading.value = true
|
loading.value = true
|
||||||
error.value = false
|
error.value = false
|
||||||
|
|
||||||
@@ -77,17 +77,17 @@ export function usePagination(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
|
...pageState.search,
|
||||||
[pageField]: pageState.page,
|
[pageField]: pageState.page,
|
||||||
[sizeField]: pageState.pageSize,
|
[sizeField]: pageState.pageSize,
|
||||||
...pageState.search
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await requestFn(params)
|
const res = await requestFn(params)
|
||||||
|
|
||||||
const rawData = res[dataKey]
|
const rawData = res[dataKey]
|
||||||
const total = res[totalKey]
|
const total = res[totalKey] || 99999999
|
||||||
|
console.log(total, rawData)
|
||||||
const data = typeof transformFn === 'function' ? transformFn(rawData) : rawData
|
const data = typeof transformFn === 'function' ? transformFn(rawData) : rawData
|
||||||
|
|
||||||
if (type === 'refresh') {
|
if (type === 'refresh') {
|
||||||
@@ -137,10 +137,10 @@ export function usePagination(
|
|||||||
if (autoWatchSearch && isRef(search)) {
|
if (autoWatchSearch && isRef(search)) {
|
||||||
watch(search, (newVal) => {
|
watch(search, (newVal) => {
|
||||||
pageState.search = newVal
|
pageState.search = newVal
|
||||||
// clearTimeout(debounceTimer)
|
clearTimeout(debounceTimer)
|
||||||
// debounceTimer = setTimeout(() => {
|
debounceTimer = setTimeout(() => {
|
||||||
// refresh()
|
refresh()
|
||||||
// }, debounceTime)
|
}, debounceTime)
|
||||||
}, {
|
}, {
|
||||||
deep: true
|
deep: true
|
||||||
})
|
})
|
||||||
|
73
packageA/pages/moreJobs/moreJobs.vue
Normal file
73
packageA/pages/moreJobs/moreJobs.vue
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<template>
|
||||||
|
<view class="collection-content">
|
||||||
|
<renderJobs :list="list" :longitude="longitudeVal" :latitude="latitudeVal"></renderJobs>
|
||||||
|
<loadmore ref="loadmoreRef"></loadmore>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import dictLabel from '@/components/dict-Label/dict-Label.vue';
|
||||||
|
import { reactive, inject, watch, ref, onMounted } from 'vue';
|
||||||
|
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app';
|
||||||
|
import useUserStore from '@/stores/useUserStore';
|
||||||
|
const { $api, navTo, navBack, vacanciesTo } = inject('globalFunction');
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import useLocationStore from '@/stores/useLocationStore';
|
||||||
|
import { usePagination } from '@/hook/usePagination';
|
||||||
|
import { jobMoreMap } from '@/utils/markdownParser';
|
||||||
|
const { longitudeVal, latitudeVal } = storeToRefs(useLocationStore());
|
||||||
|
const loadmoreRef = ref(null);
|
||||||
|
|
||||||
|
// 响应式搜索条件(可以被修改)
|
||||||
|
const searchParams = ref({});
|
||||||
|
const pageSize = ref(10);
|
||||||
|
const { list, loading, refresh, loadMore } = usePagination(
|
||||||
|
(params) => $api.createRequest('/app/job/list', params, 'GET', true),
|
||||||
|
null, // 转换函数
|
||||||
|
{
|
||||||
|
pageSize: pageSize,
|
||||||
|
search: searchParams,
|
||||||
|
autoWatchSearch: true,
|
||||||
|
onBeforeRequest: () => {
|
||||||
|
loadmoreRef.value?.change('loading');
|
||||||
|
},
|
||||||
|
onAfterRequest: () => {
|
||||||
|
loadmoreRef.value?.change('more');
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
onLoad((options) => {
|
||||||
|
let params = jobMoreMap.get(options.jobId);
|
||||||
|
if (params) {
|
||||||
|
uni.setStorageSync('jobMoreMap', params);
|
||||||
|
} else {
|
||||||
|
params = uni.getStorageSync('jobMoreMap');
|
||||||
|
}
|
||||||
|
const objs = removeNullProperties(params);
|
||||||
|
searchParams.value = objs;
|
||||||
|
refresh();
|
||||||
|
});
|
||||||
|
|
||||||
|
function removeNullProperties(obj) {
|
||||||
|
for (const key in obj) {
|
||||||
|
if (obj.hasOwnProperty(key) && obj[key] === null) {
|
||||||
|
delete obj[key]; // 删除值为 null 的属性
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
onReachBottom(() => {
|
||||||
|
loadMore();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="stylus" scoped>
|
||||||
|
.collection-content{
|
||||||
|
padding: 1rpx 28rpx 20rpx 28rpx;
|
||||||
|
background: #F4F4F4;
|
||||||
|
height: 100%
|
||||||
|
min-height: calc(100vh - var(--window-top) - var(--status-bar-height) - var(--window-bottom));
|
||||||
|
}
|
||||||
|
</style>
|
@@ -194,6 +194,13 @@
|
|||||||
"navigationBarBackgroundColor": "#FFFFFF",
|
"navigationBarBackgroundColor": "#FFFFFF",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/moreJobs/moreJobs",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "更多岗位",
|
||||||
|
"navigationBarBackgroundColor": "#FFFFFF"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
|
@@ -112,7 +112,7 @@ const searchParams = ref({});
|
|||||||
const pageSize = ref(10);
|
const pageSize = ref(10);
|
||||||
|
|
||||||
const { list, loading, refresh, loadMore } = usePagination(
|
const { list, loading, refresh, loadMore } = usePagination(
|
||||||
(params) => $api.createRequest('/app/job/littleVideo', params),
|
(params) => $api.createRequest('/app/job/littleVideo', params, 'GET', true),
|
||||||
dataToImg, // 转换函数
|
dataToImg, // 转换函数
|
||||||
{
|
{
|
||||||
pageSize: pageSize,
|
pageSize: pageSize,
|
||||||
@@ -122,6 +122,9 @@ const { list, loading, refresh, loadMore } = usePagination(
|
|||||||
onBeforeRequest: () => {
|
onBeforeRequest: () => {
|
||||||
loadmoreRef.value?.change('loading');
|
loadmoreRef.value?.change('loading');
|
||||||
},
|
},
|
||||||
|
onAfterRequest: () => {
|
||||||
|
loadmoreRef.value?.change('more');
|
||||||
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -244,7 +247,7 @@ function getJobList(type = 'add') {
|
|||||||
jobTitle: searchValue.value,
|
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;
|
const { rows, total } = resData;
|
||||||
if (type === 'add') {
|
if (type === 'add') {
|
||||||
const str = pageState.pageSize * (pageState.page - 1);
|
const str = pageState.pageSize * (pageState.page - 1);
|
||||||
|
1
static/svg/seemore.svg
Normal file
1
static/svg/seemore.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1753846081356" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1008" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M256 384c38.272 0 72.576 16.768 96 43.392C332.16 449.92 320 479.552 320 512c0 32.448 12.096 62.08 32 84.608A128 128 0 1 1 256 384zM512 384c38.272 0 72.576 16.768 96 43.392C588.16 449.92 576 479.552 576 512c0 32.448 12.096 62.08 32 84.608A128 128 0 1 1 512 384z" fill="#256BFA" p-id="1009"></path><path d="M768 512m-128 0a128 128 0 1 0 256 0 128 128 0 1 0-256 0Z" fill="#256BFA" p-id="1010"></path></svg>
|
After Width: | Height: | Size: 736 B |
@@ -18,6 +18,9 @@ import {
|
|||||||
UUID
|
UUID
|
||||||
} from '../lib/uuid-min';
|
} from '../lib/uuid-min';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
|
import {
|
||||||
|
clearJobMoreMap
|
||||||
|
} from '@/utils/markdownParser';
|
||||||
|
|
||||||
const useChatGroupDBStore = defineStore("messageGroup", () => {
|
const useChatGroupDBStore = defineStore("messageGroup", () => {
|
||||||
const tableName = ref('messageGroup')
|
const tableName = ref('messageGroup')
|
||||||
@@ -57,6 +60,7 @@ const useChatGroupDBStore = defineStore("messageGroup", () => {
|
|||||||
if (!baseDB.isDBReady) await baseDB.initDB();
|
if (!baseDB.isDBReady) await baseDB.initDB();
|
||||||
chatSessionID.value = sessionId
|
chatSessionID.value = sessionId
|
||||||
const list = await baseDB.db.queryByField(massageName.value, 'parentGroupId', sessionId);
|
const list = await baseDB.db.queryByField(massageName.value, 'parentGroupId', sessionId);
|
||||||
|
clearJobMoreMap() // 清空对话 加载更多参数
|
||||||
if (list.length) {
|
if (list.length) {
|
||||||
console.log('本地数据库存在该对话数据', list)
|
console.log('本地数据库存在该对话数据', list)
|
||||||
messages.value = list
|
messages.value = list
|
||||||
|
BIN
unpackage/.DS_Store
vendored
BIN
unpackage/.DS_Store
vendored
Binary file not shown.
BIN
unpackage/dist/.DS_Store
vendored
BIN
unpackage/dist/.DS_Store
vendored
Binary file not shown.
BIN
unpackage/dist/build/.DS_Store
vendored
BIN
unpackage/dist/build/.DS_Store
vendored
Binary file not shown.
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"hash": "ab0eb594",
|
"hash": "5cf4c8aa",
|
||||||
"configHash": "554cced5",
|
"configHash": "0279f4bc",
|
||||||
"lockfileHash": "5d26acb0",
|
"lockfileHash": "5d26acb0",
|
||||||
"browserHash": "86a09ddc",
|
"browserHash": "5520a35c",
|
||||||
"optimized": {},
|
"optimized": {},
|
||||||
"chunks": {}
|
"chunks": {}
|
||||||
}
|
}
|
@@ -4,6 +4,7 @@ import parseHtml from '@/lib/html-parser.js';
|
|||||||
// import DOMPurify from '@/lib/dompurify@3.2.4es.js';
|
// import DOMPurify from '@/lib/dompurify@3.2.4es.js';
|
||||||
|
|
||||||
export let codeDataList = []
|
export let codeDataList = []
|
||||||
|
export let jobMoreMap = new Map()
|
||||||
|
|
||||||
const md = new MarkdownIt({
|
const md = new MarkdownIt({
|
||||||
html: true, // 允许 HTML 标签
|
html: true, // 允许 HTML 标签
|
||||||
@@ -16,8 +17,9 @@ const md = new MarkdownIt({
|
|||||||
highlight: function(str, lang) {
|
highlight: function(str, lang) {
|
||||||
if (lang === 'job-json') {
|
if (lang === 'job-json') {
|
||||||
const result = safeExtractJson(str);
|
const result = safeExtractJson(str);
|
||||||
|
if (result) { // json解析成功
|
||||||
const jobId = result.appJobUrl.split('jobId=')[1]
|
const jobId = result.appJobUrl.split('jobId=')[1]
|
||||||
return `
|
let domContext = `
|
||||||
<a class="custom-card" data-job-id="${jobId}">
|
<a class="custom-card" data-job-id="${jobId}">
|
||||||
<div class="card-title">
|
<div class="card-title">
|
||||||
<span class="title-text" >${result.jobTitle}</span>
|
<span class="title-text" >${result.jobTitle}</span>
|
||||||
@@ -33,6 +35,13 @@ const md = new MarkdownIt({
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
`
|
`
|
||||||
|
if (result.data) {
|
||||||
|
jobMoreMap.set(jobId, result.data)
|
||||||
|
domContext +=
|
||||||
|
`<a class="custom-more" data-job-id="${jobId}">查看更多岗位<div class="more-icon"></div></a>`
|
||||||
|
}
|
||||||
|
return domContext
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// <div class="card-tag">${result.location}</div>
|
// <div class="card-tag">${result.location}</div>
|
||||||
// <div class="info-item">${result.salary}</div>
|
// <div class="info-item">${result.salary}</div>
|
||||||
@@ -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) {
|
function safeExtractJson(text) {
|
||||||
try {
|
try {
|
||||||
const match = text.match(/\{[\s\S]*?\}/); // 提取第一个完整的 JSON 块
|
const jsonObject = extractFirstJson(text);
|
||||||
if (match) {
|
return jsonObject
|
||||||
return JSON.parse(match[0]);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('JSON 解析失败:', e);
|
console.error('JSON 解析失败:', e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function clearJobMoreMap() { // 切换对话清空
|
||||||
|
jobMoreMap.clear()
|
||||||
|
}
|
||||||
|
|
||||||
export function parseMarkdown(content) {
|
export function parseMarkdown(content) {
|
||||||
if (!content) {
|
if (!content) {
|
||||||
return //处理特殊情况,比如网络异常导致的响应的 content 的值为空
|
return //处理特殊情况,比如网络异常导致的响应的 content 的值为空
|
||||||
|
Reference in New Issue
Block a user