docs: 将仓库代码注释统一为中文
This commit is contained in:
@@ -2,7 +2,7 @@ import { hostInvoke } from './desktop'
|
||||
|
||||
export interface RequestProgress { issued: boolean; requestId?: string }
|
||||
|
||||
/** A reservation makes cancel-before-dispatch definitive even across IPC ordering. */
|
||||
/** 即使在 IPC 订购中,预订也可以确保发货前取消。 */
|
||||
export function coreRequest<T>(args: Record<string, unknown>, signal: AbortSignal, timeoutMs: number, progress: RequestProgress): Promise<T> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let settled = false
|
||||
@@ -31,7 +31,7 @@ export function coreRequest<T>(args: Record<string, unknown>, signal: AbortSigna
|
||||
if (!settled) { settled = true; reject(error) }
|
||||
} finally {
|
||||
signal.removeEventListener('abort', abort)
|
||||
// Also discard a reservation if dispatch failed before Rust claimed it.
|
||||
// 如果在 Rust 声明保留之前调度失败,则也丢弃保留。
|
||||
cancel()
|
||||
}
|
||||
})()
|
||||
|
||||
@@ -4,7 +4,7 @@ import { hostInvoke } from './desktop'
|
||||
type Message = { kind: 'headers'; status: number } | { kind: 'chunk'; data: string }
|
||||
| { kind: 'done' } | { kind: 'error'; code: string }
|
||||
|
||||
/** Native session credentials stay in Rust; this channel carries response bytes only. */
|
||||
/** 本机会话凭证保留在 Rust 中;该通道仅承载响应字节。 */
|
||||
export function coreStream(path: string, init: RequestInit): Promise<Response> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const requestId = crypto.randomUUID()
|
||||
@@ -33,7 +33,7 @@ export function coreStream(path: string, init: RequestInit): Promise<Response> {
|
||||
if (message.kind === 'chunk') {
|
||||
const bytes = Uint8Array.from(atob(message.data), c => c.charCodeAt(0))
|
||||
controller.enqueue(bytes)
|
||||
// Bound queued data if a consumer stops reading without cancelling.
|
||||
// 如果消费者停止读取而不取消,则绑定排队数据。
|
||||
if ((controller.desiredSize ?? 0) < -4096) fail(new Error('CORE_STREAM_BACKPRESSURE'))
|
||||
}
|
||||
if (message.kind === 'error') fail(new Error(message.code))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/** Portable preference records are bound to the active Vault; local drafts retain their own Vault key. */
|
||||
/** 可移植偏好记录与主用Vault绑定;本地草稿保留自己的 Vault 密钥。 */
|
||||
import { ref, watch, nextTick } from 'vue'
|
||||
import { useWorkspaceStore } from '@/stores/workspace'
|
||||
import { useThemeStore } from '@/stores/theme'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/** A durable preference draft keeps its original CAS base until the user resolves a conflict. */
|
||||
/** 持久偏好草案保留其原始 CAS 基础,直到用户解决冲突。 */
|
||||
export interface LogicalRecord<T> { schema: 1; kind: string; id: string; data: T }
|
||||
export interface RecordDocument<T> { record: LogicalRecord<T>; hash: string; file_id: string }
|
||||
interface Draft<T> { record: LogicalRecord<T>; expected: string; operation_id: string }
|
||||
@@ -40,7 +40,7 @@ export class RecordBinding<T> {
|
||||
if (this.stopped) return
|
||||
const data = JSON.parse(JSON.stringify(this.options.read())) as T
|
||||
if (!this.draft && this.remote && JSON.stringify(data) === JSON.stringify(this.remote.record.data)) return
|
||||
// New edits while a request runs get a new operation, but preserve the unresolved base.
|
||||
// 请求运行时的新编辑会获取新操作,但保留未解析的基础。
|
||||
this.draft = { record: { schema: 1, kind: this.options.kind, id: this.options.id, data }, expected: this.draft?.expected ?? this.remote?.hash ?? '', operation_id: crypto.randomUUID() }
|
||||
this.restored = false; this.invalidDraft = false
|
||||
try { this.persist(); if (this.error === 'PREFERENCE_DRAFT_STORE_FAILED') this.error = '' } catch { this.error = 'PREFERENCE_DRAFT_STORE_FAILED'; this.options.changed?.() }
|
||||
@@ -71,7 +71,7 @@ export class RecordBinding<T> {
|
||||
if (this.draft.operation_id === draft.operation_id) {
|
||||
this.persist(null); this.draft = null; this.appliedHash = committed.hash
|
||||
} else {
|
||||
// The next local edit follows the just-confirmed predecessor, not its older CAS base.
|
||||
// 下一个本地编辑遵循刚刚确认的前身,而不是其较旧的 CAS 基础。
|
||||
this.draft.expected = committed.hash; this.persist()
|
||||
}
|
||||
} else if (this.remote && this.remote.hash !== this.appliedHash) {
|
||||
|
||||
Reference in New Issue
Block a user