RSSNext / Follow

🧡 Next generation information browser.
https://follow.is
GNU General Public License v3.0
10.49k stars 455 forks source link

Follow App 上 没有导出 OPML 源的功能吗? 例如图 #719

Open markyun opened 2 hours ago

markyun commented 2 hours ago

Clear and concise description of the problem

image

Suggested solution

建议加上 订阅源的导出能力。

Alternative

No response

Additional context

No response

Validations

linear[bot] commented 2 hours ago

FOL-320 Follow App 上 没有导出 OPML 源的功能吗? 例如图

weekend-project-space commented 2 hours ago

浏览器 f12 控制台

function listFeeds() {

  return new Promise((resolve, reject) => {
    const request = indexedDB.open("FOLLOW_DB", 50);

    request.onsuccess = function(event) {
      const db = event.target.result;
      console.log("数据库打开成功");

      const transaction = db.transaction(["feeds"]);
      const objectStore = transaction.objectStore("feeds");
      const cursorRequest = objectStore.openCursor();
      const results = []; // 用于存储查询结果的数组

      cursorRequest.onsuccess = function(event) {
        const cursor = event.target.result;
        if (cursor) {
          results.push(cursor.value); // 将当前记录推入数组
          cursor.continue(); // 继续遍历下一个记录
        } else {
          resolve(results); // 查询完成,返回结果
        }
      };

      cursorRequest.onerror = function(event) {
        reject("查询失败: " + event.target.error); // 查询失败,返回错误
      };
    };

    request.onerror = function(event) {
      reject("数据库打开失败: " + event.target.error); // 数据库打开失败,返回错误
    };

    request.onupgradeneeded = function(event) {
      // 这里可以处理数据库升级逻辑
    };
  });
}
function jsonToOpml(jsonData) {
  let opml = `<?xml version="1.0" encoding="UTF-8"?>
  <opml version="2.0">
    <head>
      <title>Feed List</title>
    </head>
    <body>`;

  jsonData.forEach(feed => {
    opml += `
      <outline
          type="${feed.type || 'feed'}"
          text="${feed.title || ''}"
          title="${feed.title || ''}"
          xmlUrl="${feed.url || ''}"
          htmlUrl="${feed.siteUrl || ''}"
          description="${feed.description || ''}">
      </outline>`;
  });

  opml += `
    </body>
  </opml>`;

  return opml;
}

function downloadOpml(opml, filename = 'feeds.opml') {
  const blob = new Blob([opml], { type: 'application/xml' });
  const url = URL.createObjectURL(blob);
  const a = document.createElement('a');
  a.href = url;
  a.download = filename;
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
  URL.revokeObjectURL(url); // 释放对象 URL
}

downloadOpml(jsonToOpml(await listFeeds()))

回车导出

markyun commented 2 hours ago

浏览器 f12 控制台

function listFeeds() {

  return new Promise((resolve, reject) => {
    const request = indexedDB.open("FOLLOW_DB", 50);

    request.onsuccess = function(event) {
      const db = event.target.result;
      console.log("数据库打开成功");

      const transaction = db.transaction(["feeds"]);
      const objectStore = transaction.objectStore("feeds");
      const cursorRequest = objectStore.openCursor();
      const results = []; // 用于存储查询结果的数组

      cursorRequest.onsuccess = function(event) {
        const cursor = event.target.result;
        if (cursor) {
          results.push(cursor.value); // 将当前记录推入数组
          cursor.continue(); // 继续遍历下一个记录
        } else {
          resolve(results); // 查询完成,返回结果
        }
      };

      cursorRequest.onerror = function(event) {
        reject("查询失败: " + event.target.error); // 查询失败,返回错误
      };
    };

    request.onerror = function(event) {
      reject("数据库打开失败: " + event.target.error); // 数据库打开失败,返回错误
    };

    request.onupgradeneeded = function(event) {
      // 这里可以处理数据库升级逻辑
    };
  });
}
function jsonToOpml(jsonData) {
  let opml = `<?xml version="1.0" encoding="UTF-8"?>
  <opml version="2.0">
    <head>
      <title>Feed List</title>
    </head>
    <body>`;

  jsonData.forEach(feed => {
    opml += `
      <outline
          type="${feed.type || 'feed'}"
          text="${feed.title || ''}"
          title="${feed.title || ''}"
          xmlUrl="${feed.url || ''}"
          htmlUrl="${feed.siteUrl || ''}"
          description="${feed.description || ''}">
      </outline>`;
  });

  opml += `
    </body>
  </opml>`;

  return opml;
}

function downloadOpml(opml, filename = 'feeds.opml') {
  const blob = new Blob([opml], { type: 'application/xml' });
  const url = URL.createObjectURL(blob);
  const a = document.createElement('a');
  a.href = url;
  a.download = filename;
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
  URL.revokeObjectURL(url); // 释放对象 URL
}

downloadOpml(jsonToOpml(await listFeeds()))

回车导出

good job

const7 commented 52 minutes ago

官方的(但目前似乎有些小问题,没有导出自定义title):https://api.follow.is/subscriptions/export