|
@@ -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();",
|
|
|
+ " };",
|
|
|
+ "};",
|
|
|
+ ""
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|