feat: migrate utils
This commit is contained in:
22
frontend/src/utils/utils.ts
Normal file
22
frontend/src/utils/utils.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
export const DEFAULT_COLOR: string = '#536dfe';
|
||||||
|
|
||||||
|
export function gcd(a: number, b: number): number {
|
||||||
|
if (b == 0) return a;
|
||||||
|
return gcd(b, a % b);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function lcm(a: number, b: number): number {
|
||||||
|
return a / gcd(a, b) * b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Monday-first the day of week from given date instead of Sunday-first.
|
||||||
|
* @param date The date for getting weekday.
|
||||||
|
* @returns The zero-based weekday. 0 stands for Monday.
|
||||||
|
*/
|
||||||
|
export function getWeekday(date: Date): number {
|
||||||
|
let day = date.getDay();
|
||||||
|
if (day == 0) return 6;
|
||||||
|
else return day - 1;
|
||||||
|
}
|
||||||
@@ -7,11 +7,11 @@ import {
|
|||||||
getFullOwn as apiCollectionGetFullOwn,
|
getFullOwn as apiCollectionGetFullOwn,
|
||||||
getSharing as apiCollectionGetSharing,
|
getSharing as apiCollectionGetSharing,
|
||||||
getDetailOwn as apiCollectionGetDetailOwn,
|
getDetailOwn as apiCollectionGetDetailOwn,
|
||||||
type CollectionRow,
|
|
||||||
deleteOwn as apiCollectionDeleteOwn,
|
deleteOwn as apiCollectionDeleteOwn,
|
||||||
updateOwn as apiCollectionUpdateOwn,
|
updateOwn as apiCollectionUpdateOwn,
|
||||||
addSharing as apiCollectionAddSharing,
|
addSharing as apiCollectionAddSharing,
|
||||||
deleteSharing as apiCollectionDeleteSharing
|
deleteSharing as apiCollectionDeleteSharing,
|
||||||
|
type CollectionRow,
|
||||||
} from '@/api/collection';
|
} from '@/api/collection';
|
||||||
import OwnedItem from '@/components/collection/OwnedItem.vue';
|
import OwnedItem from '@/components/collection/OwnedItem.vue';
|
||||||
import SharingItem from '@/components/collection/SharingItem.vue';
|
import SharingItem from '@/components/collection/SharingItem.vue';
|
||||||
@@ -251,4 +251,16 @@ const deleteSharingItem = async (username: string) => {
|
|||||||
<MessageBox ref="messagebox" />
|
<MessageBox ref="messagebox" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped>
|
||||||
|
div.control-list {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.control-list > * {
|
||||||
|
margin-right: 0.75rem;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
margin-left: 0 !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user