ChatGPT-Next-Web [功能请求]:切换到统一同步协议,并使用tauri http包作为本地客户端,

eni9jsuy  于 2个月前  发布在  其他
关注(0)|答案(2)|浏览(32)

让我们将其转换为RPC,这是一个建议:

type WebDavConfig = {
  type: 'webdav',
  endpoint: string,
  username: string,
  password: string
}

type UpstashConfig = {
  type: 'upstash',
  endpoint: string,
  username: STORAGE_KEY,
  apiKey: string
}

type SyncAction = {
  type: 'check'
} | {
  type: 'get',
  key: string,
} | {
  type: 'set',
  key: string,
  value: string
}

type SyncPayload = {
  config: WebDavConfig | UpstashConfig,
  action: SyncAction
}

// client side
function createUpstashClient() {
  return async check() {
    return await call('/api/sync', { /* webdav config */ })
  },
  // get(key), set(key, value)
}

// server side, /api/sync/route.ts
async function handle(req) {
  const payload = JSON.parse(await req.json()) as SyncPayload;

  // dispatch payload to server side check/get/set actions
}

主要思路是将之前在客户端完成的所有同步操作转移到服务器端。缺点是,除非我们保留内置的官方同步端点,否则桌面应用程序无法再使用同步功能。

  • 最初由@Yidadaa在#4285(评论)中发布*
vfwfrxfs

vfwfrxfs1#

对于Web版本来说,这个特性是不可能实现的。

qlzsbp2j

qlzsbp2j2#

对于Tauri/desktop applications,它更安全可靠,开发者可以轻松利用其功能(例如laverage feature that not possible for web version),尤其是由于它是用Rust编写的。

相关问题