feat: 微客宝H5客户端 - 基础架构+核心页面

This commit is contained in:
li
2026-03-14 19:44:03 +08:00
parent 54d2f617bb
commit 0e974da09c
3738 changed files with 811180 additions and 21 deletions
+32
View File
@@ -0,0 +1,32 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [0.2.0](https://github.com/unjs/pathe/compare/v0.1.0...v0.2.0) (2021-09-27)
### ⚠ BREAKING CHANGES
* improved implementation with tests (#3)
### Features
* improved implementation with tests ([#3](https://github.com/unjs/pathe/issues/3)) ([d8d0cb5](https://github.com/unjs/pathe/commit/d8d0cb51dbca7295248c36f93510738057f2828d))
## [0.1.0](https://github.com/unjs/pathe/compare/v0.0.3...v0.1.0) (2021-09-24)
### [0.0.3](https://github.com/unjs/pathe/compare/v0.0.2...v0.0.3) (2021-09-24)
### Bug Fixes
* add hotfix for resolve ([a221d34](https://github.com/unjs/pathe/commit/a221d3468c81802da03823bd606de70a524a7b55))
### [0.0.2](https://github.com/unjs/pathe/compare/v0.0.1...v0.0.2) (2021-09-22)
### Bug Fixes
* **pkg:** expose types ([77000b1](https://github.com/unjs/pathe/commit/77000b1a45780fd62c93dc71d8264f10d97af864))
### 0.0.1 (2021-09-22)
+44
View File
@@ -0,0 +1,44 @@
MIT License
Copyright (c) 2021 UnJS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--------------------------------------------------------------------------------
Copyright Joyent, Inc. and other Node contributors.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
+61
View File
@@ -0,0 +1,61 @@
# pathe
> Normalized paths for Node.js
[![version][npm-v-src]][npm-v-href]
[![downloads][npm-d-src]][npm-d-href]
[![size][size-src]][size-href]
🧪 This package is still experimental and might not handle all cases. Please track issues.
## ❓ Why
For [historical reasons](https://docs.microsoft.com/en-us/archive/blogs/larryosterman/why-is-the-dos-path-character), windows followed MS-DOS
and using backslash for separating paths rather than slash used for macOS, Linux, and other Posix operating systems. Nowadays, [Windows](https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN) supports both Slash and Backslash for paths.
[Node.js's built in `path` module](https://nodejs.org/api/path.html) in the default operation of the path module varies based on the operating system on which a Node.js application is running. Specifically, when running on a Windows operating system, the path module will assume that Windows-style paths are being used. **This makes inconsistent code behavior between Windows and POSIX.**
This package is a drop-in replacement of the Node.js's `path` module and ensures paths are normalized with slash `/`.
Compared to popular [upath](https://github.com/anodynos/upath), pathe is providing **identical exports** of Node.js with normalization on **all operations** and written in modern **ESM/Typescript**.
## 💿 Install
Install using npm or yarn:
```bash
npm i pathe
# or
yarn add pathe
```
Import:
```js
// ESM / Typescript
import { resolve } from 'pathe'
// CommonJS
const { resolve } = require('pathe')
```
Read more about path utils from [Node.js documentation](https://nodejs.org/api/path.html) and rest assured behavior is ALWAYS like POSIX regardless of your input paths format and running platform!
## License
MIT. Made with 💖
Some code used form Node.js project. See [LICENSE](./LICENSE).
<!-- Refs -->
[npm-v-src]: https://img.shields.io/npm/v/pathe?style=flat-square
[npm-v-href]: https://npmjs.com/package/pathe
[npm-d-src]: https://img.shields.io/npm/dm/pathe?style=flat-square
[npm-d-href]: https://npmjs.com/package/pathe
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/pathe/ci/main?style=flat-square
[github-actions-href]: https://github.com/unjs/pathe/actions?query=workflow%3Aci
[size-src]: https://packagephobia.now.sh/badge?p=pathe
[size-href]: https://packagephobia.now.sh/result?p=pathe
+208
View File
@@ -0,0 +1,208 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const path = require('path');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
const path__default = /*#__PURE__*/_interopDefaultLegacy(path);
function normalizeWindowsPath(input = "") {
if (!input.includes("\\")) {
return input;
}
return input.replace(/\\/g, "/");
}
const _UNC_REGEX = /^[/][/]/;
const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
const sep = "/";
const delimiter = ":";
const normalize = function(path2) {
if (path2.length === 0) {
return ".";
}
path2 = normalizeWindowsPath(path2);
const isUNCPath = path2.match(_UNC_REGEX);
const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
const isPathAbsolute = isAbsolute(path2);
const trailingSeparator = path2[path2.length - 1] === "/";
path2 = normalizeString(path2, !isPathAbsolute);
if (path2.length === 0) {
if (isPathAbsolute) {
return "/";
}
return trailingSeparator ? "./" : ".";
}
if (trailingSeparator) {
path2 += "/";
}
if (isUNCPath) {
if (hasUNCDrive) {
return `//./${path2}`;
}
return `//${path2}`;
}
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
};
const join = function(...args) {
if (args.length === 0) {
return ".";
}
let joined;
for (let i = 0; i < args.length; ++i) {
const arg = args[i];
if (arg.length > 0) {
if (joined === void 0) {
joined = arg;
} else {
joined += `/${arg}`;
}
}
}
if (joined === void 0) {
return ".";
}
return normalize(joined);
};
const resolve = function(...args) {
args = args.map((arg) => normalizeWindowsPath(arg));
let resolvedPath = "";
let resolvedAbsolute = false;
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
const path2 = i >= 0 ? args[i] : process.cwd();
if (path2.length === 0) {
continue;
}
resolvedPath = `${path2}/${resolvedPath}`;
resolvedAbsolute = isAbsolute(path2);
}
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
return `/${resolvedPath}`;
}
return resolvedPath.length > 0 ? resolvedPath : ".";
};
function normalizeString(path2, allowAboveRoot) {
let res = "";
let lastSegmentLength = 0;
let lastSlash = -1;
let dots = 0;
let char = null;
for (let i = 0; i <= path2.length; ++i) {
if (i < path2.length) {
char = path2[i];
} else if (char === "/") {
break;
} else {
char = "/";
}
if (char === "/") {
if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
if (res.length > 2) {
const lastSlashIndex = res.lastIndexOf("/");
if (lastSlashIndex === -1) {
res = "";
lastSegmentLength = 0;
} else {
res = res.slice(0, lastSlashIndex);
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
}
lastSlash = i;
dots = 0;
continue;
} else if (res.length !== 0) {
res = "";
lastSegmentLength = 0;
lastSlash = i;
dots = 0;
continue;
}
}
if (allowAboveRoot) {
res += res.length > 0 ? "/.." : "..";
lastSegmentLength = 2;
}
} else {
if (res.length > 0) {
res += `/${path2.slice(lastSlash + 1, i)}`;
} else {
res = path2.slice(lastSlash + 1, i);
}
lastSegmentLength = i - lastSlash - 1;
}
lastSlash = i;
dots = 0;
} else if (char === "." && dots !== -1) {
++dots;
} else {
dots = -1;
}
}
return res;
}
const isAbsolute = function(p) {
return _IS_ABSOLUTE_RE.test(p);
};
const toNamespacedPath = function(p) {
return normalizeWindowsPath(p);
};
const extname = function(p) {
return path__default["default"].posix.extname(normalizeWindowsPath(p));
};
const relative = function(from, to) {
return path__default["default"].posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
};
const dirname = function(p) {
return path__default["default"].posix.dirname(normalizeWindowsPath(p));
};
const format = function(p) {
return normalizeWindowsPath(path__default["default"].posix.format(p));
};
const basename = function(p, ext) {
return path__default["default"].posix.basename(normalizeWindowsPath(p), ext);
};
const parse = function(p) {
return path__default["default"].posix.parse(normalizeWindowsPath(p));
};
const _path = /*#__PURE__*/Object.freeze({
__proto__: null,
sep: sep,
delimiter: delimiter,
normalize: normalize,
join: join,
resolve: resolve,
normalizeString: normalizeString,
isAbsolute: isAbsolute,
toNamespacedPath: toNamespacedPath,
extname: extname,
relative: relative,
dirname: dirname,
format: format,
basename: basename,
parse: parse
});
const index = {
..._path
};
exports.basename = basename;
exports["default"] = index;
exports.delimiter = delimiter;
exports.dirname = dirname;
exports.extname = extname;
exports.format = format;
exports.isAbsolute = isAbsolute;
exports.join = join;
exports.normalize = normalize;
exports.normalizeString = normalizeString;
exports.parse = parse;
exports.relative = relative;
exports.resolve = resolve;
exports.sep = sep;
exports.toNamespacedPath = toNamespacedPath;
+20
View File
@@ -0,0 +1,20 @@
import path from 'path';
declare const sep = "/";
declare const delimiter = ":";
declare const normalize: typeof path.normalize;
declare const join: typeof path.join;
declare const resolve: typeof path.resolve;
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
declare const isAbsolute: typeof path.isAbsolute;
declare const toNamespacedPath: typeof path.toNamespacedPath;
declare const extname: typeof path.extname;
declare const relative: typeof path.relative;
declare const dirname: typeof path.dirname;
declare const format: typeof path.format;
declare const basename: typeof path.basename;
declare const parse: typeof path.parse;
declare const _default: Omit<path.PlatformPath, "win32" | "posix">;
export { basename, _default as default, delimiter, dirname, extname, format, isAbsolute, join, normalize, normalizeString, parse, relative, resolve, sep, toNamespacedPath };
+186
View File
@@ -0,0 +1,186 @@
import path from 'path';
function normalizeWindowsPath(input = "") {
if (!input.includes("\\")) {
return input;
}
return input.replace(/\\/g, "/");
}
const _UNC_REGEX = /^[/][/]/;
const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
const sep = "/";
const delimiter = ":";
const normalize = function(path2) {
if (path2.length === 0) {
return ".";
}
path2 = normalizeWindowsPath(path2);
const isUNCPath = path2.match(_UNC_REGEX);
const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
const isPathAbsolute = isAbsolute(path2);
const trailingSeparator = path2[path2.length - 1] === "/";
path2 = normalizeString(path2, !isPathAbsolute);
if (path2.length === 0) {
if (isPathAbsolute) {
return "/";
}
return trailingSeparator ? "./" : ".";
}
if (trailingSeparator) {
path2 += "/";
}
if (isUNCPath) {
if (hasUNCDrive) {
return `//./${path2}`;
}
return `//${path2}`;
}
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
};
const join = function(...args) {
if (args.length === 0) {
return ".";
}
let joined;
for (let i = 0; i < args.length; ++i) {
const arg = args[i];
if (arg.length > 0) {
if (joined === void 0) {
joined = arg;
} else {
joined += `/${arg}`;
}
}
}
if (joined === void 0) {
return ".";
}
return normalize(joined);
};
const resolve = function(...args) {
args = args.map((arg) => normalizeWindowsPath(arg));
let resolvedPath = "";
let resolvedAbsolute = false;
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
const path2 = i >= 0 ? args[i] : process.cwd();
if (path2.length === 0) {
continue;
}
resolvedPath = `${path2}/${resolvedPath}`;
resolvedAbsolute = isAbsolute(path2);
}
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
return `/${resolvedPath}`;
}
return resolvedPath.length > 0 ? resolvedPath : ".";
};
function normalizeString(path2, allowAboveRoot) {
let res = "";
let lastSegmentLength = 0;
let lastSlash = -1;
let dots = 0;
let char = null;
for (let i = 0; i <= path2.length; ++i) {
if (i < path2.length) {
char = path2[i];
} else if (char === "/") {
break;
} else {
char = "/";
}
if (char === "/") {
if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
if (res.length > 2) {
const lastSlashIndex = res.lastIndexOf("/");
if (lastSlashIndex === -1) {
res = "";
lastSegmentLength = 0;
} else {
res = res.slice(0, lastSlashIndex);
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
}
lastSlash = i;
dots = 0;
continue;
} else if (res.length !== 0) {
res = "";
lastSegmentLength = 0;
lastSlash = i;
dots = 0;
continue;
}
}
if (allowAboveRoot) {
res += res.length > 0 ? "/.." : "..";
lastSegmentLength = 2;
}
} else {
if (res.length > 0) {
res += `/${path2.slice(lastSlash + 1, i)}`;
} else {
res = path2.slice(lastSlash + 1, i);
}
lastSegmentLength = i - lastSlash - 1;
}
lastSlash = i;
dots = 0;
} else if (char === "." && dots !== -1) {
++dots;
} else {
dots = -1;
}
}
return res;
}
const isAbsolute = function(p) {
return _IS_ABSOLUTE_RE.test(p);
};
const toNamespacedPath = function(p) {
return normalizeWindowsPath(p);
};
const extname = function(p) {
return path.posix.extname(normalizeWindowsPath(p));
};
const relative = function(from, to) {
return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
};
const dirname = function(p) {
return path.posix.dirname(normalizeWindowsPath(p));
};
const format = function(p) {
return normalizeWindowsPath(path.posix.format(p));
};
const basename = function(p, ext) {
return path.posix.basename(normalizeWindowsPath(p), ext);
};
const parse = function(p) {
return path.posix.parse(normalizeWindowsPath(p));
};
const _path = /*#__PURE__*/Object.freeze({
__proto__: null,
sep: sep,
delimiter: delimiter,
normalize: normalize,
join: join,
resolve: resolve,
normalizeString: normalizeString,
isAbsolute: isAbsolute,
toNamespacedPath: toNamespacedPath,
extname: extname,
relative: relative,
dirname: dirname,
format: format,
basename: basename,
parse: parse
});
const index = {
..._path
};
export { basename, index as default, delimiter, dirname, extname, format, isAbsolute, join, normalize, normalizeString, parse, relative, resolve, sep, toNamespacedPath };
+40
View File
@@ -0,0 +1,40 @@
{
"name": "pathe",
"version": "0.2.0",
"description": "Normalized paths for Node.js",
"repository": "unjs/pathe",
"license": "MIT",
"sideEffects": false,
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "siroc build",
"lint": "eslint --ext .ts .",
"prepublishOnly": "yarn build",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "nyc mocha -r jiti/register test/*"
},
"devDependencies": {
"@nuxtjs/eslint-config-typescript": "latest",
"@types/chai": "^4.2.22",
"@types/mocha": "^9.0.0",
"@types/node": "^16.9.6",
"chai": "^4.3.4",
"eslint": "latest",
"jiti": "^1.12.3",
"mocha": "^9.1.1",
"nyc": "^15.1.0",
"siroc": "latest",
"standard-version": "latest",
"typescript": "^4.4.3"
}
}