Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves/category imgs #1025

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions developers/src/api/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export const useUserClient = ($message, t) => {
)
? {
...defaultApiConfig,
keystore,
keystore: {
app_id: keystore.user_id,
scope: keystore.scope,
authorization_id: keystore.authorization_id,
session_private_key: keystore.private_key
},
}
: defaultApiConfig;
return MixinApi(config);
Expand All @@ -41,7 +46,12 @@ export const useBotClient = ($message, t, keystore, onError = undefined) => {
)
? {
...defaultApiConfig,
keystore,
keystore: {
app_id: keystore.user_id,
session_id: keystore.session_id,
server_public_key: keystore.pin_token,
session_private_key: keystore.private_key
},
}
: defaultApiConfig;
return MixinApi(config);
Expand Down
53 changes: 45 additions & 8 deletions developers/src/components/AppForm/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,39 @@

<transition name="fade">
<div v-if="show_options" class="options">
<span
v-for="(item, key) in tm('information.category_list')"
<div
v-for="(item, key) in options"
:key="key"
:class="key === value ? 'active' : ''"
:class="['option', item.key === value && 'active']"
@click="useClickCategory(key)"
>
<img class="category-icon" :src="getImageUrl(`../assets/img/svg/Category${key}.svg`)" />
{{item}}
</span>
<img class="category-icon" :src="item.img_src" :alt="item.value" />
{{item.value}}
</div>
</div>
</transition>
</div>
</div>
</template>

<script>
import { reactive, toRefs } from 'vue';
import { reactive, toRefs, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { getImageUrl } from '@/utils/tools';
import BOOKSIcon from '@/assets/img/svg/CategoryBOOKS.svg';
import BUSINESSIcon from '@/assets/img/svg/CategoryBUSINESS.svg';
import EDUCATIONIcon from '@/assets/img/svg/CategoryEDUCATION.svg';
import GAMESIcon from '@/assets/img/svg/CategoryGAMES.svg';
import MUSICIcon from '@/assets/img/svg/CategoryMUSIC.svg';
import NEWSIcon from '@/assets/img/svg/CategoryNEWS.svg';
import OTHERIcon from '@/assets/img/svg/CategoryOTHER.svg';
import PHOTOIcon from '@/assets/img/svg/CategoryPHOTO.svg';
import SHOPPINGIcon from '@/assets/img/svg/CategorySHOPPING.svg';
import SOCIALIcon from '@/assets/img/svg/CategorySOCIAL.svg';
import TOOLSIcon from '@/assets/img/svg/CategoryTOOLS.svg';
import TRADINGIcon from '@/assets/img/svg/CategoryTRADING.svg';
import VIDEOIcon from '@/assets/img/svg/CategoryVIDEO.svg';
import WALLETIcon from '@/assets/img/svg/CategoryWALLET.svg';

export default {
props: {
Expand All @@ -52,7 +66,30 @@ export default {
ctx.emit('update:value', key);
};

const iconMap = {
WALLET: WALLETIcon,
TRADING: TRADINGIcon,
BUSINESS: BUSINESSIcon,
SOCIAL: SOCIALIcon,
SHOPPING: SHOPPINGIcon,
EDUCATION: EDUCATIONIcon,
NEWS: NEWSIcon,
TOOLS: TOOLSIcon,
GAMES: GAMESIcon,
BOOKS: BOOKSIcon,
MUSIC: MUSICIcon,
PHOTO: PHOTOIcon,
VIDEO: VIDEOIcon,
OTHER: OTHERIcon,
};
const options = computed(() => Object.entries(tm('information.category_list')).map(([key, value]) => ({
key,
value,
img_src: iconMap[key],
})));

return {
options,
...toRefs(state),
useToggleOptions,
useClickCategory,
Expand Down Expand Up @@ -112,7 +149,7 @@ export default {
border-radius: 0.25rem;
box-shadow: 0 0.25rem 1.125rem rgba(0, 0, 0, 0.1);

span {
.option {
display: flex;
align-items: center;
margin: 0.5rem 0;
Expand Down
8 changes: 4 additions & 4 deletions developers/src/components/Auth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</template>

<script>
import { getED25519KeyPair } from '@mixin.dev/mixin-node-sdk';
import { base64RawURLEncode, getED25519KeyPair } from '@mixin.dev/mixin-node-sdk';
import { getUrlParameter, ls } from '@/utils';
import { useUserClient } from '@/api';
import { useRouter } from 'vue-router';
Expand All @@ -30,13 +30,13 @@ export default {
if (error === 'access_denied') return useAccessDenied();

const code = getUrlParameter('code');
const { privateKey, publicKey } = getED25519KeyPair();
const { seed, publicKey } = getED25519KeyPair();

const client = useUserClient($message, t);
client.oauth.getToken({
client_id: import.meta.env.VITE_APP_CLIENT_ID,
code,
ed25519: publicKey,
ed25519: base64RawURLEncode(publicKey),
// eslint-disable-next-line consistent-return
}).then((resp) => {
if (!resp) return useAccessDenied();
Expand All @@ -52,7 +52,7 @@ export default {
user_id: import.meta.env.VITE_APP_CLIENT_ID,
scope,
authorization_id,
private_key: privateKey,
private_key: seed.toString('hex'),
};
ls.set('token', keystore);

Expand Down
17 changes: 12 additions & 5 deletions developers/src/components/Modals/UpdateTokenModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
<input v-model="session_id" />
</div>
<div class="edit-item">
<label>Pin Token</label>
<label>Server Public Key</label>
<input v-model="pin_token" />
</div>
<div class="edit-item">
<label>Private Key</label>
<textarea v-model="private_key"></textarea>
<label>Session Private Key</label>
<input v-model="private_key" />
</div>
<div class="edit-item intro-container">
<label></label>
<div class="intro">{{ t('wallet.secret_intro') }}</div>
</div>
<div class="btns">
Expand Down Expand Up @@ -79,6 +78,7 @@ export default {
.main {
padding: 3.125rem 2.5rem 2.5rem 2.5rem;
overflow: hidden;
width: 600px;
}

h3 {
Expand All @@ -90,14 +90,18 @@ h3 {
label {
font-weight: 700;
min-width: 5.625rem;
margin-right: 20px;
}

.edit-item {
display: flex;
align-items: center;
margin-bottom: 1.25rem;

label {
width: 35%;
margin-right: 20px;
}

input {
width: 100%;
max-width: 492px;
Expand All @@ -118,6 +122,8 @@ label {
}

&.intro-container {
display: flex;
justify-content: end;
margin-top: -0.5rem;

.intro {
Expand Down Expand Up @@ -173,6 +179,7 @@ label {
}

label {
width: 100%;
font-weight: 700;
text-align: left;
line-height: 1rem;
Expand Down
2 changes: 1 addition & 1 deletion developers/src/utils/localStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const ls = {
const info = JSON.parse(value);
// TODO: signature is error if use old token
if (validator.isUUID(key, 4)) {
if (info && !validator.isBase64(info.private_key, { urlSafe: true })) {
if (info && !validator.isHexadecimal(info.private_key)) {
window.localStorage.removeItem(key);
return {};
}
Expand Down
Loading