feat: migrated from fresh

This commit is contained in:
Yuki.N 2025-04-07 18:51:10 +08:00
commit 6772660b69
24 changed files with 3010 additions and 0 deletions

23
.gitignore vendored Normal file
View file

@ -0,0 +1,23 @@
node_modules
# Output
.output
.vercel
.netlify
.wrangler
/.svelte-kit
/build
# OS
.DS_Store
Thumbs.db
# Env
.env
.env.*
!.env.example
!.env.test
# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

1
.npmrc Normal file
View file

@ -0,0 +1 @@
engine-strict=true

6
.prettierignore Normal file
View file

@ -0,0 +1,6 @@
# Package Managers
package-lock.json
pnpm-lock.yaml
yarn.lock
bun.lock
bun.lockb

15
.prettierrc Normal file
View file

@ -0,0 +1,15 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
]
}

38
README.md Normal file
View file

@ -0,0 +1,38 @@
# sv
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
## Creating a project
If you're seeing this, you've probably already done this step. Congrats!
```bash
# create a new project in the current directory
npx sv create
# create a new project in my-app
npx sv create my-app
```
## Developing
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
```bash
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
```
## Building
To create a production version of your app:
```bash
npm run build
```
You can preview the production build with `npm run preview`.
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.

37
eslint.config.js Normal file
View file

@ -0,0 +1,37 @@
import prettier from 'eslint-config-prettier';
import js from '@eslint/js';
import { includeIgnoreFile } from '@eslint/compat';
import svelte from 'eslint-plugin-svelte';
import globals from 'globals';
import { fileURLToPath } from 'node:url';
import ts from 'typescript-eslint';
import svelteConfig from './svelte.config.js';
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
export default ts.config(
includeIgnoreFile(gitignorePath),
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs.recommended,
prettier,
...svelte.configs.prettier,
{
languageOptions: {
globals: { ...globals.browser, ...globals.node }
},
rules: { 'no-undef': 'off' }
},
{
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
ignores: ['eslint.config.js', 'svelte.config.js'],
languageOptions: {
parserOptions: {
projectService: true,
extraFileExtensions: ['.svelte'],
parser: ts.parser,
svelteConfig
}
}
}
);

41
package.json Normal file
View file

@ -0,0 +1,41 @@
{
"name": "ygo-aux-tools",
"private": true,
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"prepare": "svelte-kit sync || echo ''",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"format": "prettier --write .",
"lint": "prettier --check . && eslint ."
},
"devDependencies": {
"@eslint/compat": "^1.2.5",
"@eslint/js": "^9.18.0",
"@fontsource/fira-mono": "^5.0.0",
"@neoconfetti/svelte": "^2.0.0",
"@sveltejs/adapter-auto": "^4.0.0",
"@sveltejs/kit": "^2.16.0",
"@sveltejs/vite-plugin-svelte": "^5.0.0",
"eslint": "^9.18.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-svelte": "^3.0.0",
"globals": "^16.0.0",
"prettier": "^3.4.2",
"prettier-plugin-svelte": "^3.3.3",
"svelte": "^5.25.0",
"svelte-check": "^4.0.0",
"typescript": "^5.0.0",
"typescript-eslint": "^8.20.0",
"vite": "^6.2.5"
},
"pnpm": {
"onlyBuiltDependencies": [
"esbuild"
]
}
}

2094
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

32
src/app.css Normal file
View file

@ -0,0 +1,32 @@
:root {
--primary-color: #0f4a84;
--primary-hover: #3c82bb;
--primary-light: #e1eef7;
--text-color: #1a365d;
--text-light: #718096;
--bg-color: #f7fafc;
--card-bg: #ffffff;
--border-color: #cbd5e0;
--switch-off: #e2e8f0;
--switch-on: var(--primary-color);
--switch-knob: #ffffff;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
line-height: 1.6;
min-height: 100vh;
padding: 1rem;
}

13
src/app.d.ts vendored Normal file
View file

@ -0,0 +1,13 @@
// See https://svelte.dev/docs/kit/types#app.d.ts
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}
export {};

12
src/app.html Normal file
View file

@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>

46
src/routes/+layout.svelte Normal file
View file

@ -0,0 +1,46 @@
<script lang="ts">
import '../app.css';
let { children } = $props();
</script>
<div class="app">
<main>
{@render children()}
</main>
<footer></footer>
</div>
<style>
.app {
display: flex;
flex-direction: column;
min-height: 100vh;
}
main {
flex: 1;
display: flex;
flex-direction: column;
padding: 1rem;
width: 100%;
max-width: 64rem;
margin: 0 auto;
box-sizing: border-box;
}
footer {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 12px;
}
@media (min-width: 480px) {
footer {
padding: 12px 0;
}
}
</style>

98
src/routes/+page.svelte Normal file
View file

@ -0,0 +1,98 @@
<script lang="ts">
</script>
<svelte:head>
<title>游戏王辅助工具</title>
<meta name="description" content="YGO Auxiliary Tools" />
</svelte:head>
<section>
<div class="index-container">
<ul class="tool-list">
<li><a href="/ritual-beast">灵兽特招记录</a></li>
<li><a href="/simultaneous-equation-cannons">连栗砲固定式计算器</a></li>
</ul>
</div>
</section>
<style>
:root {
--primary-color: #0f4a84;
--primary-hover: #3c82bb;
--primary-light: #e1eef7;
--text-color: #1a365d;
--text-light: #718096;
--bg-color: #f7fafc;
--card-bg: #ffffff;
--border-color: #cbd5e0;
--switch-off: #e2e8f0;
--switch-on: var(--primary-color);
--switch-knob: #ffffff;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
section {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex: 0.6;
}
.index-container {
background: var(--card-bg);
border-radius: 12px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
padding: 1.5rem;
width: 100%;
max-width: 360px;
margin: 0 auto;
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
}
@media (max-height: 600px) {
.index-container {
position: static;
transform: none;
margin: 2rem auto;
}
}
.tool-list {
list-style: none;
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.tool-list li a {
display: block;
padding: 0.75rem 1rem;
background-color: var(--primary-light);
color: var(--primary-color);
text-decoration: none;
border-radius: 8px;
font-weight: 500;
transition: all 0.2s ease;
border: 1px solid var(--border-color);
text-align: center;
}
.tool-list li a:hover {
background-color: var(--primary-color);
color: white;
transform: translateY(-2px);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
</style>

3
src/routes/+page.ts Normal file
View file

@ -0,0 +1,3 @@
// since there's no dynamic data here, we can prerender
// it so that it gets served as a static asset in production
export const prerender = true;

View file

@ -0,0 +1,26 @@
<svelte:head>
<title>About</title>
<meta name="description" content="About this app" />
</svelte:head>
<div class="text-column">
<h1>About this app</h1>
<p>
This is a <a href="https://svelte.dev/docs/kit">SvelteKit</a> app. You can make your own by typing
the following into your command line and following the prompts:
</p>
<pre>npx sv create</pre>
<p>
The page you're looking at is purely static HTML, with no client-side interactivity needed.
Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening
the devtools network panel and reloading.
</p>
<p>
The <a href="/sverdle">Sverdle</a> page illustrates SvelteKit's data loading and form handling. Try
using it with JavaScript disabled!
</p>
</div>

View file

@ -0,0 +1,9 @@
import { dev } from '$app/environment';
// we don't need any JS on this page, though we'll load
// it in dev so that we get hot module replacement
export const csr = dev;
// since there's no dynamic data here, we can prerender
// it so that it gets served as a static asset in production
export const prerender = true;

View file

@ -0,0 +1,215 @@
<script lang="ts">
export let data;
let rb = data.rb.map((rb: any) => ({ ...rb }));
let announcement = '';
function handleToggle(index: number, checked: boolean) {
rb[index].special_summon = checked;
announcement = `${rb[index].name} ${checked ? '已特招' : '未特招'}`;
}
function handleReset() {
rb = data.rb.map((rb) => ({ ...rb, special_summon: false }));
announcement = `已重置所有灵兽特招状态`;
}
</script>
<div class="container" role="region" aria-label="灵兽特招记录">
<h1 id="ritual-beast-title">灵兽特招记录</h1>
<div class="ritual-beast-list" role="list" aria-labelledby="ritual-beast-title">
{#each rb as _rb, index}
<div class="ritual-beast-item" role="listitem">
<span id={`rb-name-${index}`}>{_rb.name}</span>
<label class="switch">
<input
type="checkbox"
bind:checked={_rb.special_summon}
onchange={(e: Event) => handleToggle(index, (e.target as HTMLInputElement).checked)}
aria-labelledby={`rb-name-${index}`}
aria-checked={_rb.special_summon}
/>
<span class="slider round" aria-hidden="true"></span>
</label>
</div>
{/each}
</div>
<button type="reset" id="resetButton" onclick={handleReset} aria-label="重置">重置</button>
<div aria-live="polite" class="sr-only">
{announcement}
</div>
</div>
<style>
:root {
--primary-color: #0f4a84;
--primary-hover: #3c82bb;
--primary-light: #e1eef7;
--text-color: #1a365d;
--text-light: #718096;
--bg-color: #f7fafc;
--card-bg: #ffffff;
--border-color: #cbd5e0;
--switch-off: #e2e8f0;
--switch-on: var(--primary-color);
--switch-knob: #ffffff;
}
.container {
background: var(--card-bg);
border-radius: 12px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
padding: 1.5rem;
width: 100%;
max-width: 360px;
margin: 2rem auto;
}
h1 {
font-size: 1.5rem;
margin-bottom: 1.5rem;
color: var(--text-color);
text-align: center;
font-weight: 600;
}
.ritual-beast-list {
display: grid;
gap: 0.75rem;
margin-bottom: 1.5rem;
}
.ritual-beast-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75rem 1rem;
background: rgba(255, 255, 255, 0.9);
border-radius: 8px;
border: 1px solid var(--border-color);
transition:
transform 0.2s,
box-shadow 0.2s;
}
.ritual-beast-item span {
font-size: 1rem;
font-weight: 500;
}
.switch {
position: relative;
display: inline-block;
width: 44px;
height: 24px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
position: absolute;
}
.switch input:focus-visible + .slider {
outline: 2px solid var(--primary-color);
outline-offset: 2px;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: var(--switch-off);
transition: all 0.3s ease;
border-radius: 34px;
}
.slider:before {
position: absolute;
content: '';
height: 20px;
width: 20px;
left: 2px;
bottom: 2px;
background-color: var(--switch-knob);
transition: all 0.3s ease;
border-radius: 50%;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
input:checked + .slider {
background-color: var(--switch-on);
}
input:checked + .slider:before {
transform: translateX(20px);
}
/* Reset Button */
button#resetButton {
display: block;
width: 100%;
padding: 0.75rem;
background-color: var(--primary-color);
color: white;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
margin-top: 1rem;
}
button#resetButton:hover {
background-color: var(--primary-hover);
}
button#resetButton:active {
transform: translateY(0);
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
/* Responsive Grid for Landscape Mode */
@media (min-width: 640px) and (orientation: landscape),
(max-width: 640px) and (orientation: landscape) {
.container {
max-width: 600px;
}
.ritual-beast-list {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 0.75rem;
}
}
/* Portrait mode fallback to one column */
@media (orientation: portrait) {
.ritual-beast-list {
display: block;
}
}
@media (min-width: 1024px) {
.container {
max-width: 800px;
}
}
</style>

View file

@ -0,0 +1,25 @@
import type { PageLoad } from './$types';
interface RitualBeastType {
id: number;
name: string;
special_summon: boolean;
}
export const load: PageLoad = () => {
const data: RitualBeastType[] = new Array(
{ id: 1, name: '企鹅(兽)', special_summon: false },
{ id: 2, name: '川豚(兽)', special_summon: false },
{ id: 3, name: '新蕾拉(人兽)', special_summon: false },
{ id: 4, name: '星龙', special_summon: false },
{ id: 5, name: '火狮(兽)', special_summon: false },
{ id: 6, name: '老蕾拉(人)', special_summon: false },
{ id: 7, name: '薇茵达(人兽)', special_summon: false },
{ id: 8, name: '长老(人)', special_summon: false },
{ id: 9, name: '雯(人)', special_summon: false },
{ id: 10, name: '雷鹰(兽)', special_summon: false }
);
return {
rb: data as RitualBeastType[]
};
};

View file

@ -0,0 +1,192 @@
<script lang="ts">
export let data;
let totalCards: number | null = null;
let xyzRank: number | null = null;
let fusionRank: number | null = null;
let targetRank: number | null = null;
$: isValidCombo =
xyzRank !== null && fusionRank !== null ? 2 * xyzRank + fusionRank === totalCards : false;
$: canActivateEffect =
xyzRank !== null && fusionRank !== null && targetRank !== null
? xyzRank + fusionRank === targetRank
: false;
</script>
<div class="equation-calculator" role="region" aria-label={data.SEC.title}>
<h1 id="main-title">{data.SEC.title}</h1>
<!-- Phase 1 -->
<div class="calc-phase">
<h2>{data.SEC.phase1}</h2>
<div class="calc-input">
<label>
{data.SEC.totalCards}
<input type="number" bind:value={totalCards} />
</label>
</div>
<div class="calc-input">
<label>
{data.SEC.xyzRank}
<input type="number" bind:value={xyzRank} />
</label>
</div>
<div class="calc-input">
<label>
{data.SEC.fusionRank}
<input type="number" bind:value={fusionRank} />
</label>
</div>
{#if totalCards !== 0}
<div class={`result-feedback ${isValidCombo ? 'result-valid' : 'result-invalid'}`}>
{isValidCombo ? data.SEC.validCombo : data.SEC.invalidCombo}
</div>
{/if}
</div>
<!-- Phase 2 -->
<div class="calc-phase">
<h2>{data.SEC.phase2}</h2>
<div class="calc-input">
<label>
{data.SEC.targetRank}
<input type="number" bind:value={targetRank} />
</label>
</div>
{#if targetRank !== 0}
<div class={`result-feedback ${canActivateEffect ? 'result-valid' : 'result-invalid'}`}>
{canActivateEffect ? data.SEC.validEffect : data.SEC.invalidEffect}
</div>
{/if}
</div>
<!-- Effect Description -->
<div class="effect-description">
<p>{data.SEC.effectText}</p>
</div>
</div>
<style>
:root {
--primary-color: #0f4a84;
--primary-hover: #3c82bb;
--primary-light: #e1eef7;
--text-color: #1a365d;
--text-light: #718096;
--bg-color: #f7fafc;
--card-bg: #ffffff;
--border-color: #cbd5e0;
}
.equation-calculator {
background: var(--card-bg);
border-radius: 12px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
padding: 1.5rem;
width: 100%;
max-width: 480px;
margin: 2rem auto;
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
color: var(--text-color);
line-height: 1.6;
}
.equation-calculator h1 {
color: var(--primary-color);
text-align: center;
margin-bottom: 1.5rem;
font-size: 1.5rem;
font-weight: 600;
}
.calc-phase {
background-color: var(--primary-light);
border-radius: 8px;
padding: 1.25rem;
margin-bottom: 1.5rem;
border: 1px solid var(--border-color);
}
.calc-phase h2 {
color: var(--primary-color);
font-size: 1.25rem;
margin-bottom: 1rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--border-color);
}
.calc-input {
margin-bottom: 1rem;
}
.calc-input label {
display: block;
margin-bottom: 0.5rem;
color: var(--text-color);
font-weight: 500;
}
.calc-input input[type='number'] {
width: 100%;
padding: 0.75rem;
border: 1px solid var(--border-color);
border-radius: 6px;
background-color: var(--card-bg);
color: var(--text-color);
font-size: 1rem;
transition: all 0.2s ease;
}
.calc-input input[type='number']:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 2px var(--primary-light);
}
.result-feedback {
padding: 0.75rem;
border-radius: 6px;
margin-top: 1rem;
font-weight: 500;
text-align: center;
}
.result-valid {
background-color: rgba(16, 185, 129, 0.1);
color: #065f46;
}
.result-invalid {
background-color: rgba(239, 68, 68, 0.1);
color: #991b1b;
}
.effect-description {
font-size: 0.875rem;
color: var(--text-color);
line-height: 1.5;
padding: 0.75rem;
background-color: var(--primary-light);
border-radius: 6px;
margin-top: 1.5rem;
}
@media (min-width: 640px) {
.equation-calculator {
padding: 2rem;
}
.calc-phase {
padding: 1.5rem;
}
}
</style>

View file

@ -0,0 +1,38 @@
import type { PageLoad } from '../$types';
interface SimultaneousEquationCannonsType {
title: string;
phase1: string;
phase2: string;
totalCards: string;
xyzRank: string;
fusionRank: string;
targetRank: string;
validCombo: string;
invalidCombo: string;
validEffect: string;
invalidEffect: string;
effectText: string;
}
export const load: PageLoad = () => {
const data: SimultaneousEquationCannonsType = {
title: '连栗炮固定式计算器',
phase1: '第一阶段:除外条件',
phase2: '第二阶段:效果结算',
totalCards: '双方手牌+场上卡总数',
xyzRank: '超量怪兽阶级2只相同',
fusionRank: '融合怪兽阶级',
targetRank: '目标怪兽等级/阶级',
validCombo: '✔️ 条件满足2×超量阶级 + 融合阶级 = 总卡数',
invalidCombo: '❌ 不满足条件2×超量阶级 + 融合阶级 ≠ 总卡数',
validEffect: '✔️ 效果可发动:超量 + 融合阶级 = 目标阶级',
invalidEffect: '❌ 无法发动:阶级总和与目标不匹配',
effectText:
'从额外牌组将等级·阶级合计等于双方手牌·场上卡数量的2只同阶级超量怪兽和1只融合怪兽除外' +
'然后选择对手1只表侧怪兽将阶级合计等于该怪兽等级的1超量+1融合返回额外牌组之后对手场上卡全部除外。'
};
return {
SEC: data as SimultaneousEquationCannonsType
};
};

3
static/robots.txt Normal file
View file

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

18
svelte.config.js Normal file
View file

@ -0,0 +1,18 @@
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://svelte.dev/docs/kit/integrations
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: {
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
adapter: adapter()
}
};
export default config;

19
tsconfig.json Normal file
View file

@ -0,0 +1,19 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}

6
vite.config.ts Normal file
View file

@ -0,0 +1,6 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit()]
});