Initialize Compose Launcher source and deployment

This commit is contained in:
tongtong committed 2026-11-26 02:34:19 +08:00
commit 12a8c24441
77 files changed
+9594

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
/node_modules/
/dist/
+1417
View File
File diff suppressed because it is too large. Load diff
+12
View File
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Vibe Launcher · 桌面布局</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="./src/main.ts"></script>
</body>
</html>
+28
View File
@@ -0,0 +1,28 @@
{
"name": "vibe-launcher-frontend",
"private": true,
"version": "1.1.0",
"type": "module",
"packageManager": "pnpm@10.34.5",
"engines": {
"node": "^24.0.0",
"pnpm": "10.34.5"
},
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"type-check": "vue-tsc --noEmit"
},
"dependencies": {
"element-plus": "2.14.7",
"vue": "3.5.44"
},
"devDependencies": {
"@types/node": "24.19.2",
"@vitejs/plugin-vue": "6.0.10",
"typescript": "6.0.3",
"vite": "8.2.4",
"vue-tsc": "3.3.11"
}
}
+886
View File
@@ -0,0 +1,886 @@
lockfileVersion: "9.0"
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
dependencies:
element-plus:
specifier: 2.14.7
version: 2.14.7(vue@3.5.44(typescript@6.0.3))
vue:
specifier: 3.5.44
version: 3.5.44(typescript@6.0.3)
devDependencies:
"@types/node":
specifier: 24.19.2
version: 24.19.2
"@vitejs/plugin-vue":
specifier: 6.0.10
version: 6.0.10(vite@8.2.4(@types/node@24.19.2))(vue@3.5.44(typescript@6.0.3))
typescript:
specifier: 6.0.3
version: 6.0.3
vite:
specifier: 8.2.4
version: 8.2.4(@types/node@24.19.2)
vue-tsc:
specifier: 3.3.11
version: 3.3.11(typescript@6.0.3)
packages:
"@babel/helper-string-parser@7.29.11":
resolution:
integrity: sha512-snZbO7MEDOof+hvNa97EjEY7qD7h2kwvQr5AJC3ZhQudKW5dnej6k3kP9NQV88hJwaS8vDqRLFo9rivLEhle2g==
engines:
node: ">=6.9.0"
"@babel/helper-validator-identifier@7.29.7":
resolution:
integrity: sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==
engines:
node: ">=6.9.0"
"@babel/parser@7.29.12":
resolution:
integrity: sha512-WJ7JBp/Q4+z/ImydtI7jS6NVco5++632ExBemSX+Ysb+G1lCwQ5BVo3SY+jGGOcZXI4ZccbZSUSJLNBW6eEpJg==
engines:
node: ">=6.0.0"
hasBin: true
"@babel/types@7.29.11":
resolution:
integrity: sha512-WCsemW40Cpc6gouC1SrY6PBaZ+oLRlEVY9XBvZBI7il/HyUrb2nJ505wE1MHEFyDZNnrWDEuy4jL50WVHfTTSQ==
engines:
node: ">=6.9.0"
"@ctrl/tinycolor@4.2.2":
resolution:
integrity: sha512-9rQHijqB2Rq6qOEC/xHaA6aPlsKGi5kmCQW50O1asn9g63XFeD5NmBwysriistW5Xx0JPafyD/TA7yk2S3pXGQ==
engines:
node: ">=14"
"@element-plus/icons-vue@2.3.2":
resolution:
integrity: sha512-OzIuTaIfC8QXEPmJvB4Y4kw34rSXdCJzxcD1kFStBvr8bK6X1zQAYDo0CNMjojnfTqRQCJ0I7prlErcoRiET2A==
peerDependencies:
vue: ^3.2.0
"@floating-ui/core@1.8.0":
resolution:
integrity: sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ==
"@floating-ui/dom@1.8.0":
resolution:
integrity: sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg==
"@floating-ui/utils@0.2.12":
resolution:
integrity: sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==
"@jridgewell/sourcemap-codec@1.6.0":
resolution:
integrity: sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==
"@oxc-project/types@0.156.0":
resolution:
integrity: sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==
"@rolldown/binding-android-arm-eabi@1.2.16":
resolution:
integrity: sha512-ia3DwAs0OsMGS7+IConptSiyk9pEXkOx/AbJ2n/lAGxH3QkWQus1t8d7gnAT38FCU2sQu8lUbeR6AiZFv4JxaA==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- arm
os:
- android
"@rolldown/binding-android-arm64@1.2.16":
resolution:
integrity: sha512-kx5wBiMB6E7TEvpl2B9gjLU004BkvEm2Dr941BFjx/SontPwSzNuQUIoVKxHHoSjpFIfHMmcguyLOtyn0hObRg==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- arm64
os:
- android
"@rolldown/binding-darwin-arm64@1.2.16":
resolution:
integrity: sha512-qslZrXnKJU4cUpjoAmtAo/KQM9e2IRMlmpig6Zpwj+8KWxW8v+nkAf9216Bsek9lOC1jvg2yCjygCFo2f83msQ==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- arm64
os:
- darwin
"@rolldown/binding-darwin-x64@1.2.16":
resolution:
integrity: sha512-FdF+y48ND13eAyM2mQn+85kvAqNlvRWROy2rhgA463X/0Gv4vGtazZtfaF1mRBLscYvtOlh4QnLjOWiFzX69OQ==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- x64
os:
- darwin
"@rolldown/binding-freebsd-x64@1.2.16":
resolution:
integrity: sha512-ddjqFM5e95AgLbUPtKIS7V1KTVlA0RUgCVr5mn+/IEhsdy3pr+Vuj/HZ7nlMN2FyxIwUktOH1LEPIQXO1v9y1Q==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- x64
os:
- freebsd
"@rolldown/binding-linux-arm-gnueabihf@1.2.16":
resolution:
integrity: sha512-tHdKWbFkFBI687iim3LIyIvyL7j66VvQYkDPss5Stn/qyE2tWkR1YD0dXmXPFKKqT/o5ZEJVsaRsWS2meQwGOA==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- arm
os:
- linux
"@rolldown/binding-linux-arm64-gnu@1.2.16":
resolution:
integrity: sha512-FJiLGAblPBMlBEdbOqw6kW6QcXDWAf/oJu7gYs9ZJZwmg+K+/zjFLxPTIY9izJUzxzc24FHvmseyA0IvJSl17w==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- arm64
os:
- linux
libc:
- glibc
"@rolldown/binding-linux-arm64-musl@1.2.16":
resolution:
integrity: sha512-hrJpblMsrQ58U9veWpbXzkhV5zStunds6HWLprqq1qauvgBr1E6P+24kLj6lSLI9vjRn/RYpjprhkHQPKGWpNg==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- arm64
os:
- linux
libc:
- musl
"@rolldown/binding-linux-ppc64-gnu@1.2.16":
resolution:
integrity: sha512-qJd/dC6j6CwLG9/s/RP2nb1RZ0GIgj7Ioj7x/SYa3RzjVrlzrmH0fhIOpfvqQDeIsdP0loi+kHaMhJzY1PBIaA==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- ppc64
os:
- linux
libc:
- glibc
"@rolldown/binding-linux-s390x-gnu@1.2.16":
resolution:
integrity: sha512-Vx7Xg5uUJuNcujJjI70OICaH0EYj80BtOLZTSN7uOYg8QOLlyKnaG0IW7Fn/J0IpJsaKzmDKMhOQv1JBM9m9vg==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- s390x
os:
- linux
libc:
- glibc
"@rolldown/binding-linux-x64-gnu@1.2.16":
resolution:
integrity: sha512-TNKhgE3uJTsTzatUSSYt0Kgo+Oa2uSlSjz4r1aEIea7HX6ULBym4fAlYUhG1i6pjNf2njfCUAfKwr6C3E9Xg1w==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- x64
os:
- linux
libc:
- glibc
"@rolldown/binding-linux-x64-musl@1.2.16":
resolution:
integrity: sha512-7chXdpjXZ8qG0+mIxECN3cT9kvhZ3/oZhMX6Pp876P7CDrIy8nJswva6Mq357JR7eYXfuskwZxMeV1SzoZdHrA==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- x64
os:
- linux
libc:
- musl
"@rolldown/binding-openharmony-arm64@1.2.16":
resolution:
integrity: sha512-Kwjt+7uNTJK5/MDkGWGVO2KQPnj8yAV75dMpfwyHZrJSXWHrniOB0aUEWlVYf3H1hOqFLIStLdM5QXq6bnKmOQ==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- arm64
os:
- openharmony
"@rolldown/binding-win32-arm64-msvc@1.2.16":
resolution:
integrity: sha512-/LH6WfjDRXXJz/p5xl4TmU+jpcnwcxbKEQBW/GZE0JHfN0lGIyTtsUEGaQ/q/GikkGJ2yLKe6pwm7AnEWO8pdw==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- arm64
os:
- win32
"@rolldown/binding-win32-x64-msvc@1.2.16":
resolution:
integrity: sha512-1lv1KvX0Z871zfk7vw+dnXMMnHNyDwMzWG8Kv3HxDXMOhzCX4SHc7HK319fInP0i+0p9D8brkfzL7pJOaGl+tw==
engines:
node: ^20.19.0 || >=22.12.0
cpu:
- x64
os:
- win32
"@rolldown/pluginutils@1.0.1":
resolution:
integrity: sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==
"@sxzz/popperjs-es@2.11.8":
resolution:
integrity: sha512-wOwESXvvED3S8xBmcPWHs2dUuzrE4XiZeFu7e1hROIJkm02a49N120pmOXxY33sBb6hArItm5W5tcg1cBtV+HQ==
"@types/lodash-es@4.17.12":
resolution:
integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==
"@types/lodash@4.17.27":
resolution:
integrity: sha512-VenMRv/eKNrspX9v3H4dbmjsrnCOYdYBG3kxXKk3dG6X+urBGcj2Prww3xw1U5K4FV/mE4h5GbWd0szEKf+9ew==
"@types/node@24.19.2":
resolution:
integrity: sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==
"@types/web-bluetooth@0.0.21":
resolution:
integrity: sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==
"@vitejs/plugin-vue@6.0.10":
resolution:
integrity: sha512-b80aUQh3n+qEzzZm5oQp3rT2QImeCx58K6eFl/RkJ3d65KW0kTuv5lNsLRVAjbW9YRUpo/wzmvzMgV34bTAItA==
engines:
node: ^20.19.0 || >=22.12.0
peerDependencies:
vite: ~8.2.4
vue: ^3.2.25 || ^3.6.0-rc.10
"@volar/language-core@2.4.28":
resolution:
integrity: sha512-w4qhIJ8ZSitgLAkVay6AbcnC7gP3glYM3fYwKV3srj8m494E3xtrCv6E+bWviiK/8hs6e6t1ij1s2Endql7vzQ==
"@volar/source-map@2.4.28":
resolution:
integrity: sha512-yX2BDBqJkRXfKw8my8VarTyjv48QwxdJtvRgUpNE5erCsgEUdI2DsLbpa+rOQVAJYshY99szEcRDmyHbF10ggQ==
"@volar/typescript@2.4.28":
resolution:
integrity: sha512-Ja6yvWrbis2QtN4ClAKreeUZPVYMARDYZl9LMEv1iQ1QdepB6wn0jTRxA9MftYmYa4DQ4k/DaSZpFPUfxl8giw==
"@vue/compiler-core@3.5.44":
resolution:
integrity: sha512-k34nCytbK8PQ1gR2mGROYOw6Pnv/mumqIdrZ3x2tbyXZDWm7ViKGLTfdB+DRrWqEQsLgGJvn0WN9jBif5zCTLQ==
"@vue/compiler-dom@3.5.44":
resolution:
integrity: sha512-W5AoBFWdw1lQAKiHowkfgFKFab82oSRT6sGsPfw/q1GRjsy/ZJFLHGhJyBRIFN9APLTUduDH9U2JAiPOIyKuYg==
"@vue/compiler-sfc@3.5.44":
resolution:
integrity: sha512-dzHmQ4jXTpdr5FjIQUeykVakN/uzqFbUo9/C5ikBFg3a3PeM6uRxeczx1ZbXBML0/zJstEh3ygYipzR5Z7b2Pw==
"@vue/compiler-ssr@3.5.44":
resolution:
integrity: sha512-xr5gb1JVHlfXJwSlRz1FeP6uxoazdzHuMTVLE7up+4Vrqxk219CvxLPxD9NXBt47yvZW7+p4DXfyp4O1fkByIA==
"@vue/language-core@3.3.11":
resolution:
integrity: sha512-QJmpliwAVpC/OxubIByPAhNzsQPRc8/gxlN2qnVzVfIMjMDz/9RnXRFoetjz5yEgXVXyp4LqhXq3V53PjmNzFw==
"@vue/reactivity@3.5.44":
resolution:
integrity: sha512-u+QJdKeBBEADkPdevsL+6E12QlYVfBD8Zcw5qjDQKtamI6l14KyqazJMobhCKelhWN5zpyKUiEDoTyHE93cqWw==
"@vue/runtime-core@3.5.44":
resolution:
integrity: sha512-uEa/ndwjhrrhnOfb2p+sZy6zeoamJOISqaLSJGk/8R6nABT1ZldpzcJoPzKj+zHVomVBPcmQYyC2r4LtvDV6CQ==
"@vue/runtime-dom@3.5.44":
resolution:
integrity: sha512-3fc4ARcXVhVBaJ3ujWiNZJARD6pkyRcwG+ZYhMzjKtKUp7MAY0HLwr7r3Smep3Li6ZaWT6ewdmx8XqdaD5oNZg==
"@vue/server-renderer@3.5.44":
resolution:
integrity: sha512-R4S1UoH4h5Frrauv8Z5XE5TxV9oBiUSgWIC4TyVK1FK+RocRnOLwFA5Xcmo2011RlgJp+AbZCnw6afrhlgRuUQ==
"@vue/shared@3.5.44":
resolution:
integrity: sha512-H82XLH0DjmSOdbEwO15x3QTo1f5PWEtv237eLpYKc0mqLu+B8hnq16lFWmuBmNurkeiG3wr+oM1FhOll/YVFRg==
"@vueuse/core@15.0.0":
resolution:
integrity: sha512-Zv67h5mrk7YHDJsRObx+DXaCBz6RKBUpxqLesJ+3xZNPG6yuQs7ja7kg3veFrrouYLWAqydQ7CwGEbLVxB43Ng==
engines:
node: ">=22"
peerDependencies:
vue: ^3.5.0
"@vueuse/metadata@15.0.0":
resolution:
integrity: sha512-sfWE5LADAKJ0KnjtGliMdSN8Ij/L7uP6rXIZlgPloAI4zvvefbw6H5Lt7KJA6RqQOYgVqWF5Guj50HHMIzygBg==
engines:
node: ">=22"
"@vueuse/shared@15.0.0":
resolution:
integrity: sha512-vbNXhGrbV53xPOMSyOzMHQRvhMgZf7oNDw2RChUetVxwTIEkInQ1joZ9JbT0G3z2n2AJNjvmCWeM9ySYrnvogA==
engines:
node: ">=22"
peerDependencies:
vue: ^3.5.0
alien-signals@3.2.1:
resolution:
integrity: sha512-I8FjmltrfnDFoZedi5CG8DghVYNhzb/Ijluz7tCSJH0xpd0484Kowhbb1XDYOxfJpU1p5wnM2X54dA+IfGyD1g==
async-validator@4.2.5:
resolution:
integrity: sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==
csstype@3.2.3:
resolution:
integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==
dayjs@1.11.23:
resolution:
integrity: sha512-QDTCU0M0MxR3hQfnlDJfwekQiaanm1ubOD231u73WBckQ/fsamwRLiE2GBz6D3a/xF1NgfiDLJjXBa1hYOYTtQ==
detect-libc@2.1.2:
resolution:
integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==
engines:
node: ">=8"
element-plus@2.14.7:
resolution:
integrity: sha512-lrG7pZyCS+mpCNVpzxxyu5r35+T6V0hzkAeIwn7HA6to772XSTHKuYCZG51OfzlqaxGbNegLxs650zAF1j43gA==
peerDependencies:
vue: ^3.3.7
entities@7.0.1:
resolution:
integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==
engines:
node: ">=0.12"
estree-walker@2.0.2:
resolution:
integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==
fdir@6.5.0:
resolution:
integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==
engines:
node: ">=12.0.0"
peerDependencies:
picomatch: ^3 || ^4
peerDependenciesMeta:
picomatch:
optional: true
fsevents@2.3.3:
resolution:
integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
engines:
node: ^8.16.0 || ^10.6.0 || >=11.0.0
os:
- darwin
lightningcss-android-arm64@1.33.0:
resolution:
integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==
engines:
node: ">= 12.0.0"
cpu:
- arm64
os:
- android
lightningcss-darwin-arm64@1.33.0:
resolution:
integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==
engines:
node: ">= 12.0.0"
cpu:
- arm64
os:
- darwin
lightningcss-darwin-x64@1.33.0:
resolution:
integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==
engines:
node: ">= 12.0.0"
cpu:
- x64
os:
- darwin
lightningcss-freebsd-x64@1.33.0:
resolution:
integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==
engines:
node: ">= 12.0.0"
cpu:
- x64
os:
- freebsd
lightningcss-linux-arm-gnueabihf@1.33.0:
resolution:
integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==
engines:
node: ">= 12.0.0"
cpu:
- arm
os:
- linux
lightningcss-linux-arm64-gnu@1.33.0:
resolution:
integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==
engines:
node: ">= 12.0.0"
cpu:
- arm64
os:
- linux
libc:
- glibc
lightningcss-linux-arm64-musl@1.33.0:
resolution:
integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==
engines:
node: ">= 12.0.0"
cpu:
- arm64
os:
- linux
libc:
- musl
lightningcss-linux-x64-gnu@1.33.0:
resolution:
integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==
engines:
node: ">= 12.0.0"
cpu:
- x64
os:
- linux
libc:
- glibc
lightningcss-linux-x64-musl@1.33.0:
resolution:
integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==
engines:
node: ">= 12.0.0"
cpu:
- x64
os:
- linux
libc:
- musl
lightningcss-win32-arm64-msvc@1.33.0:
resolution:
integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==
engines:
node: ">= 12.0.0"
cpu:
- arm64
os:
- win32
lightningcss-win32-x64-msvc@1.33.0:
resolution:
integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==
engines:
node: ">= 12.0.0"
cpu:
- x64
os:
- win32
lightningcss@1.33.0:
resolution:
integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==
engines:
node: ">= 12.0.0"
lodash-es@4.18.1:
resolution:
integrity: sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==
lodash-unified@1.0.3:
resolution:
integrity: sha512-WK9qSozxXOD7ZJQlpSqOT+om2ZfcT4yO+03FuzAHD0wF6S0l0090LRPDx3vhTTLZ8cFKpBn+IOcVXK6qOcIlfQ==
peerDependencies:
"@types/lodash-es": "*"
lodash: "*"
lodash-es: "*"
lodash@4.18.1:
resolution:
integrity: sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==
magic-string@0.30.21:
resolution:
integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==
memoize-one@6.0.0:
resolution:
integrity: sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==
muggle-string@0.4.1:
resolution:
integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==
nanoid@3.3.20:
resolution:
integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==
engines:
node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1
hasBin: true
normalize-wheel-es@1.2.0:
resolution:
integrity: sha512-Wj7+EJQ8mSuXr2iWfnujrimU35R2W4FAErEyTmJoJ7ucwTn2hOUSsRehMb5RSYkxXGTM7Y9QpvPmp++w5ftoJw==
path-browserify@1.0.1:
resolution:
integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==
picocolors@1.1.1:
resolution:
integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==
picomatch@4.0.7:
resolution:
integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==
engines:
node: ">=12"
postcss@8.5.32:
resolution:
integrity: sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==
engines:
node: ^10 || ^12 || >=14
rolldown@1.2.16:
resolution:
integrity: sha512-bWvlMpFKiTfDKfnK7FC2MPgPeWCf/Kpwsq49ApdW+FQaBZb6O6dZ4MAPbPUjp7hYQrw/RobqCzn64BRrQecGHw==
engines:
node: ^20.19.0 || >=22.12.0
hasBin: true
source-map-js@1.2.2:
resolution:
integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==
engines:
node: ">=0.10.0"
tinyglobby@0.2.17:
resolution:
integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==
engines:
node: ">=12.0.0"
typescript@6.0.3:
resolution:
integrity: sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==
engines:
node: ">=14.17"
hasBin: true
undici-types@7.24.6:
resolution:
integrity: sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==
vite@8.2.4:
resolution:
integrity: sha512-lfauXnrf2x0p+UoA+wXh0dgFWnUjCyG6Js95KBkgaCwUU9k0DAHI4W6Q0WCx+h+5g+Alce1y4Zi2QjjK0UvGBw==
engines:
node: ^20.19.0 || >=22.12.0
hasBin: true
peerDependencies:
"@types/node": ^20.19.0 || >=22.12.0
"@vitejs/devtools": ^0.4.0 || ^0.5.0
esbuild: ^0.27.0 || ^0.28.0
jiti: ">=1.21.0"
less: ^4.0.0
sass: ^1.70.0
sass-embedded: ^1.70.0
stylus: ">=0.54.8"
sugarss: ^5.0.0
terser: ^5.16.0
tsx: ^4.8.1
yaml: ^2.4.2
peerDependenciesMeta:
"@types/node":
optional: true
"@vitejs/devtools":
optional: true
esbuild:
optional: true
jiti:
optional: true
less:
optional: true
sass:
optional: true
sass-embedded:
optional: true
stylus:
optional: true
sugarss:
optional: true
terser:
optional: true
tsx:
optional: true
yaml:
optional: true
vscode-uri@3.2.0:
resolution:
integrity: sha512-m2gXo3bn0G1kT9InzMf07fTbqMbGtyckj3bH5ktLO+1Ssv+yiATZ4dhwaQv9UZWxJh6E9IFGnQyjgWVDWVBDrg==
vue-component-type-helpers@3.3.14:
resolution:
integrity: sha512-Pq3+OnbCiPCHk0R7KSZrx+j/XXaUn2kSQ1epxq60w8CPbByLjC1EJgV51n4WY851sTXUVzsNMuitywdkdVyKjA==
vue-tsc@3.3.11:
resolution:
integrity: sha512-gOb0B9rtU2+f1dszwPqSH5kAieIF9ReeLhD3kSRNHv5WZZUQz/JdVXW0RTdqhNTMlQkqKzrTTviqKr/4FYZraQ==
hasBin: true
peerDependencies:
typescript: ">=5.0.0"
vue@3.5.44:
resolution:
integrity: sha512-dvvmaOCG7lAMkJTPqPwWeGMsPS6DIsFsfZDUgBp9V6mHf9b3+/wyVwYR4Es+WV6uJC0FKRxp81Obcq0ZwUcGFQ==
peerDependencies:
typescript: "*"
peerDependenciesMeta:
typescript:
optional: true
snapshots:
"@babel/helper-string-parser@7.29.11": {}
"@babel/helper-validator-identifier@7.29.7": {}
"@babel/parser@7.29.12":
dependencies:
"@babel/types": 7.29.11
"@babel/types@7.29.11":
dependencies:
"@babel/helper-string-parser": 7.29.11
"@babel/helper-validator-identifier": 7.29.7
"@ctrl/tinycolor@4.2.2": {}
"@element-plus/icons-vue@2.3.2(vue@3.5.44(typescript@6.0.3))":
dependencies:
vue: 3.5.44(typescript@6.0.3)
"@floating-ui/core@1.8.0":
dependencies:
"@floating-ui/utils": 0.2.12
"@floating-ui/dom@1.8.0":
dependencies:
"@floating-ui/core": 1.8.0
"@floating-ui/utils": 0.2.12
"@floating-ui/utils@0.2.12": {}
"@jridgewell/sourcemap-codec@1.6.0": {}
"@oxc-project/types@0.156.0": {}
"@rolldown/binding-android-arm-eabi@1.2.16":
optional: true
"@rolldown/binding-android-arm64@1.2.16":
optional: true
"@rolldown/binding-darwin-arm64@1.2.16":
optional: true
"@rolldown/binding-darwin-x64@1.2.16":
optional: true
"@rolldown/binding-freebsd-x64@1.2.16":
optional: true
"@rolldown/binding-linux-arm-gnueabihf@1.2.16":
optional: true
"@rolldown/binding-linux-arm64-gnu@1.2.16":
optional: true
"@rolldown/binding-linux-arm64-musl@1.2.16":
optional: true
"@rolldown/binding-linux-ppc64-gnu@1.2.16":
optional: true
"@rolldown/binding-linux-s390x-gnu@1.2.16":
optional: true
"@rolldown/binding-linux-x64-gnu@1.2.16":
optional: true
"@rolldown/binding-linux-x64-musl@1.2.16":
optional: true
"@rolldown/binding-openharmony-arm64@1.2.16":
optional: true
"@rolldown/binding-win32-arm64-msvc@1.2.16":
optional: true
"@rolldown/binding-win32-x64-msvc@1.2.16":
optional: true
"@rolldown/pluginutils@1.0.1": {}
"@sxzz/popperjs-es@2.11.8": {}
"@types/lodash-es@4.17.12":
dependencies:
"@types/lodash": 4.17.27
"@types/lodash@4.17.27": {}
"@types/node@24.19.2":
dependencies:
undici-types: 7.24.6
"@types/web-bluetooth@0.0.21": {}
"@vitejs/plugin-vue@6.0.10(vite@8.2.4(@types/node@24.19.2))(vue@3.5.44(typescript@6.0.3))":
dependencies:
"@rolldown/pluginutils": 1.0.1
vite: 8.2.4(@types/node@24.19.2)
vue: 3.5.44(typescript@6.0.3)
"@volar/language-core@2.4.28":
dependencies:
"@volar/source-map": 2.4.28
"@volar/source-map@2.4.28": {}
"@volar/typescript@2.4.28":
dependencies:
"@volar/language-core": 2.4.28
path-browserify: 1.0.1
vscode-uri: 3.2.0
"@vue/compiler-core@3.5.44":
dependencies:
"@babel/parser": 7.29.12
"@vue/shared": 3.5.44
entities: 7.0.1
estree-walker: 2.0.2
source-map-js: 1.2.2
"@vue/compiler-dom@3.5.44":
dependencies:
"@vue/compiler-core": 3.5.44
"@vue/shared": 3.5.44
"@vue/compiler-sfc@3.5.44":
dependencies:
"@babel/parser": 7.29.12
"@vue/compiler-core": 3.5.44
"@vue/compiler-dom": 3.5.44
"@vue/compiler-ssr": 3.5.44
"@vue/shared": 3.5.44
estree-walker: 2.0.2
magic-string: 0.30.21
postcss: 8.5.32
source-map-js: 1.2.2
"@vue/compiler-ssr@3.5.44":
dependencies:
"@vue/compiler-dom": 3.5.44
"@vue/shared": 3.5.44
"@vue/language-core@3.3.11":
dependencies:
"@volar/language-core": 2.4.28
"@vue/compiler-dom": 3.5.44
"@vue/shared": 3.5.44
alien-signals: 3.2.1
muggle-string: 0.4.1
path-browserify: 1.0.1
picomatch: 4.0.7
"@vue/reactivity@3.5.44":
dependencies:
"@vue/shared": 3.5.44
"@vue/runtime-core@3.5.44":
dependencies:
"@vue/reactivity": 3.5.44
"@vue/shared": 3.5.44
"@vue/runtime-dom@3.5.44":
dependencies:
"@vue/reactivity": 3.5.44
"@vue/runtime-core": 3.5.44
"@vue/shared": 3.5.44
csstype: 3.2.3
"@vue/server-renderer@3.5.44":
dependencies:
"@vue/compiler-ssr": 3.5.44
"@vue/runtime-dom": 3.5.44
"@vue/shared": 3.5.44
"@vue/shared@3.5.44": {}
"@vueuse/core@15.0.0(vue@3.5.44(typescript@6.0.3))":
dependencies:
"@types/web-bluetooth": 0.0.21
"@vueuse/metadata": 15.0.0
"@vueuse/shared": 15.0.0(vue@3.5.44(typescript@6.0.3))
vue: 3.5.44(typescript@6.0.3)
"@vueuse/metadata@15.0.0": {}
"@vueuse/shared@15.0.0(vue@3.5.44(typescript@6.0.3))":
dependencies:
vue: 3.5.44(typescript@6.0.3)
alien-signals@3.2.1: {}
async-validator@4.2.5: {}
csstype@3.2.3: {}
dayjs@1.11.23: {}
detect-libc@2.1.2: {}
element-plus@2.14.7(vue@3.5.44(typescript@6.0.3)):
dependencies:
"@ctrl/tinycolor": 4.2.2
"@element-plus/icons-vue": 2.3.2(vue@3.5.44(typescript@6.0.3))
"@floating-ui/dom": 1.8.0
"@popperjs/core": "@sxzz/popperjs-es@2.11.8"
"@types/lodash": 4.17.27
"@types/lodash-es": 4.17.12
"@vueuse/core": 15.0.0(vue@3.5.44(typescript@6.0.3))
async-validator: 4.2.5
dayjs: 1.11.23
lodash: 4.18.1
lodash-es: 4.18.1
lodash-unified: 1.0.3(@types/lodash-es@4.17.12)(lodash-es@4.18.1)(lodash@4.18.1)
memoize-one: 6.0.0
normalize-wheel-es: 1.2.0
vue: 3.5.44(typescript@6.0.3)
vue-component-type-helpers: 3.3.14
entities@7.0.1: {}
estree-walker@2.0.2: {}
fdir@6.5.0(picomatch@4.0.7):
optionalDependencies:
picomatch: 4.0.7
fsevents@2.3.3:
optional: true
lightningcss-android-arm64@1.33.0:
optional: true
lightningcss-darwin-arm64@1.33.0:
optional: true
lightningcss-darwin-x64@1.33.0:
optional: true
lightningcss-freebsd-x64@1.33.0:
optional: true
lightningcss-linux-arm-gnueabihf@1.33.0:
optional: true
lightningcss-linux-arm64-gnu@1.33.0:
optional: true
lightningcss-linux-arm64-musl@1.33.0:
optional: true
lightningcss-linux-x64-gnu@1.33.0:
optional: true
lightningcss-linux-x64-musl@1.33.0:
optional: true
lightningcss-win32-arm64-msvc@1.33.0:
optional: true
lightningcss-win32-x64-msvc@1.33.0:
optional: true
lightningcss@1.33.0:
dependencies:
detect-libc: 2.1.2
optionalDependencies:
lightningcss-android-arm64: 1.33.0
lightningcss-darwin-arm64: 1.33.0
lightningcss-darwin-x64: 1.33.0
lightningcss-freebsd-x64: 1.33.0
lightningcss-linux-arm-gnueabihf: 1.33.0
lightningcss-linux-arm64-gnu: 1.33.0
lightningcss-linux-arm64-musl: 1.33.0
lightningcss-linux-x64-gnu: 1.33.0
lightningcss-linux-x64-musl: 1.33.0
lightningcss-win32-arm64-msvc: 1.33.0
lightningcss-win32-x64-msvc: 1.33.0
lodash-es@4.18.1: {}
lodash-unified@1.0.3(@types/lodash-es@4.17.12)(lodash-es@4.18.1)(lodash@4.18.1):
dependencies:
"@types/lodash-es": 4.17.12
lodash: 4.18.1
lodash-es: 4.18.1
lodash@4.18.1: {}
magic-string@0.30.21:
dependencies:
"@jridgewell/sourcemap-codec": 1.6.0
memoize-one@6.0.0: {}
muggle-string@0.4.1: {}
nanoid@3.3.20: {}
normalize-wheel-es@1.2.0: {}
path-browserify@1.0.1: {}
picocolors@1.1.1: {}
picomatch@4.0.7: {}
postcss@8.5.32:
dependencies:
nanoid: 3.3.20
picocolors: 1.1.1
source-map-js: 1.2.2
rolldown@1.2.16:
dependencies:
"@oxc-project/types": 0.156.0
"@rolldown/pluginutils": 1.0.1
optionalDependencies:
"@rolldown/binding-android-arm-eabi": 1.2.16
"@rolldown/binding-android-arm64": 1.2.16
"@rolldown/binding-darwin-arm64": 1.2.16
"@rolldown/binding-darwin-x64": 1.2.16
"@rolldown/binding-freebsd-x64": 1.2.16
"@rolldown/binding-linux-arm-gnueabihf": 1.2.16
"@rolldown/binding-linux-arm64-gnu": 1.2.16
"@rolldown/binding-linux-arm64-musl": 1.2.16
"@rolldown/binding-linux-ppc64-gnu": 1.2.16
"@rolldown/binding-linux-s390x-gnu": 1.2.16
"@rolldown/binding-linux-x64-gnu": 1.2.16
"@rolldown/binding-linux-x64-musl": 1.2.16
"@rolldown/binding-openharmony-arm64": 1.2.16
"@rolldown/binding-win32-arm64-msvc": 1.2.16
"@rolldown/binding-win32-x64-msvc": 1.2.16
source-map-js@1.2.2: {}
tinyglobby@0.2.17:
dependencies:
fdir: 6.5.0(picomatch@4.0.7)
picomatch: 4.0.7
typescript@6.0.3: {}
undici-types@7.24.6: {}
vite@8.2.4(@types/node@24.19.2):
dependencies:
lightningcss: 1.33.0
picomatch: 4.0.7
postcss: 8.5.32
rolldown: 1.2.16
tinyglobby: 0.2.17
optionalDependencies:
"@types/node": 24.19.2
fsevents: 2.3.3
vscode-uri@3.2.0: {}
vue-component-type-helpers@3.3.14: {}
vue-tsc@3.3.11(typescript@6.0.3):
dependencies:
"@volar/typescript": 2.4.28
"@vue/language-core": 3.3.11
typescript: 6.0.3
vue@3.5.44(typescript@6.0.3):
dependencies:
"@vue/compiler-dom": 3.5.44
"@vue/compiler-sfc": 3.5.44
"@vue/runtime-dom": 3.5.44
"@vue/server-renderer": 3.5.44
"@vue/shared": 3.5.44
optionalDependencies:
typescript: 6.0.3
+432
View File
@@ -0,0 +1,432 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
import {
ElButton, ElCheckbox, ElConfigProvider, ElInput, ElInputNumber, ElMessage, ElMessageBox,
ElOption, ElSelect, ElTabPane, ElTabs,
} from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import ReleaseDialog from "./ReleaseDialog.vue";
import LayoutSurface from "./LayoutSurface.vue";
import {
builtInLayout, clamp, copyLayout, devices, normalizeLayout, templates, validate,
type Layout, type LayoutItem, type Payload, type Template,
} from "./layout";
const draftKey = "vibe-launcher-draft-v3";
const layout = ref(builtInLayout());
const savedLayout = ref(JSON.stringify(layout.value));
try {
const draft = localStorage.getItem(draftKey);
if (draft) layout.value = normalizeLayout(JSON.parse(draft));
} catch {
ElMessage.warning("本地草稿无法读取");
}
const dirty = computed(() => JSON.stringify(layout.value) !== savedLayout.value);
watch(layout, () => {
try {
if (dirty.value) localStorage.setItem(draftKey, JSON.stringify(layout.value));
else localStorage.removeItem(draftKey);
} catch {
ElMessage.warning("无法保存本地草稿,请导出当前布局");
}
}, { deep: true });
async function confirmReplace() {
if (!dirty.value) return true;
try {
await ElMessageBox.confirm("当前画布有未发布的改动。替换前可以取消并导出草稿。", "替换当前画布", {
type: "warning", confirmButtonText: "替换", cancelButtonText: "取消",
});
return true;
} catch {
return false;
}
}
function markPublished(revision: number) {
layout.value.revision = revision;
savedLayout.value = JSON.stringify(layout.value);
}
const pageIndex = ref(0);
const selectedId = ref<string>();
const page = computed(() => layout.value.pages[pageIndex.value]!);
const selected = computed(() => page.value.items.find(item => item.id === selectedId.value));
const tab = ref("preview");
const snap = ref(true);
const guides = ref(true);
const release = ref(false);
const fileInput = ref<HTMLInputElement>();
const stage = ref<HTMLElement>();
const stageSize = ref({ width: 0, height: 0 });
const undoStack = ref<Layout[]>([]);
const redoStack = ref<Layout[]>([]);
const canvas = computed(() => layout.value.canvas);
const designScale = computed(() => Math.min(
1, Math.max(1, stageSize.value.width - 36) / canvas.value.designWidth,
Math.max(1, stageSize.value.height - 36) / canvas.value.designHeight,
));
const issues = computed(() => validate(layout.value));
const json = computed(() => JSON.stringify(layout.value, null, 2));
const hosted = ["https:", "http:"].includes(location.protocol);
const sizes = ["1080x1920", "1080x2160", "1080x2340", "1080x2400"];
const size = computed(() => canvas.value.designWidth + "x" + canvas.value.designHeight);
const fitModes = [
{ value: "contain", label: "等比居中" },
{ value: "elastic", label: "弹性行距" },
{ value: "stretch", label: "拉伸" },
];
const background = computed(() => page.value.background);
const backgrounds = [
{ value: "wallpaper", label: "系统壁纸" },
{ value: "solid", label: "纯色" },
{ value: "gradient", label: "渐变" },
];
const payloadFields: { key: keyof Pick<Payload, "label" | "package" | "provider" | "intent">; label: string; type?: string }[] = [
{ key: "label", label: "显示名称" }, { key: "package", label: "应用包名", type: "app_icon" },
{ key: "provider", label: "组件 Provider", type: "widget" }, { key: "intent", label: "快捷方式 Intent", type: "shortcut" },
];
const visiblePayload = computed(() => payloadFields.filter(field => !field.type || field.type === selected.value?.type));
const fields = ["x", "y", "w", "h", "z"] as const;
function remember() {
undoStack.value.push(copyLayout(layout.value));
if (undoStack.value.length > 60) undoStack.value.shift();
redoStack.value = [];
}
function restore(from: Layout[], to: Layout[]) {
const saved = from.pop();
if (!saved) return;
to.push(copyLayout(layout.value));
layout.value = { ...saved, revision: layout.value.revision };
selectPage(Math.min(pageIndex.value, saved.pages.length - 1));
}
function selectPage(index: number) {
pageIndex.value = index;
selectedId.value = undefined;
}
function changePages(add: boolean) {
remember();
if (add) {
layout.value.pages.splice(pageIndex.value + 1, 0, { index: 0, background: { type: "wallpaper" }, items: [] });
} else {
layout.value.pages.splice(pageIndex.value, 1);
}
layout.value.pages.forEach((entry, index) => { entry.index = index; });
selectPage(Math.min(pageIndex.value + Number(add), layout.value.pages.length - 1));
}
function changeSize(value: string) {
const [w, h] = value.split("x").map(Number);
if (!w || !h || value === size.value) return;
remember();
canvas.value.designWidth = w;
canvas.value.designHeight = h;
}
function updateValue<T extends object, K extends keyof T>(record: T, key: K, value: T[K] | undefined) {
if (value === undefined || value === record[key]) return;
remember();
record[key] = value;
}
const grid = (n: number) => snap.value ? Math.round(n / 12) * 12 : Math.round(n);
function addItem(template: Template, x?: number, y?: number) {
const count = page.value.items.length;
if (count >= 80) { ElMessage.warning("本页最多 80 个元素"); return; }
remember();
const w = Math.min(template.w, canvas.value.designWidth);
const h = Math.min(template.h, canvas.value.designHeight);
let suffix = count + 1;
while (page.value.items.some(item => item.id === "e" + suffix)) suffix++;
const item = {
id: "e" + suffix, type: template.type, w, h, z: 2, payload: { ...template.payload },
x: clamp(grid(x ?? 108 + count % 4 * 216), 0, canvas.value.designWidth - w),
y: clamp(grid(y ?? 300 + count % 3 * 60), 0, canvas.value.designHeight - h),
};
page.value.items.push(item);
selectedId.value = item.id;
tab.value = "properties";
}
function clickBlank(event: MouseEvent) {
if ((event.target as HTMLElement).closest(".layout-item")) return;
const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
addItem(templates[0]!, (event.clientX - rect.left) / designScale.value - 66,
(event.clientY - rect.top) / designScale.value - 84);
}
function removeItem() {
if (!selected.value) return;
remember();
page.value.items = page.value.items.filter(item => item.id !== selectedId.value);
selectedId.value = undefined;
}
function changeLayer(item: LayoutItem, top: boolean) {
const layers = page.value.items.filter(entry => entry !== item).map(entry => entry.z);
if (!layers.length) return;
const layer = top ? Math.min(2147483647, Math.max(...layers) + 1)
: Math.max(-2147483648, Math.min(...layers) - 1);
updateValue(item, "z", layer);
}
function align() {
remember();
const round = (n: number) => Math.round(n / 12) * 12;
for (const item of page.value.items) {
item.w = clamp(round(item.w), 1, canvas.value.designWidth);
item.h = clamp(round(item.h), 1, canvas.value.designHeight);
item.x = clamp(round(item.x), 0, canvas.value.designWidth - item.w);
item.y = clamp(round(item.y), 0, canvas.value.designHeight - item.h);
}
ElMessage.success("已对齐到 12px 栅格");
}
let drag: { item: LayoutItem; original: LayoutItem; pointer: number; clientX: number; clientY: number;
resize: boolean; moved: boolean; scale: number } | undefined;
function startDrag(event: PointerEvent, item: LayoutItem, resize: boolean) {
if (!event.isPrimary || event.button !== 0 || drag) return;
event.stopPropagation();
selectedId.value = item.id;
drag = { item, original: { ...item }, pointer: event.pointerId, clientX: event.clientX,
clientY: event.clientY, resize, moved: false, scale: designScale.value };
(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);
}
function moveDrag(event: PointerEvent) {
if (!drag || event.pointerId !== drag.pointer) return;
const dx = (event.clientX - drag.clientX) / drag.scale;
const dy = (event.clientY - drag.clientY) / drag.scale;
if (!drag.moved) {
if (Math.hypot(event.clientX - drag.clientX, event.clientY - drag.clientY) < 3) return;
remember();
drag.moved = true;
}
const { item, original, resize } = drag;
if (resize) {
const right = Math.max(1, canvas.value.designWidth - item.x);
const bottom = Math.max(1, canvas.value.designHeight - item.y);
item.w = clamp(grid(original.w + dx), Math.min(24, right), right);
item.h = clamp(grid(original.h + dy), Math.min(24, bottom), bottom);
} else {
item.x = clamp(grid(original.x + dx), 0, Math.max(0, canvas.value.designWidth - item.w));
item.y = clamp(grid(original.y + dy), 0, Math.max(0, canvas.value.designHeight - item.h));
}
}
function finishDrag(event: PointerEvent) {
if (drag?.pointer === event.pointerId) drag = undefined;
}
function keys(event: KeyboardEvent) {
if (release.value || drag || event.defaultPrevented ||
(event.target instanceof Element && event.target.closest("input,textarea,select,[contenteditable]"))) return;
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "z") {
event.preventDefault();
if (event.shiftKey) restore(redoStack.value, undoStack.value);
else restore(undoStack.value, redoStack.value);
} else if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "y") {
event.preventDefault();
restore(redoStack.value, undoStack.value);
} else if (event.key === "Delete" && selected.value) {
event.preventDefault();
removeItem();
}
}
function loadLayout(value: Layout, online = false) {
remember();
layout.value = value;
if (online) savedLayout.value = JSON.stringify(value);
selectPage(0);
}
async function importFile(event: Event) {
const input = event.target as HTMLInputElement;
const file = input.files?.[0];
input.value = "";
if (!file) return;
try {
if (file.size > 1024 * 1024) throw new Error("布局超过 1 MiB");
const imported = normalizeLayout(JSON.parse(await file.text()));
if (!(await confirmReplace())) return;
loadLayout(imported);
ElMessage.success("已导入 " + file.name);
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : "布局导入失败");
}
}
function download() {
const url = URL.createObjectURL(new Blob([json.value], { type: "application/json" }));
const link = document.createElement("a");
link.href = url;
link.download = "launcher_layout.json";
link.click();
window.setTimeout(() => URL.revokeObjectURL(url), 1000);
}
async function copyJson() {
try {
await navigator.clipboard.writeText(json.value);
ElMessage.success("已复制 JSON");
} catch {
tab.value = "json";
ElMessage.warning("无法访问剪贴板,可在 JSON 面板中复制");
}
}
function showIssues() {
tab.value = "rules";
if (!issues.value.length) ElMessage.success("校验通过");
}
const stageObserver = new ResizeObserver(([entry]) => {
if (entry) stageSize.value = { width: entry.contentRect.width, height: entry.contentRect.height };
});
onMounted(() => {
if (stage.value) stageObserver.observe(stage.value);
window.addEventListener("keydown", keys);
});
onUnmounted(() => {
stageObserver.disconnect();
window.removeEventListener("keydown", keys);
});
</script>
<template>
<ElConfigProvider :locale="zhCn" size="small">
<header class="toolbar">
<h1>桌面布局编辑器</h1>
<nav aria-label="编辑命令">
<ElButton :disabled="!undoStack.length" @click="restore(undoStack, redoStack)">撤销</ElButton>
<ElButton :disabled="!redoStack.length" @click="restore(redoStack, undoStack)">重做</ElButton>
<ElButton :disabled="!page.items.length" @click="align">对齐栅格</ElButton>
<ElButton :disabled="!selected" @click="removeItem">删除元素</ElButton>
<ElButton @click="showIssues">校验</ElButton>
<ElButton @click="fileInput?.click()">导入</ElButton>
<ElButton @click="download">导出</ElButton>
<ElButton v-if="hosted" type="primary" @click="release = true">布局发布</ElButton>
</nav>
<input ref="fileInput" type="file" accept=".json,application/json" hidden @change="importFile">
</header>
<div class="workspace">
<aside class="settings" aria-label="画布设置">
<section>
<h2>添加内容</h2>
<div class="templates">
<ElButton v-for="template in templates" :key="template.label" :disabled="page.items.length >= 80"
@click="addItem(template)">{{ template.label }}</ElButton>
</div>
</section>
<section>
<h2>画布</h2>
<label>基准尺寸
<ElSelect :model-value="size" aria-label="基准尺寸" @change="changeSize">
<ElOption v-for="option in new Set([...sizes, size])" :key="option" :value="option"
:label="option.replace('x', ' × ')" />
</ElSelect>
</label>
<label>顶部安全区 <ElInputNumber :model-value="canvas.safeTop" :min="0" :max="8192" :precision="0"
aria-label="顶部安全区" @change="updateValue(canvas, 'safeTop', $event)" /></label>
<label>底部安全区 <ElInputNumber :model-value="canvas.safeBottom" :min="0" :max="8192" :precision="0"
aria-label="底部安全区" @change="updateValue(canvas, 'safeBottom', $event)" /></label>
<ElCheckbox v-model="snap">吸附 12px 栅格</ElCheckbox>
<ElCheckbox v-model="guides">显示参考线</ElCheckbox>
</section>
<section>
<h2>本页背景</h2>
<ElSelect :model-value="background.type" aria-label="本页背景" @change="updateValue(background, 'type', $event)">
<ElOption v-for="option in backgrounds" :key="option.value" v-bind="option" />
<ElOption v-if="!backgrounds.some(option => option.value === background.type)" :value="background.type" />
</ElSelect>
<label v-if="background.type === 'solid'">背景颜色
<input type="color" :value="background.color || '#151a22'"
@change="updateValue(background, 'color', ($event.target as HTMLInputElement).value)">
</label>
<template v-if="background.type === 'gradient'">
<label>渐变起点 <input type="color" :value="background.from || '#151a22'"
@change="updateValue(background, 'from', ($event.target as HTMLInputElement).value)"></label>
<label>渐变终点 <input type="color" :value="background.to || '#151a22'"
@change="updateValue(background, 'to', ($event.target as HTMLInputElement).value)"></label>
</template>
</section>
<section>
<h2>映射策略</h2>
<ElSelect :model-value="layout.fit.mode" aria-label="映射策略" @change="updateValue(layout.fit, 'mode', $event)">
<ElOption v-for="option in fitModes" :key="option.value" v-bind="option" />
<ElOption v-if="!fitModes.some(option => option.value === layout.fit.mode)" :value="layout.fit.mode" />
</ElSelect>
<label>留白位置 <ElInputNumber :model-value="layout.fit.anchorY" :min="0" :max="1" :step="0.05"
aria-label="留白位置" @change="updateValue(layout.fit, 'anchorY', $event)" /></label>
</section>
</aside>
<main class="editor">
<div class="canvas-head">
<strong>设计稿</strong>
<span>{{ canvas.designWidth }} × {{ canvas.designHeight }}</span>
<span class="hint">双击空白添加图标 · 拖动右下角调整尺寸</span>
</div>
<div ref="stage" class="stage" @pointermove="moveDrag" @pointerup="finishDrag"
@pointercancel="finishDrag" @lostpointercapture="finishDrag">
<LayoutSurface :layout="layout" :page="page" :selected-id="selectedId" :guides="guides" editable
:style="{ width: (canvas.designWidth * designScale) + 'px' }"
@start-drag="startDrag" @clear="selectedId = undefined" @dblclick="clickBlank" />
</div>
<div class="page-bar" aria-label="布局页面">
<ElButton v-for="(_, index) in layout.pages" :key="index"
:type="index === pageIndex ? 'primary' : 'default'" @click="selectPage(index)">
第 {{ index + 1 }} 页
</ElButton>
<ElButton :disabled="layout.pages.length >= 20" @click="changePages(true)">新增页</ElButton>
<ElButton :disabled="layout.pages.length === 1" @click="changePages(false)">删除本页</ElButton>
</div>
</main>
<aside class="inspector" aria-label="预览与属性">
<ElTabs v-model="tab" stretch>
<ElTabPane label="设备预览" name="preview" lazy>
<div class="previews">
<figure v-for="device in devices" :key="device.name">
<LayoutSurface :layout="layout" :page="page" :device="device" />
<figcaption>{{ device.name }}<small>{{ device.w }} × {{ device.h }}</small></figcaption>
</figure>
</div>
</ElTabPane>
<ElTabPane label="属性" name="properties" lazy>
<div v-if="selected" :key="selected.id" class="item-properties">
<h2>{{ selected.payload.label || selected.type }}</h2>
<label>ID <ElInput :model-value="selected.id" readonly /></label>
<label v-for="field in fields" :key="field">{{ field.toUpperCase() }}
<ElInputNumber :model-value="selected[field]" :precision="0" :aria-label="field"
@change="updateValue(selected!, field, $event)" />
</label>
<label v-for="field in visiblePayload" :key="field.key">{{ field.label }}
<input class="property-input" :value="selected.payload[field.key] ?? ''"
@change="updateValue(selected!.payload, field.key, ($event.target as HTMLInputElement).value)">
</label>
<div class="json-actions">
<ElButton @click="changeLayer(selected!, true)">置顶</ElButton>
<ElButton @click="changeLayer(selected!, false)">置底</ElButton>
<ElButton @click="removeItem">删除</ElButton>
</div>
<label v-if="selected.type === 'dock_bg'">圆角
<ElInputNumber :model-value="selected.payload.radius ?? 56" :min="0" :precision="0"
aria-label="圆角" @change="updateValue(selected!.payload, 'radius', $event)" />
</label>
</div>
<p v-else class="empty">选择画布上的元素查看属性。</p>
</ElTabPane>
<ElTabPane :label="issues.length ? '校验 (' + issues.length + ')' : '校验'" name="rules" lazy>
<ul v-if="issues.length" class="issues">
<li v-for="(issue, index) in issues" :key="index" :class="issue.level">
<b>{{ issue.path }}</b><span>{{ issue.message }}</span>
</li>
</ul>
<p v-else class="empty">校验通过。</p>
</ElTabPane>
<ElTabPane label="JSON" name="json" lazy>
<div class="json-actions">
<ElButton @click="copyJson">复制 JSON</ElButton>
<ElButton @click="download">下载 JSON</ElButton>
<ElButton @click="loadLayout(builtInLayout())">重置示例</ElButton>
</div>
<pre>{{ json }}</pre>
</ElTabPane>
</ElTabs>
</aside>
</div>
<ReleaseDialog v-if="hosted" v-model="release" :layout="layout" :has-errors="issues.some(issue => issue.level === 'error')"
:confirm-replace="confirmReplace" :warnings="issues.filter(issue => issue.level === 'warning')"
@load="loadLayout" @published="markPublished" />
</ElConfigProvider>
</template>
+67
View File
@@ -0,0 +1,67 @@
<script setup lang="ts">
import { computed } from "vue";
import {
backgroundStyle, clamp, deviceMapper, devices, iconColor, sortedItems,
type Layout, type LayoutItem, type Page,
} from "./layout";
const props = defineProps<{
layout: Layout;
page: Page;
device?: typeof devices[number];
selectedId?: string;
editable?: boolean;
guides?: boolean;
}>();
const emit = defineEmits<{
startDrag: [event: PointerEvent, item: LayoutItem, resize: boolean];
clear: [];
}>();
const canvas = computed(() => props.layout.canvas);
const width = computed(() => props.device?.w ?? canvas.value.designWidth);
const height = computed(() => props.device?.h ?? canvas.value.designHeight);
const mapper = computed(() => props.device
? deviceMapper(canvas.value, props.layout.fit, props.page.items, props.device)
: { sx: 1, sy: 1, x: (n: number) => n, y: (n: number) => n });
const items = computed(() => sortedItems(props.page));
const known = new Set(["app_icon", "widget", "shortcut", "dock_bg"]);
const visible = computed(() => props.editable ? items.value : items.value.filter(item => known.has(item.type)));
const percent = (n: number, total: number) => (n / total * 100) + "%";
function itemStyle(item: LayoutItem) {
const m = mapper.value;
return {
left: percent(m.x(item.x), width.value),
top: percent(m.y(item.y), height.value),
width: percent(item.w * m.sx, width.value),
height: percent(item.h * m.sy, height.value),
borderRadius: item.type === "dock_bg" ? Math.max(0, item.payload.radius ?? 56) * m.sx / width.value * 100 + "cqw" : undefined,
"--icon-fill": iconColor(item),
};
}
function title(item: LayoutItem) {
return item.payload.label || item.payload.package || item.payload.provider || item.payload.intent || item.type;
}
</script>
<template>
<div class="layout-surface" :class="{ editable, 'with-guides': guides }"
:style="{ aspectRatio: width + '/' + height, background: backgroundStyle(page.background) }"
@pointerdown="editable && emit('clear')">
<template v-if="editable">
<div class="safe-zone top" :style="{ height: percent(clamp(canvas.safeTop, 0, height), height) }"></div>
<div class="safe-zone bottom" :style="{ height: percent(clamp(canvas.safeBottom, 0, height), height) }"></div>
</template>
<div v-for="item in visible" :key="item.id" class="layout-item"
:class="[item.type, { selected: item.id === selectedId }]" :style="itemStyle(item)"
:title="title(item)" :tabindex="editable ? 0 : undefined"
@pointerdown="editable && emit('startDrag', $event, item, false)">
<template v-if="item.type === 'app_icon' || item.type === 'shortcut'">
<span class="icon-art">{{ (item.payload.label || title(item)).slice(0, 1).toUpperCase() }}</span>
<span class="icon-label">{{ title(item) }}</span>
</template>
<span v-else-if="item.type !== 'dock_bg'" class="widget-label">{{ title(item) }}</span>
<span v-if="editable" class="resize-handle" aria-hidden="true"
@pointerdown="emit('startDrag', $event, item, true)"></span>
</div>
</div>
</template>
+173
View File
@@ -0,0 +1,173 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { ElButton, ElDialog, ElInput, ElMessageBox } from "element-plus";
import { normalizeLayout, type Issue, type Layout } from "./layout";
interface HistoryEntry { revision: number; publishedAt: string; restoredFrom?: number }
interface History { revisions: HistoryEntry[]; nextBefore: number | null }
const open = defineModel<boolean>({ required: true });
const props = defineProps<{ layout: Layout; hasErrors: boolean; confirmReplace: () => Promise<boolean>; warnings: Issue[] }>();
const emit = defineEmits<{ load: [layout: Layout, online?: boolean]; published: [revision: number] }>();
const token = ref("");
const tag = ref<string>();
const revision = ref<number>();
const history = ref<HistoryEntry[]>([]);
const nextBefore = ref<number | null>(null);
const busy = ref(false);
const status = ref("");
const error = ref(false);
const apiBase = new URL("./api/admin/", location.href);
watch(token, () => {
tag.value = revision.value = undefined;
nextBefore.value = null;
history.value = [];
status.value = "";
error.value = false;
});
async function request<T>(path: string, options: RequestInit = {}) {
const credential = token.value.trim();
if (!credential) throw new Error("请输入管理员令牌");
const headers = new Headers(options.headers);
headers.set("Authorization", "Bearer " + credential);
const response = await fetch(new URL(path, apiBase), {
...options, headers, cache: "no-store", redirect: "error",
signal: AbortSignal.timeout(10000),
});
if (response.status === 401 || response.status === 412 || response.status === 428) tag.value = undefined;
const data = await response.json().catch(() => null);
if (!response.ok) {
const issues: Issue[] = Array.isArray(data?.issues) ? data.issues.slice(0, 8) : [];
const message = response.status === 412
? "线上布局已更新。请先导出本地改动,再读取线上布局。"
: data?.message || "HTTP " + response.status;
throw new Error([message, ...issues.map(issue => issue.path + " · " + issue.message)].join("\n"));
}
if (!data) throw new Error("服务端返回的内容不是有效 JSON");
return { data: data as T, etag: response.headers.get("ETag") ?? undefined };
}
async function run(action: () => Promise<string>) {
if (busy.value) return;
busy.value = true;
error.value = false;
status.value = "正在连接服务端…";
try {
status.value = await action();
} catch (failure) {
error.value = true;
status.value = failure instanceof Error ? failure.message : "请求失败";
} finally {
busy.value = false;
}
}
async function loadHistory(append = false) {
const path = append ? "history?before=" + nextBefore.value : "history";
const { data } = await request<History>(path);
history.value = append ? [...history.value, ...data.revisions] : data.revisions;
nextBefore.value = data.nextBefore;
}
async function refreshHistory(message: string) {
history.value = [];
nextBefore.value = null;
try {
await loadHistory();
return message;
} catch {
return message + " 版本历史暂时读取失败。";
}
}
async function loadOnline() {
if (busy.value || !(await props.confirmReplace())) return;
return run(async () => {
const { data, etag } = await request<unknown>("layout");
const layout = normalizeLayout(data);
tag.value = etag;
revision.value = layout.revision;
emit("load", layout, true);
return refreshHistory("已读取线上 v" + layout.revision + ",可返回画布编辑。");
});
}
async function loadVersion(version: number) {
if (busy.value || !(await props.confirmReplace())) return;
return run(async () => {
const { data } = await request<unknown>("history/" + version);
const layout = normalizeLayout(data);
emit("load", { ...layout, revision: revision.value ?? layout.revision });
return "已载入 v" + version + ",当前线上为 v" + revision.value + "。";
});
}
async function confirmPublish(version?: number) {
const rollback = version !== undefined;
if (rollback && !(await props.confirmReplace())) return;
const warnings = props.warnings.slice(0, 5).map(issue => issue.path + " · " + issue.message);
if (props.warnings.length > 5) warnings.push("其余警告可在校验面板查看");
try {
await ElMessageBox.confirm(rollback ? "将 v" + version + " 的布局发布为新版本,应用到所有已连接设备?"
: ["将当前画布发布到所有已连接设备?", ...warnings].join("\n"), rollback ? "确认回滚" : "确认发布", {
type: "warning", confirmButtonText: rollback ? "回滚" : "发布", cancelButtonText: "取消",
});
} catch {
return;
}
return run(async () => {
if (!tag.value) throw new Error("发布前请先读取线上版本");
const { data, etag } = await request<Layout>(rollback ? "rollback" : "layout", {
method: rollback ? "POST" : "PUT",
headers: { "If-Match": tag.value, "Content-Type": "application/json" },
body: JSON.stringify(rollback ? { revision: version } : props.layout),
});
tag.value = etag;
revision.value = data.revision;
if (rollback) emit("load", normalizeLayout(data), true);
else emit("published", data.revision);
return refreshHistory("已发布 v" + data.revision + ",设备会在下次同步时更新。");
});
}
function moreHistory() {
return run(async () => {
await loadHistory(true);
return "当前线上为 v" + revision.value + "。";
});
}
</script>
<template>
<ElDialog v-model="open" title="布局发布" width="min(600px, calc(100vw - 32px))"
:close-on-click-modal="false" :close-on-press-escape="!busy" :show-close="!busy">
<label class="token-field">管理员令牌
<ElInput v-model="token" type="password" autocomplete="off" spellcheck="false"
aria-label="管理员令牌" :disabled="busy" @keyup.enter="loadOnline" />
</label>
<div class="release-actions">
<ElButton :disabled="busy" @click="loadOnline">读取线上布局</ElButton>
<ElButton type="primary" :disabled="busy || !tag || hasErrors" @click="confirmPublish()">发布当前画布</ElButton>
<ElButton :disabled="busy" @click="open = false">返回编辑</ElButton>
</div>
<p v-if="hasErrors" class="release-error">请先修正画布校验错误。</p>
<output class="release-status" :class="{ 'release-error': error }" aria-live="polite">{{ status }}</output>
<h2 v-if="history.length">发布历史</h2>
<ol v-if="history.length" class="release-history">
<li v-for="entry in history" :key="entry.revision">
<span>
<strong>v{{ entry.revision }}{{ entry.revision === revision ? '(当前)' : '' }}</strong>
<small v-if="entry.restoredFrom">回滚自 v{{ entry.restoredFrom }}</small>
<small>{{ new Date(entry.publishedAt).toLocaleString() }}</small>
</span>
<div v-if="entry.revision !== revision">
<ElButton :disabled="busy || !tag" @click="loadVersion(entry.revision)">载入编辑</ElButton>
<ElButton :disabled="busy || !tag" @click="confirmPublish(entry.revision)">回滚</ElButton>
</div>
</li>
</ol>
<ElButton v-if="nextBefore !== null" :disabled="busy || !tag" @click="moreHistory">更多版本</ElButton>
</ElDialog>
</template>
+203
View File
@@ -0,0 +1,203 @@
import defaultLayout from "../../android/app/src/main/assets/default_layout.json" with { type: "json" };
export interface Payload {
label?: string | null;
package?: string | null;
provider?: string | null;
intent?: string | null;
radius?: number | null;
}
export interface LayoutItem {
id: string;
type: string;
x: number;
y: number;
w: number;
h: number;
z: number;
payload: Payload;
}
export interface Background {
type: string;
color?: string;
from?: string;
to?: string;
}
export interface Page { index: number; background: Background; items: LayoutItem[] }
export interface Layout {
schemaVersion: 3;
revision: number;
canvas: { designWidth: number; designHeight: number; safeTop: number; safeBottom: number };
fit: { mode: string; anchorY: number };
pages: Page[];
}
export interface Issue { level: "error" | "warning"; path: string; message: string }
export type Template = Pick<LayoutItem, "type" | "w" | "h" | "payload"> & { label: string };
export const templates: Template[] = [
{ type: "app_icon", label: "应用图标", w: 132, h: 168, payload: { package: "com.tencent.mm", label: "微信" } },
{ type: "app_icon", label: "相机", w: 132, h: 168, payload: { package: "com.android.camera", label: "相机" } },
{ type: "widget", label: "时钟组件", w: 864, h: 320, payload: { provider: "com.android.deskclock/.ClockWidget", label: "时钟" } },
{ type: "widget", label: "天气组件", w: 420, h: 300, payload: { provider: "com.android.weather/.WeatherWidget", label: "天气" } },
{ type: "widget", label: "音乐组件", w: 420, h: 300, payload: { provider: "com.spotify/.MusicWidget", label: "音乐" } },
{ type: "shortcut", label: "快捷方式", w: 132, h: 168, payload: { intent: "weixin://scanqrcode", label: "扫一扫" } },
{ type: "dock_bg", label: "Dock 底板", w: 936, h: 200, payload: { radius: 56 } },
];
export const devices = [
{ name: "16:9", w: 1080, h: 1920 },
{ name: "16:8", w: 1080, h: 2160 },
{ name: "19.5:9", w: 1080, h: 2340 },
{ name: "2K 20:9", w: 1440, h: 3120 },
{ name: "16:10", w: 1440, h: 2304 },
{ name: "平板 4:3", w: 1600, h: 2560 },
];
const canvasDefaults = { designWidth: 1080, designHeight: 1920, safeTop: 132, safeBottom: 72 };
const fitDefaults = { mode: "contain", anchorY: 0.5 };
const object = (value: unknown): value is Record<string, unknown> =>
typeof value === "object" && value !== null && !Array.isArray(value);
const finite = (value: unknown): value is number => typeof value === "number" && Number.isFinite(value);
const int = (value: unknown): value is number => finite(value) && Number.isInteger(value)
&& value >= -2147483648 && value <= 2147483647;
export function normalizeLayout(raw: unknown): Layout {
if (!object(raw) || (raw.schemaVersion !== undefined && raw.schemaVersion !== 3)) throw new Error("仅支持 v3 布局");
if (raw.canvas !== undefined && !object(raw.canvas) || raw.fit !== undefined && !object(raw.fit)) {
throw new Error("画布或映射字段格式不正确");
}
const canvas = { ...canvasDefaults, ...raw.canvas };
const fit = { ...fitDefaults, ...raw.fit };
if (!Object.keys(canvasDefaults).every(key => int(canvas[key as keyof typeof canvasDefaults]))
|| canvas.designWidth < 320 || canvas.designHeight < 480 || canvas.designWidth > 8192
|| canvas.designHeight > 8192 || typeof fit.mode !== "string" || !finite(fit.anchorY)) {
throw new Error("画布尺寸或映射参数无效");
}
if (raw.revision !== undefined && !int(raw.revision)) throw new Error("版本号必须是整数");
if (!Array.isArray(raw.pages) || !raw.pages.length || raw.pages.length > 20) throw new Error("布局必须包含 1–20 页");
const pages = raw.pages.map((page, index) => {
if (!object(page) || page.items !== undefined && (!Array.isArray(page.items) || page.items.length > 80)) {
throw new Error("第 " + (index + 1) + " 页的元素格式有误或超过 80 项");
}
if (page.background !== undefined && (!object(page.background) ||
page.background.type !== undefined && typeof page.background.type !== "string" ||
["color", "from", "to"].some(key => object(page.background) && page.background[key] != null && typeof page.background[key] !== "string"))) {
throw new Error("页面背景格式无效");
}
const items = (page.items ?? []) as unknown[];
return {
...page, index, background: { type: "wallpaper", ...page.background } as Background,
items: items.map(item => {
if (!object(item) || typeof item.id !== "string" || typeof item.type !== "string" ||
!finite(item.x) || !finite(item.y) || !finite(item.w) || !finite(item.h) ||
item.z !== undefined && !int(item.z)) {
throw new Error("元素 ID、类型、尺寸或层级格式无效");
}
const payload = item.payload === undefined ? {} : item.payload;
if (!object(payload) || ["label", "package", "provider", "intent"].some(
key => payload[key] != null && typeof payload[key] !== "string",
) || payload.radius != null && !int(payload.radius)) throw new Error("元素内容格式无效");
return { ...item, id: item.id, type: item.type, x: item.x, y: item.y, w: item.w, h: item.h,
z: item.z ?? 1, payload };
}),
};
});
return { ...raw, schemaVersion: 3, revision: raw.revision ?? 1, canvas, fit, pages };
}
export const builtInLayout = () => normalizeLayout(structuredClone(defaultLayout));
export const copyLayout = (layout: Layout): Layout => JSON.parse(JSON.stringify(layout));
export const sortedItems = (page: Page) => [...page.items].sort((a, b) => a.z - b.z);
export const clamp = (n: number, min: number, max: number) => Math.max(min, Math.min(max, n));
const color = (value: string | undefined) =>
typeof value === "string" && /^#(?:[\da-f]{6}|[\da-f]{3})$/i.test(value) ? value : "#151a22";
export function backgroundStyle(bg: Background) {
if (bg.type === "solid") return color(bg.color);
if (bg.type === "gradient") return "linear-gradient(" + color(bg.from) + "," + color(bg.to) + ")";
return undefined;
}
export function validate(layout: Layout): Issue[] {
const issues: Issue[] = [];
const { designWidth, designHeight, safeTop, safeBottom } = layout.canvas;
const add = (level: Issue["level"], path: string, message: string) => issues.push({ level, path, message });
if (safeTop < 0 || safeBottom < 0) add("error", "画布", "安全区不能为负数");
if (safeTop + safeBottom >= designHeight) add("warning", "画布", "安全区总和达到画布高度");
if (safeTop < 118) add("warning", "顶部安全区", "顶部安全区偏小,内容可能被状态栏遮挡");
if (safeBottom < 40) add("warning", "底部安全区", "底部安全区偏小,内容可能被手势条遮挡");
if (!["contain", "elastic", "stretch"].includes(layout.fit.mode)) add("warning", "映射策略", "手机会按等比居中处理");
if (layout.fit.anchorY < 0 || layout.fit.anchorY > 1) add("warning", "留白位置", "应在 0–1 之间");
layout.pages.forEach((page, index) => {
const ids = new Set<string>();
page.items.forEach((item, i) => {
const path = "第 " + (index + 1) + " 页 · " + (item.payload.label || item.id || (i + 1));
if (!item.id.trim() || ids.has(item.id)) add("error", path, "ID 为空或重复");
ids.add(item.id);
if (item.x < 0 || item.y < 0 || item.w <= 0 || item.h <= 0 ||
item.x + item.w > designWidth + 0.5 || item.y + item.h > designHeight + 0.5) {
add("error", path, "尺寸无效或元素超出画布");
}
if (item.type === "app_icon" && !item.payload.package?.trim()) add("error", path, "应用图标需要包名");
if (item.type === "widget" && !item.payload.provider?.includes("/")) add("error", path, "组件需填写包名/类名");
if (item.type === "shortcut" && !item.payload.intent?.trim()) add("warning", path, "快捷方式缺少 Intent");
if (!templates.some(template => template.type === item.type)) add("warning", path, "手机会跳过未知类型");
if (item.y < safeTop || item.y + item.h > designHeight - safeBottom) add("warning", path, "元素进入安全区");
if (item.type !== "dock_bg" && page.items.slice(i + 1).some(other => other.type !== "dock_bg" &&
item.x < other.x + other.w && item.x + item.w > other.x &&
item.y < other.y + other.h && item.y + item.h > other.y)) {
add("warning", path, "元素与同页其他元素重叠");
}
});
});
return issues;
}
export function deviceMapper(canvas: Layout["canvas"], fit: Layout["fit"], items: LayoutItem[], dev: typeof devices[number]) {
const sx = dev.w / canvas.designWidth;
const sy = dev.h / canvas.designHeight;
const mode = fit.mode.toLowerCase();
if (mode === "stretch") return { sx, sy, x: (x: number) => x * sx, y: (y: number) => y * sy };
const extra = dev.h - canvas.designHeight * sx;
if (mode === "elastic" && extra > 0.5) {
const bands: [number, number][] = [];
const spans = items.map(item => [item.y, item.y + item.h] as const).sort((a, b) => a[0] - b[0]);
for (const [top, bottom] of spans) {
const last = bands.at(-1);
if (last && top < last[1] - 0.5) last[1] = Math.max(last[1], bottom);
else bands.push([top, bottom]);
}
let previous = 0;
let cumulative = 0;
const gaps = bands.map(([top, bottom]) => {
cumulative += Math.max(0, top - previous);
previous = bottom;
return [top, cumulative] as const;
});
const totalBlank = cumulative + Math.max(0, canvas.designHeight - previous) || 1;
return {
sx, sy: sx,
x: (x: number) => x * sx,
y: (y: number) => {
let blank = 0;
for (const [top, offset] of gaps) {
if (y < top - 0.5) break;
blank = offset;
}
return y * sx + blank * extra / totalBlank;
},
};
}
const scale = Math.min(sx, sy);
const ox = (dev.w - canvas.designWidth * scale) / 2;
const oy = (dev.h - canvas.designHeight * scale) * clamp(fit.anchorY, 0, 1);
return { sx: scale, sy: scale, x: (x: number) => ox + x * scale, y: (y: number) => oy + y * scale };
}
export function iconColor(item: LayoutItem) {
let hue = 0;
for (const char of item.payload.package || item.payload.label || item.id) {
hue = (hue * 31 + char.charCodeAt(0)) % 360;
}
return "linear-gradient(150deg,hsl(" + hue + " 62% 56%),hsl(" + (hue + 25) + " 55% 34%))";
}
+8
View File
@@ -0,0 +1,8 @@
import { createApp } from "vue";
import "element-plus/theme-chalk/index.css";
import "element-plus/theme-chalk/dark/css-vars.css";
import "./styles.css";
import App from "./App.vue";
document.documentElement.classList.add("dark");
createApp(App).mount("#app");
+122
View File
@@ -0,0 +1,122 @@
:root {
color-scheme: dark;
font-family: system-ui, "Microsoft YaHei UI", sans-serif;
font-size: 14px;
color: #e0e8f2;
background: #10151e;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
#app { min-width: 320px; }
h1, h2, p, figure { margin: 0; }
h1 { font-size: 17px; white-space: nowrap; }
h2 { font-size: 13px; font-weight: 650; }
small { color: #9caec3; }
.toolbar {
display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
gap: 12px; padding: 14px 20px; border-bottom: 1px solid #2a3547; background: #161e2a;
}
.toolbar nav, .page-bar, .templates, .json-actions, .release-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar .el-button, .page-bar .el-button, .templates .el-button, .json-actions .el-button, .release-actions .el-button {
margin: 0;
}
.workspace {
display: grid; grid-template-columns: 224px minmax(0, 1fr) 348px;
height: calc(100dvh - 54px); min-height: 610px;
}
.settings, .inspector { overflow: auto; background: #151d29; }
.settings { border-right: 1px solid #2a3547; }
.settings section { display: grid; gap: 10px; padding: 16px; border-bottom: 1px solid #2a3547; }
.settings .el-checkbox { margin: 0; height: auto; }
.settings label, .item-properties label, .token-field {
display: grid; gap: 5px; font-size: 12px; color: #b7c5d7;
}
.settings label.el-checkbox { display: inline-flex; }
.settings .el-input-number, .item-properties .el-input-number { width: 100%; }
.settings input[type=color] { width: 100%; height: 28px; cursor: pointer; }
.editor { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.canvas-head {
display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 12px 16px;
color: #aebed0; border-bottom: 1px solid #2a3547;
}
.canvas-head strong { color: #e0e8f2; }
.hint { margin-left: auto; font-size: 12px; }
.stage {
flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden;
background: radial-gradient(ellipse at center, #222e42, #10151e 75%);
}
.layout-surface {
position: relative; overflow: hidden; width: 100%; container-type: inline-size;
isolation: isolate; background: linear-gradient(155deg, #263748, #141b2b 68%);
outline: 1px solid #42536b; border-radius: 5px;
}
.layout-surface.editable { touch-action: none; user-select: none; box-shadow: 0 12px 36px #050b16a6; }
.layout-surface.with-guides::before {
content: ""; position: absolute; inset: 0; pointer-events: none;
background: linear-gradient(#b3c8ea12 1px, transparent 1px), linear-gradient(90deg, #b3c8ea12 1px, transparent 1px);
background-size: 8.333% 5%;
}
.safe-zone { position: absolute; left: 0; right: 0; pointer-events: none; background: #4b9cf22a; }
.safe-zone.top { top: 0; border-bottom: 1px dashed #79b9fc; }
.safe-zone.bottom { bottom: 0; border-top: 1px dashed #79b9fc; }
.layout-item {
position: absolute; display: flex; align-items: center; justify-content: center; flex-direction: column;
min-width: 0; min-height: 0; padding: 0; color: #f4f8fb; overflow: hidden;
}
.editable .layout-item { cursor: grab; }
.layout-item.selected, .editable .layout-item:focus-visible { outline: 1px solid #7bc2ff; outline-offset: -1px; }
.layout-item.widget { background: #6f91b442; border: 1px solid #9ab6d267; border-radius: 1.6cqw; }
.layout-item.dock_bg { background: #b0bfdd30; border: 1px solid #a3b8d44a; }
.icon-art {
display: grid; place-items: center; width: 74%; max-width: 15cqw; aspect-ratio: 1;
border-radius: 26%; background: var(--icon-fill); font-size: 4cqw; font-weight: bold;
}
.icon-label, .widget-label {
font-size: 2.55cqw; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.widget-label { font-size: 3.1cqw; }
.resize-handle {
position: absolute; inset: auto 0 0 auto; width: 11px; height: 11px;
background: #a2d0fa; border-radius: 3px 0 0 0; cursor: nwse-resize; opacity: 0;
}
.selected > .resize-handle, .layout-item:hover > .resize-handle, .layout-item:focus-visible > .resize-handle { opacity: 1; }
.page-bar { border-top: 1px solid #2a3547; padding: 10px 12px; background: #161e2a; }
.inspector { border-left: 1px solid #2a3547; padding: 0 12px 12px; }
.previews { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px 12px; }
.previews figure { display: flex; align-items: center; flex-direction: column; justify-content: flex-end; gap: 8px; }
.previews figcaption { text-align: center; font-size: 12px; }
.previews small, .release-history small { display: block; font-size: 11px; }
.item-properties { display: grid; gap: 10px; }
.property-input {
width: 100%; height: 24px; padding: 0 8px; border: 1px solid var(--el-border-color);
border-radius: 4px; color: var(--el-text-color-regular); background: var(--el-fill-color-blank);
}
.property-input:focus { outline: 1px solid var(--el-color-primary); }
.empty { color: #9caec3; padding: 10px 0; }
.issues, .release-history { list-style: none; padding: 0; margin: 8px 0; }
.issues li { display: grid; gap: 4px; margin-bottom: 8px; padding: 8px; border-left: 2px solid #d7a754; }
.issues li.error { border-color: #f17c7c; }
pre { color: #a7ccea; font-size: 11px; max-width: 100%; overflow: auto; }
.release-actions { margin: 12px 0; }
.release-status { display: block; white-space: pre-wrap; margin-bottom: 12px; }
.release-error { color: #f49797; }
.release-history { max-height: 38vh; overflow: auto; }
.release-history li {
display: flex; gap: 10px; align-items: center; justify-content: space-between;
padding: 8px 0; border-top: 1px solid #394254;
}
@media (max-width: 1120px) {
.workspace { grid-template-columns: 188px minmax(0, 1fr) 288px; }
.hint { margin-left: 0; }
}
@media (max-width: 820px) {
.workspace { height: auto; grid-template-columns: 180px minmax(0, 1fr); }
.editor { min-height: 550px; }
.inspector { grid-column: 1 / -1; }
.previews { grid-template-columns: repeat(auto-fit, minmax(85px, 120px)); }
}
@media (max-width: 540px) {
.workspace { display: flex; flex-direction: column; }
.editor { order: -1; min-height: 520px; }
.settings { display: grid; grid-template-columns: 1fr 1fr; }
}
+41
View File
@@ -0,0 +1,41 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { runInNewContext } from "node:vm";
import { normalizeLayout, validate } from "./src/layout.ts";
const fixtures = JSON.parse(readFileSync(new URL("../docs/layout-cases.json", import.meta.url), "utf8"));
const offline = readFileSync(new URL("./canvas.html", import.meta.url), "utf8");
const offlineFunction = name => {
const start = offline.indexOf("function " + name + "(");
const end = offline.indexOf("\n}", start) + 2;
assert.ok(start >= 0 && end > start, name);
return offline.slice(start, end);
};
for (const { name, accepted, layout } of fixtures) {
let editorAccepted;
try {
editorAccepted = !validate(normalizeLayout(layout)).some(issue => issue.level === "error");
} catch {
editorAccepted = false;
}
assert.equal(editorAccepted, accepted, "Vue editor: " + name);
const offlineAccepted = runInNewContext(`
let state, activePage, selectedId;
function pushHistory() {}
function syncControls() {}
function fitCanvas() {}
function render() {}
${offlineFunction("importLayout")}
${offlineFunction("validate")}
try {
importLayout(layout);
validate().errors === 0;
} catch {
false;
}
`, { layout });
assert.equal(offlineAccepted, accepted, "Offline editor: " + name);
}
console.log(`${fixtures.length} shared cases passed in both editors`);
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"lib": [
"ES2022",
"DOM",
"DOM.Iterable"
],
"types": [
"vite/client",
"node"
]
},
"include": [
"src/**/*.ts",
"src/**/*.vue",
"vite.config.ts"
]
}
+13
View File
@@ -0,0 +1,13 @@
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const proxy = { "/api": { target: env.LAUNCHER_API_TARGET || "http://127.0.0.1:8080" } };
return {
base: "./",
plugins: [vue()],
server: { proxy },
preview: { proxy },
};
});