first commit

This commit is contained in:
2026-09-08 20:28:54 +08:00
commit 2ada8d3d5a
37380 changed files with 4886169 additions and 0 deletions
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2013-2016 Evan You
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.
@@ -0,0 +1,65 @@
# vue-router [![Build Status](https://img.shields.io/circleci/project/vuejs/vue-router/dev.svg)](https://circleci.com/gh/vuejs/vue-router)
> This is vue-router 2.0 which works only with Vue 2.0. For the 1.x router see the [1.0 branch](https://github.com/vuejs/vue-router/tree/1.0).
### Introduction
`vue-router` is the official router for [Vue.js](http://vuejs.org). It deeply integrates with Vue.js core to make building Single Page Applications with Vue.js a breeze. Features include:
- Nested route/view mapping
- Modular, component-based router configuration
- Route params, query, wildcards
- View transition effects powered by Vue.js' transition system
- Fine-grained navigation control
- Links with automatic active CSS classes
- HTML5 history mode or hash mode, with auto-fallback in IE9
- Customizable Scroll Behavior
Get started with the [documentation](http://vuejs.github.io/vue-router), or play with the [examples](https://github.com/vuejs/vue-router/tree/dev/examples) (see how to run them below).
### Development Setup
``` bash
# install deps
npm install
# build dist files
npm run build
# serve examples at localhost:8080
npm run dev
# lint & run all tests
npm test
# serve docs at localhost:4000 (requires global gitbook-cli)
npm run docs
```
## Questions
For questions and support please use the [Discord chat server](https://chat.vuejs.org) or [the official forum](http://forum.vuejs.org). The issue list of this repo is **exclusively** for bug reports and feature requests.
## Issues
Please make sure to read the [Issue Reporting Checklist](https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#issue-reporting-guidelines) before opening an issue. Issues not conforming to the guidelines may be closed immediately.
## Contribution
Please make sure to read the [Contributing Guide](https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md) before making a pull request.
## Changelog
Details changes for each release are documented in the [release notes](https://github.com/vuejs/vue-router/releases).
## Stay In Touch
- For latest releases and announcements, follow on Twitter: [@vuejs](https://twitter.com/vuejs)
## License
[MIT](http://opensource.org/licenses/MIT)
Copyright (c) 2013-2017 Evan You
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,22 @@
{
"name": "vue-router",
"version": "3.0.1",
"description": "Official router for Vue.js 2",
"author": "Evan You",
"license": "MIT",
"main": "dist/vue-router.common.js",
"module": "dist/vue-router.esm.js",
"unpkg": "dist/vue-router.js",
"repository": {
"type": "git",
"url": "https://github.com/vuejs/vue-router.git"
},
"typings": "types/index.d.ts",
"keywords": [
"vue",
"router",
"routing"
],
"scripts": {},
"devDependencies": {}
}
@@ -0,0 +1,16 @@
import "./vue";
import { VueRouter } from "./router";
export default VueRouter;
export {
RouterMode,
RawLocation,
RedirectOption,
RouterOptions,
RouteConfig,
RouteRecord,
Location,
Route,
NavigationGuard
} from "./router";
@@ -0,0 +1,126 @@
import Vue, { ComponentOptions, PluginFunction, AsyncComponent } from "vue";
type Component = ComponentOptions<Vue> | typeof Vue | AsyncComponent;
type Dictionary<T> = { [key: string]: T };
export type RouterMode = "hash" | "history" | "abstract";
export type RawLocation = string | Location;
export type RedirectOption = RawLocation | ((to: Route) => RawLocation);
export type NavigationGuard = (
to: Route,
from: Route,
next: (to?: RawLocation | false | ((vm: Vue) => any) | void) => void
) => any
export declare class VueRouter {
constructor (options?: RouterOptions);
app: Vue;
mode: RouterMode;
currentRoute: Route;
beforeEach (guard: NavigationGuard): Function;
beforeResolve (guard: NavigationGuard): Function;
afterEach (hook: (to: Route, from: Route) => any): Function;
push (location: RawLocation, onComplete?: Function, onAbort?: Function): void;
replace (location: RawLocation, onComplete?: Function, onAbort?: Function): void;
go (n: number): void;
back (): void;
forward (): void;
getMatchedComponents (to?: RawLocation | Route): Component[];
onReady (cb: Function, errorCb?: Function): void;
onError (cb: Function): void;
addRoutes (routes: RouteConfig[]): void;
resolve (to: RawLocation, current?: Route, append?: boolean): {
location: Location;
route: Route;
href: string;
// backwards compat
normalizedTo: Location;
resolved: Route;
};
static install: PluginFunction<never>;
}
type Position = { x: number, y: number };
type PositionResult = Position | { selector: string, offset?: Position } | void;
export interface RouterOptions {
routes?: RouteConfig[];
mode?: RouterMode;
fallback?: boolean;
base?: string;
linkActiveClass?: string;
linkExactActiveClass?: string;
parseQuery?: (query: string) => Object;
stringifyQuery?: (query: Object) => string;
scrollBehavior?: (
to: Route,
from: Route,
savedPosition: Position | void
) => PositionResult | Promise<PositionResult>;
}
type RoutePropsFunction = (route: Route) => Object;
export interface PathToRegexpOptions {
sensitive?: boolean;
strict?: boolean;
end?: boolean;
}
export interface RouteConfig {
path: string;
name?: string;
component?: Component;
components?: Dictionary<Component>;
redirect?: RedirectOption;
alias?: string | string[];
children?: RouteConfig[];
meta?: any;
beforeEnter?: NavigationGuard;
props?: boolean | Object | RoutePropsFunction;
caseSensitive?: boolean;
pathToRegexpOptions?: PathToRegexpOptions;
}
export interface RouteRecord {
path: string;
regex: RegExp;
components: Dictionary<Component>;
instances: Dictionary<Vue>;
name?: string;
parent?: RouteRecord;
redirect?: RedirectOption;
matchAs?: string;
meta: any;
beforeEnter?: (
route: Route,
redirect: (location: RawLocation) => void,
next: () => void
) => any;
props: boolean | Object | RoutePropsFunction | Dictionary<boolean | Object | RoutePropsFunction>;
}
export interface Location {
name?: string;
path?: string;
hash?: string;
query?: Dictionary<string>;
params?: Dictionary<string>;
append?: boolean;
replace?: boolean;
}
export interface Route {
path: string;
name?: string;
hash: string;
query: Dictionary<string>;
params: Dictionary<string>;
fullPath: string;
matched: RouteRecord[];
redirectedFrom?: string;
meta?: any;
}
@@ -0,0 +1,22 @@
/**
* Augment the typings of Vue.js
*/
import Vue from "vue";
import VueRouter, { Route, RawLocation, NavigationGuard } from "./index";
declare module "vue/types/vue" {
interface Vue {
$router: VueRouter;
$route: Route;
}
}
declare module "vue/types/options" {
interface ComponentOptions<V extends Vue> {
router?: VueRouter;
beforeRouteEnter?: NavigationGuard;
beforeRouteLeave?: NavigationGuard;
beforeRouteUpdate?: NavigationGuard;
}
}