Skip to content

Commit

Permalink
feat: save secret #2
Browse files Browse the repository at this point in the history
Signed-off-by: seven <zilisheng1996@gmail.com>
  • Loading branch information
Blankll committed Feb 21, 2024
1 parent 7984b8c commit 9e48f2e
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
with:
tagName: ${{ steps.tag_release.outputs.version }}
releaseName: ${{ steps.tag_release.outputs.version }}
appVersion: ${{ steps.tag_release.outputs.version }}
appVersion: "${{ steps.tag_release.outputs.versionNumber }}"
releaseBody: |
${{ steps.changelog.outputs.compareurl }}
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/ico" href="/icon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AnyTerm</title>
</head>
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"oh-vue-icons": "^1.0.0-rc3",
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1",
"ulidx": "^2.3.0",
"vue": "^3.3.4",
"vue-i18n": "^9.9.0",
"vue-router": "^4.2.5"
Expand Down
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"fullscreen": false,
"resizable": true,
"title": "AnyTerm",
"width": 800,
"height": 600
"width": 1200,
"height": 750
}
]
}
Expand Down
6 changes: 3 additions & 3 deletions src/assets/styles/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ body,
width: 100%;
}
:root {
--theme-color: #36ad6a;
--theme-color-hover: #19934e;
--theme-color: #FF8911;
--theme-color-hover: #7F27FF;
--dange-color: #cd2158;
}
:root[theme='light'] {
Expand All @@ -30,4 +30,4 @@ body {
color: var(--text-color);
transition: .3s;
font-size: 14px;
}
}
4 changes: 2 additions & 2 deletions src/assets/theme/naive-theme-overrides.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const naiveThemeOverrides = {
common: {
primaryColor: '#36ad6a',
primaryColorHover: '#19934e',
primaryColor: '#FF8911',
primaryColorHover: '#7F27FF',
},
};
14 changes: 12 additions & 2 deletions src/store/secretStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineStore } from 'pinia';

import { ulid } from 'ulidx';
export enum SecretType {
SSH_KEY = 'SSH_KEY',
PASSWORD = 'PASSWORD',
Expand All @@ -22,5 +22,15 @@ export const useSecretStore = defineStore('secretStore', {
};
},
getters: {},
actions: {},
actions: {
saveSecret(secret: Secret) {
if (!secret.id) {
secret.id = ulid();
this.secrets.push(secret);
} else {
const index = this.secrets.findIndex(s => s.id === secret.id);
this.secrets[index] = secret;
}
},
},
});
19 changes: 19 additions & 0 deletions src/views/secret/components/key-list.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<div class="secret-list">
<n-card v-for="secret in secrets" :key="secret.id" :title="secret.name" hoverable> </n-card>
</div>
</template>

<script setup lang="ts">
import { useSecretStore } from '../../../store';
const secretStore = useSecretStore();
const { secrets } = toRefs(secretStore);
</script>

<style lang="scss" scoped>
.n-card {
max-width: 300px;
}
</style>
22 changes: 7 additions & 15 deletions src/views/secret/components/new-key-dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,13 @@
</n-tabs>
<template #footer>
<div class="card-footer">
<div class="left">
<n-button
type="info"
:loading="testLoading"
:disabled="!validationPassed"
@click="verify"
>
{{ $t('secret.verify') }}
</n-button>
</div>
<div class="right">
<n-button @click="closeModal">{{ $t('dialogOps.cancel') }}</n-button>
<n-button
type="primary"
:loading="saveLoading"
:disabled="!validationPassed"
@click="saveSecret"
@click="submitSaveSecret"
>
{{ $t('dialogOps.confirm') }}
</n-button>
Expand All @@ -117,10 +107,13 @@

<script setup lang="ts">
import { CustomError } from '../../../common';
import { Secret } from '../../../store';
import { Secret, useSecretStore } from '../../../store';
import { useLang } from '../../../lang';
import { FormValidationError } from 'naive-ui';
const secretStore = useSecretStore();
const { saveSecret } = secretStore;
const lang = useLang();
// DOM
const connectFormRef = ref();
Expand Down Expand Up @@ -192,11 +185,10 @@ const verify = async (event: MouseEvent) => {
}
};
const saveSecret = async (event: MouseEvent) => {
const submitSaveSecret = async (event: MouseEvent) => {
event.preventDefault();
saveLoading.value = !saveLoading.value;
// @TODO: save secret
// saveConnection(formData.value);
saveSecret({ ...formData.value } as Secret);
saveLoading.value = !saveLoading.value;
showModal.value = false;
};
Expand Down
2 changes: 0 additions & 2 deletions src/views/secret/components/tool-bar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
</template>

<script setup lang="ts">
import { defineEmits } from 'vue';
const emit = defineEmits(['newSecretEmit']);
const addSecret = () => {
Expand Down
2 changes: 2 additions & 0 deletions src/views/secret/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
<div>
<tool-bar @new-secret-emit="toolBarEmit" />
<new-key-dialog ref="addKeyDialogRef" />
<key-list />
</div>
</template>

<script setup lang="ts">
import ToolBar from './components/tool-bar.vue';
import NewKeyDialog from './components/new-key-dialog.vue';
import KeyList from './components/key-list.vue';
const addKeyDialogRef = ref();
const toolBarEmit = () => {
Expand Down

0 comments on commit 9e48f2e

Please sign in to comment.