个人代码段记录(Visual Studio与 Visual Studio Code)

一、 Visual Studio代码段

1. action.snippet

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>action</Title>
			<Shortcut>action</Shortcut>
			<Description>controller的action 的代码片段</Description>
			<Author>Microsoft Corporation</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
				<SnippetType>SurroundsWith</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>comment</ID>
					<ToolTip>注释</ToolTip>
					<Default>comment</Default>
				</Literal>
					
				<Literal>
					<ID>requestType</ID>
					<ToolTip>请求方式</ToolTip>
					<Default>HttpPost</Default>
				</Literal>
					
				<Literal>
					<ID>responseClass</ID>
					<ToolTip>返回类型</ToolTip>
					<Default>responseClass</Default>
				</Literal>
					
				<Literal>
					<ID>actionName</ID>
					<ToolTip>名称</ToolTip>
					<Default>actionName</Default>
				</Literal>
					
				<Literal>
					<ID>requestClass</ID>
					<ToolTip>要计算的表达式</ToolTip>
					<Default>requestClass</Default>
				</Literal>
					
				<Literal>
					<ID>handler</ID>
					<ToolTip>处理方式</ToolTip>
					<Default>handler</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[/// <summary>
		/// $comment$
		/// </summary>
		/// <param name="request"></param>
		/// <returns></returns>
		[$requestType$]
		public ResponseHolder<$responseClass$> $actionName$ (RequestHolder<$requestClass$> request)
		{
			return $handler$(request);
		}]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

2. ei

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>ei</Title>
			<Shortcut>ei</Shortcut>
			<Description>枚举值的代码片段</Description>
			<Author>Microsoft Corporation</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
				<SnippetType>SurroundsWith</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>note</ID>
					<ToolTip>枚举注释</ToolTip>
					<Default></Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>枚举名</ToolTip>
					<Default>MyProperty</Default>
				</Literal>
				<Literal>
					<ID>value</ID>
					<ToolTip>枚举值</ToolTip>
					<Default>0</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[/// <summary>
											 /// $note$
											 /// </summary>
											 $property$ = $value$,$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

3. prop

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>prop</Title>
			<Shortcut>prop</Shortcut>
			<Description>自动实现的属性的代码片段
语言版本:  C# 3.0 或更高版本</Description>
			<Author>Microsoft Corporation</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>type</ID>
					<ToolTip>属性类型</ToolTip>
					<Default>int</Default>
				</Literal>
				<Literal>
					<ID>property</ID>
					<ToolTip>属性名</ToolTip>
					<Default>MyProperty</Default>
				</Literal>
				<Literal>
					<ID>note</ID>
					<ToolTip>属性注释</ToolTip>
					<Default></Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[/// <summary>
			///	$note$
			/// <summary>
			public $type$ $property$ { get; set; }$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

二、Visual Studio Code代码段

1. html

{
	// Place your snippets for html here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	// Example:
	// "Print to console": {
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
	"new page": {
		"prefix": "page",
		"body": [
			"<div class='page $1'>",
			"\t<div class='navbar'>",
			"\t\t<div class='navbar-bg'></div>",
			"\t\t<div class='navbar-inner'>",
			"\t\t\t<div class='left'>",
			"\t\t\t\t<a href='#' class='link back'>",
			"\t\t\t\t\t<i class='icon icon-back'></i>",
			"\t\t\t\t</a>",
			"\t\t\t</div>",
			"\t\t\t<div class='title'>$2</div>",
			"\t\t</div>",
			"\t</div>",
			"\t<div class='page-content'>",
			"\t</div>",
			"</div>"
		],
		"description": "F7 View"
	}
}

2. javascript

{
	// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	// Example:
	// "Print to console": {
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
	"controll js": {
		"prefix": "controller",
		"body": [
			"let thisPage = {",
			"\tpageOn: {},",
			"}",
			"",
			"let \\$\\$ = null;",
			"let t7 = null;",
			"let el = null;",
			"let app = null;",
			"",
			"let pageData = {};",
			"let pageControl = {};",
			"",
			"thisPage.pageOn.pageInit = function (e, page) {",
			"\t\\$\\$ = page.app.\\$;",
			"\tt7 = page.app.t7;",
			"\tel = page.\\$el;",
			"\tapp = page.app;",
			"",
			"\tbindEvent();",
			"};",
			"",
			"thisPage.pageOn.pageBeforeIn = function (e, page) {",
			"\t\\$\\$ = page.app.\\$;",
			"\tt7 = page.app.t7;",
			"\tel = page.\\$el;",
			"\tapp = page.app;",
			"",
			"\tpageData.paramters = page.route.params;",
			"",
			"\tbindData();",
			"};",
			"",
			"thisPage.pageOn.pageBeforeRemove = function (e, page) {",
			"\tpageData = null;",
			"\tpageControl = null;",
			"};",
			"",
			"function bindData() {",
			"};",
			"",
			"function bindEvent() {",
			"};",
			"",
			"export default thisPage;"
		],
		"description": "ES6 Controller js"
	},
	"find js": {
		"body": "el.find('$1')",
		"prefix": "ef",
		"description": "获取元素"
	},
	"on js": {
		"body": [
			"el.on('$1', '$2$CLIPBOARD', function (e) {",
			"})",
		],
		"prefix": "eo",
		"description": "添加事件"
	},
	"api js":{
		"body": [
			"import post from '@/utils/request';",
			"",
			"const baseUrl = '$1';",
			"",
			"const apiUrl = {};",
			"",
		],
		"prefix": "api",
		"description": "vue api代码段"
	},
	"api function js":{
		"body":[
			"export function $1({ $2,$3,$4 }) {",
			"\treturn post({",
			"\t\turl: apiUrl.$1,",
			"\t\tdata:{",
			"\t\t\tData: {",
			"\t\t\t\t$2: $2,",
			"\t\t\t\t$3: $3,",
			"\t\t\t\t$4: $4,",
			"\t\t\t}",
			"\t\t}",
			"});",
			"}"
		],
		"prefix": "afu",
		"description": "vue api function 代码段"
	},
	"api url js":{
		"body": "$1: baseUrl + '$1'",
		"prefix": "aurl",
		"description": "vuw api url 代码段"
	}
}
posted @ 2021-12-17 17:24  zero_night  阅读(84)  评论(0)    收藏  举报