-
Notifications
You must be signed in to change notification settings - Fork 15
feat: 支持前端显示和编辑sortName #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,8 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { computed, defineComponent, onMounted, PropType, ref, watch } from "vue"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Chart, GenreXml, MusicXmlWithABJacket } from "@/client/apiGen"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Chart, GenreXml, MusicXmlWithABJacket, ShiftMethod } from "@/client/apiGen"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { addVersionList, genreList, globalCapture, selectedADir, selectedMusic as info, selectMusicId, updateAddVersionList, updateGenreList, updateMusicList, selectedLevel } from "@/store/refs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import api from "@/client/api"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { NButton, NFlex, NForm, NFormItem, NInput, NInputNumber, NSelect, NSwitch, NTabPane, NTabs, SelectOption, useDialog, useMessage } from "naive-ui"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { NButton, NFlex, NForm, NFormItem, NInput, NInputNumber, NPopover, NRadio, NSelect, NSwitch, NTabPane, NTabs, SelectOption, useDialog, useMessage } from "naive-ui"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import JacketBox from "../JacketBox"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import dxIcon from "@/assets/dxIcon.png"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import stdIcon from "@/assets/stdIcon.png"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -29,7 +29,12 @@ const Component = defineComponent({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| const sync = (key: keyof MusicXmlWithABJacket, method: Function) => async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!info.value) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| info.value!.modified = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await method(info.value.id!, info.value.assetDir, (info.value as any)[key]!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const value = (info.value as any)[key]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const result = (await method(info.value.id!, info.value.assetDir, value)).data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (key === "sortName" && typeof result === "string" && result !== value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 如果调用的是sortName接口,且返回的字符串(经过格式化后的实际内容)和传过去的值不同的话,则覆盖之 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| info.value!.sortName = result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
29
to
38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 是不是其实也没啥,在浏览器里unhandled promise rejection本质上和把错误console.error到控制台是一样的,(又不是node, unhandled promise rejection会崩)我是懒得改了 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| watch(() => info.value?.name, sync('name', api.EditMusicName)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -41,6 +46,7 @@ const Component = defineComponent({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| watch(() => info.value?.utageKanji, sync('utageKanji', api.EditMusicUtageKanji)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| watch(() => info.value?.comment, sync('comment', api.EditMusicComment)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| watch(() => info.value?.longMusic, sync('longMusic', api.EditMusicLong)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| watch(() => info.value?.sortName, sync('sortName', api.EditMusicSortName)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onMounted(()=>{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ('mediaSession' in navigator) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -103,6 +109,14 @@ const Component = defineComponent({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| <NInput v-model:value={info.value.comment}/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </NFormItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </>} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <NFormItem label={t('music.edit.sortName')}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <NPopover trigger="hover"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trigger: () => <NInput v-model:value={info.value!.sortName} class="w-0 grow"/>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: () => <div>{t('music.edit.sortNameTips')}</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </NPopover> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </NFormItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <AcbAwb song={info.value}/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <NTabs type="line" animated barWidth={0} v-model:value={selectedLevel.value} class="levelTabs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style={{'--n-tab-padding': 0, '--n-pane-padding-top': 0, '--n-tab-text-color-hover': ''}}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
assetDirparameter is directly obtained from the route and used to retrieve music data. This is highly susceptible to a Path Traversal vulnerability, as an attacker could use..sequences to access or manipulate files outside the intended directory. Additionally, when a music track is not found, the API currently returns an empty string"". This can lead to unexpected frontend behavior, potentially clearing thesortNamefield. It's more RESTful and robust to returnNotFound()(HTTP 404) to clearly indicate that the resource was not found. This change will also require adding atry-catchblock in the frontend'ssyncfunction to handle API errors.