This commit is contained in:
dap 2024-08-07 13:34:24 +08:00
commit 20ae9b313b
10 changed files with 83 additions and 16 deletions

View File

@ -21,9 +21,6 @@ jobs:
post-update:
# if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
steps:
- name: Checkout code
uses: actions/checkout@v4

View File

@ -2,7 +2,8 @@
"page": {
"demos": {
"title": "Demos",
"naive": "Naive UI"
"naive": "Naive UI",
"table": "Table"
}
}
}

View File

@ -2,7 +2,8 @@
"page": {
"demos": {
"title": "演示",
"naive": "Naive UI"
"naive": "Naive UI",
"table": "Table"
}
}
}

View File

@ -24,6 +24,15 @@ const routes: RouteRecordRaw[] = [
path: '/demos/naive',
component: () => import('#/views/demos/naive/index.vue'),
},
{
meta: {
icon: 'mdi:shield-key-outline',
title: $t('page.demos.table'),
},
name: 'Table',
path: '/demos/table',
component: () => import('#/views/demos/table/index.vue'),
},
],
},
];

View File

@ -0,0 +1,31 @@
<script setup lang="ts">
import { ref } from 'vue';
import { NDataTable } from 'naive-ui';
const columns = ref([
{
key: 'no',
title: 'No',
},
{
key: 'title',
title: 'Title',
},
{
key: 'length',
title: 'Length',
},
]);
const data = [
{ length: '4:18', no: 3, title: 'Wonderwall' },
{ length: '4:48', no: 4, title: "Don't Look Back in Anger" },
{ length: '7:27', no: 12, title: 'Champagne Supernova' },
];
</script>
<template>
<NDataTable :columns="columns" :data="data" />
</template>
<style scoped></style>

View File

@ -50,7 +50,7 @@
"sass": "^1.77.8",
"vite": "^5.3.5",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-dts": "4.0.0-beta.2",
"vite-plugin-dts": "4.0.0",
"vite-plugin-html": "^3.2.2"
}
}

View File

@ -90,7 +90,7 @@
"node": ">=20",
"pnpm": ">=9"
},
"packageManager": "pnpm@9.6.0",
"packageManager": "pnpm@9.7.0",
"pnpm": {
"peerDependencyRules": {
"allowedVersions": {

View File

@ -40,5 +40,34 @@ function isValidColor(color?: string) {
}
return new TinyColor(color).isValid;
}
/**
* HLS字符串转换为RGB颜色字符串
*
* HLS值的字符串
* TinyColor对象便
*
* RGB颜色字符串
*
* @param str HLS颜色值的字符串'deg''grad''rad''turn'
* @returns RGB颜色字符串
*/
function hlsStringToRGBString(str: string): string {
// 移除HLS字符串中的度量单位以便正确解析
const color = new TinyColor(
`hsl(${str.replaceAll(/deg|grad|rad|turn/g, '')})`,
);
// 检查颜色是否有效,如果无效则直接返回原始字符串
if (!color.isValid) {
return str;
}
// 返回转换后的RGB颜色字符串
return color.toRgbString();
}
export { convertToHsl, convertToHslCssVar, isValidColor, TinyColor };
export {
convertToHsl,
convertToHslCssVar,
hlsStringToRGBString,
isValidColor,
TinyColor,
};

View File

@ -1,7 +1,7 @@
import { reactive, watch } from 'vue';
import { preferences } from '@vben/preferences';
import { updateCSSVariables } from '@vben/utils';
import { hlsStringToRGBString, updateCSSVariables } from '@vben/utils';
/**
*
@ -102,7 +102,7 @@ export function useNaiveDesignTokens() {
const getCssVariableValue = (variable: string, isColor: boolean = true) => {
const value = rootStyles.getPropertyValue(variable);
return isColor ? `hsl(${value})` : value;
return isColor ? hlsStringToRGBString(value) : value;
};
watch(
@ -150,7 +150,6 @@ export function useNaiveDesignTokens() {
},
{ immediate: true },
);
return {
commonTokens,
};

View File

@ -652,8 +652,8 @@ importers:
specifier: ^0.5.1
version: 0.5.1(vite@5.3.5(@types/node@22.1.0)(sass@1.77.8)(terser@5.31.3))
vite-plugin-dts:
specifier: 4.0.0-beta.2
version: 4.0.0-beta.2(@types/node@22.1.0)(rollup@4.20.0)(typescript@5.5.4)(vite@5.3.5(@types/node@22.1.0)(sass@1.77.8)(terser@5.31.3))
specifier: 4.0.0
version: 4.0.0(@types/node@22.1.0)(rollup@4.20.0)(typescript@5.5.4)(vite@5.3.5(@types/node@22.1.0)(sass@1.77.8)(terser@5.31.3))
vite-plugin-html:
specifier: ^3.2.2
version: 3.2.2(vite@5.3.5(@types/node@22.1.0)(sass@1.77.8)(terser@5.31.3))
@ -9224,8 +9224,8 @@ packages:
peerDependencies:
vite: '>=2.0.0'
vite-plugin-dts@4.0.0-beta.2:
resolution: {integrity: sha512-7PYDxeKvFjRpeqvWTRT8YqX2J1uOrxgvHtXkRYAMfjonIHMSz/ZXjxPiRefBbXOTydqWk7jSZK3vwEt4Gvzbfw==}
vite-plugin-dts@4.0.0:
resolution: {integrity: sha512-MOGyecSNqXGxExPfDYtsH3cFted5UA04BP3JdI05i2BQRJmgjKeeUn6ymAWnEpZ6UY88Xd1n1NDmkO9q7YB5vA==}
engines: {node: ^14.18.0 || >=16.0.0}
peerDependencies:
typescript: '*'
@ -18563,7 +18563,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
vite-plugin-dts@4.0.0-beta.2(@types/node@22.1.0)(rollup@4.20.0)(typescript@5.5.4)(vite@5.3.5(@types/node@22.1.0)(sass@1.77.8)(terser@5.31.3)):
vite-plugin-dts@4.0.0(@types/node@22.1.0)(rollup@4.20.0)(typescript@5.5.4)(vite@5.3.5(@types/node@22.1.0)(sass@1.77.8)(terser@5.31.3)):
dependencies:
'@microsoft/api-extractor': 7.47.4(@types/node@22.1.0)
'@rollup/pluginutils': 5.1.0(rollup@4.20.0)