import {
	http,
	Method
} from '@/utils/request.js';
  // 使用storage模块的方法设置登录状态为false
import storage from "@/utils/storage.js";
const request = http.request;


/**
 * 获取农技知识列表（新）
 * @param params
 */
export function getKnowledgeList(params) {
  return http.request({
    url: "uniapp/knowledge/list",
    method: Method.GET,
    // needToken: true,
    data:params,
  });
}

/**
 * 获取农技知识详情（新）
 * @param params
 */
export function getKnowledgeDetail(params) {
  return http.request({
    url: "uniapp/knowledge/detail",
    method: Method.GET,
    // needToken: true,
    data:params,
  });
}

/**
 * 增加阅读量（新）
 * @param params
 */
export function getKnowledgeView(params) {
  return http.request({
    url: "uniapp/knowledge/view",
    method: Method.POST,
    // needToken: true,
    data:params,
  });
}
/**
 * 点赞文章
 * @param id 文章ID
 */
export function likeArticle(id) {
  return http.request({
    url: `uniapp/knowledge/like/${id}`,
    method: Method.POST,
    needToken: true,
  });
}

/**
 * 取消点赞文章
 * @param id 文章ID
 */
export function unlikeArticle(id) {
  return http.request({
    url: `uniapp/knowledge/like/${id}`,
    method: Method.DELETE,
    needToken: true,
  });
}

/**
 * 收藏文章
 * @param id 文章ID
 */
export function favoriteArticle(id) {
  return http.request({
    url: `uniapp/knowledge/favorite/${id}`,
    method: Method.POST,
    needToken: true,
  });
}

/**
 * 取消收藏文章
 * @param id 文章ID
 */
export function unfavoriteArticle(id) {
  return http.request({
    url: `uniapp/knowledge/favorite/${id}`,
    method: Method.DELETE,
    needToken: true,
  });
}