@2kog/kacha 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +0 -14
  2. package/bin/init-project.js +14 -23
  3. package/package.json +1 -1
  4. package/server/asset-watch.js +12 -3
  5. package/server/image-assets.js +2 -2
  6. package/server/index.js +4 -0
  7. package/server/project-scripts.js +93 -0
  8. package/server/project-settings.js +101 -12
  9. package/server/project-storyboard.js +89 -0
  10. package/src/assets/css/workbench.css +14 -15
  11. package/src/components/AssetStoryEditor.vue +15 -9
  12. package/src/components/JimengPromptPreview.vue +69 -0
  13. package/src/components/ProjectMarkdown.vue +2 -1
  14. package/src/components/ScriptVersionDiff.vue +96 -0
  15. package/src/components/StoryboardDocument.vue +99 -0
  16. package/src/i18n/en.json +42 -7
  17. package/src/layouts/WorkbenchLayout.vue +35 -46
  18. package/src/router/index.js +8 -2
  19. package/src/service/project-markdown.js +13 -1
  20. package/src/service/resume.js +18 -0
  21. package/src/views/assets/CharacterAssets.vue +39 -5
  22. package/src/views/home/ProjectHome.vue +119 -0
  23. package/src/views/scripts/ProjectScripts.vue +272 -0
  24. package/src/views/scripts/ProjectStoryboard.vue +126 -0
  25. package/src/views/settings/ProjectSettings.vue +62 -20
  26. package/templates/project/.lfsconfig +2 -0
  27. package/templates/project/AGENTS.md +116 -15
  28. package/templates/project/README.md +51 -7
  29. package/templates/project/assets/audio/.gitkeep +0 -0
  30. package/templates/project/assets/characters/.gitkeep +0 -0
  31. package/templates/project/assets/other/.gitkeep +0 -0
  32. package/templates/project/assets/props/.gitkeep +0 -0
  33. package/templates/project/assets/scenes/.gitkeep +0 -0
  34. package/templates/project/config/.gitkeep +0 -0
  35. package/templates/project/docs/art//345/234/272/346/231/257/344/270/216/347/251/272/351/227/264.md +3 -0
  36. package/templates/project/docs/art//350/247/222/350/211/262/347/276/216/346/234/257.md +3 -0
  37. package/templates/project/docs/art//351/201/223/345/205/267/347/276/216/346/234/257.md +3 -0
  38. package/templates/project/docs/other//350/241/245/345/205/205/350/257/264/346/230/216.md +7 -0
  39. package/templates/project/docs/story//344/270/226/347/225/214/350/247/202/344/270/216/350/247/222/350/211/262.md +3 -0
  40. package/templates/project/env.template +5 -0
  41. package/templates/project/gitignore.template +5 -0
  42. package/templates/project/package.json +8 -0
  43. package/templates/project/scripts/.gitkeep +0 -0
  44. package/templates/project/storyboard/.gitkeep +0 -0
  45. package/vite.config.js +1 -1
  46. package/templates/project/assets/audio/README.md +0 -5
  47. package/templates/project/assets/characters/README.md +0 -5
  48. package/templates/project/assets/other/README.md +0 -3
  49. package/templates/project/assets/props/README.md +0 -3
  50. package/templates/project/assets/scenes/README.md +0 -3
@@ -0,0 +1,69 @@
1
+ <script>
2
+ import { marked } from 'marked'
3
+ import { Copy } from 'lucide-vue-next'
4
+ import ProjectMarkdown from './ProjectMarkdown.vue'
5
+
6
+ function promptSections(markdown) {
7
+ const sections = []
8
+ let section = { source: '', prompt: '' }
9
+ let prose = false
10
+ function finish() {
11
+ if (section.source.trim()) sections.push(section)
12
+ section = { source: '', prompt: '' }
13
+ prose = false
14
+ }
15
+ for (const token of marked.lexer(markdown)) {
16
+ if (token.type === 'code' || token.type === 'blockquote') {
17
+ finish()
18
+ sections.push({ source: token.raw, prompt: token.text })
19
+ continue
20
+ }
21
+ if (token.type === 'heading') finish()
22
+ if (token.type === 'paragraph' && /^可复制提示词[::]\s*$/.test(token.text)) {
23
+ finish()
24
+ section.source = token.raw
25
+ finish()
26
+ prose = true
27
+ continue
28
+ }
29
+ if (!prose && token.type === 'paragraph' && /^生成/.test(token.text)) {
30
+ finish()
31
+ prose = true
32
+ }
33
+ section.source += token.raw
34
+ if (prose) section.prompt += token.raw
35
+ }
36
+ finish()
37
+ return sections
38
+ }
39
+
40
+ export default {
41
+ components: { Copy, ProjectMarkdown },
42
+ props: { source: String, file: String },
43
+ data() { return { feedback: null } },
44
+ computed: { sections() { return promptSections(this.source) } },
45
+ methods: {
46
+ async copy(section, index) {
47
+ try {
48
+ await navigator.clipboard.writeText(section.prompt.trim())
49
+ this.feedback = { index, label: '已复制' }
50
+ } catch {
51
+ this.feedback = { index, label: '复制失败' }
52
+ }
53
+ },
54
+ },
55
+ }
56
+ </script>
57
+ <template>
58
+ <section v-for="(section, i) in sections" :key="i">
59
+ <div v-if="section.prompt.trim()" class="prompt-actions">
60
+ <button type="button" class="secondary" @click="copy(section, i)">
61
+ <Copy :size="14" /><span aria-live="polite">{{ $t(feedback?.index === i ? feedback.label : '复制提示词') }}</span>
62
+ </button>
63
+ </div>
64
+ <ProjectMarkdown :source="section.source" :file="file" show-images />
65
+ </section>
66
+ </template>
67
+ <style scoped>
68
+ .prompt-actions { display:flex; justify-content:flex-end; margin:8px 0 4px }
69
+ </style>
@@ -22,7 +22,8 @@ export default {
22
22
 
23
23
  <style scoped>
24
24
  .markdown { font-size: 14px; line-height: 1.68; overflow-wrap: anywhere; }
25
- .markdown :deep(h1) { font-size: 21px; }
25
+ .markdown :deep(h1) { font-size: 24px; }
26
+ .markdown :deep(h2) { font-size: 18px; }
26
27
  .markdown :deep(a) { color: var(--accent); }
27
28
  .markdown :deep(img) { display: block; max-width: 100%; height: auto; border-radius: 7px; }
28
29
  .markdown :deep(.markdown-table) { max-width: 100%; margin-block: 12px; overflow-x: auto; }
@@ -0,0 +1,96 @@
1
+ <script>
2
+ function numberedLines(source) {
3
+ return source === '' ? [] : source.replace(/\r\n/g, '\n').replace(/\n$/, '').split('\n')
4
+ .map((text, index) => ({ text, number: index + 1 }))
5
+ }
6
+
7
+ function compareLines(current, historic) {
8
+ const left = numberedLines(current)
9
+ const right = numberedLines(historic)
10
+ const width = right.length + 1
11
+ const cells = (left.length + 1) * width
12
+ const lengths = cells <= 4_000_000 ? new Uint32Array(cells) : null
13
+ if (lengths) {
14
+ for (let i = left.length - 1; i >= 0; i--) {
15
+ for (let j = right.length - 1; j >= 0; j--) {
16
+ const k = i * width + j
17
+ lengths[k] = left[i].text === right[j].text
18
+ ? 1 + lengths[k + width + 1]
19
+ : Math.max(lengths[k + width], lengths[k + 1])
20
+ }
21
+ }
22
+ }
23
+
24
+ const rows = []
25
+ let i = 0
26
+ let j = 0
27
+ while (i < left.length || j < right.length) {
28
+ if (i < left.length && j < right.length && left[i].text === right[j].text) {
29
+ rows.push({ left: left[i++], right: right[j++], changed: false })
30
+ continue
31
+ }
32
+ const added = []
33
+ const removed = []
34
+ while (i < left.length || j < right.length) {
35
+ if (i < left.length && j < right.length && left[i].text === right[j].text) break
36
+ if (!lengths && i < left.length && j < right.length) {
37
+ added.push(left[i++])
38
+ removed.push(right[j++])
39
+ } else if (j === right.length || (i < left.length && lengths[i * width + j + width] >= lengths[i * width + j + 1])) {
40
+ added.push(left[i++])
41
+ } else {
42
+ removed.push(right[j++])
43
+ }
44
+ }
45
+ for (let k = 0; k < Math.max(added.length, removed.length); k++) {
46
+ rows.push({ left: added[k], right: removed[k], changed: true })
47
+ }
48
+ }
49
+ return rows
50
+ }
51
+
52
+ export default {
53
+ props: {
54
+ current: { type: String, required: true },
55
+ historic: { type: String, required: true },
56
+ version: { type: String, required: true },
57
+ },
58
+ computed: {
59
+ rows() {
60
+ return compareLines(this.current, this.historic)
61
+ },
62
+ },
63
+ }
64
+ </script>
65
+
66
+ <template>
67
+ <div class="diff-scroll">
68
+ <table class="script-diff">
69
+ <thead><tr><th scope="col">{{ $t('当前版本') }}</th><th scope="col">{{ version }}</th></tr></thead>
70
+ <tbody>
71
+ <tr v-for="(row, index) in rows" :key="index">
72
+ <td :class="{ added: row.changed && row.left, blank: !row.left }">
73
+ <div><span class="line-number">{{ row.left?.number }}</span><span>{{ row.changed && row.left ? '+' : '' }}</span><code>{{ row.left?.text }}</code></div>
74
+ </td>
75
+ <td :class="{ removed: row.changed && row.right, blank: !row.right }">
76
+ <div><span class="line-number">{{ row.right?.number }}</span><span>{{ row.changed && row.right ? '−' : '' }}</span><code>{{ row.right?.text }}</code></div>
77
+ </td>
78
+ </tr>
79
+ </tbody>
80
+ </table>
81
+ </div>
82
+ </template>
83
+
84
+ <style scoped>
85
+ .diff-scroll { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
86
+ .script-diff { width: 100%; min-width: 32rem; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
87
+ th { padding: 8px 12px; text-align: start; background: var(--surface-muted, #eef1f5); }
88
+ td { padding: 0; vertical-align: top; }
89
+ td + td, th + th { border-inline-start: 1px solid var(--line); }
90
+ td div { display: grid; grid-template-columns: 4ch 1ch minmax(0, 1fr); gap: 8px; padding-inline: 8px; }
91
+ .line-number { color: var(--muted); text-align: end; font-variant-numeric: tabular-nums; user-select: none; }
92
+ code { white-space: pre-wrap; overflow-wrap: anywhere; }
93
+ .added { background: #e9f7ec; }
94
+ .removed { background: #ffeded; }
95
+ .blank { background: #f6f8fa; }
96
+ </style>
@@ -0,0 +1,99 @@
1
+ <script>
2
+ import { X } from 'lucide-vue-next'
3
+ import AssetStoryEditor from './AssetStoryEditor.vue'
4
+ import JimengPromptPreview from './JimengPromptPreview.vue'
5
+ import ProjectMarkdown from './ProjectMarkdown.vue'
6
+ import { projectFileUrl } from '@/service/project-markdown.js'
7
+
8
+ export default {
9
+ components: { X, AssetStoryEditor, JimengPromptPreview, ProjectMarkdown },
10
+ data() {
11
+ return { revision: 0, doc: null, article: '', draft: null, busy: false, error: '' }
12
+ },
13
+ mounted() {
14
+ import.meta.hot?.on('workbench:storyboard:changed', this.reload)
15
+ },
16
+ beforeUnmount() {
17
+ import.meta.hot?.off('workbench:storyboard:changed', this.reload)
18
+ },
19
+ methods: {
20
+ async reload() {
21
+ if (!this.$refs.dialog.open || this.draft !== null || this.busy) return
22
+ const doc = this.doc
23
+ const revision = ++this.revision
24
+ try {
25
+ const response = await fetch(projectFileUrl(doc.file), { cache: 'no-store' })
26
+ if (!response.ok) throw new Error()
27
+ const article = await response.text()
28
+ if (this.doc === doc && this.draft === null && revision === this.revision) {
29
+ this.article = article
30
+ this.error = ''
31
+ }
32
+ } catch {
33
+ if (this.doc === doc && revision === this.revision) this.error = '读取失败'
34
+ }
35
+ },
36
+ async open(doc) {
37
+ this.doc = doc
38
+ this.article = ''
39
+ this.draft = null
40
+ this.error = ''
41
+ this.busy = true
42
+ this.$refs.dialog.showModal()
43
+ try {
44
+ const response = await fetch(projectFileUrl(doc.file))
45
+ if (!response.ok) throw new Error()
46
+ this.article = await response.text()
47
+ } catch {
48
+ this.error = '读取失败'
49
+ } finally {
50
+ this.busy = false
51
+ }
52
+ },
53
+ close() {
54
+ if (this.busy) return
55
+ if (this.draft !== null && this.draft !== this.article && !window.confirm(this.$t('放弃未保存的修改?'))) return
56
+ this.$refs.dialog.close()
57
+ },
58
+ async save() {
59
+ this.busy = true
60
+ this.error = ''
61
+ try {
62
+ const response = await fetch(projectFileUrl(this.doc.file), {
63
+ method: 'PUT', headers: { 'Content-Type': 'application/json' },
64
+ body: JSON.stringify({ original: this.article, markdown: this.draft }),
65
+ })
66
+ if (!response.ok) {
67
+ this.error = response.status === 409 ? '文件已更新,请复制草稿后重新打开' : '保存失败'
68
+ return
69
+ }
70
+ this.article = this.draft
71
+ this.draft = null
72
+ } catch {
73
+ this.error = '保存失败'
74
+ } finally {
75
+ this.busy = false
76
+ }
77
+ },
78
+ },
79
+ }
80
+ </script>
81
+ <template>
82
+ <dialog ref="dialog" class="dialog storyboard-document" aria-labelledby="storyboard-document-title" @cancel.prevent="close">
83
+ <template v-if="doc">
84
+ <header><strong id="storyboard-document-title">{{ doc.name }}</strong><button class="secondary" :disabled="busy" :aria-label="$t('关闭')" @click="close"><X :size="18" /></button></header>
85
+ <p v-if="error" role="alert">{{ $t(error) }}</p>
86
+ <AssetStoryEditor v-model:draft="draft" :label="doc.file" :busy="busy || error === '读取失败'"
87
+ @edit="draft = article" @cancel="draft = null; reload()" @save="save">
88
+ <JimengPromptPreview v-if="doc.name === '即梦.md'" :source="article" :file="doc.file" />
89
+ <ProjectMarkdown v-else :source="article" :file="doc.file" show-images />
90
+ </AssetStoryEditor>
91
+ </template>
92
+ </dialog>
93
+ </template>
94
+ <style scoped>
95
+ dialog.storyboard-document { width:min(860px,92vw); padding:20px }
96
+ header { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px }
97
+ .storyboard-document :deep(.asset-story-panel) { max-height:65dvh; overflow:auto }
98
+ .storyboard-document :deep(textarea) { min-height:45dvh }
99
+ </style>
package/src/i18n/en.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
- "Git LFS 存储目标": "Git LFS Storage Destination",
3
- "Git LFS 使用这里保存的 OSS 配置直传和下载媒体。": "Git LFS uploads and downloads media directly using the OSS settings saved here.",
2
+ "试听默认音色": "Preview default voice",
3
+ "无法播放默认音色": "Unable to play the default voice",
4
+ "{name} 预览": "{name} preview",
5
+ "复制提示词": "Copy prompt",
6
+ "已复制": "Copied",
7
+ "复制失败": "Copy failed",
8
+ "放弃未保存的修改?": "Discard unsaved changes?",
9
+ "文件已更新,请复制草稿后重新打开": "File changed. Copy your draft and reopen the document.",
10
+ "保存失败": "Save failed",
11
+ "继续制作": "Continue working",
12
+ "成片连播": "Project screening",
13
+ "无法播放此视频": "Unable to play this video",
14
+ "暂无成片": "No final videos yet",
15
+ "故事": "Story",
16
+ "分镜": "Storyboard",
17
+ "缩小": "Zoom out",
18
+ "重置视图": "Reset view",
19
+ "放大": "Zoom in",
20
+ "适应画布": "Fit to view",
21
+ "加载中": "Loading",
22
+ "暂无分镜": "No storyboard media yet",
23
+ "默认片段": "Default clip",
24
+ "首页": "Home",
25
+ "项目首页": "Project home",
26
+ "项目总览": "Project overview",
27
+ "分集": "Episodes",
28
+ "其他素材": "Other assets",
29
+ "读取失败": "Could not load",
30
+ "正在读取历史版本": "Loading version…",
31
+ "当前版本": "Current version",
32
+ "剧本": "Scripts",
33
+ "剧本目录": "Script index",
34
+ "无法读取剧本目录": "Could not load the script index",
35
+ "暂无剧本": "No scripts yet",
36
+ "片头": "Opening",
37
+ "片尾": "Ending",
38
+ "成片": "Final videos",
39
+ "返回剧本": "Back to script",
4
40
  "当前项目没有可同步的文件": "This project has no files to sync",
5
41
  "本地和云端存在冲突路径,请调整文件名后重新预览": "Local and cloud paths collide. Rename the affected files and preview again.",
6
42
  "发现 {legacy} 个旧对象,其中 {reuse} 个可尝试校验后复用。": "Found {legacy} legacy objects. {reuse} are candidates for verification and reuse.",
@@ -109,18 +145,17 @@
109
145
  "无法保存项目设置": "Unable to save project settings",
110
146
  "语言": "Language",
111
147
  "制作工作台": "Production Workbench",
112
- "制作项目": "Production Project",
148
+ "项目工作台": "Project Workbench",
113
149
  "工作台": "Workbench",
150
+ "总览": "Overview",
114
151
  "设定": "Settings",
115
152
  "资产": "Assets",
116
- "项目设定": "Project Settings",
117
- "navigation.项目设定": "Project",
118
153
  "角色": "Characters",
119
154
  "场景": "Scenes",
120
155
  "道具": "Props",
121
156
  "其他": "Other",
122
157
  "音频": "Audio",
123
- "项目设定目录": "Project Settings Index",
158
+ "设定目录": "Settings Index",
124
159
  "故事设定": "Story Settings",
125
160
  "世界观与角色": "Worldbuilding and Characters",
126
161
  "美术设定": "Art Direction",
@@ -131,7 +166,7 @@
131
166
  "3D 电影 CG 风格": "Cinematic 3D CG Style",
132
167
  "分镜与视频生成": "Storyboards and Video Generation",
133
168
  "角色原画与三视图": "Character Art and Turnarounds",
134
- "无法读取项目设定目录": "Unable to load the project settings index",
169
+ "无法读取设定目录": "Unable to load the settings index",
135
170
  "无法读取 {file}": "Unable to read {file}",
136
171
  "取消": "Cancel",
137
172
  "保存": "Save",
@@ -1,22 +1,25 @@
1
1
  <script>
2
- import { ElOption, ElSelect } from 'element-plus'
3
- import 'element-plus/es/components/select/style/css'
4
- import { AudioLines, BookOpen, Box, ChevronRight, CircleAlert, CircleCheck, Layers3, LoaderCircle, Mountain, Plug, Settings, Users, X } from 'lucide-vue-next'
2
+ import { ElMessage, ElDropdown, ElDropdownItem, ElDropdownMenu } from 'element-plus'
3
+ import 'element-plus/es/components/dropdown/style/css'
4
+ import 'element-plus/es/components/dropdown-item/style/css'
5
+ import 'element-plus/es/components/dropdown-menu/style/css'
6
+ import 'element-plus/es/components/message/style/css'
7
+ import { AudioLines, BookOpen, Box, Check, ChevronRight, CircleAlert, CircleCheck, Clapperboard, FileText, Globe, Layers3, LoaderCircle, Mountain, Plug, Settings, Users, X } from 'lucide-vue-next'
5
8
  import projectBrand from 'virtual:project-brand'
6
9
  import { language, languages } from '@/i18n/index.js'
7
10
 
8
11
  export default {
9
- components: { ElOption, ElSelect, AudioLines, BookOpen, Box, ChevronRight, CircleAlert, CircleCheck, Layers3, LoaderCircle, Mountain, Plug, Settings, Users, X },
12
+ components: { ElDropdown, ElDropdownItem, ElDropdownMenu, AudioLines, BookOpen, Box, Check, ChevronRight, CircleAlert, CircleCheck, Clapperboard, FileText, Globe, Layers3, LoaderCircle, Mountain, Plug, Settings, Users, X },
10
13
  props: { sections: { type: Array, required: true } },
11
14
  data() {
12
15
  return {
16
+ language,
13
17
  languages,
14
18
  logoFile: null,
15
19
  logoPreview: '',
16
20
  configSaving: false,
17
21
  configTab: 'basics',
18
- localeDraft: language.locale,
19
- localeError: false,
22
+ localeSaving: false,
20
23
  storageLoading: false,
21
24
  storageDraft: { endpoint: '', bucket: '', prefix: '', keyId: '', secret: '' },
22
25
  storageStatus: { hasKeyId: false, hasSecret: false },
@@ -30,16 +33,10 @@ export default {
30
33
  },
31
34
  computed: {
32
35
  projectName() {
33
- return projectBrand.name || this.$t('制作项目')
34
- },
35
- storageLfsTarget() {
36
- const { bucket, prefix } = this.storageDraft
37
- if (!bucket) return ''
38
- const directory = prefix.trim().replace(/^\/+|\/+$/g, '')
39
- return [bucket, directory, '__kacha_lfs__', 'objects'].filter(Boolean).join('/') + '/'
36
+ return projectBrand.name || 'Kacha'
40
37
  },
41
38
  projectDescription() {
42
- return projectBrand.description || this.$t('制作工作台')
39
+ return projectBrand.description || this.$t('项目工作台')
43
40
  },
44
41
  },
45
42
  methods: {
@@ -80,23 +77,21 @@ export default {
80
77
  this.storageLoading = false
81
78
  }
82
79
  },
83
- async saveProjectLocale() {
84
- if (this.configSaving) return
85
- this.configSaving = true
86
- this.localeError = false
80
+ async saveProjectLocale(locale) {
81
+ if (this.localeSaving || locale === language.locale) return
82
+ this.localeSaving = true
87
83
  try {
88
84
  const response = await fetch('/api/project-global', {
89
85
  method: 'PUT',
90
86
  headers: { 'Content-Type': 'application/json' },
91
- body: JSON.stringify({ locale: this.localeDraft }),
87
+ body: JSON.stringify({ locale }),
92
88
  })
93
89
  if (!response.ok) throw new Error()
94
- language.locale = this.localeDraft
95
- this.$refs.projectConfig.close()
90
+ language.locale = locale
96
91
  } catch {
97
- this.localeError = true
92
+ ElMessage.error(this.$t('无法保存语言设置'))
98
93
  } finally {
99
- this.configSaving = false
94
+ this.localeSaving = false
100
95
  }
101
96
  },
102
97
  async testProjectStorage() {
@@ -144,8 +139,6 @@ export default {
144
139
  },
145
140
  openProjectConfig() {
146
141
  this.configTab = 'basics'
147
- this.localeDraft = language.locale
148
- this.localeError = false
149
142
  this.configDraft = { name: projectBrand.name, description: projectBrand.description }
150
143
  this.configError = false
151
144
  this.$refs.projectConfig.showModal()
@@ -185,11 +178,11 @@ export default {
185
178
  <template>
186
179
  <div class="shell">
187
180
  <aside class="sidebar">
188
- <div class="brand"><span class="brand-icon"><img v-if="projectLogo" :src="projectLogo" alt="" @error="projectLogo = ''" /><span v-else class="brand-rabbit" aria-hidden="true"></span></span><div><strong>{{ projectName }}</strong><small>{{ projectDescription }}</small></div></div>
181
+ <RouterLink class="brand" :to="{ name: 'home' }" :aria-label="$t('项目首页')"><span class="brand-icon"><img v-if="projectLogo" :src="projectLogo" alt="" @error="projectLogo = ''" /><span v-else class="brand-rabbit" aria-hidden="true"></span></span><div><strong>{{ projectName }}</strong><small>{{ projectDescription }}</small></div></RouterLink>
189
182
  <nav :aria-label="$t('工作台')">
190
183
  <template v-for="(item, index) in sections" :key="item.name">
191
184
  <div v-if="item.group !== sections[index - 1]?.group" class="nav-title">{{ $t(item.group) }}</div>
192
- <RouterLink class="nav-link" :class="{ 'settings-nav': item.name === 'settings' }"
185
+ <RouterLink class="nav-link"
193
186
  :to="{ name: item.name }" exact-active-class="selected">
194
187
  <component :is="item.icon" :size="17" />{{ $t(item.label, {}, 'navigation') }}<ChevronRight class="nav-arrow" :size="14" />
195
188
  </RouterLink>
@@ -203,6 +196,21 @@ export default {
203
196
  <ChevronRight :size="14" aria-hidden="true" />
204
197
  <strong>{{ $t($route.meta.label) }}</strong>
205
198
  <div class="topbar-actions">
199
+ <ElDropdown trigger="click" placement="bottom-end" :disabled="localeSaving" @command="saveProjectLocale">
200
+ <button type="button" class="topbar-icon-button language-trigger" :aria-label="[$t('语言'), languages[language.locale]].join(' · ')" :title="$t('语言')" :disabled="localeSaving">
201
+ <Globe :size="17" aria-hidden="true" />
202
+ <span>{{ language.locale === 'en' ? 'EN' : '中文' }}</span>
203
+ </button>
204
+ <template #dropdown>
205
+ <ElDropdownMenu>
206
+ <ElDropdownItem v-for="(label, locale) in languages" :key="locale" :command="locale"
207
+ :aria-current="language.locale === locale ? 'true' : undefined">
208
+ <span :lang="locale">{{ label }}</span>
209
+ <Check v-if="language.locale === locale" :size="14" aria-hidden="true" />
210
+ </ElDropdownItem>
211
+ </ElDropdownMenu>
212
+ </template>
213
+ </ElDropdown>
206
214
  <button type="button" class="topbar-icon-button project-config-trigger" :aria-label="$t('全局设置')"
207
215
  :title="$t('全局设置')" aria-haspopup="dialog" @click="openProjectConfig">
208
216
  <Settings :size="17" aria-hidden="true" />
@@ -224,9 +232,6 @@ export default {
224
232
  <button id="project-storage-tab" type="button" role="tab" :class="{ current: configTab === 'storage' }"
225
233
  :aria-selected="configTab === 'storage'" aria-controls="project-storage-panel" :disabled="configSaving || storageLoading || storageTesting"
226
234
  @click="selectConfigTab('storage')">{{ $t('存储设置') }}</button>
227
- <button id="project-other-tab" type="button" role="tab" :class="{ current: configTab === 'other' }"
228
- :aria-selected="configTab === 'other'" aria-controls="project-other-panel" :disabled="configSaving || storageLoading || storageTesting"
229
- @click="selectConfigTab('other')">{{ $t('其它设置') }}</button>
230
235
  </div>
231
236
  <div v-show="configTab === 'basics'" id="project-basics-panel" class="dialog-body" role="tabpanel" aria-labelledby="project-basics-tab">
232
237
  <form id="project-config-form" class="project-config-form" @submit.prevent="saveProjectConfig">
@@ -257,11 +262,6 @@ export default {
257
262
  </div>
258
263
  <div v-if="configTab === 'storage'" id="project-storage-panel" class="dialog-body" role="tabpanel" aria-labelledby="project-storage-tab">
259
264
  <form id="project-storage-form" class="project-config-form" autocomplete="off" @submit.prevent="saveProjectStorage">
260
- <div class="storage-lfs-target">
261
- <strong>{{ $t('Git LFS 存储目标') }}</strong>
262
- <p>{{ $t('Git LFS 使用这里保存的 OSS 配置直传和下载媒体。') }}</p>
263
- <code v-if="!storageLoading && storageLfsTarget">{{ storageLfsTarget }}</code>
264
- </div>
265
265
  <label class="field">{{ $t('OSS 地址') }}
266
266
  <input v-model.trim="storageDraft.endpoint" placeholder="oss-cn-hangzhou.aliyuncs.com" required :disabled="storageLoading || configSaving" />
267
267
  </label>
@@ -299,17 +299,6 @@ export default {
299
299
  <p v-if="storageError" class="project-config-error" role="alert">{{ $t(storageError) }}</p>
300
300
  </form>
301
301
  </div>
302
- <div v-if="configTab === 'other'" id="project-other-panel" class="dialog-body" role="tabpanel" aria-labelledby="project-other-tab">
303
- <form id="project-other-form" class="project-config-form" @submit.prevent="saveProjectLocale">
304
- <div class="field">
305
- <label for="project-locale">{{ $t('语言') }}</label>
306
- <ElSelect id="project-locale" v-model="localeDraft" :teleported="false" :disabled="configSaving">
307
- <ElOption v-for="(label, locale) in languages" :key="locale" :value="locale" :label="label" :lang="locale" />
308
- </ElSelect>
309
- </div>
310
- <p v-if="localeError" class="project-config-error" role="alert">{{ $t('无法保存语言设置') }}</p>
311
- </form>
312
- </div>
313
302
  <footer class="dialog-footer">
314
303
  <button v-if="configTab === 'storage'" type="button" class="secondary storage-test-button"
315
304
  :disabled="configSaving || storageLoading || storageTesting" @click="testProjectStorage">
@@ -1,17 +1,23 @@
1
+ import ProjectStoryboard from '@/views/scripts/ProjectStoryboard.vue'
1
2
  import { createRouter, createWebHistory } from 'vue-router'
2
3
  import WorkbenchLayout from '@/layouts/WorkbenchLayout.vue'
3
4
  import CharacterAssets from '@/views/assets/CharacterAssets.vue'
4
5
  import ImageAssets from '@/views/assets/ImageAssets.vue'
5
6
  import AudioAssets from '@/views/assets/AudioAssets.vue'
6
7
  import ProjectSettings from '@/views/settings/ProjectSettings.vue'
8
+ import ProjectScripts from '@/views/scripts/ProjectScripts.vue'
9
+
10
+ import ProjectHome from '@/views/home/ProjectHome.vue'
7
11
 
8
12
  const pages = [
9
- { name: 'settings', group: '设定', label: '项目设定', icon: 'BookOpen', component: ProjectSettings },
13
+ { name: 'settings', group: '总览', label: '设定', icon: 'BookOpen', component: ProjectSettings },
10
14
  { name: 'characters', group: '资产', label: '角色', icon: 'Users', component: CharacterAssets },
11
15
  { name: 'scenes', group: '资产', label: '场景', icon: 'Mountain', component: ImageAssets, props: { kind: 'scenes' } },
12
16
  { name: 'props', group: '资产', label: '道具', icon: 'Box', component: ImageAssets, props: { kind: 'props' } },
13
17
  { name: 'other', group: '资产', label: '其他', icon: 'Layers3', component: ImageAssets, props: { kind: 'other' } },
14
18
  { name: 'audio', group: '资产', label: '音频', icon: 'AudioLines', component: AudioAssets },
19
+ { name: 'scripts', group: '故事', label: '剧本', icon: 'FileText', component: ProjectScripts },
20
+ { name: 'storyboard', group: '故事', label: '分镜', icon: 'Clapperboard', component: ProjectStoryboard },
15
21
  ]
16
22
 
17
23
  const routes = [
@@ -20,7 +26,7 @@ const routes = [
20
26
  component: WorkbenchLayout,
21
27
  props: { sections: pages.map(({ name, group, label, icon }) => ({ name, group, label, icon })) },
22
28
  children: [
23
- { path: '', redirect: { name: 'settings' } },
29
+ { path: '', name: 'home', component: ProjectHome, meta: { group: '总览', label: '首页' } },
24
30
  ...pages.map(({ name, group, label, component, props }) => ({
25
31
  path: name,
26
32
  name,
@@ -1,8 +1,18 @@
1
+ import { reactive } from 'vue'
1
2
  import { Marked, Renderer } from 'marked'
2
3
  import DOMPurify from 'dompurify'
3
4
 
4
5
  export const projectFileUrl = file => '/api/settings?file=' + encodeURIComponent(file)
5
6
 
7
+ const imageVersions = reactive(new Map())
8
+ for (const kind of ['characters', 'scenes', 'props', 'other', 'settings', 'scripts', 'storyboard']) {
9
+ import.meta.hot?.on('workbench:' + kind + ':changed', ({ files = [] }) => {
10
+ for (const file of files) {
11
+ if (/\.(png|jpe?g|webp|gif|avif)$/i.test(file)) imageVersions.set(file, Date.now())
12
+ }
13
+ })
14
+ }
15
+
6
16
  export function renderProjectMarkdown(markdown, file, sanitizeOptions) {
7
17
  const local = file ? new URL(file, 'https://project.invalid/') : null
8
18
  const parser = new Marked({
@@ -16,7 +26,9 @@ export function renderProjectMarkdown(markdown, file, sanitizeOptions) {
16
26
  if (/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(token.href)) return
17
27
  try {
18
28
  const resource = new URL(token.href, local)
19
- token.href = projectFileUrl(decodeURIComponent(resource.pathname.slice(1))) + resource.hash
29
+ const file = decodeURIComponent(resource.pathname.slice(1))
30
+ const version = token.type === 'image' && imageVersions.get(file)
31
+ token.href = projectFileUrl(file) + (version ? '&modified=' + version : '') + resource.hash
20
32
  } catch {
21
33
  token.href = '#'
22
34
  }
@@ -0,0 +1,18 @@
1
+ import brand from 'virtual:project-brand'
2
+
3
+ const key = 'kacha:last-work:' + brand.name
4
+
5
+ export function rememberWork(name, query, labels) {
6
+ try {
7
+ localStorage.setItem(key, JSON.stringify({ name, query, labels, selected: true }))
8
+ } catch { /* Storage can be disabled by the browser. */ }
9
+ }
10
+
11
+ export function recentWork() {
12
+ try {
13
+ const item = JSON.parse(localStorage.getItem(key))
14
+ if (!item?.selected && !item?.query?.group && !(item?.query?.file && item.query.file !== 'index.md')) return null
15
+ if (['scripts', 'storyboard'].includes(item?.name) && Array.isArray(item.labels)) return item
16
+ } catch { /* An unreadable entry is ignored. */ }
17
+ return null
18
+ }