main.ts 1.6 KB

12345678910111213141516171819202122232425
  1. // Isolated visual fixture: no application API requests or user data writes.
  2. import { createApp, defineComponent, h, ref } from 'vue'
  3. import WorkspaceApprovalCard from '@/components/workspace/WorkspaceApprovalCard.vue'
  4. import '@/styles/tokens.css'
  5. import '@/styles/global.css'
  6. const query = new URLSearchParams(location.search)
  7. document.documentElement.classList.toggle('dark', query.has('dark'))
  8. createApp(defineComponent({ setup() {
  9. const busy = ref(false), result = ref(''), automatic = ref(false)
  10. async function choose(choice: 'once'|'deny'|'auto') {
  11. busy.value = true
  12. await new Promise(resolve => setTimeout(resolve, 600))
  13. automatic.value = choice === 'auto'
  14. result.value = choice === 'auto' ? '自动允许已开启,后续不再询问' : choice === 'once' ? '已允许本次操作' : '已拒绝本次操作'
  15. busy.value = false
  16. }
  17. return () => h('main', { style: 'min-height:100dvh;display:grid;place-items:center;background:var(--surface);color:var(--text-primary)' }, [
  18. h('div', { style: 'width:100%;max-width:390px;padding:16px;box-sizing:border-box' }, result.value ? [
  19. h('p', { role: 'status' }, result.value),
  20. h('button', { onClick: () => { result.value = automatic.value ? '已自动允许下一次操作' : '' } }, '模拟下一次审批'),
  21. h('button', { onClick: () => { result.value = ''; automatic.value = false } }, '重新预览'),
  22. ] : h(WorkspaceApprovalCard, { prompt: query.has('long') ? '运行工具:' + '请核对下面的工具参数与文件路径。'.repeat(80) : '瑶儿想调用图片生成工具', busy: busy.value, onChoose: choose })),
  23. ])
  24. } })).mount('#app')