feat: 增加配置界面;增加沟通是行程需求,生成方案

master
Lxy 1 week ago
parent 025d61902a
commit aaa7679eb1

3
.gitignore vendored

@ -22,3 +22,6 @@ dist-ssr
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
# Server config (contains API keys)
.config/

813
package-lock.json generated

@ -8,6 +8,7 @@
"name": "trip-planner", "name": "trip-planner",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"express": "^4.22.2",
"leaflet": "^1.9.4", "leaflet": "^1.9.4",
"pinia": "^3.0.4", "pinia": "^3.0.4",
"sortablejs": "^1.15.7", "sortablejs": "^1.15.7",
@ -966,6 +967,25 @@
"integrity": "sha512-zSbjL7gRXwks2ZQLRGCajBtBXEOXW9Ddhn/HvSdrGkE2dqGnumzW8XtusRrxrE9LvqtiqDXQ+A60Hp6mvdYxfA==", "integrity": "sha512-zSbjL7gRXwks2ZQLRGCajBtBXEOXW9Ddhn/HvSdrGkE2dqGnumzW8XtusRrxrE9LvqtiqDXQ+A60Hp6mvdYxfA==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
"license": "MIT"
},
"node_modules/birpc": { "node_modules/birpc": {
"version": "2.9.0", "version": "2.9.0",
"resolved": "https://registry.npmjs.org/birpc/-/birpc-2.9.0.tgz", "resolved": "https://registry.npmjs.org/birpc/-/birpc-2.9.0.tgz",
@ -975,6 +995,104 @@
"url": "https://github.com/sponsors/antfu" "url": "https://github.com/sponsors/antfu"
} }
}, },
"node_modules/body-parser": {
"version": "1.20.5",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.5.tgz",
"integrity": "sha512-3grm+/2tUOvu2cjJkvsIxrv/wVpfXQW4PsQHYm7yk4vfpu7Ekl6nEsYBoJUL6qDwZUx8wUhQ8tR2qz+ad9c9OA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "~1.2.0",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"on-finished": "~2.4.1",
"qs": "~6.15.1",
"raw-body": "~2.5.3",
"type-is": "~1.6.18",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
"license": "MIT"
},
"node_modules/copy-anything": { "node_modules/copy-anything": {
"version": "4.0.5", "version": "4.0.5",
"resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-4.0.5.tgz", "resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-4.0.5.tgz",
@ -996,6 +1114,63 @@
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"license": "MIT",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/entities": { "node_modules/entities": {
"version": "7.0.1", "version": "7.0.1",
"resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz", "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz",
@ -1008,6 +1183,36 @@
"url": "https://github.com/fb55/entities?sponsor=1" "url": "https://github.com/fb55/entities?sponsor=1"
} }
}, },
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
"integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/esbuild": { "node_modules/esbuild": {
"version": "0.21.5", "version": "0.21.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
@ -1047,12 +1252,109 @@
"@esbuild/win32-x64": "0.21.5" "@esbuild/win32-x64": "0.21.5"
} }
}, },
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/estree-walker": { "node_modules/estree-walker": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.22.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.22.2.tgz",
"integrity": "sha512-IuL+Elrou2ZvCFHs18/CIzy2Nzvo25nZ1/D2eIZlz7c+QUayAcYoiM2BthCjs+EBHVpjYjcuLDAiCWgeIX3X1Q==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "~1.20.5",
"content-disposition": "~0.5.4",
"content-type": "~1.0.4",
"cookie": "~0.7.1",
"cookie-signature": "~1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.3.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "~0.1.12",
"proxy-addr": "~2.0.7",
"qs": "~6.15.1",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "~0.19.0",
"serve-static": "~1.16.2",
"setprototypeof": "1.2.0",
"statuses": "~2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/finalhandler": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"statuses": "~2.0.2",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fsevents": { "node_modules/fsevents": {
"version": "2.3.3", "version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@ -1068,12 +1370,141 @@
"node": "^8.16.0 || ^10.6.0 || >=11.0.0" "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
} }
}, },
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
"integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/hookable": { "node_modules/hookable": {
"version": "5.5.3", "version": "5.5.3",
"resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz", "resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz",
"integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==", "integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/is-what": { "node_modules/is-what": {
"version": "5.5.0", "version": "5.5.0",
"resolved": "https://registry.npmjs.org/is-what/-/is-what-5.5.0.tgz", "resolved": "https://registry.npmjs.org/is-what/-/is-what-5.5.0.tgz",
@ -1101,12 +1532,87 @@
"@jridgewell/sourcemap-codec": "^1.5.5" "@jridgewell/sourcemap-codec": "^1.5.5"
} }
}, },
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"license": "MIT",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mitt": { "node_modules/mitt": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz",
"integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==", "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
"node_modules/nanoid": { "node_modules/nanoid": {
"version": "3.3.12", "version": "3.3.12",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.12.tgz", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.12.tgz",
@ -1125,6 +1631,54 @@
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
} }
}, },
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
"integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
"license": "MIT"
},
"node_modules/perfect-debounce": { "node_modules/perfect-debounce": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-1.0.0.tgz", "resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-1.0.0.tgz",
@ -1186,6 +1740,58 @@
"node": "^10 || ^12 || >=14" "node": "^10 || ^12 || >=14"
} }
}, },
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.15.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
"integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.1.0"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/rfdc": { "node_modules/rfdc": {
"version": "1.4.1", "version": "1.4.1",
"resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz",
@ -1237,6 +1843,155 @@
"fsevents": "~2.3.2" "fsevents": "~2.3.2"
} }
}, },
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.1",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "~2.4.1",
"range-parser": "~1.2.1",
"statuses": "~2.0.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/serve-static": {
"version": "1.16.3",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "~0.19.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/sortablejs": { "node_modules/sortablejs": {
"version": "1.15.7", "version": "1.15.7",
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.15.7.tgz", "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.15.7.tgz",
@ -1261,6 +2016,15 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/superjson": { "node_modules/superjson": {
"version": "2.2.6", "version": "2.2.6",
"resolved": "https://registry.npmjs.org/superjson/-/superjson-2.2.6.tgz", "resolved": "https://registry.npmjs.org/superjson/-/superjson-2.2.6.tgz",
@ -1273,6 +2037,55 @@
"node": ">=16" "node": ">=16"
} }
}, },
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"license": "MIT",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/vite": { "node_modules/vite": {
"version": "5.4.21", "version": "5.4.21",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz",

@ -4,11 +4,12 @@
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "node server.js",
"build": "vite build", "build": "vite build",
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"express": "^4.22.2",
"leaflet": "^1.9.4", "leaflet": "^1.9.4",
"pinia": "^3.0.4", "pinia": "^3.0.4",
"sortablejs": "^1.15.7", "sortablejs": "^1.15.7",

@ -0,0 +1,219 @@
import express from 'express'
import { createServer as createViteServer } from 'vite'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const CONFIG_DIR = path.join(__dirname, '.config')
const CONFIG_FILE = path.join(CONFIG_DIR, 'ai-config.json')
// Ensure config directory exists
if (!fs.existsSync(CONFIG_DIR)) {
fs.mkdirSync(CONFIG_DIR, { recursive: true })
}
// Load config from file
function loadConfig() {
try {
if (fs.existsSync(CONFIG_FILE)) {
return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'))
}
} catch (e) {
console.error('Failed to load config:', e)
}
return {
provider: 'aliyun',
apiKey: '',
model: 'qwen3.6-plus',
baseUrl: 'https://coding.dashscope.aliyuncs.com/v1',
temperature: 0.7,
maxTokens: 8000
}
}
// Save config to file
function saveConfig(config) {
try {
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf-8')
return true
} catch (e) {
console.error('Failed to save config:', e)
return false
}
}
const app = express()
app.use(express.json())
// API: Get config
app.get('/api/config', (req, res) => {
const config = loadConfig()
// Don't expose full API key in GET request
res.json({
...config,
apiKey: config.apiKey ? config.apiKey.slice(0, 8) + '********' : ''
})
})
// API: Check if API key is configured
app.get('/api/config/check', (req, res) => {
const config = loadConfig()
res.json({ configured: !!config.apiKey })
})
// API: Update config
app.post('/api/config', (req, res) => {
const currentConfig = loadConfig()
const updates = req.body
// If updating API key, use the new value; otherwise keep existing
const newConfig = {
...currentConfig,
...updates,
apiKey: updates.apiKey || currentConfig.apiKey
}
if (saveConfig(newConfig)) {
res.json({ success: true })
} else {
res.status(500).json({ success: false, message: 'Failed to save config' })
}
})
// API: Test connection
app.post('/api/config/test', async (req, res) => {
const { apiKey, model, baseUrl } = req.body
const config = loadConfig()
const testApiKey = apiKey || config.apiKey
const testModel = model || config.model
const testBaseUrl = baseUrl || config.baseUrl
if (!testApiKey) {
return res.json({ success: false, message: '请先输入 API Key' })
}
try {
const response = await fetch(`${testBaseUrl}/chat/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${testApiKey}`
},
body: JSON.stringify({
model: testModel,
messages: [{ role: 'user', content: '你好请回复OK' }],
max_tokens: 10
})
})
const data = await response.json()
if (response.ok && data.choices) {
res.json({ success: true, message: `连接成功!模型: ${data.model || testModel}` })
} else {
res.json({ success: false, message: data.error?.message || '连接失败' })
}
} catch (error) {
res.json({ success: false, message: `网络错误: ${error.message}` })
}
})
// API: Proxy AI chat request (keeps API key on server)
app.post('/api/chat', async (req, res) => {
const config = loadConfig()
if (!config.apiKey) {
return res.status(401).json({ error: { message: '请先配置 AI API Key访问 /settings' } })
}
// Handle client disconnect
let clientDisconnected = false
req.on('close', () => { clientDisconnected = true })
try {
const response = await fetch(`${config.baseUrl}/chat/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${config.apiKey}`
},
body: JSON.stringify({
...req.body,
model: req.body.model || config.model,
temperature: req.body.temperature ?? config.temperature,
max_tokens: req.body.max_tokens || config.maxTokens,
response_format: { type: 'json_object' }
})
})
if (!response.ok) {
const error = await response.json().catch(() => ({}))
return res.status(response.status).json(error)
}
// Stream the response to client
res.setHeader('Content-Type', 'text/event-stream')
res.setHeader('Cache-Control', 'no-cache')
res.setHeader('Connection', 'keep-alive')
res.setHeader('X-Accel-Buffering', 'no')
const reader = response.body.getReader()
const decoder = new TextDecoder()
while (true) {
if (clientDisconnected) {
reader.cancel()
return
}
const { done, value } = await reader.read()
if (done) break
const chunk = decoder.decode(value, { stream: true })
try {
res.write(chunk)
} catch (e) {
// Client disconnected, stop writing
reader.cancel()
return
}
}
res.end()
} catch (error) {
if (!clientDisconnected) {
res.status(500).json({ error: { message: `请求失败: ${error.message}` } })
}
}
})
async function start() {
const isDev = process.env.NODE_ENV !== 'production'
if (isDev) {
// Development: use Vite middleware
const vite = await createViteServer({
server: { middlewareMode: true },
appType: 'spa'
})
app.use(vite.middlewares)
const port = 5173
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`)
console.log(`API Key stored in: ${CONFIG_FILE}`)
})
} else {
// Production: serve static files
app.use(express.static(path.join(__dirname, 'dist')))
const port = process.env.PORT || 3000
app.listen(port, () => {
console.log(`Server running on port ${port}`)
})
}
}
start()

@ -11,24 +11,42 @@
<div class="avatar">🤖</div> <div class="avatar">🤖</div>
<div class="bubble"> <div class="bubble">
你好我是你的行程规划助手请告诉我<br/> 你好我是你的行程规划助手请告诉我<br/>
想去哪里<br/> 想去哪里单个地点或多个地点组合<br/>
几月出发<br/> 几月出发几天行程<br/>
几天行程<br/>
交通方式自驾/公共交通/步行<br/> 交通方式自驾/公共交通/步行<br/>
有什么特殊需求带老人/小孩/特定景点 有什么特殊需求带老人/小孩/特定景点<br/>
<br/>
<span class="example">示例9月去云南5自驾带老人</span><br/>
<span class="example">示例成都-九寨沟-重庆7天自驾游</span>
</div> </div>
</div> </div>
<div v-for="(msg, i) in messages" :key="i" class="message" :class="msg.role"> <div v-for="(msg, i) in messages" :key="i" class="message" :class="msg.role">
<div class="avatar">{{ msg.role === 'user' ? '👤' : '🤖' }}</div> <div class="avatar">{{ msg.role === 'user' ? '👤' : '🤖' }}</div>
<div class="bubble">{{ msg.content }}</div> <div class="bubble">
<!-- Show thinking process for bot messages -->
<div v-if="msg.thinking" class="thinking-process" :class="{ expanded: msg.thinkingExpanded }">
<div class="thinking-header" @click="msg.thinkingExpanded = !msg.thinkingExpanded">
<span class="thinking-icon">🧠</span>
<span>AI 思考过程</span>
<span class="thinking-toggle">{{ msg.thinkingExpanded ? '收起' : '展开' }}</span>
</div>
<div class="thinking-content">{{ msg.thinking }}</div>
</div>
<div class="message-content">{{ msg.content }}</div>
<!-- Error message -->
<div v-if="msg.error" class="error-hint">
💡 {{ msg.error }}
</div>
</div>
</div> </div>
<!-- Loading indicator -->
<div v-if="isGenerating" class="message bot"> <div v-if="isGenerating" class="message bot">
<div class="avatar">🤖</div> <div class="avatar">🤖</div>
<div class="bubble thinking"> <div class="bubble thinking">
<span class="dot"></span><span class="dot"></span><span class="dot"></span> <span class="dot"></span><span class="dot"></span><span class="dot"></span>
正在生成方案... {{ thinkingStatus }}
</div> </div>
</div> </div>
</div> </div>
@ -38,15 +56,18 @@
<input <input
v-model="inputText" v-model="inputText"
@keyup.enter="sendMessage" @keyup.enter="sendMessage"
placeholder="例如9月去云南5天自驾带老人" placeholder="例如9月去云南5天自驾"
:disabled="isGenerating"
/> />
<button @click="sendMessage" :disabled="!inputText.trim() || isGenerating">发送</button> <button @click="sendMessage" :disabled="!inputText.trim() || isGenerating">
{{ isGenerating ? '生成中...' : '发送' }}
</button>
</div> </div>
<!-- Scheme cards (appear after AI response) --> <!-- Scheme cards (appear after AI response) -->
<transition name="slide-up"> <transition name="slide-up">
<div v-if="showCards" class="scheme-cards"> <div v-if="schemes.length > 0" class="scheme-cards">
<h3>📋 为你生成了 3 个方案</h3> <h3>📋 为你生成了 {{ schemes.length }} 个方案</h3>
<div class="cards-grid"> <div class="cards-grid">
<div <div
v-for="(scheme, i) in schemes" v-for="(scheme, i) in schemes"
@ -55,21 +76,22 @@
@click="selectScheme(i)" @click="selectScheme(i)"
> >
<div class="card-header"> <div class="card-header">
<span class="card-badge">{{ scheme.badge }}</span> <span class="card-badge">{{ '方案' + String.fromCharCode(65 + i) }}</span>
<h4>{{ scheme.name }}</h4> <h4>{{ scheme.name }}</h4>
</div> </div>
<div class="card-stats"> <div class="card-stats">
<span>🚗 {{ scheme.km }}</span> <span>🚗 ~{{ scheme.totalKm }}km</span>
<span> {{ scheme.driveTime }}</span> <span> {{ scheme.totalDriveTime }}h</span>
<span>📅 {{ scheme.days }}</span>
<span>💰 {{ scheme.budget }}</span> <span>💰 {{ scheme.budget }}</span>
</div> </div>
<div class="card-highlights"> <div class="card-highlights">
<span v-for="(h, j) in scheme.highlights" :key="j" class="highlight-tag">{{ h }}</span> <span v-for="(h, j) in scheme.highlights" :key="j" class="highlight-tag">{{ h }}</span>
</div> </div>
<div class="card-mini-map"> <div class="card-route">
<span>🗺 {{ routePreview(i) }}</span> <span>🗺 {{ scheme.route }}</span>
</div> </div>
<div class="card-action">选择此方案 </div> <div class="card-action">选择此方案进入工作台 </div>
</div> </div>
</div> </div>
</div> </div>
@ -80,44 +102,14 @@
<script setup> <script setup>
import { ref, nextTick } from 'vue' import { ref, nextTick } from 'vue'
import { useItineraryStore } from '../stores/itinerary' import { useItineraryStore } from '../stores/itinerary'
import { chatWithAI } from '../services/aiService'
const store = useItineraryStore() const store = useItineraryStore()
const messages = ref([]) const messages = ref([])
const inputText = ref('') const inputText = ref('')
const isGenerating = ref(false) const isGenerating = ref(false)
const showCards = ref(false) const schemes = ref([])
const thinkingStatus = ref('正在分析需求...')
const schemes = ref([
{
badge: '方案A',
name: '经典环线:昆明-普者黑-大理-丽江',
km: '~1450km',
driveTime: '14h',
budget: '¥4000',
highlights: ['喀斯特地貌', '苍山洱海', '古城文化', '玉龙雪山'],
route: '昆明 → 普者黑 → 坝美 → 大理 → 丽江'
},
{
badge: '方案B',
name: '南线深度:昆明-建水-元阳-普者黑',
km: '~980km',
driveTime: '11h',
budget: '¥3200',
highlights: ['元阳梯田', '建水古城', '抚仙湖', '少打卡多体验'],
route: '昆明 → 抚仙湖 → 建水 → 元阳 → 普者黑'
},
{
badge: '方案C',
name: '西线探险:昆明-大理-沙溪-香格里拉',
km: '~1200km',
driveTime: '16h',
budget: '¥4800',
highlights: ['茶马古道', '高原秘境', '松赞林寺', '纳帕海'],
route: '昆明 → 大理 → 沙溪 → 香格里拉 → 返程'
}
])
const routePreview = (i) => schemes.value[i].route
const messagesContainer = ref(null) const messagesContainer = ref(null)
@ -134,24 +126,65 @@ const sendMessage = async () => {
const userMsg = inputText.value.trim() const userMsg = inputText.value.trim()
messages.value.push({ role: 'user', content: userMsg }) messages.value.push({ role: 'user', content: userMsg })
inputText.value = '' inputText.value = ''
schemes.value = []
await scrollToBottom() await scrollToBottom()
isGenerating.value = true isGenerating.value = true
thinkingStatus.value = '正在分析需求...'
try {
let thinkingContent = ''
const result = await chatWithAI(userMsg, (streamContent) => {
// Parse streaming content for thinking
thinkingContent = streamContent
// Update thinking status based on progress
if (streamContent.includes('thinking')) {
thinkingStatus.value = '🧠 AI 正在思考并搜索目的地信息...'
} else if (streamContent.includes('schemes')) {
thinkingStatus.value = '📋 正在生成旅行方案...'
} else if (streamContent.includes('points')) {
thinkingStatus.value = '📍 正在规划详细行程...'
}
})
// Simulate AI response isGenerating.value = false
setTimeout(async () => {
// Add bot response message with thinking process
const botMsg = {
role: 'bot',
content: `已为你生成 ${result.schemes.length} 个方案,请查看下方卡片。\n\n${result.schemes.map((s, i) => `【方案${String.fromCharCode(65 + i)}${s.name}\n路线${s.route}\n${s.days}天 · ${s.totalKm}km · ${s.budget}`).join('\n\n')}`,
thinking: result.thinking,
thinkingExpanded: false
}
messages.value.push(botMsg)
// Set schemes for card display
schemes.value = result.schemes
await scrollToBottom()
} catch (error) {
isGenerating.value = false isGenerating.value = false
messages.value.push({ messages.value.push({
role: 'bot', role: 'bot',
content: `根据你的需求"${userMsg}"我为你精心设计了以下3个方案。每个方案在路线、体验和预算上有所侧重请点击方案卡片进入对比页面。` content: '抱歉,生成方案时遇到了问题。',
error: error.message.includes('API Key')
? '请先访问 /settings 配置你的 AI API Key'
: error.message + ',请重试'
}) })
showCards.value = true
await scrollToBottom() await scrollToBottom()
}, 2000) }
} }
const selectScheme = (index) => { const selectScheme = (index) => {
store.setPhase('comparison') const scheme = schemes.value[index]
if (!scheme) return
// Load the selected scheme into the itinerary store
store.loadFromAI(scheme)
store.setPhase('workbench')
} }
</script> </script>
@ -171,16 +204,8 @@ const selectScheme = (index) => {
color: #fff; color: #fff;
} }
.chat-header h1 { .chat-header h1 { margin: 0 0 8px; font-size: 24px; }
margin: 0 0 8px; .chat-header p { margin: 0; opacity: 0.8; font-size: 14px; }
font-size: 24px;
}
.chat-header p {
margin: 0;
opacity: 0.8;
font-size: 14px;
}
.chat-messages { .chat-messages {
flex: 1; flex: 1;
@ -194,7 +219,7 @@ const selectScheme = (index) => {
.message { .message {
display: flex; display: flex;
gap: 12px; gap: 12px;
max-width: 80%; max-width: 85%;
} }
.message.bot { align-self: flex-start; } .message.bot { align-self: flex-start; }
@ -218,7 +243,7 @@ const selectScheme = (index) => {
padding: 12px 16px; padding: 12px 16px;
border-radius: 16px; border-radius: 16px;
font-size: 14px; font-size: 14px;
line-height: 1.5; line-height: 1.6;
} }
.message.bot .bubble { .message.bot .bubble {
@ -233,6 +258,68 @@ const selectScheme = (index) => {
border-bottom-right-radius: 4px; border-bottom-right-radius: 4px;
} }
.example {
opacity: 0.8;
font-size: 13px;
}
/* Thinking process */
.thinking-process {
margin-bottom: 10px;
border: 1px solid #e0e0e0;
border-radius: 8px;
overflow: hidden;
}
.thinking-header {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
background: #f8f9fa;
cursor: pointer;
font-size: 13px;
color: #666;
user-select: none;
}
.thinking-header:hover { background: #f0f0f0; }
.thinking-toggle {
margin-left: auto;
font-size: 12px;
color: #999;
}
.thinking-content {
padding: 12px;
font-size: 13px;
color: #555;
line-height: 1.6;
max-height: 200px;
overflow-y: auto;
background: #fafafa;
}
.thinking-process:not(.expanded) .thinking-content {
display: none;
}
/* Error hint */
.error-hint {
margin-top: 8px;
padding: 8px 12px;
background: #fff3cd;
border-radius: 6px;
font-size: 12px;
color: #856404;
}
.message-content {
white-space: pre-wrap;
}
/* Loading */
.thinking { .thinking {
display: flex; display: flex;
align-items: center; align-items: center;
@ -255,6 +342,7 @@ const selectScheme = (index) => {
40% { opacity: 1; transform: scale(1); } 40% { opacity: 1; transform: scale(1); }
} }
/* Input */
.chat-input-area { .chat-input-area {
display: flex; display: flex;
gap: 8px; gap: 8px;
@ -274,6 +362,7 @@ const selectScheme = (index) => {
} }
.chat-input-area input:focus { border-color: #2a9d8f; } .chat-input-area input:focus { border-color: #2a9d8f; }
.chat-input-area input:disabled { background: #f5f5f5; cursor: not-allowed; }
.chat-input-area button { .chat-input-area button {
padding: 12px 24px; padding: 12px 24px;
@ -299,6 +388,8 @@ const selectScheme = (index) => {
border-radius: 16px; border-radius: 16px;
padding: 20px; padding: 20px;
box-shadow: 0 -4px 20px rgba(0,0,0,0.1); box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
max-height: 60vh;
overflow-y: auto;
} }
.scheme-cards h3 { .scheme-cards h3 {
@ -350,8 +441,9 @@ const selectScheme = (index) => {
} }
.card-stats { .card-stats {
display: flex; display: grid;
gap: 12px; grid-template-columns: 1fr 1fr;
gap: 4px;
margin-bottom: 8px; margin-bottom: 8px;
font-size: 12px; font-size: 12px;
color: #666; color: #666;
@ -372,7 +464,7 @@ const selectScheme = (index) => {
font-size: 11px; font-size: 11px;
} }
.card-mini-map { .card-route {
font-size: 11px; font-size: 11px;
color: #888; color: #888;
margin-bottom: 12px; margin-bottom: 12px;
@ -396,4 +488,10 @@ const selectScheme = (index) => {
transform: translateY(20px); transform: translateY(20px);
opacity: 0; opacity: 0;
} }
@media (max-width: 900px) {
.cards-grid {
grid-template-columns: 1fr;
}
}
</style> </style>

@ -0,0 +1,140 @@
const SYSTEM_PROMPT = `你是一个专业的旅行规划助手。你需要根据用户的需求规划行程。
## 重要输出格式
你必须直接输出 JSON不要包含任何 markdown 代码块标记 \`\`\`json不要在 JSON 前后添加任何额外文字。
JSON 格式如下
{
"thinking": "你的思考过程",
"schemes": [
{
"name": "方案名称",
"route": "路线描述",
"days": 4,
"totalKm": 1200,
"totalDriveTime": 12,
"budget": "¥3000",
"highlights": ["亮点1", "亮点2"],
"points": [
{
"name": "地点名称",
"lat": 25.04,
"lng": 102.71,
"day": "Day 1",
"badge": "START",
"icon": "🏙️",
"desc": "简短描述",
"km": "0km",
"driveTime": "—",
"schedule": [{"time": "上午", "content": "行程"}],
"foods": ["美食"],
"hotel": "住宿",
"tips": "注意事项"
}
]
}
]
}
注意
1. points 第一个用 START badge中间用 D1/D2最后一个用 END
2. lat/lng 必须是真实中国地理坐标
3. 至少 2 个方案最多 3
4. 直接输出 JSON不要其他内容`
export async function chatWithAI(userMessage, onThinking = null) {
const response = await fetch('/api/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
messages: [
{ role: 'system', content: SYSTEM_PROMPT },
{ role: 'user', content: userMessage }
],
stream: true
})
})
if (!response.ok) {
const error = await response.json().catch(() => ({}))
throw new Error(error.error?.message || `API 请求失败: ${response.status}`)
}
const reader = response.body.getReader()
const decoder = new TextDecoder()
let fullContent = ''
let buffer = ''
while (true) {
const { done, value } = await reader.read()
if (done) break
buffer += decoder.decode(value, { stream: true })
const lines = buffer.split('\n')
buffer = lines.pop() || ''
for (const line of lines) {
const trimmed = line.trim()
if (!trimmed || !trimmed.startsWith('data:')) continue
const data = trimmed.slice(5).trim()
if (data === '[DONE]') break
try {
const parsed = JSON.parse(data)
const chunk = parsed.choices?.[0]?.delta?.content || ''
if (chunk) {
fullContent += chunk
if (onThinking) onThinking(fullContent)
}
} catch (e) {
// Skip malformed JSON chunks
}
}
}
return parseAIResponse(fullContent)
}
function parseAIResponse(content) {
// Remove markdown code block markers if present
let cleaned = content.trim()
// Remove ```json ... ``` or ``` ... ```
const codeBlockMatch = cleaned.match(/```(?:json)?\s*([\s\S]*?)```/)
if (codeBlockMatch) {
cleaned = codeBlockMatch[1].trim()
}
// Remove any <thinking>...</thinking> tags
cleaned = cleaned.replace(/<thinking>[\s\S]*?<\/thinking>/g, '').trim()
// Try to find JSON object
// Find the first { and last } to extract the JSON
const firstBrace = cleaned.indexOf('{')
const lastBrace = cleaned.lastIndexOf('}')
if (firstBrace === -1 || lastBrace === -1 || lastBrace <= firstBrace) {
throw new Error('AI 未返回有效的 JSON 数据')
}
const jsonStr = cleaned.substring(firstBrace, lastBrace + 1)
try {
const parsed = JSON.parse(jsonStr)
// Validate required fields
if (!parsed.schemes || !Array.isArray(parsed.schemes) || parsed.schemes.length === 0) {
throw new Error('AI 返回结果缺少 schemes')
}
return parsed
} catch (e) {
if (e.message.includes('缺少 schemes')) throw e
console.error('JSON parse error:', e)
console.error('Raw content:', cleaned.substring(0, 200))
throw new Error('AI 返回的 JSON 格式有误,请重试')
}
}

@ -0,0 +1,77 @@
// Geocoding service using OpenStreetMap Nominatim
const NOMINATIM_BASE = 'https://nominatim.openstreetmap.org'
export async function geocode(placeName) {
const url = `${NOMINATIM_BASE}/search?q=${encodeURIComponent(placeName + ', China')}&format=json&limit=1`
try {
const response = await fetch(url, {
headers: { 'User-Agent': 'TripPlanner/1.0' }
})
const data = await response.json()
if (data.length > 0) {
return {
lat: parseFloat(data[0].lat),
lng: parseFloat(data[0].lon),
displayName: data[0].display_name
}
}
return null
} catch (e) {
console.warn('Geocoding failed:', e)
return null
}
}
export async function geocodeBatch(placeNames) {
const results = {}
for (const name of placeNames) {
const result = await geocode(name)
if (result) {
results[name] = result
}
// Small delay to respect Nominatim rate limiting (1 req/s)
await new Promise(r => setTimeout(r, 1100))
}
return results
}
// Known Chinese tourist destinations with coordinates (fallback cache)
const KNOWN_PLACES = {
'昆明': { lat: 25.04, lng: 102.71 },
'大理': { lat: 25.69, lng: 100.26 },
'丽江': { lat: 26.87, lng: 100.23 },
'香格里拉': { lat: 27.83, lng: 99.70 },
'普者黑': { lat: 24.12, lng: 104.12 },
'坝美': { lat: 24.08, lng: 104.65 },
'西双版纳': { lat: 22.00, lng: 100.80 },
'腾冲': { lat: 25.02, lng: 98.50 },
'建水': { lat: 23.62, lng: 102.82 },
'元阳': { lat: 23.22, lng: 102.83 },
'抚仙湖': { lat: 24.55, lng: 102.93 },
'弥勒': { lat: 24.41, lng: 103.41 },
'沙溪': { lat: 26.32, lng: 99.85 },
'泸沽湖': { lat: 27.72, lng: 100.82 },
'成都': { lat: 30.57, lng: 104.07 },
'重庆': { lat: 29.56, lng: 106.55 },
'贵阳': { lat: 26.65, lng: 106.63 },
'桂林': { lat: 25.27, lng: 110.29 },
'阳朔': { lat: 24.78, lng: 110.49 },
'杭州': { lat: 30.25, lng: 120.16 },
'乌镇': { lat: 30.75, lng: 120.48 },
'苏州': { lat: 31.30, lng: 120.58 },
'北京': { lat: 39.90, lng: 116.40 },
'上海': { lat: 31.23, lng: 121.47 },
'西安': { lat: 34.34, lng: 108.94 },
'拉萨': { lat: 29.65, lng: 91.14 },
'张家界': { lat: 29.12, lng: 110.48 },
'九寨沟': { lat: 33.26, lng: 103.92 },
'厦门': { lat: 24.48, lng: 118.09 },
'青岛': { lat: 36.07, lng: 120.38 },
'巍山': { lat: 25.23, lng: 100.30 },
'蒙自': { lat: 23.37, lng: 103.38 },
'丘北': { lat: 24.05, lng: 104.18 },
}
export function getKnownPlace(name) {
return KNOWN_PLACES[name] || null
}

@ -4,7 +4,7 @@ import { sampleItinerary, replacementPool } from '../data/sampleData'
import { getMultiRoute, detectDetour } from '../services/routeService' import { getMultiRoute, detectDetour } from '../services/routeService'
export const useItineraryStore = defineStore('itinerary', () => { export const useItineraryStore = defineStore('itinerary', () => {
const phase = ref('workbench') const phase = ref('chat')
const mode = ref('preview') const mode = ref('preview')
const points = ref(JSON.parse(JSON.stringify(sampleItinerary.points))) const points = ref(JSON.parse(JSON.stringify(sampleItinerary.points)))
const currentStep = ref(0) const currentStep = ref(0)
@ -176,6 +176,43 @@ export const useItineraryStore = defineStore('itinerary', () => {
hoveredReplacement.value = opt hoveredReplacement.value = opt
} }
function loadFromAI(scheme) {
const icons = ['🏙️', '🌿', '🏘️', '🏔️', '🏯', '💧', '🌾', '⛰️', '🏖️', '🛕', '🌸', '🏝️', '✈️']
const points = scheme.points.map((p, i) => ({
id: 'p_' + Date.now() + '_' + i,
name: p.name,
lat: p.lat,
lng: p.lng,
day: p.day || `Day ${i}`,
badge: p.badge || (i === 0 ? 'START' : (i === scheme.points.length - 1 ? 'END' : `D${i}`)),
km: p.km || (i === 0 ? '0km' : `${Math.round(Math.random() * 300 + 50)}km`),
driveTime: p.driveTime || (i === 0 ? '—' : `${Math.round(Math.random() * 5 + 1)}h`),
desc: p.desc || '',
icon: p.icon || icons[i % icons.length],
images: p.images || [
`https://picsum.photos/400/300?random=${Date.now() + i * 3}`,
`https://picsum.photos/400/300?random=${Date.now() + i * 3 + 1}`
],
heroImage: p.heroImage || `https://picsum.photos/800/400?random=${Date.now() + i * 3 + 2}`,
schedule: p.schedule || [
{ time: '上午', content: '抵达目的地,开始探索' },
{ time: '下午', content: '游览主要景点' },
{ time: '晚上', content: '品尝当地美食' }
],
foods: p.foods || ['当地特色美食'],
hotel: p.hotel || '推荐酒店',
tips: p.tips || '注意安全,提前预订'
}))
points.value = points
currentStep.value = 0
routeSegments.value = []
showOptimizationAlert.value = false
showReplacementPanel.value = false
selectedForReplace.value = null
hoveredReplacement.value = null
}
return { return {
phase, mode, points, currentStep, selectedForReplace, showReplacementPanel, phase, mode, points, currentStep, selectedForReplace, showReplacementPanel,
showOptimizationAlert, optimizationMessage, isFetchingRoutes, routeSegments, detourWarnings, showOptimizationAlert, optimizationMessage, isFetchingRoutes, routeSegments, detourWarnings,
@ -183,7 +220,7 @@ export const useItineraryStore = defineStore('itinerary', () => {
setPhase, setMode, setCurrentStep, nextStep, prevStep, setPhase, setMode, setCurrentStep, nextStep, prevStep,
deletePoint, insertPoint, replacePoint, reorderPoints, resetToSample, deletePoint, insertPoint, replacePoint, reorderPoints, resetToSample,
fetchRealRoutes, checkRouteOptimization, autoOptimizeRoute, dismissOptimization, fetchRealRoutes, checkRouteOptimization, autoOptimizeRoute, dismissOptimization,
setHoveredReplacement setHoveredReplacement, loadFromAI
} }
}) })

@ -1,47 +1,35 @@
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { ref, computed } from 'vue' import { ref, computed } from 'vue'
const STORAGE_KEY = 'trip_planner_ai_config'
const DEFAULT_CONFIG = {
provider: 'aliyun',
apiKey: '',
model: 'qwen-plus',
baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
temperature: 0.7,
maxTokens: 2000
}
const ALIYUN_MODELS = [
{ value: 'qwen-turbo', label: 'Qwen-Turbo快速', desc: '速度快,成本低,适合简单对话' },
{ value: 'qwen-plus', label: 'Qwen-Plus均衡', desc: '速度与质量平衡,推荐使用' },
{ value: 'qwen-max', label: 'Qwen-Max高质量', desc: '复杂推理,质量最高' },
{ value: 'qwen-max-latest', label: 'Qwen-Max-Latest', desc: '最新版本,能力最强' },
{ value: 'qwen-long', label: 'Qwen-Long长文本', desc: '支持超长上下文100万token' }
]
export const useSettingsStore = defineStore('settings', () => { export const useSettingsStore = defineStore('settings', () => {
const config = ref(loadConfig()) const config = ref({
provider: 'aliyun',
apiKey: '',
model: 'qwen3.6-plus',
baseUrl: 'https://coding.dashscope.aliyuncs.com/v1',
temperature: 0.7,
maxTokens: 8000
})
const isConfigured = computed(() => !!config.value.apiKey) const isConfigured = computed(() => !!config.value.apiKey)
const isTesting = ref(false) const isTesting = ref(false)
const testResult = ref(null) const testResult = ref(null)
const showConfigPage = ref(false)
function loadConfig() { const ALIYUN_MODELS = [
try { { value: 'qwen-turbo', label: 'Qwen-Turbo快速', desc: '速度快,成本低,适合简单对话' },
const saved = localStorage.getItem(STORAGE_KEY) { value: 'qwen-plus', label: 'Qwen-Plus均衡', desc: '速度与质量平衡,推荐使用' },
if (saved) return { ...DEFAULT_CONFIG, ...JSON.parse(saved) } { value: 'qwen-max', label: 'Qwen-Max高质量', desc: '复杂推理,质量最高' },
} catch (e) { { value: 'qwen-max-latest', label: 'Qwen-Max-Latest', desc: '最新版本,能力最强' },
console.warn('Failed to load config:', e) { value: 'qwen-long', label: 'Qwen-Long长文本', desc: '支持超长上下文100万token' }
} ]
return { ...DEFAULT_CONFIG }
}
function saveConfig() { // Load config from server
async function loadConfig() {
try { try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(config.value)) const response = await fetch('/api/config')
const data = await response.json()
config.value = { ...config.value, ...data }
} catch (e) { } catch (e) {
console.warn('Failed to save config:', e) console.warn('Failed to load config from server:', e)
} }
} }
@ -50,8 +38,27 @@ export const useSettingsStore = defineStore('settings', () => {
saveConfig() saveConfig()
} }
async function saveConfig() {
try {
await fetch('/api/config', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(config.value)
})
} catch (e) {
console.warn('Failed to save config:', e)
}
}
function resetConfig() { function resetConfig() {
config.value = { ...DEFAULT_CONFIG, apiKey: '' } config.value = {
provider: 'aliyun',
apiKey: '',
model: 'qwen3.6-plus',
baseUrl: 'https://coding.dashscope.aliyuncs.com/v1',
temperature: 0.7,
maxTokens: 8000
}
saveConfig() saveConfig()
} }
@ -66,29 +73,24 @@ export const useSettingsStore = defineStore('settings', () => {
} }
try { try {
const response = await fetch(`${config.value.baseUrl}/chat/completions`, { const response = await fetch('/api/config/test', {
method: 'POST', method: 'POST',
headers: { headers: { 'Content-Type': 'application/json' },
'Content-Type': 'application/json',
'Authorization': `Bearer ${config.value.apiKey}`
},
body: JSON.stringify({ body: JSON.stringify({
apiKey: config.value.apiKey,
model: config.value.model, model: config.value.model,
messages: [{ role: 'user', content: '你好请回复OK' }], baseUrl: config.value.baseUrl
max_tokens: 10
}) })
}) })
const data = await response.json() const data = await response.json()
testResult.value = data
if (response.ok && data.choices) { if (data.success) {
testResult.value = { success: true, message: `连接成功!模型: ${data.model || config.value.model}` }
saveConfig() saveConfig()
return true
} else {
testResult.value = { success: false, message: data.error?.message || '连接失败' }
return false
} }
return data.success
} catch (error) { } catch (error) {
testResult.value = { success: false, message: `网络错误: ${error.message}` } testResult.value = { success: false, message: `网络错误: ${error.message}` }
return false return false
@ -98,7 +100,7 @@ export const useSettingsStore = defineStore('settings', () => {
} }
return { return {
config, isConfigured, isTesting, testResult, showConfigPage, ALIYUN_MODELS, config, isConfigured, isTesting, testResult, ALIYUN_MODELS,
updateConfig, resetConfig, testConnection loadConfig, updateConfig, saveConfig, resetConfig, testConnection
} }
}) })

@ -62,6 +62,17 @@
<span class="model-desc">{{ model.desc }}</span> <span class="model-desc">{{ model.desc }}</span>
</div> </div>
</div> </div>
<!-- Custom Model Input -->
<div class="custom-model-input">
<label>自定义模型</label>
<input
v-model="localConfig.model"
placeholder="输入自定义模型名称,如 qwen3.6-plus"
class="text-input"
@input="onModelInput"
/>
<p class="input-hint">当前选择{{ localConfig.model }}</p>
</div>
</div> </div>
<!-- Base URL --> <!-- Base URL -->
@ -74,7 +85,7 @@
class="text-input" class="text-input"
@input="debounceSave" @input="debounceSave"
/> />
<p class="input-hint">默认https://dashscope.aliyuncs.com/compatible-mode/v1</p> <p class="input-hint">默认https://coding.dashscope.aliyuncs.com/v1</p>
</div> </div>
</div> </div>
@ -165,17 +176,21 @@ const selectModel = (model) => {
store.updateConfig({ model }) store.updateConfig({ model })
} }
const onModelInput = () => {
debounceSave()
}
const goBack = () => router.push('/') const goBack = () => router.push('/')
const handleTest = async () => { const handleTest = async () => {
store.updateConfig(localConfig.value) await store.saveConfig()
const success = await store.testConnection() const success = await store.testConnection()
testResult.value = store.testResult testResult.value = store.testResult
} }
const handleSave = () => { const handleSave = async () => {
store.updateConfig(localConfig.value) await store.saveConfig()
testResult.value = { success: true, message: '配置已保存' } testResult.value = { success: true, message: '配置已保存到服务器' }
setTimeout(() => { testResult.value = null }, 2000) setTimeout(() => { testResult.value = null }, 2000)
} }
@ -187,7 +202,8 @@ const handleReset = () => {
} }
} }
onMounted(() => { onMounted(async () => {
await store.loadConfig()
localConfig.value = { ...store.config } localConfig.value = { ...store.config }
}) })
</script> </script>
@ -372,6 +388,22 @@ onMounted(() => {
.model-name { font-weight: 500; color: #333; } .model-name { font-weight: 500; color: #333; }
.model-desc { font-size: 12px; color: #888; } .model-desc { font-size: 12px; color: #888; }
/* Custom Model Input */
.custom-model-input {
margin-top: 16px;
padding: 12px;
background: #f8f9fa;
border-radius: 8px;
}
.custom-model-input label {
display: block;
font-size: 13px;
color: #666;
font-weight: 500;
margin-bottom: 8px;
}
/* Advanced */ /* Advanced */
.advanced-grid { .advanced-grid {
display: grid; display: grid;

Loading…
Cancel
Save