增加admin管理帐号和项目的界面--初步实现

This commit is contained in:
Cheng Zhou
2025-12-17 20:12:49 +08:00
parent 4f50237f56
commit c074c2b5bc
18933 changed files with 2088454 additions and 63 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021-present Johnson Chu
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.
+36
View File
@@ -0,0 +1,36 @@
# vue-tsc
Install: `npm i vue-tsc -D`
Usage: `vue-tsc --noEmit && vite build`
Vue 3 command line Type-Checking tool base on IDE plugin [Volar](https://github.com/vuejs/language-tools).
Roadmap:
- [x] Type-Checking with `--noEmit`
- [x] Use released LSP module
- [x] Make `typescript` as peerDependencies
- [x] Cleaner dependencies (remove `prettyhtml`, `prettier` etc.) (with `vscode-vue-languageservice` version >= 0.26.4)
- [x] dts emit support
- [x] Watch mode support
## Usage
Type check:
`vue-tsc --noEmit`
Build dts:
`vue-tsc --declaration --emitDeclarationOnly`
Check out https://github.com/vuejs/language-tools/discussions/640#discussioncomment-1555479 for example repo.
## Sponsors
<p align="center">
<a href="https://cdn.jsdelivr.net/gh/johnsoncodehk/sponsors/sponsors.svg">
<img src="https://cdn.jsdelivr.net/gh/johnsoncodehk/sponsors/sponsors.svg"/>
</a>
</p>
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env node
const semver = require('semver')
const fs = require('fs');
const tsPkg = require('typescript/package.json');
const readFileSync = fs.readFileSync;
const tscPath = require.resolve('typescript/lib/tsc');
const proxyApiPath = require.resolve('../out/index');
const { state } = require('../out/shared');
fs.readFileSync = (...args) => {
if (args[0] === tscPath) {
let tsc = readFileSync(...args);
// add *.vue files to allow extensions
tryReplace(/supportedTSExtensions = .*(?=;)/, s => s + '.concat([[".vue"]])');
tryReplace(/supportedJSExtensions = .*(?=;)/, s => s + '.concat([[".vue"]])');
tryReplace(/allSupportedExtensions = .*(?=;)/, s => s + '.concat([[".vue"]])');
// proxy createProgram apis
tryReplace(/function createProgram\(.+\) {/, s => s + ` return require(${JSON.stringify(proxyApiPath)}).createProgram(...arguments);`);
// patches logic for checking root file extension in build program for incremental builds
if (semver.gt(tsPkg.version, '5.0.0')) {
tryReplace(
`for (const existingRoot of buildInfoVersionMap.roots) {`,
`for (const existingRoot of buildInfoVersionMap.roots
.filter(file => !file.toLowerCase().includes('__vls_'))
.map(file => file.replace(/\.vue\.(j|t)sx?$/i, '.vue'))
) {`
);
tryReplace(
`return [toFileId(key), toFileIdListId(state.exportedModulesMap.getValues(key))];`,
`return [toFileId(key), toFileIdListId(new Set(arrayFrom(state.exportedModulesMap.getValues(key)).filter(file => file !== void 0)))];`
);
}
if (semver.gte(tsPkg.version, '5.0.4')) {
tryReplace(
`return createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, host);`,
s => `buildInfo.program.fileNames = buildInfo.program.fileNames
.filter(file => !file.toLowerCase().includes('__vls_'))
.map(file => file.replace(/\.vue\.(j|t)sx?$/i, '.vue'));\n` + s
);
}
return tsc;
function tryReplace(search, replace) {
const before = tsc;
tsc = tsc.replace(search, replace);
const after = tsc;
if (after === before) {
throw 'Search string not found: ' + JSON.stringify(search.toString());
}
}
}
return readFileSync(...args);
};
(function main() {
try {
require(tscPath);
}
catch (err) {
if (err === 'hook') {
state.hook.worker.then(main);
}
else {
throw err;
}
}
})();
+17
View File
@@ -0,0 +1,17 @@
import type * as ts from 'typescript/lib/tsserverlibrary';
import * as vue from '@vue/language-core';
export type Hook = (program: _Program) => void;
export type _Program = ts.Program & {
__vue: ProgramContext;
};
interface ProgramContext {
projectVersion: number;
options: ts.CreateProgramOptions;
languageHost: vue.TypeScriptLanguageHost;
vueCompilerOptions: Partial<vue.VueCompilerOptions>;
langaugeContext: vue.LanguageContext;
languageService: ts.LanguageService;
}
export declare function createProgram(options: ts.CreateProgramOptions): _Program;
export {};
//# sourceMappingURL=index.d.ts.map
+126
View File
@@ -0,0 +1,126 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createProgram = void 0;
const vue = require("@vue/language-core");
const volarTs = require("@volar/typescript");
const shared_1 = require("./shared");
const windowsPathReg = /\\/g;
function createProgram(options) {
if (!options.options.noEmit && !options.options.emitDeclarationOnly)
throw toThrow('js emit is not supported');
if (!options.options.noEmit && options.options.noEmitOnError)
throw toThrow('noEmitOnError is not supported');
if (options.options.extendedDiagnostics || options.options.generateTrace)
throw toThrow('--extendedDiagnostics / --generateTrace is not supported, please run `Write Virtual Files` in VSCode to write virtual files and use `--extendedDiagnostics` / `--generateTrace` via tsc instead of vue-tsc to debug.');
if (!options.host)
throw toThrow('!options.host');
const ts = require('typescript');
let program = options.oldProgram;
if (shared_1.state.hook) {
program = shared_1.state.hook.program;
program.__vue.options = options;
}
else if (!program) {
const ctx = {
projectVersion: 0,
options,
get languageHost() {
return languageHost;
},
get vueCompilerOptions() {
return vueCompilerOptions;
},
get languageService() {
return vueTsLs;
},
get langaugeContext() {
return languageContext;
},
};
const vueCompilerOptions = getVueCompilerOptions();
const scripts = new Map();
const languageHost = {
workspacePath: ctx.options.host.getCurrentDirectory().replace(windowsPathReg, '/'),
rootPath: ctx.options.host.getCurrentDirectory().replace(windowsPathReg, '/'),
getCompilationSettings: () => ctx.options.options,
getScriptFileNames: () => {
return ctx.options.rootNames;
},
getScriptSnapshot,
getProjectVersion: () => {
return ctx.projectVersion.toString();
},
getProjectReferences: () => ctx.options.projectReferences,
getCancellationToken: ctx.options.host.getCancellationToken ? () => ctx.options.host.getCancellationToken() : undefined,
};
const languageContext = vue.createLanguageContext(languageHost, vue.createLanguages(ts, languageHost.getCompilationSettings(), vueCompilerOptions));
const languageServiceHost = volarTs.createLanguageServiceHost(languageContext, ts, ts.sys);
const vueTsLs = ts.createLanguageService(languageServiceHost, volarTs.getDocumentRegistry(ts, ts.sys.useCaseSensitiveFileNames, languageHost.workspacePath));
volarTs.decorateLanguageService(languageContext.virtualFiles, vueTsLs, false);
program = volarTs.getProgram(ts, languageContext, vueTsLs, ts.sys);
program.__vue = ctx;
function getVueCompilerOptions() {
const tsConfig = ctx.options.options.configFilePath;
if (typeof tsConfig === 'string') {
return vue.createParsedCommandLine(ts, ts.sys, tsConfig.replace(windowsPathReg, '/')).vueOptions;
}
return {};
}
function getScriptSnapshot(fileName) {
return getScript(fileName)?.scriptSnapshot;
}
function getScript(fileName) {
const script = scripts.get(fileName);
if (script?.projectVersion === ctx.projectVersion) {
return script;
}
const modifiedTime = ts.sys.getModifiedTime?.(fileName)?.valueOf() ?? 0;
if (script?.modifiedTime === modifiedTime) {
return script;
}
if (ctx.options.host.fileExists(fileName)) {
const fileContent = ctx.options.host.readFile(fileName);
if (fileContent !== undefined) {
const script = {
projectVersion: ctx.projectVersion,
modifiedTime,
scriptSnapshot: ts.ScriptSnapshot.fromString(fileContent),
version: ctx.options.host.createHash?.(fileContent) ?? fileContent,
};
scripts.set(fileName, script);
return script;
}
}
}
}
else {
const ctx = program.__vue;
ctx.options = options;
ctx.projectVersion++;
}
const vueCompilerOptions = program.__vue.vueCompilerOptions;
if (vueCompilerOptions?.hooks) {
const index = (shared_1.state.hook?.index ?? -1) + 1;
if (index < vueCompilerOptions.hooks.length) {
const hookPath = vueCompilerOptions.hooks[index];
const hook = require(hookPath);
shared_1.state.hook = {
program,
index,
worker: (async () => await hook(program))(),
};
throw 'hook';
}
}
for (const rootName of options.rootNames) {
// register file watchers
options.host.getSourceFile(rootName, ts.ScriptTarget.ESNext);
}
return program;
}
exports.createProgram = createProgram;
function toThrow(msg) {
console.error(msg);
return msg;
}
//# sourceMappingURL=index.js.map
+9
View File
@@ -0,0 +1,9 @@
import type { _Program } from './index';
export declare const state: {
hook?: {
program: _Program;
index: number;
worker: Promise<any>;
};
};
//# sourceMappingURL=shared.d.ts.map
+5
View File
@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.state = void 0;
exports.state = {};
//# sourceMappingURL=shared.js.map
+31
View File
@@ -0,0 +1,31 @@
{
"name": "vue-tsc",
"version": "1.8.27",
"main": "out/index.js",
"license": "MIT",
"files": [
"bin",
"out/**/*.js",
"out/**/*.d.ts"
],
"repository": {
"type": "git",
"url": "https://github.com/vuejs/language-tools.git",
"directory": "packages/tsc"
},
"bin": {
"vue-tsc": "./bin/vue-tsc.js"
},
"dependencies": {
"@volar/typescript": "~1.11.1",
"@vue/language-core": "1.8.27",
"semver": "^7.5.4"
},
"peerDependencies": {
"typescript": "*"
},
"devDependencies": {
"@types/node": "latest"
},
"gitHead": "09c04807eb19f1261cc429af1b90c6561166ad4f"
}