Skip to content

Commit

Permalink
chore(type): module -> default
Browse files Browse the repository at this point in the history
  • Loading branch information
markthree committed Mar 16, 2022
1 parent 7e27906 commit 41d7e86
Show file tree
Hide file tree
Showing 7 changed files with 2,371 additions and 3,615 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "tov-template",
"version": "1.5.0",
"type": "module",
"description": "vite + vue3 + ts 开箱即用现代开发模板",
"scripts": {
"dev": "vite",
Expand Down Expand Up @@ -44,16 +43,15 @@
"markdown-it-prism": "^2.2.3",
"mockjs": "^1.1.0",
"nprogress": "^0.2.0",
"ora": "^6.1.0",
"pinia": "^2.0.12",
"plop": "^3.0.5",
"prism-theme-vars": "^0.2.2",
"typescript": "^4.6.2",
"unplugin-auto-import": "^0.6.4",
"unplugin-auto-import": "^0.6.6",
"unplugin-icons": "^0.13.4",
"unplugin-vue-components": "^0.17.21",
"vite": "^2.8.6",
"vite-auto-import-resolvers": "^2.1.6",
"vite-auto-import-resolvers": "^2.2.2",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-inspect": "^0.4.3",
"vite-plugin-md": "^0.11.9",
Expand Down
5,940 changes: 2,350 additions & 3,590 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion presets/types/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ declare global {
const useCssVars: typeof import('vue')['useCssVars']
const useCycleList: typeof import('@vueuse/core')['useCycleList']
const useDark: typeof import('@vueuse/core')['useDark']
const useDarks: typeof import('/src/composables/useDarks')['default']
const useDarks: typeof import('/code/tov-template/src/composables/useDarks')['default']
const useDebounce: typeof import('@vueuse/core')['useDebounce']
const useDebouncedRefHistory: typeof import('@vueuse/core')['useDebouncedRefHistory']
const useDebounceFn: typeof import('@vueuse/core')['useDebounceFn']
Expand Down
10 changes: 5 additions & 5 deletions scripts/create.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fse from 'fs-extra'
const fse = require('fs-extra')

import {
showExt,
const {
showDir,
showExt,
moduleTypes
} from './shared/base.js'
} = require('./shared/base')

/**
* 自动创建
Expand Down Expand Up @@ -78,4 +78,4 @@ function create(plop) {
})
}

export default create
module.exports = create
14 changes: 4 additions & 10 deletions scripts/remove.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import ora from 'ora'
import fg from 'fast-glob'
import fse from 'fs-extra'
import { basename } from 'path'
import { showDir, moduleTypes } from './shared/base.js'
const fg = require('fast-glob')
const fse = require('fs-extra')
const { basename } = require('path')
const { showDir, moduleTypes } = require('./shared/base')

/**
* 自动删除
* @param {import('plop').NodePlopAPI} plop
*/
function remove(plop) {
const spinner = ora()

plop.setActionType('remove', (answers, config, plop) => {
const { name, type, shouldRemove } = answers
const dir = showDir(type)
Expand All @@ -37,7 +34,6 @@ function remove(plop) {
const dir = showDir(type)
return dirs.includes(`./src/${dir}`)
})
spinner.stop()
return types
}
},
Expand All @@ -48,7 +44,6 @@ function remove(plop) {
return `请选择您要删除的 ${type} 模块`
},
async choices({ type }) {
spinner.start(`读取现有 ${type} 模块中~~`)
const dir = showDir(type)
let modules = await fg(`./src/${dir}/*.*`, {
deep: 1,
Expand All @@ -57,7 +52,6 @@ function remove(plop) {
modules = modules.map(module => {
return basename(module)
})
spinner.stop()
return modules
}
},
Expand Down
11 changes: 8 additions & 3 deletions scripts/shared/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @param {boolean} isMarkdown 是否是 markdown,默认为 false
* @returns {string} 扩展名
*/
export const showExt = (type, isMarkdown = false) => {
const showExt = (type, isMarkdown = false) => {
const isTs =
type === 'api' || type === 'store' || type === 'module'
const ext = isMarkdown ? 'md' : isTs ? 'ts' : 'vue'
Expand All @@ -14,7 +14,7 @@ export const showExt = (type, isMarkdown = false) => {
/**
* 模块类型
*/
export const moduleTypes = [
const moduleTypes = [
'api',
'page',
'store',
Expand All @@ -28,9 +28,14 @@ export const moduleTypes = [
* 获取目录
* @param {string} type 类型
*/
export const showDir = type => {
const showDir = type => {
if (type === 'api') {
return 'api'
}
return `${type}s`
}

module.exports = {
showExt,
showDir
}
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"useDefineForClassFields": true,
"baseUrl": ".",
"paths": {
"~/*": ["src/*"],
"/src/*": ["src/*"]
"~/*": ["src/*"]
}
},
"include": [
Expand Down

0 comments on commit 41d7e86

Please sign in to comment.