From 820c53378fb6c5f761b262ceeeba7e84b412ed23 Mon Sep 17 00:00:00 2001 From: luoer Date: Sun, 8 Oct 2023 17:29:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/vite/color.ts | 2 +- scripts/vite/icon-file.json | 266 ++++++++++++++++++++++++++++++++++++ tsconfig.node.json | 8 +- vite.config.ts | 17 ++- 4 files changed, 290 insertions(+), 3 deletions(-) create mode 100644 scripts/vite/icon-file.json diff --git a/scripts/vite/color.ts b/scripts/vite/color.ts index a33a1e7..38386e4 100644 --- a/scripts/vite/color.ts +++ b/scripts/vite/color.ts @@ -1,7 +1,7 @@ const unoLevels = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900]; const arcoLevels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; -export const arcoToUnoColor = (arcoColorName: string) => { +export const arcoToUnoColor = (arcoColorName: string): { [id: string]: string } => { const colors = {}; for (let i = 0; i < 10; i++) { colors[unoLevels[i]] = `rgb(var(--${arcoColorName}-${arcoLevels[i]}))`; diff --git a/scripts/vite/icon-file.json b/scripts/vite/icon-file.json new file mode 100644 index 0000000..97b66ca --- /dev/null +++ b/scripts/vite/icon-file.json @@ -0,0 +1,266 @@ +[ + { + "id": 21721547, + "name": "标准图-记事本", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59044", + "font_class": "txt", + "freeze": 0, + "path_attributes": "fill=\"#8289AD\"|fill=\"#FFFFFF\"|fill=\"#CDCFDE\"" + }, + { + "id": 21721548, + "name": "标准图-工作表", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59045", + "font_class": "excel", + "freeze": 0, + "path_attributes": "fill=\"#4CB050\"|fill=\"#FFFFFF\"|fill=\"#B7DFB9\"" + }, + { + "id": 21721549, + "name": "标准图-幻灯片", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59046", + "font_class": "ppt", + "freeze": 0, + "path_attributes": "fill=\"#FF9333\"|fill=\"#FFFFFF\"|fill=\"#FFD3AD\"" + }, + { + "id": 21721550, + "name": "标准图-视频文件", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59047", + "font_class": "video", + "freeze": 0, + "path_attributes": "fill=\"#7C8EEE\"|fill=\"#FFFFFF\"|fill=\"#CAD1F8\"" + }, + { + "id": 21721551, + "name": "标准图-文件夹", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59048", + "font_class": "folder", + "freeze": 0, + "path_attributes": "fill=\"#FFA000\"|fill=\"#FFFFFF\"|fill=\"#FFCA28\"" + }, + { + "id": 21721552, + "name": "标准图-图片文件", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59049", + "font_class": "image", + "freeze": 0, + "path_attributes": "fill=\"#F6AD00\"|fill=\"#FFF7F7\"|fill=\"#FFFFFF\"|fill=\"#FBDE99\"" + }, + { + "id": 21721553, + "name": "标准图-未知文件", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59050", + "font_class": "unknown", + "freeze": 0, + "path_attributes": "fill=\"#CCCCCC\"|fill=\"#EAEAEA\"|fill=\"#FFFFFF\"" + }, + { + "id": 21721554, + "name": "标准图-压缩文件", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59051", + "font_class": "zip", + "freeze": 0, + "path_attributes": "fill=\"#576A95\"|fill=\"#FFFFFF\"|fill=\"#BBC3D4\"" + }, + { + "id": 21721555, + "name": "标准图-链接", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59052", + "font_class": "link", + "freeze": 0, + "path_attributes": "fill=\"#4876F9\"|fill=\"#FFFFFF\"|fill=\"#B5C8FC\"" + }, + { + "id": 21721556, + "name": "标准图-PDF文档", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59053", + "font_class": "pdf", + "freeze": 0, + "path_attributes": "fill=\"#FA4E4E\"|fill=\"#FFFFFF\"|fill=\"#FDB8B8\"" + }, + { + "id": 21721557, + "name": "标准图-Word文档", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59054", + "font_class": "word", + "freeze": 0, + "path_attributes": "fill=\"#4876F9\"|fill=\"#FFFFFF\"|fill=\"#B5C8FC\"" + }, + { + "id": 21721558, + "name": "标准图-声音文件", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59055", + "font_class": "audio", + "freeze": 0, + "path_attributes": "fill=\"#F16C00\"|fill=\"#FFFFFF\"|fill=\"#F9C499\"" + }, + { + "id": 21721566, + "name": "缩略图-幻灯片", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59056", + "font_class": "ippt", + "freeze": 0, + "path_attributes": "fill=\"#FF9333\"|fill=\"#FFFFFF\"" + }, + { + "id": 21721567, + "name": "缩略图-记事本", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59057", + "font_class": "itxt", + "freeze": 0, + "path_attributes": "fill=\"#8289AD\"|fill=\"#FFFFFF\"" + }, + { + "id": 21721568, + "name": "缩略图-工作表", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59058", + "font_class": "iexcel", + "freeze": 0, + "path_attributes": "fill=\"#4CB050\"|fill=\"#FFFFFF\"" + }, + { + "id": 21721569, + "name": "缩略图-视频文件", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59059", + "font_class": "ivideo", + "freeze": 0, + "path_attributes": "fill=\"#7C8EEE\"|fill=\"#FFFFFF\"" + }, + { + "id": 21721570, + "name": "缩略图-图片文件", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59060", + "font_class": "iimage", + "freeze": 0, + "path_attributes": "fill=\"#F6AD00\"|fill=\"#FFF7F7\"|fill=\"#FFFFFF\"" + }, + { + "id": 21721571, + "name": "缩略图-未知文件", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59061", + "font_class": "iunknown", + "freeze": 0, + "path_attributes": "fill=\"#CCCCCC\"|fill=\"#FFFFFF\"" + }, + { + "id": 21721572, + "name": "缩略图-文件夹", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59062", + "font_class": "ifolder", + "freeze": 0, + "path_attributes": "fill=\"#FFA000\"|fill=\"#FFCA28\"" + }, + { + "id": 21721573, + "name": "缩略图-压缩文件", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59063", + "font_class": "izip", + "freeze": 0, + "path_attributes": "fill=\"#576A95\"|fill=\"#FFFFFF\"" + }, + { + "id": 21721574, + "name": "缩略图-Word", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59064", + "font_class": "iword", + "freeze": 0, + "path_attributes": "fill=\"#4876F9\"|fill=\"#FFFFFF\"" + }, + { + "id": 21721575, + "name": "缩略图-PDF文档", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59065", + "font_class": "ipdf", + "freeze": 0, + "path_attributes": "fill=\"#FA4E4E\"|fill=\"#FFFFFF\"" + }, + { + "id": 21721576, + "name": "缩略图-声音文件", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59066", + "font_class": "iaudio", + "freeze": 0, + "path_attributes": "fill=\"#F16C00\"|fill=\"#FFFFFF\"" + }, + { + "id": 21721577, + "name": "缩略图-链接", + "project_id": 4270790, + "projectId": 4270790, + "show_svg": "", + "unicode": "59067", + "font_class": "ilink", + "freeze": 0, + "path_attributes": "fill=\"#4876F9\"|fill=\"#FFFFFF\"" + } +] diff --git a/tsconfig.node.json b/tsconfig.node.json index 56e4b43..f377885 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -6,5 +6,11 @@ "allowSyntheticDefaultImports": true, "resolveJsonModule": true }, - "include": ["vite.config.ts", "scripts/vite/**/*.ts", "package.json", "src/types/env.d.ts"] + "include": [ + "vite.config.ts", + "scripts/vite/**/*", + "scripts/vite/icon-file.json", + "package.json", + "src/types/env.d.ts" + ] } diff --git a/vite.config.ts b/vite.config.ts index 3c11007..dac6e3f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -10,6 +10,7 @@ import { defineConfig, loadEnv } from "vite"; import Page from "vite-plugin-pages"; import plugin from "./scripts/vite/plugin"; import { arcoToUnoColor } from "./scripts/vite/color"; +import fileIcon from "./scripts/vite/icon-file.json"; /** * vite 配置 @@ -96,7 +97,21 @@ export default defineConfig(({ mode }) => { }, }, include: ["src/**/*.{vue,ts,tsx,css,scss,sass,less,styl}"], - presets: [presetUno(), presetIcons({ prefix: "" })], + presets: [ + presetUno(), + presetIcons({ + prefix: "", + collections: { + 'icon-file': (() => { + const icons = {}; + for (const item of fileIcon) { + icons[item.font_class] = item.show_svg + } + return icons; + })(), + }, + }), + ], }), /**