fix(files): unwrap injected refs via reactive context for v-model
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
# Changelog: 文件管理 v-model 显示 [object Object] 修复
|
||||
|
||||
**日期**: 2026-06-02
|
||||
|
||||
## 摘要
|
||||
|
||||
修复文件管理页路径/筛选等输入框显示 `[object Object]`、无法浏览目录的问题。
|
||||
|
||||
## 动机
|
||||
|
||||
`provideFilesPage` 注入的是含 `ref` 的普通对象;子组件模板中 `p.currentPath` 等不会自动解包,Vuetify `v-model` 绑到 Ref 实例导致界面不可用。
|
||||
|
||||
## 涉及文件
|
||||
|
||||
- `frontend/src/composables/files/filesPageContext.ts` — `provide(..., reactive(ctx))`
|
||||
|
||||
## 迁移 / 重启
|
||||
|
||||
- 仅前端静态资源,重新 build 并上传 `web/app/` 即可,无需重启后端。
|
||||
|
||||
## 验证
|
||||
|
||||
1. 打开 `/app/#/files`,路径框应显示正常路径(如 `/www/wwwroot`),非 `[object Object]`
|
||||
2. 选择服务器后列表可加载;刷新/上级目录可用
|
||||
@@ -1,15 +1,18 @@
|
||||
import { inject, provide, type InjectionKey } from 'vue'
|
||||
import { inject, provide, reactive, type InjectionKey, type UnwrapNestedRefs } from 'vue'
|
||||
import type { useFilesPage } from './useFilesPage'
|
||||
|
||||
export type FilesPageContext = ReturnType<typeof useFilesPage>
|
||||
|
||||
export const filesPageKey: InjectionKey<FilesPageContext> = Symbol('filesPage')
|
||||
/** Reactive proxy so injected Ref fields unwrap in child templates (v-model). */
|
||||
export type FilesPageContextProvided = UnwrapNestedRefs<FilesPageContext>
|
||||
|
||||
export const filesPageKey: InjectionKey<FilesPageContextProvided> = Symbol('filesPage')
|
||||
|
||||
export function provideFilesPage(ctx: FilesPageContext): void {
|
||||
provide(filesPageKey, ctx)
|
||||
provide(filesPageKey, reactive(ctx) as FilesPageContextProvided)
|
||||
}
|
||||
|
||||
export function useFilesPageContext(): FilesPageContext {
|
||||
export function useFilesPageContext(): FilesPageContextProvided {
|
||||
const ctx = inject(filesPageKey)
|
||||
if (!ctx) {
|
||||
throw new Error('useFilesPageContext() must be used inside FilesPage')
|
||||
|
||||
Reference in New Issue
Block a user