mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 07:50:25 +08:00
refactor: rsa存储方式调整等
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
"splitpanes": "^3.1.5",
|
"splitpanes": "^3.1.5",
|
||||||
"sql-formatter": "^14.0.0",
|
"sql-formatter": "^14.0.0",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^9.0.1",
|
||||||
"vue": "^3.3.11",
|
"vue": "^3.3.12",
|
||||||
"vue-router": "^4.2.5",
|
"vue-router": "^4.2.5",
|
||||||
"xterm": "^5.3.0",
|
"xterm": "^5.3.0",
|
||||||
"xterm-addon-fit": "^0.8.0",
|
"xterm-addon-fit": "^0.8.0",
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ const handleSearchProps = computed(() => {
|
|||||||
|
|
||||||
// 处理透传的 事件
|
// 处理透传的 事件
|
||||||
const handleEvents = computed(() => {
|
const handleEvents = computed(() => {
|
||||||
let itemEvents = props.item?.props ?? {};
|
let itemEvents = props.item?.events ?? {};
|
||||||
return itemEvents;
|
return itemEvents;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ export class OptionsApi {
|
|||||||
*/
|
*/
|
||||||
convertFn: (apiResp: any) => any;
|
convertFn: (apiResp: any) => any;
|
||||||
|
|
||||||
|
// remote: boolean = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 远程方法参数属性字段,存在该值,则说明使用remote-method进行远程搜索
|
||||||
|
*/
|
||||||
|
remoteMethodParamProp: string;
|
||||||
|
|
||||||
withConvertFn(fn: (apiResp: any) => any) {
|
withConvertFn(fn: (apiResp: any) => any) {
|
||||||
this.convertFn = fn;
|
this.convertFn = fn;
|
||||||
return this;
|
return this;
|
||||||
@@ -72,6 +79,15 @@ export class OptionsApi {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否使用select的remote方式远程搜索调用
|
||||||
|
* @param remoteReqParamKey remote请求参数对应的prop,需要将输入的value赋值给params[paramProp]进行远程搜索
|
||||||
|
*/
|
||||||
|
isRemote(paramProp: string) {
|
||||||
|
this.remoteMethodParamProp = paramProp;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用api获取组件可选项
|
* 调用api获取组件可选项
|
||||||
* @returns 组件可选项信息
|
* @returns 组件可选项信息
|
||||||
@@ -228,7 +244,7 @@ export class SearchItem {
|
|||||||
if (!this.events) {
|
if (!this.events) {
|
||||||
this.events = {};
|
this.events = {};
|
||||||
}
|
}
|
||||||
this.props[event] = eventFn;
|
this.events[event] = eventFn;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +268,19 @@ export class SearchItem {
|
|||||||
// 使用api获取组件可选项需要将options转为响应式,否则组件无法响应式获取组件可选项
|
// 使用api获取组件可选项需要将options转为响应式,否则组件无法响应式获取组件可选项
|
||||||
this.options = ref(null);
|
this.options = ref(null);
|
||||||
|
|
||||||
|
// 存在远程搜索请求参数prop,则为使用远程搜索可选项
|
||||||
|
if (optionsApi.remoteMethodParamProp) {
|
||||||
|
return this.withOneProps('remote', true).withOneProps('remote-method', async (value: any) => {
|
||||||
|
if (!value) {
|
||||||
|
this.options.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 将输入的内容赋值为真实api请求参数中指定的属性字段
|
||||||
|
optionsApi.params[optionsApi.remoteMethodParamProp] = value;
|
||||||
|
this.options.value = await this.optionsApi.getOptions();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 立即执行,则直接调用api获取并赋值options
|
// 立即执行,则直接调用api获取并赋值options
|
||||||
if (this.optionsApi.immediate) {
|
if (this.optionsApi.immediate) {
|
||||||
this.optionsApi.getOptions().then((res) => {
|
this.optionsApi.getOptions().then((res) => {
|
||||||
@@ -277,4 +306,13 @@ export class SearchItem {
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 赋值placeholder
|
||||||
|
* @param val placeholder
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
withPlaceholder(val: string): SearchItem {
|
||||||
|
return this.withOneProps('placeholder', val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -882,7 +882,7 @@ defineExpose({
|
|||||||
}
|
}
|
||||||
|
|
||||||
.update_field_active {
|
.update_field_active {
|
||||||
background-color: var(--el-color-success);
|
background-color: var(--el-color-success-light-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
.column-type {
|
.column-type {
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<page-table :search-items="searchItems" v-model:query-form="query" :columns="columns" :page-api="logApi.list">
|
<page-table :page-api="logApi.list" :search-items="searchItems" v-model:query-form="query" :columns="columns"> </page-table>
|
||||||
<template #selectAccount>
|
|
||||||
<el-select remote :remote-method="getAccount" v-model="query.creatorId" filterable placeholder="请输入并选择账号" clearable>
|
|
||||||
<el-option v-for="item in accounts" :key="item.id" :label="item.username" :value="item.id"> </el-option>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</page-table>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -16,10 +10,24 @@ import { logApi, accountApi } from '../api';
|
|||||||
import PageTable from '@/components/pagetable/PageTable.vue';
|
import PageTable from '@/components/pagetable/PageTable.vue';
|
||||||
import { TableColumn } from '@/components/pagetable';
|
import { TableColumn } from '@/components/pagetable';
|
||||||
import { LogTypeEnum } from '../enums';
|
import { LogTypeEnum } from '../enums';
|
||||||
import { SearchItem } from '@/components/SearchForm';
|
import { OptionsApi, SearchItem } from '@/components/SearchForm';
|
||||||
|
|
||||||
const searchItems = [
|
const searchItems = [
|
||||||
SearchItem.slot('creatorId', '操作人', 'selectAccount'),
|
SearchItem.select('creatorId', '操作人')
|
||||||
|
.withPlaceholder('请输入并选择账号')
|
||||||
|
.withOptionsApi(
|
||||||
|
OptionsApi.new(accountApi.list, { username: null })
|
||||||
|
.withConvertFn((res: any) => {
|
||||||
|
const accounts = res.list;
|
||||||
|
return accounts.map((x: any) => {
|
||||||
|
return {
|
||||||
|
label: x.username,
|
||||||
|
value: x.id,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.isRemote('username')
|
||||||
|
),
|
||||||
SearchItem.select('type', '操作结果').withEnum(LogTypeEnum),
|
SearchItem.select('type', '操作结果').withEnum(LogTypeEnum),
|
||||||
SearchItem.input('description', '描述'),
|
SearchItem.input('description', '描述'),
|
||||||
];
|
];
|
||||||
@@ -41,18 +49,8 @@ const state = reactive({
|
|||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 0,
|
pageSize: 0,
|
||||||
},
|
},
|
||||||
accounts: [] as any,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { query, accounts } = toRefs(state);
|
const { query } = toRefs(state);
|
||||||
|
|
||||||
const getAccount = (username: any) => {
|
|
||||||
if (!username) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
accountApi.list.request({ username }).then((res) => {
|
|
||||||
state.accounts = res.list;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss"></style>
|
<style lang="scss"></style>
|
||||||
|
|||||||
@@ -450,6 +450,16 @@
|
|||||||
estree-walker "^2.0.2"
|
estree-walker "^2.0.2"
|
||||||
source-map-js "^1.0.2"
|
source-map-js "^1.0.2"
|
||||||
|
|
||||||
|
"@vue/compiler-core@3.3.12":
|
||||||
|
version "3.3.12"
|
||||||
|
resolved "https://registry.npmmirror.com/@vue/compiler-core/-/compiler-core-3.3.12.tgz#3346c0f55ce0d59e17c21d9eef9154b70c19931b"
|
||||||
|
integrity sha512-qAtjyG3GBLG0chzp5xGCyRLLe6wFCHmjI82aGzwuGKyznNP+GJJMxjc0wOYWDB2YKfho7niJFdoFpo0CZZQg9w==
|
||||||
|
dependencies:
|
||||||
|
"@babel/parser" "^7.23.5"
|
||||||
|
"@vue/shared" "3.3.12"
|
||||||
|
estree-walker "^2.0.2"
|
||||||
|
source-map-js "^1.0.2"
|
||||||
|
|
||||||
"@vue/compiler-dom@3.3.11":
|
"@vue/compiler-dom@3.3.11":
|
||||||
version "3.3.11"
|
version "3.3.11"
|
||||||
resolved "https://registry.npmmirror.com/@vue/compiler-dom/-/compiler-dom-3.3.11.tgz#36a76ea3a296d41bad133a6912cb0a847d969e4f"
|
resolved "https://registry.npmmirror.com/@vue/compiler-dom/-/compiler-dom-3.3.11.tgz#36a76ea3a296d41bad133a6912cb0a847d969e4f"
|
||||||
@@ -458,7 +468,31 @@
|
|||||||
"@vue/compiler-core" "3.3.11"
|
"@vue/compiler-core" "3.3.11"
|
||||||
"@vue/shared" "3.3.11"
|
"@vue/shared" "3.3.11"
|
||||||
|
|
||||||
"@vue/compiler-sfc@3.3.11", "@vue/compiler-sfc@^3.3.11":
|
"@vue/compiler-dom@3.3.12":
|
||||||
|
version "3.3.12"
|
||||||
|
resolved "https://registry.npmmirror.com/@vue/compiler-dom/-/compiler-dom-3.3.12.tgz#267c54b388d58f30fc120ea496ebf27d4ea8368b"
|
||||||
|
integrity sha512-RdJU9oEYaoPKUdGXCy0l+i4clesdDeLmbvRlszoc9iagsnBnMmQtYfCPVQ5BHB6o7K4SCucDdJM2Dh3oXB0D6g==
|
||||||
|
dependencies:
|
||||||
|
"@vue/compiler-core" "3.3.12"
|
||||||
|
"@vue/shared" "3.3.12"
|
||||||
|
|
||||||
|
"@vue/compiler-sfc@3.3.12":
|
||||||
|
version "3.3.12"
|
||||||
|
resolved "https://registry.npmmirror.com/@vue/compiler-sfc/-/compiler-sfc-3.3.12.tgz#6ec2c19858f264671457699c1f3a0a6fedf429fe"
|
||||||
|
integrity sha512-yy5b9e7b79dsGbMmglCe/YnhCQgBkHO7Uf6JfjWPSf2/5XH+MKn18LhzhHyxbHdJgnA4lZCqtXzLaJz8Pd8lMw==
|
||||||
|
dependencies:
|
||||||
|
"@babel/parser" "^7.23.5"
|
||||||
|
"@vue/compiler-core" "3.3.12"
|
||||||
|
"@vue/compiler-dom" "3.3.12"
|
||||||
|
"@vue/compiler-ssr" "3.3.12"
|
||||||
|
"@vue/reactivity-transform" "3.3.12"
|
||||||
|
"@vue/shared" "3.3.12"
|
||||||
|
estree-walker "^2.0.2"
|
||||||
|
magic-string "^0.30.5"
|
||||||
|
postcss "^8.4.32"
|
||||||
|
source-map-js "^1.0.2"
|
||||||
|
|
||||||
|
"@vue/compiler-sfc@^3.3.11":
|
||||||
version "3.3.11"
|
version "3.3.11"
|
||||||
resolved "https://registry.npmmirror.com/@vue/compiler-sfc/-/compiler-sfc-3.3.11.tgz#acfae240c875d067e0e2c9a4e2d910074408c73b"
|
resolved "https://registry.npmmirror.com/@vue/compiler-sfc/-/compiler-sfc-3.3.11.tgz#acfae240c875d067e0e2c9a4e2d910074408c73b"
|
||||||
integrity sha512-U4iqPlHO0KQeK1mrsxCN0vZzw43/lL8POxgpzcJweopmqtoYy9nljJzWDIQS3EfjiYhfdtdk9Gtgz7MRXnz3GA==
|
integrity sha512-U4iqPlHO0KQeK1mrsxCN0vZzw43/lL8POxgpzcJweopmqtoYy9nljJzWDIQS3EfjiYhfdtdk9Gtgz7MRXnz3GA==
|
||||||
@@ -482,6 +516,14 @@
|
|||||||
"@vue/compiler-dom" "3.3.11"
|
"@vue/compiler-dom" "3.3.11"
|
||||||
"@vue/shared" "3.3.11"
|
"@vue/shared" "3.3.11"
|
||||||
|
|
||||||
|
"@vue/compiler-ssr@3.3.12":
|
||||||
|
version "3.3.12"
|
||||||
|
resolved "https://registry.npmmirror.com/@vue/compiler-ssr/-/compiler-ssr-3.3.12.tgz#e62499c6003ccd09acb7190167d08845e3a0eaa5"
|
||||||
|
integrity sha512-adCiMJPznfWcQyk/9HSuXGja859IaMV+b8UNSVzDatqv7h0PvT9BEeS22+gjkWofDiSg5d78/ZLls3sLA+cn3A==
|
||||||
|
dependencies:
|
||||||
|
"@vue/compiler-dom" "3.3.12"
|
||||||
|
"@vue/shared" "3.3.12"
|
||||||
|
|
||||||
"@vue/devtools-api@^6.5.0":
|
"@vue/devtools-api@^6.5.0":
|
||||||
version "6.5.0"
|
version "6.5.0"
|
||||||
resolved "https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.5.0.tgz#98b99425edee70b4c992692628fa1ea2c1e57d07"
|
resolved "https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.5.0.tgz#98b99425edee70b4c992692628fa1ea2c1e57d07"
|
||||||
@@ -498,43 +540,59 @@
|
|||||||
estree-walker "^2.0.2"
|
estree-walker "^2.0.2"
|
||||||
magic-string "^0.30.5"
|
magic-string "^0.30.5"
|
||||||
|
|
||||||
"@vue/reactivity@3.3.11":
|
"@vue/reactivity-transform@3.3.12":
|
||||||
version "3.3.11"
|
version "3.3.12"
|
||||||
resolved "https://registry.npmmirror.com/@vue/reactivity/-/reactivity-3.3.11.tgz#91f8e6c9ac60a595a5278c836b197628fd947a0d"
|
resolved "https://registry.npmmirror.com/@vue/reactivity-transform/-/reactivity-transform-3.3.12.tgz#4cb871b597eb8b321577b4d7f1e93eaebca16128"
|
||||||
integrity sha512-D5tcw091f0nuu+hXq5XANofD0OXnBmaRqMYl5B3fCR+mX+cXJIGNw/VNawBqkjLNWETrFW0i+xH9NvDbTPVh7g==
|
integrity sha512-g5TijmML7FyKkLt6QnpqNmA4KD7K/T5SbXa88Bhq+hydNQEkzA8veVXWAQuNqg9rjaFYD0rPf0a9NofKA0ENgg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@vue/shared" "3.3.11"
|
"@babel/parser" "^7.23.5"
|
||||||
|
"@vue/compiler-core" "3.3.12"
|
||||||
|
"@vue/shared" "3.3.12"
|
||||||
|
estree-walker "^2.0.2"
|
||||||
|
magic-string "^0.30.5"
|
||||||
|
|
||||||
"@vue/runtime-core@3.3.11":
|
"@vue/reactivity@3.3.12":
|
||||||
version "3.3.11"
|
version "3.3.12"
|
||||||
resolved "https://registry.npmmirror.com/@vue/runtime-core/-/runtime-core-3.3.11.tgz#63defba57bc54c1dac68a95b56c2633b1419193d"
|
resolved "https://registry.npmmirror.com/@vue/reactivity/-/reactivity-3.3.12.tgz#b4a62a7678ab20c1ef32f991342ddbb8532417da"
|
||||||
integrity sha512-g9ztHGwEbS5RyWaOpXuyIVFTschclnwhqEbdy5AwGhYOgc7m/q3NFwr50MirZwTTzX55JY8pSkeib9BX04NIpw==
|
integrity sha512-vOJORzO8DlIx88cgTnMLIf2GlLYpoXAKsuoQsK6SGdaqODjxO129pVPTd2s/N/Mb6KKZEFIHIEwWGmtN4YPs+g==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@vue/reactivity" "3.3.11"
|
"@vue/shared" "3.3.12"
|
||||||
"@vue/shared" "3.3.11"
|
|
||||||
|
|
||||||
"@vue/runtime-dom@3.3.11":
|
"@vue/runtime-core@3.3.12":
|
||||||
version "3.3.11"
|
version "3.3.12"
|
||||||
resolved "https://registry.npmmirror.com/@vue/runtime-dom/-/runtime-dom-3.3.11.tgz#1146d8d280b0fec4d2e18c4a4c8f8121d0cecc09"
|
resolved "https://registry.npmmirror.com/@vue/runtime-core/-/runtime-core-3.3.12.tgz#67ee6cfc2e85d656946975239ea635ec42dde5f6"
|
||||||
integrity sha512-OlhtV1PVpbgk+I2zl+Y5rQtDNcCDs12rsRg71XwaA2/Rbllw6mBLMi57VOn8G0AjOJ4Mdb4k56V37+g8ukShpQ==
|
integrity sha512-5iL4w7MZrSGKEZU2wFAYhDZdZmgn+s//73EfgDXW1M+ZUOl36md7tlWp1QFK/ladiq4FvQ82shVjo0KiPDPr0A==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@vue/runtime-core" "3.3.11"
|
"@vue/reactivity" "3.3.12"
|
||||||
"@vue/shared" "3.3.11"
|
"@vue/shared" "3.3.12"
|
||||||
csstype "^3.1.2"
|
|
||||||
|
|
||||||
"@vue/server-renderer@3.3.11":
|
"@vue/runtime-dom@3.3.12":
|
||||||
version "3.3.11"
|
version "3.3.12"
|
||||||
resolved "https://registry.npmmirror.com/@vue/server-renderer/-/server-renderer-3.3.11.tgz#409aed8031a125791e2143552975ecd1958ad601"
|
resolved "https://registry.npmmirror.com/@vue/runtime-dom/-/runtime-dom-3.3.12.tgz#28a239496e589037774cba7c1b27057242eedb11"
|
||||||
integrity sha512-AIWk0VwwxCAm4wqtJyxBylRTXSy1wCLOKbWxHaHiu14wjsNYtiRCSgVuqEPVuDpErOlRdNnuRgipQfXRLjLN5A==
|
integrity sha512-8mMzqiIdl+IYa/OXwKwk6/4ebLq7cYV1pUcwCSwBK2KerUa6cwGosen5xrCL9f8o2DJ9TfPFwbPEvH7OXzUpoA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@vue/compiler-ssr" "3.3.11"
|
"@vue/runtime-core" "3.3.12"
|
||||||
"@vue/shared" "3.3.11"
|
"@vue/shared" "3.3.12"
|
||||||
|
csstype "^3.1.3"
|
||||||
|
|
||||||
|
"@vue/server-renderer@3.3.12":
|
||||||
|
version "3.3.12"
|
||||||
|
resolved "https://registry.npmmirror.com/@vue/server-renderer/-/server-renderer-3.3.12.tgz#f0246aba5d5d6fdfa840ac9e4f32d76f03b20665"
|
||||||
|
integrity sha512-OZ0IEK5TU5GXb5J8/wSplyxvGGdIcwEmS8EIO302Vz8K6fGSgSJTU54X0Sb6PaefzZdiN3vHsLXO8XIeF8crQQ==
|
||||||
|
dependencies:
|
||||||
|
"@vue/compiler-ssr" "3.3.12"
|
||||||
|
"@vue/shared" "3.3.12"
|
||||||
|
|
||||||
"@vue/shared@3.3.11":
|
"@vue/shared@3.3.11":
|
||||||
version "3.3.11"
|
version "3.3.11"
|
||||||
resolved "https://registry.npmmirror.com/@vue/shared/-/shared-3.3.11.tgz#f6a038e15237edefcc90dbfe7edb806dd355c7bd"
|
resolved "https://registry.npmmirror.com/@vue/shared/-/shared-3.3.11.tgz#f6a038e15237edefcc90dbfe7edb806dd355c7bd"
|
||||||
integrity sha512-u2G8ZQ9IhMWTMXaWqZycnK4UthG1fA238CD+DP4Dm4WJi5hdUKKLg0RMRaRpDPNMdkTwIDkp7WtD0Rd9BH9fLw==
|
integrity sha512-u2G8ZQ9IhMWTMXaWqZycnK4UthG1fA238CD+DP4Dm4WJi5hdUKKLg0RMRaRpDPNMdkTwIDkp7WtD0Rd9BH9fLw==
|
||||||
|
|
||||||
|
"@vue/shared@3.3.12":
|
||||||
|
version "3.3.12"
|
||||||
|
resolved "https://registry.npmmirror.com/@vue/shared/-/shared-3.3.12.tgz#7c030c4e2f1db8beb638b159cbb86d0ff78c3198"
|
||||||
|
integrity sha512-6p0Yin0pclvnER7BLNOQuod9Z+cxSYh8pSh7CzHnWNjAIP6zrTlCdHRvSCb1aYEx6i3Q3kvfuWU7nG16CgG1ag==
|
||||||
|
|
||||||
"@vueuse/core@^10.7.0":
|
"@vueuse/core@^10.7.0":
|
||||||
version "10.7.0"
|
version "10.7.0"
|
||||||
resolved "https://registry.npmmirror.com/@vueuse/core/-/core-10.7.0.tgz#34f2f02f179dc0dcffc2be70d6b1233e011404b9"
|
resolved "https://registry.npmmirror.com/@vueuse/core/-/core-10.7.0.tgz#34f2f02f179dc0dcffc2be70d6b1233e011404b9"
|
||||||
@@ -786,10 +844,10 @@ csstype@^3.1.0:
|
|||||||
resolved "https://registry.npmmirror.com/csstype/-/csstype-3.1.1.tgz"
|
resolved "https://registry.npmmirror.com/csstype/-/csstype-3.1.1.tgz"
|
||||||
integrity sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==
|
integrity sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==
|
||||||
|
|
||||||
csstype@^3.1.2:
|
csstype@^3.1.3:
|
||||||
version "3.1.2"
|
version "3.1.3"
|
||||||
resolved "https://registry.npmmirror.com/csstype/-/csstype-3.1.2.tgz#1d4bf9d572f11c14031f0436e1c10bc1f571f50b"
|
resolved "https://registry.npmmirror.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81"
|
||||||
integrity sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==
|
integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==
|
||||||
|
|
||||||
dayjs@^1.11.3:
|
dayjs@^1.11.3:
|
||||||
version "1.11.3"
|
version "1.11.3"
|
||||||
@@ -1945,16 +2003,16 @@ vue-router@^4.2.5:
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@vue/devtools-api" "^6.5.0"
|
"@vue/devtools-api" "^6.5.0"
|
||||||
|
|
||||||
vue@^3.3.11:
|
vue@^3.3.12:
|
||||||
version "3.3.11"
|
version "3.3.12"
|
||||||
resolved "https://registry.npmmirror.com/vue/-/vue-3.3.11.tgz#898d97025f73cdb5fc4e3ae3fd07a54615232140"
|
resolved "https://registry.npmmirror.com/vue/-/vue-3.3.12.tgz#4a3a39e79d22e9826ae7c058863316333c838b63"
|
||||||
integrity sha512-d4oBctG92CRO1cQfVBZp6WJAs0n8AK4Xf5fNjQCBeKCvMI1efGQ5E3Alt1slFJS9fZuPcFoiAiqFvQlv1X7t/w==
|
integrity sha512-jYNv2QmET2OTHsFzfWHMnqgCfqL4zfo97QwofdET+GBRCHhSCHuMTTvNIgeSn0/xF3JRT5OGah6MDwUFN7MPlg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@vue/compiler-dom" "3.3.11"
|
"@vue/compiler-dom" "3.3.12"
|
||||||
"@vue/compiler-sfc" "3.3.11"
|
"@vue/compiler-sfc" "3.3.12"
|
||||||
"@vue/runtime-dom" "3.3.11"
|
"@vue/runtime-dom" "3.3.12"
|
||||||
"@vue/server-renderer" "3.3.11"
|
"@vue/server-renderer" "3.3.12"
|
||||||
"@vue/shared" "3.3.11"
|
"@vue/shared" "3.3.12"
|
||||||
|
|
||||||
which@^2.0.1:
|
which@^2.0.1:
|
||||||
version "2.0.2"
|
version "2.0.2"
|
||||||
|
|||||||
2
server/.gitignore
vendored
2
server/.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
static/static
|
static/static
|
||||||
config.yml
|
config.yml
|
||||||
|
mayfly_rsa
|
||||||
|
mayfly_rsa.pub
|
||||||
@@ -13,6 +13,8 @@ import (
|
|||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"errors"
|
"errors"
|
||||||
"mayfly-go/pkg/cache"
|
"mayfly-go/pkg/cache"
|
||||||
|
"mayfly-go/pkg/logx"
|
||||||
|
"os"
|
||||||
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
@@ -128,37 +130,68 @@ func DefaultRsaDecrypt(data string, useBase64 bool) (string, error) {
|
|||||||
return string(val), nil
|
return string(val), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicKeyK = "mayfly:public-key"
|
const (
|
||||||
const privateKeyK = "mayfly:private-key"
|
// 公钥文件路径
|
||||||
|
publicKeyFile = "./mayfly_rsa.pub"
|
||||||
|
// 私钥文件路径
|
||||||
|
privateKeyFile = "./mayfly_rsa"
|
||||||
|
|
||||||
|
publicKeyK = "mayfly:public-key"
|
||||||
|
privateKeyK = "mayfly:private-key"
|
||||||
|
)
|
||||||
|
|
||||||
// 获取系统的RSA公钥
|
// 获取系统的RSA公钥
|
||||||
func GetRsaPublicKey() (string, error) {
|
func GetRsaPublicKey() (string, error) {
|
||||||
publicKey := cache.GetStr(publicKeyK)
|
content, err := os.ReadFile(publicKeyFile)
|
||||||
if publicKey != "" {
|
|
||||||
return publicKey, nil
|
|
||||||
}
|
|
||||||
privateKey, publicKey, err := GenerateRSAKey(1024)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
publicKey := cache.GetStr(publicKeyK)
|
||||||
|
if publicKey != "" {
|
||||||
|
return publicKey, nil
|
||||||
|
}
|
||||||
|
_, pubKey, err := GenerateAndSaveRSAKey()
|
||||||
|
return pubKey, err
|
||||||
}
|
}
|
||||||
cache.SetStr(publicKeyK, publicKey, -1)
|
|
||||||
cache.SetStr(privateKeyK, privateKey, -1)
|
return string(content), nil
|
||||||
return publicKey, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取系统私钥
|
// 获取系统私钥
|
||||||
func GetRsaPrivateKey() (string, error) {
|
func GetRsaPrivateKey() (string, error) {
|
||||||
privateKey := cache.GetStr(privateKeyK)
|
content, err := os.ReadFile(privateKeyFile)
|
||||||
if privateKey != "" {
|
if err != nil {
|
||||||
return privateKey, nil
|
privateKey := cache.GetStr(privateKeyK)
|
||||||
|
if privateKey != "" {
|
||||||
|
return privateKey, nil
|
||||||
|
}
|
||||||
|
privateKey, _, err := GenerateAndSaveRSAKey()
|
||||||
|
return privateKey, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return string(content), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成并保存rsa key,优先保存于磁盘,若磁盘保存失败,则保存至缓存
|
||||||
|
//
|
||||||
|
// 依次返回 privateKey, publicKey, error
|
||||||
|
func GenerateAndSaveRSAKey() (string, string, error) {
|
||||||
privateKey, publicKey, err := GenerateRSAKey(1024)
|
privateKey, publicKey, err := GenerateRSAKey(1024)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
cache.SetStr(publicKeyK, publicKey, -1)
|
|
||||||
cache.SetStr(privateKeyK, privateKey, -1)
|
err = os.WriteFile(privateKeyFile, []byte(privateKey), 0644)
|
||||||
return privateKey, nil
|
if err != nil {
|
||||||
|
logx.ErrorTrace("RSA私钥写入磁盘文件失败, 使用缓存存储该私钥", err)
|
||||||
|
cache.SetStr(privateKeyK, privateKey, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = os.WriteFile(publicKeyFile, []byte(publicKey), 0644)
|
||||||
|
if err != nil {
|
||||||
|
logx.ErrorTrace("RSA公钥写入磁盘文件失败, 使用缓存存储该公钥", err)
|
||||||
|
cache.SetStr(publicKeyK, publicKey, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return privateKey, publicKey, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AesEncrypt 加密
|
// AesEncrypt 加密
|
||||||
|
|||||||
Reference in New Issue
Block a user