更新
21
LICENSE
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 落叶
|
||||
|
||||
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.
|
42
README.md
@@ -1,42 +0,0 @@
|
||||
# iconfont-一键下载
|
||||
|
||||
> iconfont-一键下载插件,提供vue3组件式按需编译使用(单色、多色配置),右上角点点小心心,一年赚他一个小目标~
|
||||
>
|
||||
> 推荐项目:[vue3按需使用iconfont示例](https://gitee.com/veigarchen/iconfont-download-vue3)、[uniapp按需使用iconfont示例和快速开发小程序](https://gitee.com/veigarchen/uniapp-vue3-fast)
|
||||
>
|
||||
> 前端技术交流群:<a href="https://jq.qq.com/?_wv=1027&k=Erh7LBKn" target="_blank">553655769</a>,白嫖更多资源,行业交流
|
||||
>
|
||||
> 注意:本插件仅作为下载工具,如果图标未注明可免费商用,请自行联系相关图标作者,否则后果自负
|
||||
|
||||
## 安装
|
||||
```bash
|
||||
以谷歌浏览器-版本-108.0.5359.71为例
|
||||
1、打开浏览器的扩展程序页面(浏览器右上角三个点->更多工具->扩展程序)
|
||||
2、打开开发者模式,点击加载已解压的扩展程序,选择本项目目录
|
||||
```
|
||||
|
||||
## 使用
|
||||
|
||||
```bash
|
||||
在浏览器右上角点击插件图标,点击iconfont即可使用
|
||||
```
|
||||
|
||||
## 功能列表
|
||||
|
||||
1、下载本页所有svg
|
||||
<img src="使用教程/5.png" />
|
||||
|
||||
2、导出为vue3组件使用及icon的ts文件
|
||||
|
||||
3、配置打包时的压缩数率,范围1-6,1时体积最小,6最大
|
||||
<img src="使用教程/压缩效果图.png" />
|
||||
|
||||
4、vue3按需编译使用iconfont图标:[按需编译插件示例](https://gitee.com/veigarchen/iconfont-download-vue3)
|
||||
|
||||
<img src="使用教程/build-1.png" />
|
||||
|
||||
## 关于&合作
|
||||
|
||||
```bash
|
||||
QQ/微信:1518079148
|
||||
```
|
@@ -1 +0,0 @@
|
||||
import{_ as r,c as o,a as n,b as t,w as a,r as p,o as d,d as s}from"./index.7e07b943.js";const l={},c={class:"flex",style:{gap:"15px","margin-top":"15px",padding:"20px"}},i={class:"flex",style:{gap:"15px","margin-top":"15px",padding:"20px"}},_={class:"flex",style:{gap:"15px","margin-top":"15px",padding:"20px"}},u={class:"flex",style:{gap:"15px","margin-top":"15px",padding:"20px"}},g={class:"flex",style:{gap:"15px","flex-direction":"column","margin-top":"15px",width:"200px",padding:"20px"}};function x(f,y){const e=p("c-button");return d(),o("div",null,[n("div",c,[t(e,null,{default:a(()=>[s("primary")]),_:1}),t(e,{loading:!0},{default:a(()=>[s("primary")]),_:1})]),n("div",i,[t(e,{type:"success"},{default:a(()=>[s("success")]),_:1}),t(e,{type:"success",loading:!0},{default:a(()=>[s("success")]),_:1})]),n("div",_,[t(e,{type:"error"},{default:a(()=>[s("error")]),_:1}),t(e,{type:"error",loading:!0},{default:a(()=>[s("error")]),_:1})]),n("div",u,[t(e,{type:"warning"},{default:a(()=>[s("warning")]),_:1}),t(e,{type:"warning",loading:!0},{default:a(()=>[s("warning")]),_:1})]),n("div",g,[t(e,{long:""},{default:a(()=>[s("primary")]),_:1}),t(e,{long:"",type:"success"},{default:a(()=>[s("success")]),_:1}),t(e,{long:"",type:"error"},{default:a(()=>[s("error")]),_:1}),t(e,{long:"",type:"warning"},{default:a(()=>[s("warning")]),_:1})])])}const w=r(l,[["render",x]]);export{w as default};
|
Before Width: | Height: | Size: 5.6 KiB |
BIN
img/app.jpg
Before Width: | Height: | Size: 1.6 KiB |
18
index.html
@@ -1,18 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="./favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>google-plugin</title>
|
||||
<script type="module" crossorigin src="./assets/index.7e07b943.js"></script>
|
||||
<link rel="stylesheet" href="./assets/index.7f8f52e3.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@@ -1 +0,0 @@
|
||||
console.log('bg');
|
13
js/jszip.min.js
vendored
1
js/main.min.js
vendored
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"name": "iconfont",
|
||||
"version": "1.0.0",
|
||||
"description": "iconfont-svg获取插件",
|
||||
"background": {
|
||||
"scripts": [
|
||||
"js/background.js"
|
||||
]
|
||||
},
|
||||
"browser_action": {
|
||||
"default_icon": "img/app.jpg",
|
||||
"default_title": "iconfont",
|
||||
"default_popup": "index.html"
|
||||
},
|
||||
"content_scripts": [{
|
||||
"matches": ["<all_urls>"],
|
||||
"js": ["js/jszip.min.js", "js/main.min.js"],
|
||||
"run_at": "document_end"
|
||||
}],
|
||||
"permissions": [
|
||||
"contextMenus",
|
||||
"tabs",
|
||||
"notifications",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"storage",
|
||||
"http://*/*",
|
||||
"https://*/*"
|
||||
],
|
||||
"homepage_url": "https://c44.cc",
|
||||
"manifest_version": 2
|
||||
}
|
BIN
使用教程/1.png
Before Width: | Height: | Size: 33 KiB |
BIN
使用教程/2.png
Before Width: | Height: | Size: 79 KiB |
BIN
使用教程/3.png
Before Width: | Height: | Size: 24 KiB |
BIN
使用教程/4.png
Before Width: | Height: | Size: 89 KiB |
BIN
使用教程/5.png
Before Width: | Height: | Size: 112 KiB |
BIN
使用教程/build-1.png
Before Width: | Height: | Size: 34 KiB |
BIN
使用教程/压缩效果图.png
Before Width: | Height: | Size: 9.9 KiB |
12
单文件拆分/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# dir
|
||||
node_modules
|
||||
dist
|
||||
|
||||
# file
|
||||
stats.html
|
||||
/build/auto/*.d.ts
|
||||
|
||||
# lock
|
||||
yarn.lock
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
30
单文件拆分/.prettierignore
Normal file
@@ -0,0 +1,30 @@
|
||||
# 忽略的文件夹:
|
||||
node_modules/
|
||||
dist/
|
||||
|
||||
# 忽略的文件
|
||||
package.json
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
yarn-error.log
|
||||
.babelrc
|
||||
.browserslistrc
|
||||
.eslintignore
|
||||
.gitignore
|
||||
.prettierignore
|
||||
.editorconfig
|
||||
.DS_Store
|
||||
.project
|
||||
*.yml
|
||||
*.yaml
|
||||
*.svg
|
||||
*.png
|
||||
*.jpg
|
||||
*.gif
|
||||
*.md
|
||||
*.ejs
|
||||
*.min.js
|
||||
*.min.css
|
||||
*.html
|
||||
*.js
|
||||
*.d.ts
|
11
单文件拆分/.prettierrc
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"proseWrap": "always",
|
||||
"tabWidth": 4,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"endOfLine": "auto",
|
||||
"quoteProps": "preserve",
|
||||
"htmlWhitespaceSensitivity": "ignore"
|
||||
}
|
32
单文件拆分/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"typescript.updateImportsOnFileMove.enabled": "always",
|
||||
"javascript.updateImportsOnFileMove.enabled": "always",
|
||||
"volar.codeLens.scriptSetupTools": true,
|
||||
"volar.codeLens.pugTools": true,
|
||||
"files.exclude": {
|
||||
"**/*.meta": true
|
||||
},
|
||||
"explorer.confirmDragAndDrop": false,
|
||||
"diffEditor.ignoreTrimWhitespace": false,
|
||||
"window.zoomLevel": 0,
|
||||
"[less]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[vue]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnType": true,
|
||||
"eslint.codeAction.showDocumentation": {
|
||||
"enable": true
|
||||
},
|
||||
"eslint.validate": ["typescript", "vue"],
|
||||
"prettier.singleQuote": true,
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
35
单文件拆分/index.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { resolve, join } from 'path'
|
||||
import FileUtil from './src/utils/FileUtil'
|
||||
|
||||
const siconUrl = resolve('E:/repo/code/wty-web-cloud-las-0/src/components/sicon')
|
||||
const staticIconUrl = resolve('E:/repo/code/wty-web-cloud-las-0/public/static_res/sicon')
|
||||
|
||||
const init = async () => {
|
||||
await FileUtil.deleteFileOrDirectory(staticIconUrl)
|
||||
await FileUtil.readDirectory(siconUrl, async (filepath: string) => {
|
||||
if (filepath.endsWith('.ts')) {
|
||||
const filename =
|
||||
filepath
|
||||
.substring(filepath.lastIndexOf('\\') + 1)
|
||||
.split('.')
|
||||
.shift() || ''
|
||||
try {
|
||||
let fstr = await FileUtil.readFile(filepath)
|
||||
fstr = fstr.split(`export const ${filename}Name`)[0]
|
||||
fstr = fstr.split('=')[1]
|
||||
const ctx = JSON.parse(fstr.replaceAll("'", '"'))
|
||||
Object.keys(ctx).forEach((key) => {
|
||||
let _res = JSON.stringify(ctx[key])
|
||||
if(typeof ctx[key] === 'string'){
|
||||
_res = _res.substring(1,_res.length-1)
|
||||
}
|
||||
FileUtil.writeFile(join(staticIconUrl, `./${filename}/${key}.json`), _res)
|
||||
})
|
||||
} catch {
|
||||
console.log('处理失败', filename)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
init()
|
12
单文件拆分/package.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "ts-node index.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.15.11",
|
||||
"prettier": "^2.8.7",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.9.5",
|
||||
"vm": "^0.1.0"
|
||||
}
|
||||
}
|
84
单文件拆分/src/utils/FileUtil.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
|
||||
export default class FileUtil {
|
||||
static copyFile(source: string, destination: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const rd = fs.createReadStream(source)
|
||||
rd.on('error', (err) => {
|
||||
reject(err)
|
||||
})
|
||||
|
||||
const wr = fs.createWriteStream(destination)
|
||||
wr.on('error', (err) => {
|
||||
reject(err)
|
||||
})
|
||||
wr.on('close', () => {
|
||||
resolve()
|
||||
})
|
||||
|
||||
if (!fs.existsSync(path.dirname(destination))) {
|
||||
fs.mkdirSync(path.dirname(destination), { recursive: true })
|
||||
}
|
||||
|
||||
rd.pipe(wr)
|
||||
})
|
||||
}
|
||||
|
||||
static async deleteFileOrDirectory(filePath: string): Promise<void> {
|
||||
try {
|
||||
const stats = await fs.promises.lstat(filePath)
|
||||
if (stats.isDirectory()) {
|
||||
const files = await fs.promises.readdir(filePath)
|
||||
const promises = files.map((file) => FileUtil.deleteFileOrDirectory(path.join(filePath, file)))
|
||||
await Promise.all(promises)
|
||||
await fs.promises.rmdir(filePath)
|
||||
} else {
|
||||
await fs.promises.unlink(filePath)
|
||||
}
|
||||
} catch (err) {
|
||||
}
|
||||
}
|
||||
|
||||
static readFile(filePath: string): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(filePath, 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(data)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
static async readDirectory(directoryPath: string, fileCallback?: (filePath: string) => void): Promise<void> {
|
||||
try {
|
||||
const files = await fs.promises.readdir(directoryPath)
|
||||
const promises = files.map(async (file) => {
|
||||
const filePath = path.join(directoryPath, file)
|
||||
const stats = await fs.promises.stat(filePath)
|
||||
if (stats.isDirectory()) {
|
||||
await FileUtil.readDirectory(filePath, fileCallback)
|
||||
} else {
|
||||
if (fileCallback) {
|
||||
fileCallback(filePath)
|
||||
}
|
||||
}
|
||||
})
|
||||
await Promise.all(promises)
|
||||
} catch (err) {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
static async writeFile(filePath: string, content: string): Promise<void> {
|
||||
try {
|
||||
const directoryPath = path.dirname(filePath)
|
||||
await fs.promises.mkdir(directoryPath, { recursive: true })
|
||||
await fs.promises.writeFile(filePath, content, 'utf8')
|
||||
} catch (err) {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
66
单文件拆分/src/utils/StrUtil.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
export default class StrUtil {
|
||||
/**
|
||||
* 获取uuid
|
||||
* @returns
|
||||
*/
|
||||
static uuid() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
var r = (Math.random() * 16) | 0,
|
||||
v = c == 'x' ? r : (r & 0x3) | 0x8
|
||||
return v.toString(16)
|
||||
})
|
||||
}
|
||||
|
||||
private static id = 1000
|
||||
/**
|
||||
* 获取唯一递增id
|
||||
*/
|
||||
static getId = () => {
|
||||
this.id++
|
||||
return this.id + ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断内容是否为空,null,undefined,NaN,空数组,空字符串返回true
|
||||
*/
|
||||
static isNull(str: any): boolean {
|
||||
if (Array.isArray(str)) return str.length == 0
|
||||
if (str + '' !== 'null' && str + '' !== 'undefined' && str !== '' && str + '' !== 'NaN') return false
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证邮箱
|
||||
*/
|
||||
static isEmail(obj: any): boolean {
|
||||
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/
|
||||
if (!myreg.test(obj)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证数字
|
||||
*/
|
||||
static isNumber(obj: any): boolean {
|
||||
return /^[0-9]+$/.test(obj)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取url地址中的参数对象信息
|
||||
* @param url 如/list?pageSize=1&pageNum=2
|
||||
* @param return 如{pageSize:1,pageNum:2}
|
||||
*/
|
||||
static getParam(url: any): any {
|
||||
const regex = /[?&]([^=#]+)=([^&#]*)/g
|
||||
if (url.match) {
|
||||
const matchVal = url.match(regex)
|
||||
if (matchVal)
|
||||
return matchVal.reduce((acc: any, cur: any) => {
|
||||
const [param, value] = cur.substring(1).split('=')
|
||||
acc[param] = decodeURIComponent(value)
|
||||
return acc
|
||||
}, {})
|
||||
}
|
||||
return {}
|
||||
}
|
||||
}
|
9
单文件拆分/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true
|
||||
}
|
||||
}
|