Files
dsProject/dsLightRag/static/js/ai-resource-workshop.js
2025-09-03 09:08:23 +08:00

61 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// AI资源工坊页面交互逻辑
layui.use(['form', 'laydate'], function() {
var form = layui.form;
var laydate = layui.laydate;
// 初始化表单
form.render();
// 生成按钮点击事件
document.querySelector('.generate-btn').addEventListener('click', function() {
// 显示加载动画
this.innerHTML = '<i class="fas fa-spinner fa-spin"></i> 生成中...';
this.disabled = true;
// 模拟生成过程
setTimeout(() => {
// 生成成功后跳转或显示结果
window.location.href = 'resource-preview.html';
}, 2000);
});
});
/**
* AI资源工坊页面专属脚本
*/
document.addEventListener('DOMContentLoaded', function() {
// 资源搜索功能
const searchInput = document.querySelector('.search-box input');
const searchBtn = document.querySelector('.search-box .search-btn');
if (searchBtn && searchInput) {
searchBtn.addEventListener('click', performSearch);
searchInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') performSearch();
});
}
// 资源排序功能
const sortSelect = document.querySelector('.resource-filters select');
if (sortSelect) {
sortSelect.addEventListener('change', function() {
alert(`已切换排序方式为: ${this.options[this.selectedIndex].text}`);
// 在实际项目中这里会发起AJAX请求获取排序后的资源
});
}
/**
* 执行搜索功能
*/
function performSearch() {
const keyword = searchInput.value.trim();
if (keyword) {
alert(`搜索资源: ${keyword}`);
// 在实际项目中这里会发起AJAX请求获取搜索结果
} else {
alert('请输入搜索关键词');
}
}
});