Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
glsx-posters
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 51b633cd
authored
Oct 24, 2022
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
删除svg
1 parent
1ff32813
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
75 deletions
src/assets/icons/svg/bug.svg
src/plugins/svgBuilder.js
vite.config.ts
src/assets/icons/svg/bug.svg
deleted
100644 → 0
View file @
1ff3281
<svg
width=
"128"
height=
"128"
xmlns=
"http://www.w3.org/2000/svg"
>
<path
d=
"M127.88 73.143c0 1.412-.506 2.635-1.518 3.669-1.011 1.033-2.209 1.55-3.592 1.55h-17.887c0 9.296-1.783 17.178-5.35 23.645l16.609 17.044c1.011 1.034 1.517 2.257 1.517 3.67 0 1.412-.506 2.635-1.517 3.668-.958 1.033-2.155 1.55-3.593 1.55-1.438 0-2.635-.517-3.593-1.55l-15.811-16.063a15.49 15.49 0 0 1-1.196 1.06c-.532.434-1.65 1.208-3.353 2.322a50.104 50.104 0 0 1-5.192 2.974c-1.758.87-3.94 1.658-6.546 2.364-2.607.706-5.189 1.06-7.748 1.06V47.044H58.89v73.062c-2.716 0-5.417-.367-8.106-1.102-2.688-.734-5.003-1.631-6.945-2.692a66.769 66.769 0 0 1-5.268-3.179c-1.571-1.057-2.73-1.94-3.476-2.65L33.9 109.34l-14.611 16.877c-1.066 1.14-2.344 1.711-3.833 1.711-1.277 0-2.422-.434-3.434-1.304-1.012-.978-1.557-2.187-1.635-3.627-.079-1.44.333-2.705 1.236-3.794l16.129-18.51c-3.087-6.197-4.63-13.644-4.63-22.342H5.235c-1.383 0-2.58-.517-3.592-1.55S.125 74.545.125 73.132c0-1.412.506-2.635 1.518-3.668 1.012-1.034 2.21-1.55 3.592-1.55h17.887V43.939L9.308 29.833c-1.012-1.033-1.517-2.256-1.517-3.669 0-1.412.505-2.635 1.517-3.668 1.012-1.034 2.21-1.55 3.593-1.55s2.58.516 3.593 1.55l13.813 14.106h67.396l13.814-14.106c1.012-1.034 2.21-1.55 3.592-1.55 1.384 0 2.581.516 3.593 1.55 1.012 1.033 1.518 2.256 1.518 3.668 0 1.413-.506 2.636-1.518 3.67l-13.814 14.105v23.975h17.887c1.383 0 2.58.516 3.593 1.55 1.011 1.033 1.517 2.256 1.517 3.668l-.005.01zM89.552 26.175H38.448c0-7.23 2.489-13.386 7.466-18.469C50.892 2.623 56.92.082 64 .082c7.08 0 13.108 2.541 18.086 7.624 4.977 5.083 7.466 11.24 7.466 18.469z"
/>
</svg>
\ No newline at end of file
\ No newline at end of file
src/plugins/svgBuilder.js
deleted
100644 → 0
View file @
1ff3281
import
{
readFileSync
,
readdirSync
}
from
'fs'
let
idPerfix
=
''
const
svgTitle
=
/<svg
([^
>+
]
.*
?)
>/
const
clearHeightWidth
=
/
(
width|height
)
="
([^
>+
]
.*
?)
"/g
const
hasViewBox
=
/
(
viewBox="
[^
>+
]
.*
?
"
)
/g
const
clearReturn
=
/
(\r)
|
(\n)
/g
function
findSvgFile
(
dir
)
{
const
svgRes
=
[]
const
dirents
=
readdirSync
(
dir
,
{
withFileTypes
:
true
})
for
(
const
dirent
of
dirents
)
{
if
(
dirent
.
isDirectory
())
{
svgRes
.
push
(...
findSvgFile
(
dir
+
dirent
.
name
+
'/'
))
}
else
{
const
svg
=
readFileSync
(
dir
+
dirent
.
name
)
.
toString
()
.
replace
(
clearReturn
,
''
)
.
replace
(
svgTitle
,
(
$1
,
$2
)
=>
{
// console.log(++i)
// console.log(dirent.name)
let
width
=
0
let
height
=
0
let
content
=
$2
.
replace
(
clearHeightWidth
,
(
s1
,
s2
,
s3
)
=>
{
if
(
s2
===
'width'
)
{
width
=
s3
}
else
if
(
s2
===
'height'
)
{
height
=
s3
}
return
''
})
if
(
!
hasViewBox
.
test
(
$2
))
{
content
+=
`viewBox="0 0
${
width
}
${
height
}
"`
}
return
`<symbol id="
${
idPerfix
}
-
${
dirent
.
name
.
replace
(
'.svg'
,
''
)}
"
${
content
}
>`
})
.
replace
(
'</svg>'
,
'</symbol>'
)
svgRes
.
push
(
svg
)
}
}
return
svgRes
}
export
const
svgBuilder
=
(
path
,
perfix
=
'icon'
)
=>
{
if
(
path
===
''
)
return
idPerfix
=
perfix
const
res
=
findSvgFile
(
path
)
// console.log(res.length)
// const res = []
return
{
name
:
'svg-transform'
,
transformIndexHtml
(
html
)
{
return
html
.
replace
(
'<body>'
,
`
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position: absolute; width: 0; height: 0">
${
res
.
join
(
''
)}
</svg>
`
)
}
}
}
vite.config.ts
View file @
51b633c
/*
* @Description:
* @Author: huyue
* @Date: 2022-10-10 10:54:14
* @LastEditors: huyue
* @LastEditTime: 2022-10-24 10:10:51
*/
import
{
defineConfig
}
from
'vite'
import
{
defineConfig
}
from
'vite'
import
vue
from
'@vitejs/plugin-vue'
import
vue
from
'@vitejs/plugin-vue'
import
styleImport
,
{
VantResolve
}
from
'vite-plugin-style-import'
;
import
styleImport
,
{
VantResolve
}
from
'vite-plugin-style-import'
;
import
path
from
'path'
import
path
from
'path'
import
{
svgBuilder
}
from
'./src/plugins/svgBuilder'
const
resolve
=
(
dir
:
string
)
=>
path
.
join
(
__dirname
,
dir
)
const
resolve
=
(
dir
:
string
)
=>
path
.
join
(
__dirname
,
dir
)
// https://vitejs.dev/config/
// https://vitejs.dev/config/
...
@@ -10,7 +16,6 @@ export default defineConfig({
...
@@ -10,7 +16,6 @@ export default defineConfig({
base
:
'./'
,
base
:
'./'
,
plugins
:
[
plugins
:
[
vue
(),
vue
(),
[
svgBuilder
(
'./src/assets/icons/svg/'
)],
// 这里已经将src/icons/svg/下的svg全部导入,无需再单独导入
styleImport
({
styleImport
({
resolves
:
[
VantResolve
()],
resolves
:
[
VantResolve
()],
libs
:
[
libs
:
[
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment