feat: 字体管理

This commit is contained in:
taojinlong 2024-08-26 15:05:14 +08:00
parent f781cc25fd
commit 0762fa2819
6 changed files with 136 additions and 46 deletions

View File

@ -70,3 +70,16 @@ alter table `core_chart_view`
update visualization_outer_params_target_view_info tvi INNER JOIN core_chart_view ccv on tvi.target_view_id = ccv.id
set tvi.target_ds_id = ccv.table_id
DROP TABLE IF EXISTS `core_font`;
CREATE TABLE `core_font`
(
`id` bigint NOT NULL COMMENT 'ID',
`name` varchar(255) NOT NULL COMMENT '字体名称',
`file_name` varchar(255) NOT NULL COMMENT '文件名称',
`file_trans_name` varchar(255) NOT NULL COMMENT '文件转换名称',
`is_default` tinyint(1) NOT NULL COMMENT '是否默认',
`is_BuiltIn` tinyint(1) NOT NULL COMMENT '是否内置',
PRIMARY KEY (`id`)
);

View File

@ -0,0 +1,39 @@
import request from '@/config/axios'
export interface Font {
id: string
name: string
fileName: string
isDefault: boolean
isBuiltin?: boolean
}
export const list = (data = {}) => {
return request.post({ url: '/typeface/listFont', data }).then(res => {
return res?.data
})
}
export const create = (data = {}) => {
return request.post({ url: '/typeface/create', data }).then(res => {
return res?.data
})
}
export const edit = (data = {}) => {
return request.post({ url: '/typeface/edit', data }).then(res => {
return res?.data
})
}
export const changeDefault = (data = {}) => {
return request.post({ url: '/typeface/changeDefault', data }).then(res => {
return res?.data
})
}
export const deleteById = id => {
return request.post({ url: '/typeface/delete/' + id, data: {} }).then(res => {
return res?.data
})
}

View File

@ -1,12 +1,39 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { onMounted, ref } from 'vue'
import UploadDetail from './UploadDetail.vue'
import { changeDefault, deleteById, list } from '@/api/font'
const fontKeyword = ref('')
const fontList = ref([1, 2, 3, 4, 5])
const fontList = ref([])
// const fontList = ref([1, 2, 3, 4, 5])
const uploadDetail = ref()
const uploadFont = (title, isRename?: boolean) => {
uploadDetail.value.init(title, isRename)
}
const listFont = () => {
list({}).then(res => {
fontList.value = res
})
}
const deleteFont = item => {
deleteById(item.id).then(res => {
listFont()
})
}
const setToDefault = item => {
item.isDefault = 1
changeDefault(item).then(res => {
fontList.value = res
})
}
onMounted(() => {
listFont()
})
</script>
<template>
@ -39,9 +66,9 @@ const uploadFont = (title, isRename?: boolean) => {
</div>
<div class="font-upload_btn">
<el-button @click="uploadFont('添加字体')" secondary>上传字库文件</el-button>
<el-button secondary>设为默认字体</el-button>
<el-button @click="setToDefault(ele)" secondary>设为默认字体</el-button>
<el-button @click="uploadFont('重命名', true)" secondary>重命名</el-button>
<el-button secondary>删除</el-button>
<el-button @click="deleteFont(ele)" secondary>删除</el-button>
</div>
</div>
</div>

View File

@ -0,0 +1,49 @@
package io.dataease.api.font.api;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.api.ds.vo.ExcelFileData;
import io.dataease.api.font.dto.FontDto;
import io.dataease.exception.DEException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* @Author Junjun
*/
@Tag(name = "数据集管理:数据")
@ApiSupport(order = 972)
public interface FontApi {
@Operation(summary = "预览数据")
@PostMapping("listFont")
public List<FontDto> list(@RequestBody FontDto fontDto) throws Exception;
@Operation(summary = "创建")
@PostMapping("/create")
public FontDto create(@RequestBody FontDto fontDto);
@Operation(summary = "编辑")
@PostMapping("/edit")
public FontDto edit(@RequestBody FontDto fontDto);
@Operation(summary = "删除")
@PostMapping("/delete/{id}")
public void delete(@PathVariable("id") Long id);
@Operation(summary = "变更默认设置")
@PostMapping("/changeDefault/")
public void changeDefault(@RequestBody FontDto fontDto);
@PostMapping("/uploadFile")
void upload(@RequestParam("file") MultipartFile file, @RequestParam("id") long fontID) throws DEException;
}

View File

@ -1,11 +1,11 @@
package io.dataease.api.typeface.dto;
package io.dataease.api.font.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
@Data
public class SysTypefaceDto {
public class FontDto {
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@ -28,5 +28,7 @@ public class SysTypefaceDto {
* 是否默认
*/
private Boolean isDefault;
private Boolean isBuiltin;
}

View File

@ -1,40 +0,0 @@
package io.dataease.api.typeface.api;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.api.typeface.dto.SysTypefaceDto;
import io.dataease.auth.DeApiPath;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import static io.dataease.constant.AuthResourceEnum.SYSTEM;
@Tag(name = "字体管理")
@ApiSupport(order = 881, author = "fit2cloud-someone")
@DeApiPath(value = "/sysTypeface", rt = SYSTEM)
public interface SysTypefaceApi {
@Operation(summary = "创建")
@PostMapping("/create")
SysTypefaceDto create(@RequestBody SysTypefaceDto sysVariableDto);
@Operation(summary = "编辑")
@PostMapping("/edit")
SysTypefaceDto edit(@RequestBody SysTypefaceDto sysVariableDto);
@Operation(summary = "删除")
@PostMapping("/delete/{id}")
void delete(@PathVariable("id") Long id);
@Operation(summary = "变更默认设置")
@PostMapping("/changeDefault/")
void changeDefault(@RequestBody SysTypefaceDto sysVariableDto);
}