更新前端静态网页获取方式,放弃使用后端获取api

This commit is contained in:
2025-09-09 10:47:51 +08:00
parent 6889ca37e5
commit 44a4f1bae1
25558 changed files with 2463152 additions and 153 deletions

View File

@@ -0,0 +1,28 @@
{
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"forin": false,
"freeze": false,
"immed": true,
"indent": 2,
"latedef": "nofunc",
"newcap": true,
"noarg": true,
"noempty": true,
"nonbsp": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"undef": true,
"unused": true,
"strict": true,
"maxparams": 20,
"maxdepth": 5,
"maxlen": 120,
"scripturl": true,
"node": true,
"esnext": true,
"jasmine": true
}

1
frontend/node_modules/adjust-sourcemap-loader/.nvmrc generated vendored Normal file
View File

@@ -0,0 +1 @@
8.9

21
frontend/node_modules/adjust-sourcemap-loader/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2019 Ben Holloway
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.

View File

@@ -0,0 +1,43 @@
'use strict';
var path = require('path'),
fs = require('fs');
/**
* Codec for absolute paths.
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'absolute',
decode: decode,
encode: encode,
root : root
};
/**
* Decode the given uri.
* Any path with leading slash is tested in an absolute sense.
* @this {{options: object}} A loader or compilation
* @param {string} uri A source uri to decode
* @returns {boolean|string} False where unmatched else the decoded path
*/
function decode(uri) {
return path.isAbsolute(uri) && fs.existsSync(uri) && fs.statSync(uri).isFile() && uri;
}
/**
* Encode the given file path.
* @this {{options: object}} A loader or compilation
* @returns {string} A uri
*/
function encode(absolute) {
return absolute;
}
/**
* The source-map root where relevant.
* @this {{options: object}} A loader or compilation
* @returns {string|undefined} The source-map root applicable to any encoded uri
*/
function root() {
}

View File

@@ -0,0 +1,21 @@
'use strict';
/**
* Codec for code generated by the Bower plugin.
* @type {{name:string, decode:function, abstract:boolean}}
*/
module.exports = {
name : 'bowerComponent',
decode : decode,
abstract: true
};
/**
* Validate the given uri (abstract).
* @this {{options: object}} A loader or compilation
* @param {string} uri A source uri to decode
* @returns {boolean|string} False where unmatched else True
*/
function decode(uri) {
return /^\/?([\w-]+)\s+\(bower component\)$/.test(uri);
}

View File

@@ -0,0 +1,14 @@
module.exports = [
require('./webpack-protocol'),
require('./webpack-bootstrap'),
require('./bower-component'),
require('./npm-module'),
/* insert here any additional special character CODECs */
require('./output-relative'),
require('./output-root-relative'),
require('./project-relative'),
require('./project-root-relative'),
require('./source-relative'),
require('./source-root-relative'),
require('./absolute')
];

View File

@@ -0,0 +1,35 @@
'use strict';
var path = require('path'),
fs = require('fs');
var loaderUtils = require('loader-utils');
var getContextDirectory = require('./utility/get-context-directory');
/**
* Codec for relative paths with respect to the context directory.
* @type {{name:string, decode: function}}
*/
module.exports = {
name : 'npmModule',
decode: decode
};
/**
* Decode the given uri.
* Include only module paths containing `~`.
* @this {{options: object}} A loader or compilation
* @param {string} uri A source uri to decode
* @returns {boolean|string} False where unmatched else the decoded path
*/
function decode(uri) {
/* jshint validthis:true */
if (/~/.test(uri)) {
var relative = loaderUtils.urlToRequest(uri),
base = getContextDirectory.call(this),
absFile = path.normalize(path.join(base, 'node_modules', relative)),
isValid = !!absFile && fs.existsSync(absFile) && fs.statSync(absFile).isFile();
return isValid && absFile;
}
}

View File

@@ -0,0 +1,49 @@
'use strict';
var path = require('path'),
fs = require('fs');
var getOutputDirectory = require('./utility/get-output-directory');
/**
* Codec for relative paths with respect to the output directory.
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'outputRelative',
decode: decode,
encode: encode,
root : getOutputDirectory
};
/**
* Decode the given uri.
* Any path with without leading slash is tested against output directory.
* @this {{options: object}} A loader or compilation
* @param {string} uri A source uri to decode
* @returns {boolean|string} False where unmatched else the decoded path
*/
function decode(uri) {
/* jshint validthis:true */
var base = !uri.startsWith('/') && getOutputDirectory.call(this),
absFile = !!base && path.normalize(path.join(base, uri)),
isValid = !!absFile && fs.existsSync(absFile) && fs.statSync(absFile).isFile();
return isValid && absFile;
}
/**
* Encode the given file path.
* @this {{options: object}} A loader or compilation
* @param {string} absolute An absolute file path to encode
* @returns {string} A uri without leading slash
*/
function encode(absolute) {
/* jshint validthis:true */
var base = getOutputDirectory.call(this);
if (!base) {
throw new Error('Cannot locate the Webpack output directory');
}
else {
return path.relative(base, absolute);
}
}

View File

@@ -0,0 +1,37 @@
'use strict';
var relative = require('./output-relative');
/**
* Codec for relative paths with respect to the output directory.
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'outputRootRelative',
decode: decode,
encode: encode,
root : relative.root
};
/**
* Decode the given uri.
* Any path with leading slash is tested against output directory.
* @this {{options: object}} A loader or compilation
* @param {string} uri A source uri to decode
* @returns {boolean|string} False where unmatched else the decoded path
*/
function decode(uri) {
/* jshint validthis:true */
return uri.startsWith('/') && relative.decode.call(this, uri.slice(1));
}
/**
* Encode the given file path.
* @this {{options: object}} A loader or compilation
* @param {string} absolute An absolute file path to encode
* @returns {string} A uri with leading slash
*/
function encode(absolute) {
/* jshint validthis:true */
return '/' + relative.encode.call(this, absolute);
}

View File

@@ -0,0 +1,50 @@
'use strict';
var path = require('path'),
fs = require('fs');
var getContextDirectory = require('./utility/get-context-directory'),
enhancedRelative = require('./utility/enhanced-relative');
/**
* Codec for relative paths with respect to the project directory.
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'projectRelative',
decode: decode,
encode: encode,
root : getContextDirectory
};
/**
* Decode the given uri.
* Any path with without leading slash is tested against project directory.
* @this {{options: object}} A loader or compilation
* @param {string} uri A source uri to decode
* @returns {boolean|string} False where unmatched else the decoded path
*/
function decode(uri) {
/* jshint validthis:true */
var base = !uri.startsWith('/') && getContextDirectory.call(this),
absFile = !!base && path.normalize(path.join(base, uri)),
isValid = !!absFile && fs.existsSync(absFile) && fs.statSync(absFile).isFile();
return isValid && absFile;
}
/**
* Encode the given file path.
* @this {{options: object}} A loader or compilation
* @param {string} absolute An absolute file path to encode
* @returns {string} A uri without leading slash
*/
function encode(absolute) {
/* jshint validthis:true */
var base = getContextDirectory.call(this);
if (!base) {
throw new Error('Cannot locate the Webpack project directory');
}
else {
return enhancedRelative(base, absolute);
}
}

View File

@@ -0,0 +1,37 @@
'use strict';
var relative = require('./project-relative');
/**
* Codec for relative paths with respect to the project directory.
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'projectRootRelative',
decode: decode,
encode: encode,
root : relative.root
};
/**
* Decode the given uri.
* Any path with leading slash is tested against project directory.
* @this {{options: object}} A loader or compilation
* @param {string} uri A source uri to decode
* @returns {boolean|string} False where unmatched else the decoded path
*/
function decode(uri) {
/* jshint validthis:true */
return uri.startsWith('/') && relative.decode.call(this, uri.slice(1));
}
/**
* Encode the given file path.
* @this {{options: object}} A loader or compilation
* @param {string} absolute An absolute file path to encode
* @returns {string} A uri with leading slash
*/
function encode(absolute) {
/* jshint validthis:true */
return '/' + relative.encode.call(this, absolute);
}

View File

@@ -0,0 +1,51 @@
'use strict';
var path = require('path'),
fs = require('fs');
/**
* Codec for relative paths with respect to the source directory.
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'sourceRelative',
decode: decode,
encode: encode,
root : root
};
/**
* Decode the given uri.
* Any path without leading slash is tested against source directory.
* @this {{options: object}} A loader or compilation
* @param {string} uri A source uri to decode
* @returns {boolean|string} False where unmatched else the decoded path
*/
function decode(uri) {
/* jshint validthis:true */
var base = !uri.startsWith('/') && this.context,
absFile = !!base && path.normalize(path.join(base, uri)),
isValid = !!absFile && fs.existsSync(absFile) && fs.statSync(absFile).isFile();
return isValid && absFile;
}
/**
* Encode the given file path.
* @this {{options: object}} A loader or compilation
* @param {string} absolute An absolute file path to encode
* @returns {string} A uri without leading slash
*/
function encode(absolute) {
/* jshint validthis:true */
return path.relative(this.context, absolute);
}
/**
* The source-map root where relevant.
* @this {{options: object}} A loader or compilation
* @returns {string|undefined} The source-map root applicable to any encoded uri
*/
function root() {
/* jshint validthis:true */
return this.context;
}

View File

@@ -0,0 +1,37 @@
'use strict';
var relative = require('./source-relative');
/**
* Codec for relative paths with respect to the source directory.
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'sourceRootRelative',
decode: decode,
encode: encode,
root : relative.root
};
/**
* Decode the given uri.
* Any path with leading slash is tested against source directory.
* @this {{options: object}} A loader or compilation
* @param {string} uri A source uri to decode
* @returns {boolean|string} False where unmatched else the decoded path
*/
function decode(uri) {
/* jshint validthis:true */
return uri.startsWith('/') && relative.decode.call(this, uri.slice(1));
}
/**
* Encode the given file path.
* @this {{options: object}} A loader or compilation
* @param {string} absolute An absolute file path to encode
* @returns {string} A uri with leading slash
*/
function encode(absolute) {
/* jshint validthis:true */
return '/' + relative.encode.call(this, absolute);
}

View File

@@ -0,0 +1,118 @@
'use strict';
var fs = require('fs'),
path = require('path');
var cache;
/**
* Perform <code>path.relative()</code> but try to detect and correct sym-linked node modules.
* @param {string} from The base path
* @param {string} to The full path
*/
function enhancedRelative(from, to) {
// relative path
var relative = path.relative(from, to);
// trailing is the relative path portion without any '../'
var trailing = relative.replace(/^\.{2}[\\\/]/, ''),
leading = to.replace(trailing, '');
// within project is what we want
var isInProject = (relative === trailing);
if (isInProject) {
return relative;
}
// otherwise look at symbolic linked modules
else {
var splitTrailing = trailing.split(/[\\\/]/);
// ensure failures can retry with fresh cache
for (var i = cache ? 2 : 1, foundPath = false; (i > 0) && !foundPath; i--) {
// ensure cache
cache = cache || indexLinkedModules(from);
// take elements from the trailing path and append them the the leading path in an attempt to find a package.json
for (var j = 0; (j < splitTrailing.length) && !foundPath; j++) {
// find the name of packages in the actual file location
// start at the lowest concrete directory that appears in the relative path
var packagePath = path.join.apply(path, [leading].concat(splitTrailing.slice(0, j + 1))),
packageJsonPath = path.join(packagePath, 'package.json'),
packageName = fs.existsSync(packageJsonPath) && require(packageJsonPath).name;
// lookup any package name in the cache
var linkedPackagePath = !!packageName && cache[packageName];
if (linkedPackagePath) {
// the remaining portion of the trailing path, not including the package path
var remainingPath = path.join.apply(path, splitTrailing.slice(j + 1));
// validate the remaining path in the linked location
// failure implies we will keep trying nested sym-linked packages
var linkedFilePath = path.join(linkedPackagePath, remainingPath),
isValid = !!linkedFilePath && fs.existsSync(linkedFilePath) &&
fs.statSync(linkedFilePath).isFile();
// path is found where valid
foundPath = isValid && linkedFilePath;
}
}
// cache cannot be trusted if a file can't be found
// set the cache to false to trigger its rebuild
cache = !!foundPath && cache;
}
// the relative path should now be within the project
return foundPath ? path.relative(from, foundPath) : relative;
}
}
module.exports = enhancedRelative;
/**
* Make a hash of linked modules within the given directory by breadth-first search.
* @param {string} directory A path to start searching
* @returns {object} A collection of sym-linked paths within the project keyed by their package name
*/
function indexLinkedModules(directory) {
var buffer = listSymLinkedModules(directory),
hash = {};
// while there are items in the buffer
while (buffer.length > 0) {
var modulePath = buffer.shift(),
packageJsonPath = path.join(modulePath, 'package.json'),
packageName = fs.existsSync(packageJsonPath) && require(packageJsonPath).name;
if (packageName) {
// add this path keyed by package name, so long as it doesn't exist at a lower level
hash[packageName] = hash[packageName] || modulePath;
// detect nested module and push to the buffer (breadth-first)
buffer.push.apply(buffer, listSymLinkedModules(modulePath));
}
}
return hash;
function listSymLinkedModules(directory) {
var modulesPath = path.join(directory, 'node_modules'),
hasNodeModules = fs.existsSync(modulesPath) && fs.statSync(modulesPath).isDirectory(),
subdirectories = !!hasNodeModules && fs.readdirSync(modulesPath) || [];
return subdirectories
.map(joinDirectory)
.filter(testIsSymLink);
function joinDirectory(subdirectory) {
return path.join(modulesPath, subdirectory);
}
function testIsSymLink(directory) {
return fs.lstatSync(directory).isSymbolicLink(); // must use lstatSync not statSync
}
}
}

View File

@@ -0,0 +1,17 @@
'use strict';
var path = require('path');
/**
* Infer the compilation context directory from options.
* Relative paths are resolved against process.cwd().
* @this {{options: object}} A loader or compilation
* @returns {string} process.cwd() where not defined else the output path string
*/
function getContextDirectory() {
/* jshint validthis:true */
var context = this.options ? this.options.context : null;
return !!context && path.resolve(context) || process.cwd();
}
module.exports = getContextDirectory;

View File

@@ -0,0 +1,22 @@
'use strict';
var path = require('path'),
fs = require('fs');
var getContextDirectory = require('./get-context-directory');
/**
* Infer the compilation output directory from options.
* Relative paths are resolved against the compilation context (or process.cwd() where not specified).
* @this {{options: object}} A loader or compilation
* @returns {undefined|string} The output path string, where defined
*/
function getOutputDirectory() {
/* jshint validthis:true */
var base = this.options && this.options.output ? this.options.output.directory : null,
absBase = !!base && path.resolve(getContextDirectory.call(this), base),
isValid = !!absBase && fs.existsSync(absBase) && fs.statSync(absBase).isDirectory();
return isValid ? absBase : undefined;
}
module.exports = getOutputDirectory;

View File

@@ -0,0 +1,21 @@
'use strict';
/**
* Codec for webpack generated bootstrap code.
* @type {{name:string, decode:function, abstract:boolean}}
*/
module.exports = {
name : 'webpackBootstrap',
decode : decode,
abstract: true
};
/**
* Validate the given uri (abstract).
* @this {{options: object}} A loader or compilation
* @param {string} uri A source uri to decode
* @returns {boolean|string} False where unmatched else True
*/
function decode(uri) {
return /^webpack\/bootstrap\s+\w{20}$/.test(uri);
}

View File

@@ -0,0 +1,45 @@
'use strict';
var projectRelative = require('./project-relative');
/**
* Codec for relative paths with respect to the context directory, preceded by a webpack:// protocol.
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'webpackProtocol',
decode: decode,
encode: encode,
root : root
};
/**
* Decode the given uri.
* @this {{options: object}} A loader or compilation
* @param {string} uri A source uri to decode
* @returns {boolean|string} False where unmatched else the decoded path
*/
function decode(uri) {
/* jshint validthis:true */
var analysis = /^webpack:\/{2}(.*)$/.exec(uri);
return !!analysis && projectRelative.decode.call(this, analysis[1]);
}
/**
* Encode the given file path.
* @this {{options: object}} A loader or compilation
* @param {string} absolute An absolute file path to encode
* @returns {string} A uri
*/
function encode(absolute) {
/* jshint validthis:true */
return 'webpack://' + projectRelative.encode.call(this, absolute);
}
/**
* The source-map root where relevant.
* @this {{options: object}} A loader or compilation
* @returns {string|undefined} The source-map root applicable to any encoded uri
*/
function root() {
}

10
frontend/node_modules/adjust-sourcemap-loader/index.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
/*
* MIT License http://opensource.org/licenses/MIT
* Author: Ben Holloway @bholloway
*/
'use strict';
module.exports = Object.assign(require('./lib/loader'), {
moduleFilenameTemplate: require('./lib/module-filename-template'),
codec : require('./codec')
});

View File

@@ -0,0 +1,38 @@
{
"name": "adjust-sourcemap-loader",
"version": "4.0.0",
"description": "Webpack loader that adjusts source maps",
"main": "index.js",
"engines": {
"node": ">=8.9"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bholloway/adjust-sourcemap-loader.git"
},
"keywords": [
"webpack",
"loader",
"source-map",
"sourcemap",
"sources",
"resolve",
"adjust"
],
"author": "bholloway",
"license": "MIT",
"bugs": {
"url": "https://github.com/bholloway/adjust-sourcemap-loader/issues"
},
"homepage": "https://github.com/bholloway/adjust-sourcemap-loader",
"dependencies": {
"loader-utils": "^2.0.0",
"regex-parser": "^2.2.11"
},
"devDependencies": {
"jshint": "^2.12.0"
},
"scripts": {
"lint": "jshint index.js lib codec"
}
}

143
frontend/node_modules/adjust-sourcemap-loader/readme.md generated vendored Normal file
View File

@@ -0,0 +1,143 @@
# Adjust Source-map Loader
[![NPM](https://nodei.co/npm/adjust-sourcemap-loader.png)](http://github.com/bholloway/adjust-sourcemap-loader)
Webpack loader that adjusts source maps.
Use as a **loader** to debug source-maps or to adjust source-maps between other loaders.
Use as a **module filename template** to ensure the final source-map are to your liking.
## Usage : Loader
``` javascript
require('adjust-sourcemap?format=absolute!babel?sourceMap');
```
### Source maps required
Note that **source maps** must be enabled on any preceding loader. In the above example we use `babel?sourceMap`.
### Apply via webpack config
It is preferable to adjust your `webpack.config` so to avoid having to prefix every `require()` statement:
``` javascript
module.exports = {
module: {
loaders: [
{
test : /\.js/,
loaders: ['adjust-sourcemap?format=absolute', 'babel?sourceMap']
}
]
}
};
```
## Usage : Module filename template
Specifying a certain format as the final step in a loader chain will **not** influence the final source format that Webpack will output. Instead the format is determined by the **module filename template**.
There are limitations to the filename templating that Webpack provides. This package may also operate as a custom template function that will convert output source-map sources to the desired `format`.
In the following example we ensure project-relative source-map sources are output.
```javascript
var templateFn = require('adjust-sourcemap-loader')
.moduleFilenameTemplate({
format: 'projectRelative'
});
module.exports = {
output: {
...
devtoolModuleFilenameTemplate : templateFn,
devtoolFallbackModuleFilenameTemplate: templateFn
}
};
```
## Options
As a loader, options may be set using [query parameters](https://webpack.github.io/docs/using-loaders.html#query-parameters) or by using [programmatic parameters](https://webpack.github.io/docs/how-to-write-a-loader.html#programmable-objects-as-query-option). Programmatic means the following in your `webpack.config`.
```javascript
module.exports = {
adjustSourcemapLoader: {
...
}
}
```
Where `...` is a hash of any of the following options.
* **`debug`** : `boolean|RegExp` May be used alone (boolean) or with a `RegExp` to match the resource(s) you are interested in debugging.
* **`fail`** : `boolean` Implies an **Error** if a source-map source cannot be decoded.
* **`format`** : `string` Optional output format for source-map `sources`. Must be the name of one of the available `codecs`. Omitting the format will result in **no change** and the outgoing source-map will match the incomming one.
* **`root`** : `boolean` A boolean flag that indices that a `sourceRoot` path sould be included in the output map. This is contingent on a `format` being specified.
* **`codecs`** : `Array.<{name:string, decode:function, encode:function, root:function}>` Optional Array of codecs. There are a number of built-in codecs available. If you specify you own codecs you will loose those that are built-in. However you can include them from the `codec/` directory.
Note that **query** parameters take precedence over **programmatic** parameters.
### Changing the format
Built-in codecs that may be specified as a `format` include:
* `absolute`
* `outputRelative`
* `projectRelative`
* `webpackProtocol`
* `sourceRelative` (works for loader only, **not** Module filename template)
### Specifying codecs
There are additional built-in codecs that do not support encoding. These are still necessary to decode source-map sources. If you specify your own `options.codecs` then you should **also include the built-in codecs**. Otherwise you will find that some sources cannot be decoded.
The existing codecs may be found in `/codec`, or on the loader itself:
```javascript
var inBuiltCodecs = require('adjust-sourcemap-loader').codecs,
myCodecs = [
{
name : 'foo',
decode: function(uri) {...},
encode: function(absolute) {...},
root : function() {...}
},
...
];
module.exports = {
adjustSourcemapLoader: {
codecs: inBuiltCodecs.concat(myCodecs)
}
}
```
The codec **order is important**. Those that come first have precedence. Any codec that detects a distinct URI should be foremost so that illegal paths are not encountered by successive codecs.
### Abstract codecs
A codec that detects generated code and cannot `decode()` a URI to an absolute file path.
Instead of implementing `encode()` or `root()` it should instead specify `abstract:true`. Its `decode()` function then may return `boolean` where it detects such generated sources.
For example, a built-in abstract codec will match the **Webpack bootstrap** code and ensure that its illegal source uri is not encountered by later coders.
## How it works
The loader will receive a source map as its second parameter, so long as the preceding loader was using source-maps.
The exception is the **css-loader** where the source-map is in the content, which is **not currently supported** .
The source-map `sources` are parsed by applying **codec.decode()** functions until one of them returns an absolute path to a file that exists. The exception is abstract codecs, where the source with remain unchanged.
If a format is specified then the source-map `sources` are recreated by applying the **codec.encode()** function for the stated `format` and (where the `root` option is specified) the **codec.root()** function will set the source-map `sourceRoot`.
If a codec does not specify **codec.encode()** or **codec.root()** then it may **not** be used as the `format`.