Skip to content

Commit

Permalink
feat: add cookie upload page (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
qq815776412 authored Aug 30, 2024
2 parents 1e27c74 + 6dad137 commit 69d1ad7
Show file tree
Hide file tree
Showing 7 changed files with 575 additions and 0 deletions.
155 changes: 155 additions & 0 deletions packages/app/src/components/ChipList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<template>
<div class="chip-list-container q-gutter-xs">
<q-chip
v-for="(item, index) in modelValue"
:key="item.name"
:color="[
itemIndex === index ? 'background-selected' : 'background-hover'
]"
text-color="ink-1"
class="text-ink-1 chip-wrapper"
size="12px"
>
<q-tooltip>
<q-markup-table
dense
class="chip-list-table"
separator="none"
dark
flat
>
<tbody>
<tr v-for="(value, key) in item" :key="key" class="text-white">
<td class="text-left">{{ key }}</td>
<td class="text-left">
<div style="max-width: 150px" class="ellipsis">
{{ value }}
</div>
</td>
</tr>
</tbody>
</q-markup-table>
</q-tooltip>
<div @click="() => clickHandler(item, index)">
{{ item.name }}
</div>
<q-icon
class="q-ml-sm"
name="close"
color="ink-3 delete-icon"
@click="deleteHandler(index)"
/>
</q-chip>
</div>
<div class="relative-position q-mt-md" v-show="visible">
<q-input
v-model="value"
type="textarea"
class="bg-background-3 input-wrapper"
borderless
autogrow
/>
<div class="text-right q-gutter-x-sm btn-group q-pb-sm q-pr-sm">
<QBtnStyle>
<q-btn
outline
no-caps
color="ink-2"
outlined
:label="$t('cookie_cancel')"
class="bg-white"
@click="cancelHandler"
/>
</QBtnStyle>
<QBtnStyle>
<q-btn
outline
no-caps
color="ink-2"
outlined
:label="$t('cookie_save')"
class="bg-white"
@click="saveHandler"
/>
</QBtnStyle>
</div>
</div>
</template>

<script setup lang="ts">
import { useQuasar } from 'quasar';
import { ref } from 'vue';
import QBtnStyle from '../components/style/QBtnStyle.vue';
interface Props {
modelValue: { name: string; value: string }[];
}
const $q = useQuasar();
const props = withDefaults(defineProps<Props>(), {});
const emits = defineEmits(['update:modelValue']);
const value = ref();
const itemIndex = ref(-1);
const visible = ref(false);
const deleteHandler = (index) => {
const data = [...props.modelValue];
data.splice(index, 1);
emits('update:modelValue', data);
};
const clickHandler = (item, index) => {
console.log('clickHandler');
itemIndex.value = index;
value.value = item.value;
visible.value = true;
};
const saveHandler = () => {
const data = [...props.modelValue];
const obj = { ...props.modelValue[itemIndex.value], value: value.value };
data.splice(itemIndex.value, 1, obj);
emits('update:modelValue', data);
visible.value = false;
};
const cancelHandler = () => {
visible.value = false;
};
</script>

<style lang="scss" scoped>
.chip-list-container {
.chip-wrapper {
cursor: pointer;
}
}
.chip-list-table {
background: rgba(0, 0, 0, 0);
color: #fff;
}
.delete-icon {
cursor: pointer;
&:hover {
background: $background-1;
border-radius: 50%;
}
}
.btn-group {
position: absolute;
bottom: 0;
right: 0;
}
.input-wrapper {
padding: 0px 12px;
padding-bottom: 48px;
border-radius: 8px;
::v-deep(textarea) {
resize: none;
}
}
::v-deep(.input-wrapper.q-field--outlined .q-field__control:before) {
border-color: $input-stroke-hover !important;
}
</style>
25 changes: 25 additions & 0 deletions packages/app/src/components/style/QBtnStyle.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<span class="btn-style-container">
<slot></slot>
</span>
</template>

<script setup lang="ts"></script>

<style lang="scss" scoped>
.btn-style-container {
::v-deep(.q-btn) {
padding: 0;
min-height: 26px;
height: 26px;
padding: 0 8px;
}
::v-deep(.q-btn--outline:before) {
border: 1px solid $btn-stroke;
}
::v-deep(.q-btn__content) {
padding: 0;
line-height: 14px;
}
}
</style>
41 changes: 41 additions & 0 deletions packages/app/src/components/style/QToggleStyle.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<span>
<slot></slot>
</span>
</template>

<script setup lang="ts"></script>

<style lang="scss" scoped>
::v-deep(.q-toggle__inner) {
height: 16px;
line-height: 16px;
padding-top: 0;
padding-bottom: 0;
}
::v-deep(.q-toggle__track) {
height: 16px;
border-radius: 8px;
background: $background-5;
}
::v-deep(.q-toggle__thumb) {
height: 12px !important;
width: 12px;
top: 2px;
}
::v-deep(.q-toggle__thumb:after) {
box-shadow: none;
background: $ink-on-brand;
filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.1));
left: 4px;
right: -4px;
}
::v-deep(.q-toggle__inner--truthy .q-toggle__thumb:after) {
right: 0px;
left: 0px;
}
::v-deep(.q-toggle__thumb:before) {
display: none;
}
</style>
32 changes: 32 additions & 0 deletions packages/app/src/i18n/en-US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1349,5 +1349,37 @@ If you want to create an organization, please refer to the steps listed in the T
active: 'Active',
inactive: 'Inactive',
auto_lock_when_you_leave: 'Auto lock when you leave',
cookie_auto_sync_label: 'Auto Sync',
cookie_upload_label: 'Upload',
cookie_uploaded_at: 'Uploaded at',
cookie_cancel: 'Cancel',
cookie_save: 'Save',
cookie_upload: {
title: 'Sync Your Cookies for a Better Experience',
content:
'Enhance Wise by uploading your cookies. This will reduce access restrictions and allow Wise to access more content, like your paid content, subscriptions, and HD videos. Learn more.',
footer: 'Dismiss this message'
},
cookie_overwrite: {
title: 'Proceed with Caution',
content:
'Overwriting cookies and local storage can lead to login failures and modification issues. Some websites also prevent the same cookie from being used on multiple browsers, causing account logouts elsewhere.',
footer: 'Dismiss this warning.'
},
cookie_empty: {
title: 'No Cookies Available for This Domain',
content:
'Unable to retrieve cookies for this domain. Please upload your cookies to Terminus first.'
},
cookie_action: {
upload_terminus: 'Upload To Terminus',
overwrite_browser: 'Overwrite to Browser'
},
cookie_notify: {
uploaded_successfully: 'Cookie uploaded successfully!',
uploaded_failed: 'Failed to upload cookie.',
deleted_successfully: 'Cookie deleted successfully!',
delete_failed: 'Failed to delete cookie.'
},
...termipass_en
};
8 changes: 8 additions & 0 deletions packages/app/src/pages/Mobile/collect/CollectIndexPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<page-content v-if="item.identify === 'page'" />
<download-content v-if="item.identify === 'download'" />
<rss-content v-if="item.identify === 'rss'" />
<cookie-content v-if="item.identify === 'cookie'" />
</q-tab-panel>
</q-tab-panels>
<router-view></router-view>
Expand All @@ -48,6 +49,7 @@ import { ref } from 'vue';
import PageContent from './PageContent.vue';
import RssContent from './RssContent.vue';
import DownloadContent from './DownloadContent.vue';
import CookieContent from './CookieContent.vue';
import { useBexStore } from '../../../stores/bex';
import { getAppPlatform } from '../../../platform/appPlatform';
import { ExtensionPlatform } from '../../../platform/bex/front/platform';
Expand Down Expand Up @@ -79,6 +81,12 @@ const items = ref([
identify: 'rss',
moduleTitle: 'RSS on Page',
show: true
},
{
name: 'Cookie',
icon: 'sym_r_cookie',
identify: 'cookie',
show: true
}
]);
Expand Down
Loading

0 comments on commit 69d1ad7

Please sign in to comment.