-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Barba828/feat/auto-b
Feat/auto b
- Loading branch information
Showing
50 changed files
with
1,527 additions
and
1,002 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
"singleQuote": true, | ||
"semi": false, | ||
"trailingComma": "es5", | ||
"printWidth": 100 | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 13 additions & 23 deletions
36
packages/buitar/src/components/guitar-board/board-controller/chord-card/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,30 @@ | ||
import { BoardChord } from "@buitar/to-guitar" | ||
import { GuitarBoardSetting } from '@/pages/settings/config/controller.type' | ||
import { getBoardOptionsNote } from '@/components/guitar-board/utils' | ||
|
||
import { BoardChord } from '@buitar/to-guitar' | ||
import { BoardOption } from '@buitar/to-guitar' | ||
|
||
/** | ||
* 根据 chordType 获取和弦名称 | ||
* @param chordType | ||
* @param boardSettings | ||
* @returns | ||
*/ | ||
export const getBoardChordName = ( | ||
chordType?: BoardChord['chordType'], | ||
boardSettings?: Pick<GuitarBoardSetting, 'isSharpSemitone'> | ||
) => { | ||
export const getBoardChordName = (chordType?: BoardChord['chordType'], guitarBoardOption?: Partial<BoardOption>) => { | ||
if (!chordType) { | ||
return '' | ||
return ' ' | ||
} | ||
// 自定义名称直接返回 | ||
if (chordType.tag === '*') { | ||
return chordType.name | ||
} | ||
|
||
// 根据 tone 获取和弦名称 | ||
if (!chordType.tone) return ' ' | ||
const tone = boardSettings | ||
? getBoardOptionsNote(chordType.tone, boardSettings) | ||
: chordType.tone.note | ||
const over = chordType.over | ||
? boardSettings | ||
? getBoardOptionsNote(chordType.over, boardSettings) | ||
: chordType.over.note | ||
: '' | ||
if (chordType?.tone === undefined || !guitarBoardOption?.notesOnC) { | ||
return ' ' | ||
} | ||
const note = guitarBoardOption?.notesOnC[chordType.tone % 12] | ||
const over = chordType.over ? guitarBoardOption?.notesOnC[chordType.over % 12] : '' | ||
const tag = chordType.tag | ||
if (over === tone) { | ||
return `${tone}${tag}` | ||
if (!over || over === note) { | ||
return `${note}${tag}` | ||
} else { | ||
return `${over}${tag}/${tone}` | ||
return `${over}${tag}/${note}` | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.