lrf 3 éve
szülő
commit
d2d6a9e77a
3 módosított fájl, 450 hozzáadás és 0 törlés
  1. 34 0
      vscode/key.json
  2. 77 0
      vscode/setting.json
  3. 339 0
      vscode/snippet.json

+ 34 - 0
vscode/key.json

@@ -0,0 +1,34 @@
+[
+  {
+    "key": "ctrl+oem_3",
+    "command": "-workbench.action.terminal.toggleTerminal"
+  },
+  {
+    "key": "ctrl+d",
+    "command": "editor.action.deleteLines",
+    "when": "textInputFocus && !editorReadonly"
+  },
+  {
+    "key": "shift+alt+w",
+    "command": "editor.foldRecursively",
+    "when": "editorTextFocus"
+  },
+  {
+    "key": "shift+alt+s",
+    "command": "editor.unfold",
+    "when": "editorTextFocus"
+  },
+  {
+    "key": "shift+alt+s",
+    "command": "editor.unfoldRecursively"
+  },
+  {
+    "key": "ctrl+alt+f",
+    "command": "eslint.executeAutofix"
+  },
+  {
+    "key": "alt+oem_2",
+    "command": "editor.action.triggerSuggest",
+    "when": "editorHasCompletionItemProvider && textInputFocus && !editorReadonly"
+  }
+]

+ 77 - 0
vscode/setting.json

@@ -0,0 +1,77 @@
+{
+  "sync.gist": "38a3beb36ad3969fc98c7e65e3d2095e",
+  "git.path": "S:\\software\\Git\\cmd\\git.exe",
+  "[typescript]": {
+    "editor.defaultFormatter": "esbenp.prettier-vscode"
+  },
+  "search.exclude": {
+    "**/node_modules": false,
+    "**/bower_components": true,
+    "**/target": false,
+    "**/logs": true
+  },
+  "editor.formatOnPaste": true,
+  "javascript.updateImportsOnFileMove.enabled": "always",
+  "files.encoding": "utf8",
+  "files.autoGuessEncoding": false,
+  "files.autoSave": "off",
+  "files.eol": "\n",
+  "editor.tabSize": 2,
+  "git.autofetch": true,
+  "editor.detectIndentation": false,
+  "vetur.validation.template": false,
+  // "eslint.autoFixOnSave": true,
+  "eslint.validate": [
+    "javascript",
+    "javascriptreact",
+    {
+      "language": "vue",
+      "autoFix": true
+    },
+    {
+      "language": "html",
+      "autoFix": true
+    }
+  ],
+  "vetur.format.defaultFormatter.html": "js-beautify-html",
+  "vetur.format.defaultFormatterOptions": {
+    "js-beautify-html": {
+      "wrap-line-length": 120,
+      "wrap_attributes": "aligned-multiple",
+    },
+    "prettier": {
+      "singleQuote": true,
+      "trailingComma": "es5",
+      "printWidth": 160,
+    },
+  },
+  "vetur.format.defaultFormatter.js": "vscode-typescript",
+  "git.confirmSync": false,
+  "editor.suggestSelection": "first",
+  "editor.cursorBlinking": "smooth",
+  "files.watcherExclude": {
+    "**/package-lock.json": true
+  },
+  "files.exclude": {
+    "**/.settings": true,
+    "**/.factorypath": true
+  },
+  "diffEditor.ignoreTrimWhitespace": true,
+  "editor.quickSuggestions": {
+    "strings": true
+  },
+  "[javascript]": {
+    "editor.defaultFormatter": "esbenp.prettier-vscode"
+  }, // jade/pug quotes
+  "prettier.printWidth": 180,
+  "prettier.singleQuote": true,
+  "prettier.trailingComma": "es5",
+  "prettier.bracketSpacing": true,
+  "editor.snippetSuggestions": "top",
+  "[jsonc]": {
+    "editor.defaultFormatter": "esbenp.prettier-vscode"
+  },
+  "[vue]": {
+    "editor.defaultFormatter": "octref.vetur"
+  },
+}

+ 339 - 0
vscode/snippet.json

@@ -0,0 +1,339 @@
+{
+  "vue-template": {
+    "prefix": "vue2",
+    "body": [
+      "<template>",
+      "  <div id=\"${TM_FILENAME_BASE}\">",
+      "    <p>${TM_FILENAME_BASE}</p>",
+      "  </div>",
+      "</template>",
+      "",
+      "<script>",
+      "import { mapState, createNamespacedHelpers } from 'vuex';",
+      "export default {",
+      "  name: '${TM_FILENAME_BASE}',",
+      "  props: {},",
+      "  components: {},",
+      "  data: function () {",
+      "    return {};",
+      "  },",
+      "  created() {},",
+      "  methods: {},",
+      "  computed: {",
+      "    ...mapState(['user', 'menuParams']),",
+      "    pageTitle() {",
+      "      return `${this.\\$route.meta.title}`;",
+      "    },",
+      "  },",
+      "  metaInfo() {",
+      "    return { title: this.\\$route.meta.title };",
+      "  },",
+      "};",
+      "</script>",
+      "",
+      "<style lang=\"less\" scoped></style>",
+      "",
+    ],
+    "description": "vue template"
+  },
+  "fast lodash": {
+    "prefix": "lodash",
+    "body": [
+      "const _ = require('lodash');",
+    ],
+    "description": "lodash"
+  },
+  "fast moment": {
+    "prefix": "moment",
+    "body": [
+      "const moment = require('moment');",
+    ],
+    "description": "moment"
+  },
+  "JSON copy": {
+    "prefix": "JSONps",
+    "body": [
+      "JSON.parse(JSON.stringify(${1}));",
+    ],
+    "description": "space"
+  },
+	"console in function": {
+		"prefix": "function in",
+		"body": [
+			"console.log('in function:');",
+		],
+		"description": "test button "
+	},
+	"fast import components": {
+		"prefix": "import components",
+		"body": [
+			"import ${1} from '@/components/${1}.vue';",
+		],
+		"description": "fast import components "
+  },
+  "log": {
+    "prefix": "log",
+    "body": [
+      "console.log(${1});",
+    ],
+    "description": "fast import components "
+  },
+  "duplicate": {
+    "prefix": "duplicate",
+    "body": [
+      "let dup = _.cloneDeep(${1});",
+    ],
+    "description": "fast copy "
+  },
+  // vue3模板
+  "vue3-template": {
+    "prefix": "vue3",
+    "body": [
+      "<template>",
+      "  <div id=\"${TM_FILENAME_BASE}\">",
+      "    <p>${TM_FILENAME_BASE}</p>",
+      "  </div>",
+      "</template>",
+      "",
+      "<script>",
+      "import { defineComponent, ref, reactive } from 'vue';",
+      "export default defineComponent({",
+      "  name: '${TM_FILENAME_BASE}',",
+      "  components: {},",
+      "  props: {},",
+      "  setup(props, context) {",
+      "    return {};",
+      "  },",
+      "});",
+      "</script>",
+      "",
+      "<style lang=\"less\" scoped></style>",
+      "",
+    ],
+    "description": "vue template"
+  },
+  // 服务端部分
+  "mongodb model column": {
+    "prefix": "mmc",
+    "body": [
+      "${1}: { type: ${2} }, // ${3}",
+    ],
+    "description": "mongodb fast model "
+  },
+  "egg controller config": {
+    "prefix": "egg config",
+    "body": [
+      "module.exports = {",
+      "  create: {",
+      "    requestBody: [],",
+      "  },",
+      "  destroy: {",
+      "    params: [\"!id\"],",
+      "    service: \"delete\",",
+      "  },",
+      "  update: {",
+      "    params: [\"!id\"],",
+      "    requestBody: [],",
+      "  },",
+      "  show: {",
+      "    parameters: {",
+      "      params: [\"!id\"],",
+      "    },",
+      "    service: \"fetch\",",
+      "  },",
+      "  index: {",
+      "    parameters: {",
+      "      query: {",
+      "        \"meta.createdAt@start\": \"meta.createdAt@start\",",
+      "        \"meta.createdAt@end\": \"meta.createdAt@end\",",
+      "      },",
+      "      // options: {",
+      "      //   \"meta.state\": 0 // 默认条件",
+      "      // },",
+      "    },",
+      "    service: \"query\",",
+      "    options: {",
+      "      query: [\"skip\", \"limit\"],",
+      "      sort: [\"meta.createdAt\"],",
+      "      desc: true,",
+      "      count: true,",
+      "    },",
+      "  },",
+      "};",
+      "",
+    ],
+    "description": "egg fast controller config "
+  },
+  "mongodb model free": {
+    "prefix": "fmmodel",
+    "body": [
+      "'use strict';",
+      "const Schema = require('mongoose').Schema;",
+      "const moment = require('moment');",
+      "const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');",
+      "const { ObjectId } = require('mongoose').Types;",
+      "// ${1}表",
+      "const ${TM_FILENAME_BASE} = {",
+      "  remark: { type: String },",
+      "};",
+      "const schema = new Schema(${TM_FILENAME_BASE}, { toJSON: { virtuals: true } });",
+      "schema.index({ id: 1 });",
+      "schema.index({ 'meta.createdAt': 1 });",
+      "schema.plugin(metaPlugin);",
+      "module.exports = app => {",
+      "  const { mongoose } = app;",
+      "  return mongoose.model('${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}', schema, '${TM_FILENAME_BASE}');",
+      "};",
+      "",
+    ],
+    "description": "mongodb fast model "
+  },
+  "egg service free": {
+    "prefix": "fegg service",
+    "body": [
+      "'use strict';",
+      "const { CrudService } = require('naf-framework-mongoose-free/lib/service');",
+      "const { BusinessError, ErrorCode } = require('naf-core').Error;",
+      "const _ = require('lodash');",
+      "const assert = require('assert');",
+      "",
+      "// $2",
+      "class ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Service extends CrudService {",
+      "  constructor(ctx) {",
+      "    super(ctx, '${TM_FILENAME_BASE/(.*)/${1:/downcase}/}');",
+      "    this.model = this.ctx.model.$3${TM_FILENAME_BASE/(.*)/${1:/capitalize}/};",
+      "  }",
+      "}",
+      "",
+      "module.exports = ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Service;",
+      "",
+    ],
+    "description": "egg fast service "
+  },
+  "egg controller free": {
+    "prefix": "fegg controller",
+    "body": [
+      "'use strict';",
+      "const meta = require('./.${TM_FILENAME_BASE/(.*)/${1:/downcase}/}.js');",
+      "const Controller = require('egg').Controller;",
+      "const { CrudController } = require('naf-framework-mongoose-free/lib/controller');",
+      "",
+      "// $1",
+      "class ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Controller extends Controller {",
+      "  constructor(ctx) {",
+      "    super(ctx);",
+      "    this.service = this.ctx.service.$2${TM_FILENAME_BASE/(.*)/${1:/downcase}/};",
+      "  }",
+      "}",
+      "module.exports = CrudController(${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Controller, meta);",
+      "",
+    ],
+    "description": "egg fast controller "
+  },
+  "mongodb model": {
+    "prefix": "mmodel",
+    "body": [
+      "'use strict';",
+      "const Schema = require('mongoose').Schema;",
+      "const moment = require('moment');",
+      "const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');",
+      "const { ObjectId } = require('mongoose').Types;",
+      "// ${1}表",
+      "const ${TM_FILENAME_BASE} = {",
+      "  remark: { type: String },",
+      "};",
+      "const schema = new Schema(${TM_FILENAME_BASE}, { toJSON: { virtuals: true } });",
+      "schema.index({ id: 1 });",
+      "schema.index({ 'meta.createdAt': 1 });",
+      "schema.plugin(metaPlugin);",
+      "module.exports = app => {",
+      "  const { mongoose } = app;",
+      "  return mongoose.model('${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}', schema, '${TM_FILENAME_BASE}');",
+      "};",
+      "",
+    ],
+    "description": "mongodb fast model "
+  },
+  "egg service": {
+    "prefix": "egg service",
+    "body": [
+      "'use strict';",
+      "const { CrudService } = require('naf-framework-mongoose/lib/service');",
+      "const { BusinessError, ErrorCode } = require('naf-core').Error;",
+      "const _ = require('lodash');",
+      "const assert = require('assert');",
+      "",
+      "// $2",
+      "class ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Service extends CrudService {",
+      "  constructor(ctx) {",
+      "    super(ctx, '${TM_FILENAME_BASE/(.*)/${1:/downcase}/}');",
+      "    this.model = this.ctx.model.$3${TM_FILENAME_BASE/(.*)/${1:/capitalize}/};",
+      "  }",
+      "}",
+      "",
+      "module.exports = ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Service;",
+      "",
+    ],
+    "description": "egg fast service "
+  },
+  "egg controller": {
+    "prefix": "egg controller",
+    "body": [
+      "'use strict';",
+      "const meta = require('./.${TM_FILENAME_BASE/(.*)/${1:/downcase}/}.js');",
+      "const Controller = require('egg').Controller;",
+      "const { CrudController } = require('naf-framework-mongoose/lib/controller');",
+      "",
+      "// $1",
+      "class ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Controller extends Controller {",
+      "  constructor(ctx) {",
+      "    super(ctx);",
+      "    this.service = this.ctx.service.$2${TM_FILENAME_BASE/(.*)/${1:/downcase}/};",
+      "  }",
+      "}",
+      "module.exports = CrudController(${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Controller, meta);",
+      "",
+    ],
+    "description": "egg fast controller "
+  },
+  "check result":{
+    "prefix": "cres",
+    "body":[
+      "if (this.\\$checkRes(res)) {",
+      "  ",
+      "}"
+    ],
+    "description": "fast $checkRes "
+  },
+  "$set":{
+    "prefix": "$set",
+    "body":[
+      "this.\\$set(this${1}, `${2}`, ${3});",
+    ],
+    "description": "fast $checkRes "
+  },
+  "computed var":{
+    "prefix": "comvar",
+    "body":[
+      "${1}() {",
+      "  return ${2}",
+      "},"
+    ]
+  },
+  "middleware":{
+    "prefix": "mware",
+    "body":[
+      "'use strict';",
+      "const _ = require('lodash');",
+      "module.exports = options => {",
+      "  return async function ${TM_FILENAME_BASE/(.*)/${1:/downcase}/}(ctx, next) {",
+      "    console.log('function in ${TM_FILENAME_BASE/(.*)/${1:/downcase}/} middleware');",
+      "    await next();",
+      "  };",
+      "};",
+      ""
+    ]
+  }
+
+
+}