init: frontend

This commit is contained in:
snusxd
2026-04-10 00:41:21 +03:00
commit d2b5489001
26 changed files with 4022 additions and 0 deletions

8
.editorconfig Normal file
View File

@@ -0,0 +1,8 @@
[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue,css,scss,sass,less,styl}]
charset = utf-8
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
max_line_length = 100

2
.env Normal file
View File

@@ -0,0 +1,2 @@
VITE_LASTFM_API=577403120879aadec2e6fd0d6160cca4
LASTFM_SECRET=08baaf3b3050854d019ce5884e0d6d27

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
* text=auto eol=lf

39
.gitignore vendored Normal file
View File

@@ -0,0 +1,39 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.tsbuildinfo
.eslintcache
# Cypress
/cypress/videos/
/cypress/screenshots/
# Vitest
__screenshots__/
# Vite
*.timestamp-*-*.mjs

10
.oxlintrc.json Normal file
View File

@@ -0,0 +1,10 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["eslint", "typescript", "unicorn", "oxc", "vue"],
"env": {
"browser": true
},
"categories": {
"correctness": "error"
}
}

6
.prettierrc.json Normal file
View File

@@ -0,0 +1,6 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"singleQuote": true,
"printWidth": 100
}

48
README.md Normal file
View File

@@ -0,0 +1,48 @@
# land-vue
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VS Code](https://code.visualstudio.com/) + [Vue (Official)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
## Recommended Browser Setup
- Chromium-based browsers (Chrome, Edge, Brave, etc.):
- [Vue.js devtools](https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd)
- [Turn on Custom Object Formatter in Chrome DevTools](http://bit.ly/object-formatters)
- Firefox:
- [Vue.js devtools](https://addons.mozilla.org/en-US/firefox/addon/vue-js-devtools/)
- [Turn on Custom Object Formatter in Firefox DevTools](https://fxdx.dev/firefox-devtools-custom-object-formatters/)
## Type Support for `.vue` Imports in TS
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
## Customize configuration
See [Vite Configuration Reference](https://vite.dev/config/).
## Project Setup
```sh
pnpm install
```
### Compile and Hot-Reload for Development
```sh
pnpm dev
```
### Type-Check, Compile and Minify for Production
```sh
pnpm build
```
### Lint with [ESLint](https://eslint.org/)
```sh
pnpm lint
```

19
components.d.ts vendored Normal file
View File

@@ -0,0 +1,19 @@
/* eslint-disable */
// @ts-nocheck
// biome-ignore lint: disable
// oxlint-disable
// ------
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}
/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
GeneralXd: typeof import('./src/components/general-xd.vue')['default']
NowPlaying: typeof import('./src/components/now-playing.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}
}

1
env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />

26
eslint.config.ts Normal file
View File

@@ -0,0 +1,26 @@
import { globalIgnores } from 'eslint/config'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import pluginVue from 'eslint-plugin-vue'
import pluginOxlint from 'eslint-plugin-oxlint'
import skipFormatting from 'eslint-config-prettier/flat'
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
export default defineConfigWithVueTs(
{
name: 'app/files-to-lint',
files: ['**/*.{vue,ts,mts,tsx}'],
},
globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
...pluginVue.configs['flat/essential'],
vueTsConfigs.recommended,
...pluginOxlint.buildFromOxlintConfigFile('.oxlintrc.json'),
skipFormatting,
)

13
index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

46
package.json Normal file
View File

@@ -0,0 +1,46 @@
{
"name": "land-vue",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --build",
"lint": "run-s lint:*",
"lint:oxlint": "oxlint . --fix",
"lint:eslint": "eslint . --fix --cache",
"format": "prettier --write --experimental-cli src/"
},
"dependencies": {
"axios": "^1.15.0",
"dotenv": "^17.4.1",
"unplugin-vue-components": "^32.0.0",
"vue": "^3.5.29",
"vue-router": "^5.0.4"
},
"devDependencies": {
"@tsconfig/node24": "^24.0.4",
"@types/node": "^24.11.0",
"@vitejs/plugin-vue": "^6.0.4",
"@vue/eslint-config-typescript": "^14.7.0",
"@vue/tsconfig": "^0.8.1",
"eslint": "^10.0.2",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-oxlint": "~1.50.0",
"eslint-plugin-vue": "~10.8.0",
"jiti": "^2.6.1",
"npm-run-all2": "^8.0.4",
"oxlint": "~1.50.0",
"prettier": "3.8.1",
"typescript": "~5.9.3",
"vite": "^7.3.1",
"vite-plugin-vue-devtools": "^8.0.6",
"vue-tsc": "^3.2.5"
},
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
}

3444
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

BIN
public/default-cover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

11
src/App.vue Normal file
View File

@@ -0,0 +1,11 @@
<script setup lang="ts"></script>
<style scoped>
.wrapped {
display: flex;
}
</style>
<template>
<router-view></router-view>
</template>

View File

@@ -0,0 +1,51 @@
<script setup lang="ts">
import { ref } from 'vue'
const header = 'bio'
const border_color = ref('#656565')
const background_color = ref('#353535')
const primary_color = ref('#FFFFFF')
</script>
<style scoped>
.wrapper {
width: 300px;
height: 75px;
border: 3px solid v-bind(border_color);
padding: 10px;
margin: 10px;
}
.content {
display: flex;
flex-direction: column;
justify-content: center;
gap: 10px;
}
h1 {
color: v-bind(border_color);
margin-top: -22px;
margin-left: -5px;
background-color: v-bind(background_color);
width: fit-content;
padding: 0 5px;
font-size: medium;
min-height: 1.4em;
}
p {
color: v-bind(primary_color);
margin: 0;
margin-top: -10px;
}
</style>
<template>
<div class="wrapper">
<h1>{{ header }}</h1>
<div class="content">
<p>snusxd</p>
<p>:steamhappy:</p>
</div>
</div>
</template>

View File

@@ -0,0 +1,156 @@
<script setup lang="ts">
import axios from 'axios'
import { onMounted, onUnmounted, ref } from 'vue'
import { ChangeTitle } from '@/utils/change-title'
// api
const lastfmapi = import.meta.env.VITE_LASTFM_API
const lastfmusername = 'snsxd'
const header = ref('silence...')
const artist = ref('artist')
const track = ref('track')
const labelurl = ref('public/default-cover.png')
// colors
const border_color = ref('#656565')
const background_color = ref('#353535')
const primary_color = ref('#656565') // #FFFFFF
async function checkNowPlaying(api: string, username: string) {
try {
const response = await axios.get(
`https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=${username}&api_key=${api}&format=json&limit=1`,
)
return response.data.recenttracks.track
} catch (error) {
console.error('Error fetching data:', error)
}
}
let timerId: ReturnType<typeof setTimeout>
onMounted(() => {
const updateSong = async () => {
const trackData = await checkNowPlaying(lastfmapi, lastfmusername)
console.log(trackData)
if (trackData) {
if (trackData.length > 1) {
if (header.value !== 'now playing') {
await ChangeTitle(header, header.value, 'now playing')
primary_color.value = '#FFFFFF'
}
if (artist.value != trackData[0].artist['#text'])
ChangeTitle(artist, artist.value, trackData[0].artist['#text'])
if (track.value != trackData[0].name) {
labelurl.value = `http://localhost:3000/cover/${trackData[0].artist['#text'].replace('/', '')}/${trackData[0].album['#text']}/${trackData[0].album.mbid ? trackData[0].album.mbid : '0'}`
console.log(labelurl.value)
ChangeTitle(track, track.value, trackData[0].name)
}
} else {
if (header.value !== 'silence...') ChangeTitle(header, header.value, 'silence...')
primary_color.value = '#656565'
labelurl.value = `http://localhost:3000/cover/0/0/0`
if (artist.value != trackData[0].artist['#text'])
ChangeTitle(artist, artist.value, trackData[0].artist['#text'])
if (track.value != trackData[0].name) ChangeTitle(track, track.value, trackData[0].name)
}
}
timerId = setTimeout(updateSong, 10000)
}
updateSong()
})
onUnmounted(() => {
if (timerId) clearTimeout(timerId)
})
</script>
<style scoped>
.wrapper {
background-color: v-bind(background_color);
box-shadow: 0 0 0 10px v-bind(background_color);
width: 350px;
height: 75px;
border: 3px solid v-bind(border_color);
padding: 10px;
margin: 10px;
}
.cover_name {
display: flex;
align-items: center;
gap: 15px;
margin-top: -10px;
}
.name {
display: flex;
flex-direction: column;
justify-content: center;
gap: 10px;
}
h1 {
color: v-bind(border_color);
margin-top: -22px;
margin-left: -5px;
background-color: v-bind(background_color);
width: fit-content;
padding: 0 5px;
font-size: medium;
min-height: 1.4em;
}
p {
color: v-bind(primary_color);
margin: 0;
}
.track {
font-weight: bolder;
}
img {
width: 75px;
height: auto;
}
.wave-text {
background: linear-gradient(
90deg,
v-bind(border_color),
v-bind(primary_color),
v-bind(border_color)
);
background-size: 200% auto;
-webkit-background-clip: text;
background-clip: text;
color: transparent;
animation: wave-animation 2s linear infinite;
}
@keyframes wave-animation {
0% {
background-position: 0% center;
}
100% {
background-position: -200% center;
}
}
</style>
<template>
<div class="wrapper">
<h1>
<span :class="{ 'wave-text': header === 'now playing' }">{{ header }}</span>
</h1>
<div class="cover_name">
<img :src="labelurl" />
<div class="name">
<p class="track">{{ track }}</p>
<p>{{ artist }}</p>
</div>
</div>
</div>
</template>

11
src/global.css Normal file
View File

@@ -0,0 +1,11 @@
body {
background-color: #353535;
font-family: 'Iosevka', sans-serif;
}
@font-face {
font-family: 'Iosevka';
src: url('public/fonts/sgr_iosevka_regular.woff2') format('woff2');
font-weight: normal;
font-style: normal;
}

28
src/main.ts Normal file
View File

@@ -0,0 +1,28 @@
import { createApp, h } from 'vue'
import { createWebHistory, createRouter } from 'vue-router'
import App from './App.vue'
import NowPlaying from './components/now-playing.vue'
import GeneralXd from './components/general-xd.vue'
import './global.css'
const Home = {
render() {
return h('div', { class: 'wrapped', style: 'display: flex;' }, [h(GeneralXd), h(NowPlaying)])
},
}
const routes = [
{ path: '/', component: Home },
{ path: '/nowplay', component: NowPlaying },
]
export const router = createRouter({
history: createWebHistory(),
routes,
})
const app = createApp(App)
app.use(router)
app.mount('#app')

19
src/utils/change-title.ts Normal file
View File

@@ -0,0 +1,19 @@
import type { Ref } from 'vue'
const sleep = (ms: number) => new Promise((res) => setTimeout(res, ms))
export async function ChangeTitle(refvar: Ref, old_string: string, new_string: string) {
const old_array = old_string.split(' ')
const new_array = new_string.split(' ')
for (let i = old_array.length; i >= 0; i -= 1) {
refvar.value = old_array.slice(0, i).join(' ')
await sleep(100)
}
for (let i = 0; i < new_array.length; i++) {
refvar.value = new_array.slice(0, i + 1).join(' ')
await sleep(100)
}
// refvar.value = new_string
}

18
tsconfig.app.json Normal file
View File

@@ -0,0 +1,18 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
// Extra safety for array and object lookups, but may have false positives.
"noUncheckedIndexedAccess": true,
// Path mapping for cleaner imports.
"paths": {
"@/*": ["./src/*"]
},
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
// Specified here to keep it out of the root directory.
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo"
}
}

11
tsconfig.json Normal file
View File

@@ -0,0 +1,11 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
}
]
}

28
tsconfig.node.json Normal file
View File

@@ -0,0 +1,28 @@
// TSConfig for modules that run in Node.js environment via either transpilation or type-stripping.
{
"extends": "@tsconfig/node24/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*",
"eslint.config.*"
],
"compilerOptions": {
// Most tools use transpilation instead of Node.js's native type-stripping.
// Bundler mode provides a smoother developer experience.
"module": "preserve",
"moduleResolution": "bundler",
// Include Node.js types and avoid accidentally including other `@types/*` packages.
"types": ["node"],
// Disable emitting output during `vue-tsc --build`, which is used for type-checking only.
"noEmit": true,
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
// Specified here to keep it out of the root directory.
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo"
}
}

26
vite.config.ts Normal file
View File

@@ -0,0 +1,26 @@
import { fileURLToPath, URL } from 'node:url'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
// https://vite.dev/config/
export default defineConfig({
plugins: [vue(), vueDevTools(), Components()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
proxy: {
'/caa-api': {
target: 'http://coverartarchive.org',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/caa-api/, ''),
followRedirects: true,
},
},
},
})